Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 6599c10a
authored
Oct 25, 2012
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of codecrew.fi:bortal
2 parents
623579ea
788b6bdd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
37 deletions
code/LanBortalWeb/WebContent/user/create.xhtml
code/LanBortalWeb/WebContent/useradmin/create.xhtml
code/LanBortalWeb/WebContent/useradmin/list.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserCartView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserValidator.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
code/LanBortalWeb/WebContent/user/create.xhtml
View file @
6599c10
...
...
@@ -11,7 +11,7 @@
<f:event
type=
"preRenderView"
listener=
"#{userView.initCreateView}"
/>
</f:metadata>
<ui:define
name=
"content"
>
<users:create
creating=
"true"
commitaction=
"#{userView.createUser()}"
commitvalue=
"#{i18n['user.create']}"
/>
<users:create
creating=
"true"
commitaction=
"#{userView.createUser()}"
commitvalue=
"#{i18n['user.create']}"
/>
</ui:define>
</ui:composition>
...
...
code/LanBortalWeb/WebContent/useradmin/create.xhtml
View file @
6599c10
...
...
@@ -12,7 +12,7 @@
</f:metadata>
<ui:param
name=
"thispage"
value=
"page.user.create"
/>
<ui:define
name=
"content"
>
<users:create
creating=
"true"
commitaction=
"#{userView.createUser()}"
commitvalue=
"#{i18n['user.create']}"
/>
<users:create
creating=
"true"
commitaction=
"#{userView.create
Admin
User()}"
commitvalue=
"#{i18n['user.create']}"
/>
</ui:define>
</ui:composition>
...
...
code/LanBortalWeb/WebContent/useradmin/list.xhtml
View file @
6599c10
...
...
@@ -49,7 +49,7 @@
<div
id=
"usercart"
style=
"display: #{((userCartView.isEmpty())?'none':'block')};"
>
<h:outputText
value=
"#{i18n['usercart.cartsize']}"
/>
<h:outputText
value=
" #{userCartView.userCartSize}"
/>
<h:commandButton
action=
"#{userCartView.clearCart}"
value=
"#{i18n['usercart.clear']}"
/>
<h:commandButton
action=
"#{userCartView.clearCart
()
}"
value=
"#{i18n['usercart.clear']}"
/>
<br
/>
<h:commandButton
actionListener=
"#{userSearchView.addToCart}"
value=
"#{i18n['usercart.addSearcherUsers']}"
/>
<h:commandButton
action=
"#{userCartView.traverse}"
value=
"#{i18n['usercart.traverse']}"
/>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserCartView.java
View file @
6599c10
...
...
@@ -69,7 +69,8 @@ public class UserCartView extends GenericCDIView {
updateCurrent
();
return
"/useradmin/userCartShow"
;
}
else
return
"/useradmin/list"
;
else
return
"/useradmin/list"
;
}
public
String
saveUser
()
{
...
...
@@ -102,12 +103,12 @@ public class UserCartView extends GenericCDIView {
}
public
void
clearCart
()
{
public
String
clearCart
()
{
if
(
usercart
!=
null
)
usercart
.
clear
();
//
return null;
return
null
;
}
public
boolean
isEmpty
()
{
return
usercart
==
null
||
usercart
.
isEmpty
();
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserValidator.java
View file @
6599c10
...
...
@@ -14,7 +14,9 @@ import javax.inject.Named;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.PermissionBeanLocal
;
import
fi.insomnia.bortal.beans.UserBeanLocal
;
import
fi.insomnia.bortal.enums.apps.UserPermission
;
import
fi.insomnia.bortal.utilities.I18n
;
@Named
...
...
@@ -29,12 +31,15 @@ public class UserValidator implements Serializable {
private
static
final
Integer
PASSWORD_MIN_LENGTH
=
8
;
@EJB
private
transient
UserBeanLocal
userbean
;
@EJB
private
transient
PermissionBeanLocal
permbean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserValidator
.
class
);
public
void
validateEmail
(
FacesContext
context
,
UIComponent
ui
,
Object
value
)
{
String
email
=
(
String
)
value
;
if
(
email
.
indexOf
(
'@'
)
==
-
1
)
{
if
(
!
permbean
.
hasPermission
(
UserPermission
.
MODIFY
)
&&
(
email
==
null
||
email
.
indexOf
(
'@'
)
==
-
1
)
)
{
message
(
context
,
ui
,
"userview.invalidEmail"
);
}
}
...
...
@@ -53,21 +58,25 @@ public class UserValidator implements Serializable {
public
void
password
(
FacesContext
context
,
UIComponent
ui
,
Object
object
)
{
logger
.
info
(
"Executing pwd, firstpwd {}"
,
firstpwd
);
if
(
object
==
null
)
{
message
(
context
,
ui
,
"user.passwordlengthMessage"
);
return
;
}
if
(
firstpwd
==
null
)
{
firstpwd
=
object
.
toString
();
if
(
PASSWORD_MIN_LENGTH
.
compareTo
(
firstpwd
.
length
())
>
0
)
{
message
(
context
,
ui
,
"userview.passwordTooShort"
,
PASSWORD_MIN_LENGTH
);
if
(!
permbean
.
hasPermission
(
UserPermission
.
MODIFY
))
{
if
(
object
==
null
)
{
message
(
context
,
ui
,
"user.passwordlengthMessage"
);
return
;
}
if
(
firstpwd
==
null
)
{
firstpwd
=
object
.
toString
();
if
(
PASSWORD_MIN_LENGTH
.
compareTo
(
firstpwd
.
length
())
>
0
)
{
message
(
context
,
ui
,
"userview.passwordTooShort"
,
PASSWORD_MIN_LENGTH
);
}
logger
.
info
(
"Setting firstpwd to {} as {}"
,
firstpwd
,
object
.
getClass
());
return
;
}
logger
.
info
(
"Checking length"
);
if
(!
firstpwd
.
equals
(
object
))
{
message
(
context
,
ui
,
"userview.passwordsDontMatch"
);
}
logger
.
info
(
"Setting firstpwd to {} as {}"
,
firstpwd
,
object
.
getClass
());
return
;
}
logger
.
info
(
"Checking length"
);
if
(!
firstpwd
.
equals
(
object
))
{
message
(
context
,
ui
,
"userview.passwordsDontMatch"
);
}
logger
.
info
(
"Done pwd"
);
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
View file @
6599c10
...
...
@@ -85,10 +85,10 @@ public class UserView extends GenericCDIView {
private
transient
EventBeanLocal
eventbean
;
@EJB
private
transient
CardPrintBeanLocal
cardPrintBean
;
private
File
file
;
private
StreamedContent
streamedFile
;
private
MassPrintResult
mpr
=
null
;
private
boolean
waitForAcceptance
=
false
;
...
...
@@ -142,13 +142,13 @@ public class UserView extends GenericCDIView {
// user = userbean.getEventUser(img.getUser());
// croppedImage = null;
if
(
croppedImage
==
null
)
return
null
;
if
(
croppedImage
==
null
)
return
null
;
logger
.
info
(
"Cropped image {}x{}"
,
croppedImage
.
getLeft
(),
croppedImage
.
getTop
());
logger
.
info
(
"Cropped data bytesize {}, type {}"
,
croppedImage
.
getBytes
().
length
,
croppedImage
.
getOriginalFilename
());
try
{
try
{
UserImage
newImage
=
userbean
.
saveCroppedImage
(
user
.
getUser
().
getCurrentImage
(),
croppedImage
.
getLeft
(),
croppedImage
.
getTop
(),
...
...
@@ -160,29 +160,29 @@ public class UserView extends GenericCDIView {
}
return
null
;
}
public
void
prepareCardDownload
()
{
file
=
null
;
try
{
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
this
.
user
.
getId
());
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
FileOutputStream
fostream
=
new
FileOutputStream
(
file
);
fostream
.
write
(
mpr
.
getPdf
());
fostream
.
close
();
setStreamedFile
(
new
DefaultStreamedContent
(
new
FileInputStream
(
this
.
file
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
}
}
public
String
acceptPrintedCard
()
{
if
(
mpr
!=
null
&&
mpr
.
getAffectedUsers
().
size
()
>
0
)
{
if
(
mpr
!=
null
&&
mpr
.
getAffectedUsers
().
size
()
>
0
)
{
cardPrintBean
.
acceptMassPrintResult
(
mpr
);
return
"accepted"
;
}
else
{
return
"failure"
;
}
}
...
...
@@ -290,6 +290,12 @@ public class UserView extends GenericCDIView {
return
"/user/created"
;
}
public
String
createAdminUser
()
{
userbean
.
createNewUser
(
user
,
getPassword
());
canSave
=
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
return
"/useradmin/edit"
;
}
public
void
setUserid
(
Integer
userid
)
{
this
.
userid
=
userid
;
}
...
...
@@ -357,7 +363,7 @@ public class UserView extends GenericCDIView {
public
void
raiseWaitForAcceptance
()
{
waitForAcceptance
=
true
;
}
public
boolean
isWaitForAcceptance
()
{
return
waitForAcceptance
;
}
...
...
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