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 ea0bd736
authored
Aug 26, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Siirrytty hämmentävistä listakikostuksista convertterin käyttöön.
1 parent
09a28506
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
114 deletions
code/LanBortalWeb/WebContent/resources/tools/role/form.xhtml
code/LanBortalWeb/WebContent/resources/tools/user/edit.xhtml
code/LanBortalWeb/WebContent/resources/tools/user/editroles.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/RoleView.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/UserView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/RoleConverter.java
code/LanBortalWeb/WebContent/resources/tools/role/form.xhtml
View file @
ea0bd73
...
...
@@ -17,8 +17,8 @@
<h:inputText
value=
"#{roleView.role.name}"
/>
<h:outputText
value=
"#{i18n['role.parents']}"
/>
<h:selectManyCheckbox
layout=
"pageDirection"
id =
"roleparents"
value=
"#{roleView.roleP
arents}"
>
<f:selectItems
var=
"par"
itemValue=
"#{par.id.id}"
itemLabel=
"#{par.name}"
value=
"#{roleView.possibleParents}"
/>
<h:selectManyCheckbox
converter=
"#{sessionHandler.roleConverter}"
layout=
"pageDirection"
id =
"roleparents"
value=
"#{roleView.role.p
arents}"
>
<f:selectItems
var=
"par"
itemLabel=
"#{par.name}"
value=
"#{roleView.possibleParents}"
/>
</h:selectManyCheckbox>
</h:panelGrid>
</ui:composition>
...
...
code/LanBortalWeb/WebContent/resources/tools/user/edit.xhtml
View file @
ea0bd73
...
...
@@ -37,6 +37,10 @@
<f:selectItem
id=
"male"
itemLabel=
"#{i18n['user.sex.MALE']}"
itemValue=
"MALE"
/>
<f:selectItem
id=
"female"
itemLabel=
"#{i18n['user.sex.FEMALE']}"
itemValue=
"FEMALE"
/>
</h:selectOneRadio>
<h:selectManyCheckbox
converter=
"#{sessionHandler.roleConverter}"
rendered=
"#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}"
disabled=
"#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}"
layout=
"pageDirection"
id=
"roles"
value=
"#{cc.attrs.user.roles}"
>
<f:selectItems
var=
"roleitem"
itemLabel=
"#{roleitem.name}"
value=
"#{userView.userRoles}"
/>
</h:selectManyCheckbox>
<h:commandButton
id=
"commitbtn"
action=
"#{cc.attrs.commitaction}"
value=
"#{cc.attrs.commitvalue}"
/>
</h:panelGrid>
</h:form>
...
...
code/LanBortalWeb/WebContent/resources/tools/user/editroles.xhtml
deleted
100644 → 0
View file @
09a2850
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form
id=
"userroleform"
>
<h:panelGrid
columns=
"2"
>
<h:selectManyCheckbox
disabled=
"#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}"
layout=
"pageDirection"
id=
"roles"
value=
"#{userView.userRoleIds}"
>
<f:selectItems
var=
"roleitem"
itemValue=
"#{roleitem.id.id}"
itemLabel=
"#{roleitem.name}"
value=
"#{userView.userRoles}"
/>
</h:selectManyCheckbox>
<h:commandButton
value=
"#{i18n['user.rolesave']}"
action=
"#{userView.saveRoles()}"
/>
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
View file @
ea0bd73
...
...
@@ -15,12 +15,14 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.RoleBeanLocal
;
import
fi.insomnia.bortal.beans.SecurityBeanLocal
;
import
fi.insomnia.bortal.beans.UserBeanLocal
;
import
fi.insomnia.bortal.enums.Permission
;
import
fi.insomnia.bortal.enums.RolePermission
;
import
fi.insomnia.bortal.exceptions.PermissionDeniedException
;
import
fi.insomnia.bortal.model.User
;
import
fi.insomnia.bortal.web.converter.RoleConverter
;
/**
*
...
...
@@ -32,9 +34,8 @@ public class SessionHandler {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SessionHandler
.
class
);
private
User
thisuser
=
null
;
@EJB
private
SecurityBeanLocal
secu
bean
;
private
RoleBeanLocal
role
bean
;
@EJB
private
EventBeanLocal
eventbean
;
@EJB
...
...
@@ -143,7 +144,6 @@ public class SessionHandler {
if
(
sess
!=
null
)
{
sess
.
invalidate
();
}
thisuser
=
null
;
return
"logout"
;
}
...
...
@@ -167,4 +167,8 @@ public class SessionHandler {
{
return
userbean
.
getCurrentUser
();
}
public
RoleConverter
getRoleConverter
()
{
return
new
RoleConverter
(
rolebean
,
eventbean
.
getCurrentEvent
());
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/RoleView.java
View file @
ea0bd73
...
...
@@ -43,7 +43,6 @@ public class RoleView {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RoleView
.
class
);
@EJB
private
UserBeanLocal
userbean
;
private
Set
<
String
>
roleParents
;
private
Role
role
;
private
DataModel
<
Role
>
items
;
...
...
@@ -105,28 +104,10 @@ public class RoleView {
userbean
.
fatalPermission
(
Permission
.
ROLE_MANAGEMENT
,
RolePermission
.
WRITE
,
"Does not have permission to create role!"
);
logger
.
debug
(
"Creating role {}"
,
getRole
());
role
=
roleBean
.
create
(
getRole
());
saveParents
();
return
"roleCreated"
;
}
private
void
saveParents
()
{
for
(
Role
parent:
getPossibleParents
())
{
Integer
parentid
=
parent
.
getId
().
getId
();
boolean
contains
=
this
.
roleParents
.
contains
(
parentid
.
toString
());
if
(
contains
)
{
if
(!
parent
.
getChildren
().
contains
(
role
));
{
parent
.
getChildren
().
add
(
role
);
}
}
else
{
parent
.
getChildren
().
remove
(
role
);
}
}
}
public
String
edit
()
{
userbean
.
fatalPermission
(
Permission
.
ROLE_MANAGEMENT
,
RolePermission
.
READ
);
...
...
@@ -159,11 +140,7 @@ public class RoleView {
* the role to set
*/
public
void
setRole
(
Role
role
)
{
roleParents
=
new
HashSet
<
String
>();
for
(
Role
parent
:
role
.
getParents
())
{
roleParents
.
add
(
parent
.
getId
().
getId
().
toString
());
}
this
.
role
=
role
;
this
.
role
=
role
;
}
/**
...
...
@@ -173,11 +150,5 @@ public class RoleView {
return
roleBean
.
getPossibleParents
(
getRole
());
}
public
void
setRoleParents
(
Set
<
String
>
roleParents
)
{
this
.
roleParents
=
roleParents
;
}
public
Set
<
String
>
getRoleParents
()
{
return
roleParents
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/UserView.java
View file @
ea0bd73
...
...
@@ -49,35 +49,15 @@ public class UserView {
return
"userEdit"
;
}
private
Set
<
String
>
userRoleIds
;
public
List
<
Role
>
getUserRoles
()
{
userBean
.
fatalPermission
(
Permission
.
LOGIN
,
RolePermission
.
READ
,
"does not have permission to view roles at userView!"
);
return
roleBean
.
listRoles
();
}
public
void
saveRoles
()
{
logger
.
debug
(
"saving roles: {}"
,
userRoleIds
);
for
(
Role
role
:
roleBean
.
listRoles
())
{
Integer
roleid
=
role
.
getId
().
getId
();
boolean
contains
=
userRoleIds
.
contains
(
roleid
.
toString
());
logger
.
debug
(
"Roleid {} is contained in roleids {}"
,
roleid
,
contains
);
if
(
contains
)
{
if
(!
role
.
getUsers
().
contains
(
user
))
{
logger
.
debug
(
"Adding role {} to user {}"
,
role
.
getName
(),
user
.
getLogin
());
role
.
getUsers
().
add
(
user
);
roleBean
.
mergeChanges
(
role
);
}
}
else
{
role
.
getUsers
().
remove
(
user
);
logger
.
debug
(
"Removing role {} form user {}"
,
role
.
getName
(),
user
.
getLogin
());
roleBean
.
mergeChanges
(
role
);
}
}
}
public
User
getSelf
()
{
userBean
.
fatalNotLoggedIn
();
setUser
(
userBean
.
getCurrentUser
());
...
...
@@ -150,32 +130,11 @@ public class UserView {
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
if
(
userBean
.
hasPermission
(
Permission
.
ROLE_MANAGEMENT
,
RolePermission
.
READ
))
{
userRoleIds
=
new
HashSet
<
String
>();
List
<
Role
>
roles
=
user
.
getRoles
();
if
(
roles
==
null
)
{
roles
=
new
ArrayList
<
Role
>();
}
else
{
for
(
Role
role
:
roles
)
{
userRoleIds
.
add
(
role
.
getId
().
getId
().
toString
());
}
}
}
}
public
User
getUser
()
{
return
user
;
}
public
void
setUserRoleIds
(
Set
<
String
>
userRoleIds
)
{
logger
.
debug
(
"Set new user role id:s {}"
,
userRoleIds
);
this
.
userRoleIds
=
userRoleIds
;
}
public
Set
<
String
>
getUserRoleIds
()
{
logger
.
debug
(
"Getting user role id:s: {}"
,
userRoleIds
);
return
userRoleIds
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/RoleConverter.java
View file @
ea0bd73
...
...
@@ -29,7 +29,6 @@ public class RoleConverter implements Converter {
public
Object
getAsObject
(
FacesContext
context
,
UIComponent
component
,
String
value
)
{
logger
.
debug
(
"converting string {} to Object"
,
value
);
Role
ret
=
rolebean
.
find
(
Integer
.
parseInt
(
value
),
event
);
logger
.
debug
(
"found {} from conversion"
,
ret
);
return
ret
;
}
...
...
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