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 df716303
authored
Apr 07, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add organisation role requesting bean functions
1 parent
a441fb90
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
2 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/OrgRoleBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/OrgRoleBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/OrgRoleFacade.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/OrgRoleRequestFacade.java
code/moya-utils/src/main/java/fi/codecrew/moya/enums/apps/UserPermission.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/OrgRoleBeanLocal.java
View file @
df71630
...
@@ -23,6 +23,7 @@ import java.util.List;
...
@@ -23,6 +23,7 @@ import java.util.List;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.OrgRole
;
import
fi.codecrew.moya.model.OrgRole
;
import
fi.codecrew.moya.model.OrgRoleRequest
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
...
@@ -45,4 +46,8 @@ public interface OrgRoleBeanLocal {
...
@@ -45,4 +46,8 @@ public interface OrgRoleBeanLocal {
OrgRole
addEventRole
(
Role
eventRole
,
OrgRole
orgRole
);
OrgRole
addEventRole
(
Role
eventRole
,
OrgRole
orgRole
);
void
createRequest
(
OrgRoleRequest
request
);
List
<
OrgRole
>
getRequestableRoles
();
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/OrgRoleBean.java
View file @
df71630
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,9 +34,11 @@ import org.slf4j.LoggerFactory;
...
@@ -33,9 +34,11 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.OrgRoleFacade
;
import
fi.codecrew.moya.facade.OrgRoleFacade
;
import
fi.codecrew.moya.facade.OrgRoleRequestFacade
;
import
fi.codecrew.moya.facade.RoleFacade
;
import
fi.codecrew.moya.facade.RoleFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.model.OrgRole
;
import
fi.codecrew.moya.model.OrgRole
;
import
fi.codecrew.moya.model.OrgRoleRequest
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.jpa.GenericFacade
;
import
fi.codecrew.moya.utilities.jpa.GenericFacade
;
...
@@ -45,7 +48,11 @@ import fi.codecrew.moya.utilities.jpa.GenericFacade;
...
@@ -45,7 +48,11 @@ import fi.codecrew.moya.utilities.jpa.GenericFacade;
*/
*/
@Stateless
@Stateless
@LocalBean
@LocalBean
@DeclareRoles
({
UserPermission
.
S_READ_ORGROLES
,
UserPermission
.
S_WRITE_ORGROLES
})
@DeclareRoles
({
UserPermission
.
S_READ_ORGROLES
,
UserPermission
.
S_WRITE_ORGROLES
,
UserPermission
.
S_REQUEST_ORGROLES
,
})
public
class
OrgRoleBean
implements
OrgRoleBeanLocal
{
public
class
OrgRoleBean
implements
OrgRoleBeanLocal
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrgRoleBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrgRoleBean
.
class
);
...
@@ -62,6 +69,10 @@ public class OrgRoleBean implements OrgRoleBeanLocal {
...
@@ -62,6 +69,10 @@ public class OrgRoleBean implements OrgRoleBeanLocal {
private
UserFacade
userFacade
;
private
UserFacade
userFacade
;
@EJB
@EJB
private
RoleFacade
roleFacade
;
private
RoleFacade
roleFacade
;
@EJB
private
PermissionBean
permbean
;
@EJB
private
OrgRoleRequestFacade
orgrolerequestfacade
;
public
OrgRoleBean
()
{
public
OrgRoleBean
()
{
}
}
...
@@ -183,4 +194,17 @@ public class OrgRoleBean implements OrgRoleBeanLocal {
...
@@ -183,4 +194,17 @@ public class OrgRoleBean implements OrgRoleBeanLocal {
return
orgRole
;
return
orgRole
;
}
}
@Override
@RolesAllowed
({
UserPermission
.
S_REQUEST_ORGROLES
})
public
void
createRequest
(
OrgRoleRequest
request
)
{
request
.
setRequestDate
(
new
Date
());
request
.
setUser
(
permbean
.
getCurrentUser
().
getUser
());
orgrolerequestfacade
.
create
(
request
);
}
@Override
@RolesAllowed
({
UserPermission
.
S_REQUEST_ORGROLES
})
public
List
<
OrgRole
>
getRequestableRoles
()
{
return
orgRoleFacade
.
findUserRequestable
();
}
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/OrgRoleFacade.java
View file @
df71630
...
@@ -87,4 +87,17 @@ public class OrgRoleFacade extends IntegerPkGenericFacade<OrgRole> {
...
@@ -87,4 +87,17 @@ public class OrgRoleFacade extends IntegerPkGenericFacade<OrgRole> {
return
getEm
().
createQuery
(
cq
).
getResultList
();
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
public
List
<
OrgRole
>
findUserRequestable
()
{
EventOrganiser
org
=
eventBean
.
getCurrentEvent
().
getOrganiser
();
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
OrgRole
>
cq
=
cb
.
createQuery
(
OrgRole
.
class
);
Root
<
OrgRole
>
root
=
cq
.
from
(
OrgRole
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
OrgRole_
.
eventOrganisation
),
org
),
cb
.
isTrue
(
root
.
get
(
OrgRole_
.
userRequestable
))
);
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/OrgRoleRequestFacade.java
0 → 100644
View file @
df71630
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.model.OrgRoleRequest
;
/**
* Session Bean implementation class OrgRoleFacade
*/
@Stateless
@LocalBean
public
class
OrgRoleRequestFacade
extends
IntegerPkGenericFacade
<
OrgRoleRequest
>
{
@EJB
EventBeanLocal
eventBean
;
public
OrgRoleRequestFacade
()
{
super
(
OrgRoleRequest
.
class
);
}
}
code/moya-utils/src/main/java/fi/codecrew/moya/enums/apps/UserPermission.java
View file @
df71630
...
@@ -37,11 +37,13 @@ public enum UserPermission implements IAppPermission {
...
@@ -37,11 +37,13 @@ public enum UserPermission implements IAppPermission {
INVITE_USERS
,
// ("Invite users"),
INVITE_USERS
,
// ("Invite users"),
READ_ORGROLES
,
// ("View organization roles"),
READ_ORGROLES
,
// ("View organization roles"),
WRITE_ORGROLES
,
// ("Modify organization roles"),
WRITE_ORGROLES
,
// ("Modify organization roles"),
REQUEST_ORGROLES
,
VITUTTAAKO
,
VITUTTAAKO
,
LOGGED_IN_USER
,
LOGGED_IN_USER
,
MODIFY_OWN_GAMEIDS
,
MODIFY_OWN_GAMEIDS
,
VIEW_ALL_GAMEIDS
,
VIEW_ALL_GAMEIDS
,
HELPPAGE
;
HELPPAGE
,
;
public
static
final
String
S_VIEW_ALL
=
"USER/VIEW_ALL"
;
public
static
final
String
S_VIEW_ALL
=
"USER/VIEW_ALL"
;
public
static
final
String
S_MODIFY
=
"USER/MODIFY"
;
public
static
final
String
S_MODIFY
=
"USER/MODIFY"
;
...
@@ -59,6 +61,7 @@ public enum UserPermission implements IAppPermission {
...
@@ -59,6 +61,7 @@ public enum UserPermission implements IAppPermission {
public
static
final
String
S_INVITE_USERS
=
"USER/INVITE_USERS"
;
public
static
final
String
S_INVITE_USERS
=
"USER/INVITE_USERS"
;
public
static
final
String
S_READ_ORGROLES
=
"USER/READ_ORGROLES"
;
public
static
final
String
S_READ_ORGROLES
=
"USER/READ_ORGROLES"
;
public
static
final
String
S_WRITE_ORGROLES
=
"USER/WRITE_ORGROLES"
;
public
static
final
String
S_WRITE_ORGROLES
=
"USER/WRITE_ORGROLES"
;
public
static
final
String
S_REQUEST_ORGROLES
=
"USER/REQUEST_ORGROLES"
;
public
static
final
String
S_VITUTTAAKO
=
"USER/VITUTTAAKO"
;
public
static
final
String
S_VITUTTAAKO
=
"USER/VITUTTAAKO"
;
public
static
final
String
S_MODIFY_OWN_GAMEIDS
=
"USER/MODIFY_OWN_GAMEIDS"
;
public
static
final
String
S_MODIFY_OWN_GAMEIDS
=
"USER/MODIFY_OWN_GAMEIDS"
;
public
static
final
String
S_VIEW_ALL_GAMEIDS
=
"USER/VIEW_ALL_GAMEIDS"
;
public
static
final
String
S_VIEW_ALL_GAMEIDS
=
"USER/VIEW_ALL_GAMEIDS"
;
...
...
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