Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8d7ac397
authored
Sep 03, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add email passwordchange, some menuchanges
1 parent
6ca7924f
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
173 additions
and
43 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/UserBeanLocal.java
code/MoyaWeb/WebContent/auth/sendResetMail.xhtml
code/MoyaWeb/WebContent/map/edit.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/content/PageOutputView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/map/MapManageView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/CardView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/PasswordResetView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/voting/CompoView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/voting/VotingCompoAddEntryView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
8d7ac39
...
@@ -104,7 +104,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -104,7 +104,6 @@ public class MenuBean implements MenuBeanLocal {
userPlaces
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/placemap"
),
MapPermission
.
VIEW
);
userPlaces
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/placemap"
),
MapPermission
.
VIEW
);
userPlaces
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
MapPermission
.
BUY_PLACES
);
userPlaces
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
MapPermission
.
BUY_PLACES
);
MenuNavigation
usercompetitions
=
usermenu
.
addPage
(
null
,
null
);
MenuNavigation
usercompetitions
=
usermenu
.
addPage
(
null
,
null
);
usercompetitions
.
setKey
(
"topnavi.competitions"
);
usercompetitions
.
setKey
(
"topnavi.competitions"
);
...
@@ -116,7 +115,7 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -116,7 +115,7 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation
userprofile
=
usermenu
.
addPage
(
null
,
null
);
MenuNavigation
userprofile
=
usermenu
.
addPage
(
null
,
null
);
userprofile
.
setKey
(
"topnavi.profile"
);
userprofile
.
setKey
(
"topnavi.profile"
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
MODIFY
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/logout"
),
UserPermission
.
LOGOUT
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/logout"
),
UserPermission
.
LOGOUT
);
...
@@ -129,7 +128,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -129,7 +128,6 @@ public class MenuBean implements MenuBeanLocal {
navifacade
.
create
(
usermenu
);
navifacade
.
create
(
usermenu
);
//
//
// Admin menu
// Admin menu
//
//
...
@@ -204,7 +202,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -204,7 +202,6 @@ public class MenuBean implements MenuBeanLocal {
mapnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/map/list"
),
MapPermission
.
MANAGE_MAPS
);
mapnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/map/list"
),
MapPermission
.
MANAGE_MAPS
);
mapnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/map/edit"
),
null
).
setVisible
(
false
);
mapnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/map/edit"
),
null
).
setVisible
(
false
);
// event
// event
MenuNavigation
adminevent
=
adminmenu
.
addPage
(
null
,
null
);
MenuNavigation
adminevent
=
adminmenu
.
addPage
(
null
,
null
);
adminevent
.
setKey
(
"topnavi.event"
);
adminevent
.
setKey
(
"topnavi.event"
);
...
@@ -225,17 +222,12 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -225,17 +222,12 @@ public class MenuBean implements MenuBeanLocal {
compoMenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/voting/admincompolist"
),
CompoPermission
.
VIEW_COMPOS
);
compoMenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/voting/admincompolist"
),
CompoPermission
.
VIEW_COMPOS
);
compoMenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/voting/create"
),
CompoPermission
.
MANAGE
);
compoMenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/voting/create"
),
CompoPermission
.
MANAGE
);
MenuNavigation
gamenavi
=
adminevent
.
addPage
(
null
,
null
);
MenuNavigation
gamenavi
=
adminevent
.
addPage
(
null
,
null
);
gamenavi
.
setKey
(
"topnavi.license"
);
gamenavi
.
setKey
(
"topnavi.license"
);
gamenavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/license/manageCodes"
),
LicensePermission
.
MANAGE
);
gamenavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/license/manageCodes"
),
LicensePermission
.
MANAGE
);
adminevent
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/eventorg/list"
),
EventPermission
.
MANAGE_PROPERTIES
);
adminevent
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/eventorg/list"
),
EventPermission
.
MANAGE_PROPERTIES
);
navifacade
.
create
(
adminmenu
);
navifacade
.
create
(
adminmenu
);
MenuNavigation
shopmenu
=
new
MenuNavigation
(
ev
,
"topnavi.shopnavi"
,
menusort
=
+
10
);
MenuNavigation
shopmenu
=
new
MenuNavigation
(
ev
,
"topnavi.shopnavi"
,
menusort
=
+
10
);
...
@@ -336,7 +328,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -336,7 +328,6 @@ public class MenuBean implements MenuBeanLocal {
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
UserPermission
.
VIEW_SELF
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
UserPermission
.
VIEW_SELF
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/sendPicture"
),
UserPermission
.
VIEW_SELF
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/sendPicture"
),
UserPermission
.
VIEW_SELF
);
MenuNavigation
placemapTopmenu
=
usernavi
.
addPage
(
null
,
null
);
MenuNavigation
placemapTopmenu
=
usernavi
.
addPage
(
null
,
null
);
placemapTopmenu
.
setKey
(
"topnavi.placemap"
);
placemapTopmenu
.
setKey
(
"topnavi.placemap"
);
placemapTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/placemap"
),
MapPermission
.
VIEW
);
placemapTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/placemap"
),
MapPermission
.
VIEW
);
...
@@ -373,7 +364,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -373,7 +364,6 @@ public class MenuBean implements MenuBeanLocal {
gameTopmenu
.
setKey
(
"topnavi.license"
);
gameTopmenu
.
setKey
(
"topnavi.license"
);
gameTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/license/viewCodes"
),
LicensePermission
.
VIEW_OWN_CODES
);
gameTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/license/viewCodes"
),
LicensePermission
.
VIEW_OWN_CODES
);
MenuNavigation
pollTopmenu
=
usernavi
.
addPage
(
null
,
null
);
MenuNavigation
pollTopmenu
=
usernavi
.
addPage
(
null
,
null
);
pollTopmenu
.
setKey
(
"topnavi.poll"
);
pollTopmenu
.
setKey
(
"topnavi.poll"
);
pollTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/poll/index"
),
PollPermission
.
ANSWER
);
pollTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/poll/index"
),
PollPermission
.
ANSWER
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
8d7ac39
...
@@ -523,7 +523,6 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -523,7 +523,6 @@ public class PlaceBean implements PlaceBeanLocal {
float
pagey
=
height
/
pointInMillim
;
float
pagey
=
height
/
pointInMillim
;
for
(
Place
place
:
places
)
{
for
(
Place
place
:
places
)
{
Page
page
=
new
Page
(
pdf
,
new
float
[]
{
pagex
,
pagey
});
Page
page
=
new
Page
(
pdf
,
new
float
[]
{
pagex
,
pagey
});
// place code
// place code
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
8d7ac39
...
@@ -358,9 +358,22 @@ public class UserBean implements UserBeanLocal {
...
@@ -358,9 +358,22 @@ public class UserBean implements UserBeanLocal {
}
}
@Override
@Override
public
boolean
initPasswordReset
(
String
username
,
String
url
)
{
public
boolean
initPasswordResetForUsername
(
String
username
,
String
url
)
{
User
user
=
userFacade
.
findByLogin
(
username
);
User
user
=
userFacade
.
findByLogin
(
username
);
return
initPasswordReset
(
user
,
url
);
}
@Override
public
boolean
initPasswordResetForEmail
(
String
email
,
String
url
)
{
List
<
User
>
users
=
userFacade
.
findByEmail
(
email
);
if
(
users
.
size
()
!=
1
)
{
return
false
;
}
return
initPasswordReset
(
users
.
get
(
0
),
url
);
}
private
boolean
initPasswordReset
(
User
user
,
String
url
)
{
String
hash
=
PasswordFunctions
.
generateRandomString
(
25
);
String
hash
=
PasswordFunctions
.
generateRandomString
(
25
);
logger
.
info
(
"Initializing password sending: {}, hash: {}"
,
user
,
hash
);
logger
.
info
(
"Initializing password sending: {}, hash: {}"
,
user
,
hash
);
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/UserBeanLocal.java
View file @
8d7ac39
...
@@ -38,8 +38,6 @@ public interface UserBeanLocal {
...
@@ -38,8 +38,6 @@ public interface UserBeanLocal {
boolean
resetPassword
(
User
user
,
String
password
,
String
hash
);
boolean
resetPassword
(
User
user
,
String
password
,
String
hash
);
boolean
initPasswordReset
(
String
user
,
String
mailpath
);
/**
/**
* Search EventUser entity by User entity ID
* Search EventUser entity by User entity ID
*
*
...
@@ -89,4 +87,8 @@ public interface UserBeanLocal {
...
@@ -89,4 +87,8 @@ public interface UserBeanLocal {
UserApproval
setUserApproval
(
EventUser
user
,
String
approvalName
,
boolean
approvalValue
,
String
notes
);
UserApproval
setUserApproval
(
EventUser
user
,
String
approvalName
,
boolean
approvalValue
,
String
notes
);
boolean
initPasswordResetForEmail
(
String
email
,
String
url
);
boolean
initPasswordResetForUsername
(
String
username
,
String
url
);
}
}
code/MoyaWeb/WebContent/auth/sendResetMail.xhtml
View file @
8d7ac39
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:login=
"http://java.sun.com/jsf/composite/tools/login"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
xmlns:login=
"http://java.sun.com/jsf/composite/tools/login"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:head>
<h:head>
<title></title>
<title></title>
</h:head>
</h:head>
...
@@ -12,19 +10,34 @@
...
@@ -12,19 +10,34 @@
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<h1><h:outputText
value=
"#{i18n['resetMail.header']}"
/></h1>
<h1>
<p><h:outputText
value=
"#{i18n['resetMail.body']}"
/></p>
<h:outputText
value=
"#{i18n['resetMail.header']}"
/>
</h1>
<p>
<h:outputText
value=
"#{i18n['resetMail.body']}"
/>
</p>
<h:form>
<h:form>
<h:panelGrid
columns=
"3"
>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
value=
"#{i18n['resetMail.username']}:"
for=
"username"
/>
<h:outputLabel
value=
"#{i18n['resetMail.username']}:"
for=
"username"
/>
<h:inputText
id=
"username"
value=
"#{pwdResetView.
mailuser
}"
/>
<h:inputText
id=
"username"
value=
"#{pwdResetView.
username
}"
/>
<h:message
for=
"username"
/>
<h:message
for=
"username"
/>
</h:panelGrid>
</h:panelGrid>
<h:commandButton
id=
"sendReset"
value=
"#{i18n['resetMail.send']}"
action=
"#{pwdResetView.sendMail()}"
/>
<h:commandButton
id=
"sendReset"
value=
"#{i18n['resetMail.send']}"
action=
"#{pwdResetView.sendMail()}"
/>
</h:form>
</h:form>
<h:form>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
value=
"#{i18n['resetMail.email']}:"
for=
"emailaddr"
/>
<h:inputText
id=
"emailaddr"
value=
"#{pwdResetView.emailaddr}"
/>
<h:message
for=
"emailaddr"
/>
</h:panelGrid>
<h:commandButton
id=
"sendReset"
value=
"#{i18n['resetMail.send']}"
action=
"#{pwdResetView.sendMail()}"
/>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/MoyaWeb/WebContent/map/edit.xhtml
View file @
8d7ac39
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
</h:form>
</h:form>
<h:form>
<h:form>
<p:commandButton
id=
"downloadLink"
value=
"koodipdf"
ajax=
"false"
>
<p:commandButton
id=
"downloadLink"
actionListener=
"mapManageView.generatePlacePdf"
value=
"koodipdf"
ajax=
"false"
>
<p:fileDownload
value=
"#{mapManageView.streamedFile}"
/>
<p:fileDownload
value=
"#{mapManageView.streamedFile}"
/>
</p:commandButton>
</p:commandButton>
</h:form>
</h:form>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/content/PageOutputView.java
View file @
8d7ac39
...
@@ -26,7 +26,7 @@ public class PageOutputView extends GenericCDIView {
...
@@ -26,7 +26,7 @@ public class PageOutputView extends GenericCDIView {
public
void
initIndexView
()
public
void
initIndexView
()
{
{
name
=
"/
index
"
;
name
=
"/
frontpage
"
;
initView
();
initView
();
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/map/MapManageView.java
View file @
8d7ac39
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -91,16 +92,27 @@ public class MapManageView extends GenericCDIView {
...
@@ -91,16 +92,27 @@ public class MapManageView extends GenericCDIView {
map
=
eventmapBean
.
find
(
getMapId
());
map
=
eventmapBean
.
find
(
getMapId
());
setProductlist
(
productbean
.
getProducts
());
setProductlist
(
productbean
.
getProducts
());
super
.
beginConversation
();
super
.
beginConversation
();
streamedFile
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
placebean
.
generatePlacesPdf
(
54
,
17
,
18
,
15
)),
"application/pdf"
,
"paikkakoodit"
);
if
(
map
!=
null
&&
!
map
.
getPlaces
().
isEmpty
())
}
streamedFile
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
placebean
.
generatePlacesPdf
(
54
,
17
,
18
,
15
)),
"application/pdf"
,
"paikkakoodit"
);
}
}
}
public
String
submitBg
()
public
String
submitBg
()
{
{
map
.
setMapData
(
bgFile
.
getContents
());
byte
[]
bytes
=
bgFile
.
getContents
();
if
(
bytes
==
null
&&
bgFile
.
getSize
()
>
0
)
{
bytes
=
new
byte
[(
int
)
bgFile
.
getSize
()];
try
{
bgFile
.
getInputstream
().
read
(
bytes
);
}
catch
(
IOException
e
)
{
super
.
addFaceMessage
(
"mapManage.errorUploadingBackground"
);
return
null
;
}
}
map
.
setMapData
(
bytes
);
map
=
eventmapBean
.
saveMap
(
map
);
map
=
eventmapBean
.
saveMap
(
map
);
return
null
;
return
null
;
}
}
...
@@ -348,6 +360,7 @@ public class MapManageView extends GenericCDIView {
...
@@ -348,6 +360,7 @@ public class MapManageView extends GenericCDIView {
public
void
setBgFile
(
UploadedFile
bgFile
)
{
public
void
setBgFile
(
UploadedFile
bgFile
)
{
this
.
bgFile
=
bgFile
;
this
.
bgFile
=
bgFile
;
}
}
//StreamedContent new DefaultStreamedContent(pdfstream)
//StreamedContent new DefaultStreamedContent(pdfstream)
public
StreamedContent
getStreamedFile
()
{
public
StreamedContent
getStreamedFile
()
{
...
@@ -356,6 +369,3 @@ public class MapManageView extends GenericCDIView {
...
@@ -356,6 +369,3 @@ public class MapManageView extends GenericCDIView {
return
streamedFile
;
return
streamedFile
;
}
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
View file @
8d7ac39
...
@@ -110,7 +110,24 @@ public class EventPropertyView extends GenericCDIView {
...
@@ -110,7 +110,24 @@ public class EventPropertyView extends GenericCDIView {
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]
{
privateProperty
.
getEvent
(),
privateProperty
.
getEventorg
(),
privateProperty
.
getKey
()
});
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]
{
privateProperty
.
getEvent
(),
privateProperty
.
getEventorg
(),
privateProperty
.
getKey
()
});
if
(
privateProperty
.
getKey
().
isData
()
&&
file
!=
null
)
if
(
privateProperty
.
getKey
().
isData
()
&&
file
!=
null
)
{
{
privateProperty
.
setByteValue
(
file
.
getContents
());
byte
[]
contents
=
null
;
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
}
privateProperty
.
setByteValue
(
contents
);
privateProperty
.
setByteMime
(
file
.
getContentType
());
privateProperty
.
setByteMime
(
file
.
getContentType
());
}
}
privateProperty
=
eventbean
.
saveOrCreatePrivateProperty
(
privateProperty
);
privateProperty
=
eventbean
.
saveOrCreatePrivateProperty
(
privateProperty
);
...
@@ -154,7 +171,7 @@ public class EventPropertyView extends GenericCDIView {
...
@@ -154,7 +171,7 @@ public class EventPropertyView extends GenericCDIView {
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
return
null
;
}
}
property
.
setByteValue
(
file
.
getContents
()
);
property
.
setByteValue
(
contents
);
property
.
setByteMime
(
file
.
getContentType
());
property
.
setByteMime
(
file
.
getContentType
());
}
}
property
=
eventbean
.
saveOrCreateProperty
(
property
);
property
=
eventbean
.
saveOrCreateProperty
(
property
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/CardView.java
View file @
8d7ac39
...
@@ -59,7 +59,25 @@ public class CardView extends GenericCDIView {
...
@@ -59,7 +59,25 @@ public class CardView extends GenericCDIView {
{
{
try
{
try
{
logger
.
info
(
"Templateimage: {}"
,
getTemplateImage
());
logger
.
info
(
"Templateimage: {}"
,
getTemplateImage
());
cardTemplate
=
cfbean
.
saveImage
(
cardTemplate
,
getTemplateImage
().
getContents
());
byte
[]
contents
=
null
;
UploadedFile
file
=
getTemplateImage
();
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
}
cardTemplate
=
cfbean
.
saveImage
(
cardTemplate
,
contents
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
info
(
"Error converting template image"
,
e
);
logger
.
info
(
"Error converting template image"
,
e
);
super
.
addFaceMessage
(
"template.uploadFailed"
,
e
.
getMessage
());
super
.
addFaceMessage
(
"template.uploadFailed"
,
e
.
getMessage
());
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/PasswordResetView.java
View file @
8d7ac39
...
@@ -25,7 +25,8 @@ public class PasswordResetView extends GenericCDIView {
...
@@ -25,7 +25,8 @@ public class PasswordResetView extends GenericCDIView {
private
String
confirm
;
private
String
confirm
;
private
User
user
;
private
User
user
;
private
String
mailuser
;
private
String
username
;
private
String
emailaddr
;
@EJB
@EJB
private
transient
UserBeanLocal
userbean
;
private
transient
UserBeanLocal
userbean
;
...
@@ -76,11 +77,19 @@ public class PasswordResetView extends GenericCDIView {
...
@@ -76,11 +77,19 @@ public class PasswordResetView extends GenericCDIView {
.
append
(
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getContextName
())
.
append
(
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getContextName
())
.
append
(
"/auth/resetPassword.jsf?id={0}&hash={1}"
);
.
append
(
"/auth/resetPassword.jsf?id={0}&hash={1}"
);
if
(
userbean
.
initPasswordReset
(
mailuser
,
path
.
toString
()))
{
if
(
username
!=
null
&&
!
username
.
isEmpty
())
{
if
(
userbean
.
initPasswordResetForUsername
(
username
,
path
.
toString
()))
{
return
"/auth/resetmailSent"
;
}
}
else
if
(
emailaddr
!=
null
&&
!
emailaddr
.
isEmpty
())
{
if
(
userbean
.
initPasswordResetForUsername
(
emailaddr
,
path
.
toString
()))
{
return
"/auth/resetmailSent"
;
return
"/auth/resetmailSent"
;
}
}
mailuser
=
null
;
}
username
=
null
;
emailaddr
=
null
;
this
.
addFaceMessage
(
"passwordreset.usernotfound"
);
this
.
addFaceMessage
(
"passwordreset.usernotfound"
);
return
null
;
return
null
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/voting/CompoView.java
View file @
8d7ac39
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
voting
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
voting
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
...
@@ -143,14 +144,35 @@ public class CompoView extends GenericCDIView {
...
@@ -143,14 +144,35 @@ public class CompoView extends GenericCDIView {
public
String
submitEntryfile
()
public
String
submitEntryfile
()
{
{
if
(
getUploadedFile
()
==
null
)
UploadedFile
file
=
getUploadedFile
();
if
(
file
==
null
)
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
}
byte
[]
contents
=
null
;
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
return
null
;
}
}
CompoEntryFile
cef
=
new
CompoEntryFile
(
getEntry
());
CompoEntryFile
cef
=
new
CompoEntryFile
(
getEntry
());
cef
.
setFileData
(
this
.
getUploadedFile
().
getContents
()
);
cef
.
setFileData
(
contents
);
logger
.
info
(
"Got file name {} length {}"
,
getUploadedFile
().
getFileName
(),
cef
.
getFileData
().
length
);
logger
.
info
(
"Got file name {} length {}"
,
getUploadedFile
().
getFileName
(),
cef
.
getFileData
().
length
);
cef
.
setFileName
(
getUploadedFile
().
getFileName
());
cef
.
setFileName
(
getUploadedFile
().
getFileName
());
cef
.
setMimeType
(
getUploadedFile
().
getContentType
());
cef
.
setMimeType
(
getUploadedFile
().
getContentType
());
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/voting/VotingCompoAddEntryView.java
View file @
8d7ac39
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
voting
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
voting
;
import
java.io.IOException
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.VotingBeanLocal
;
import
fi.codecrew.moya.beans.VotingBeanLocal
;
import
fi.codecrew.moya.model.CompoEntry
;
import
fi.codecrew.moya.model.CompoEntry
;
import
fi.codecrew.moya.model.CompoEntryFile
;
import
fi.codecrew.moya.model.CompoEntryFile
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@Named
@RequestScoped
@RequestScoped
public
class
VotingCompoAddEntryView
{
public
class
VotingCompoAddEntryView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
-
93065881159476197L
;
@EJB
@EJB
VotingBeanLocal
votingBean
;
VotingBeanLocal
votingBean
;
...
@@ -29,6 +36,8 @@ public class VotingCompoAddEntryView {
...
@@ -29,6 +36,8 @@ public class VotingCompoAddEntryView {
private
Integer
compoId
;
private
Integer
compoId
;
private
String
compoName
;
private
String
compoName
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VotingCompoAddEntryView
.
class
);
public
Integer
getCompoId
()
{
public
Integer
getCompoId
()
{
return
compoId
;
return
compoId
;
}
}
...
@@ -78,13 +87,41 @@ public class VotingCompoAddEntryView {
...
@@ -78,13 +87,41 @@ public class VotingCompoAddEntryView {
}
}
public
String
send
()
{
public
String
send
()
{
UploadedFile
file
=
getUploadedFile
();
if
(
file
==
null
)
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
}
byte
[]
contents
=
null
;
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
}
CompoEntry
compoEntry
=
new
CompoEntry
();
CompoEntry
compoEntry
=
new
CompoEntry
();
compoEntry
.
setTitle
(
name
);
compoEntry
.
setTitle
(
name
);
compoEntry
.
setNotes
(
notes
);
compoEntry
.
setNotes
(
notes
);
compoEntry
.
setScreenMessage
(
screenMessage
);
compoEntry
.
setScreenMessage
(
screenMessage
);
compoEntry
.
setCompo
(
votingBean
.
getCompoById
(
compoId
));
compoEntry
.
setCompo
(
votingBean
.
getCompoById
(
compoId
));
CompoEntryFile
cef
=
new
CompoEntryFile
(
compoEntry
);
CompoEntryFile
cef
=
new
CompoEntryFile
(
compoEntry
);
cef
.
setFileData
(
this
.
uploadedFile
.
getContents
()
);
cef
.
setFileData
(
contents
);
cef
.
setFileName
(
uploadedFile
.
getFileName
());
cef
.
setFileName
(
uploadedFile
.
getFileName
());
votingBean
.
addEntry
(
compoEntry
,
cef
);
votingBean
.
addEntry
(
compoEntry
,
cef
);
return
null
;
return
null
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment