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 1ad3bfcb
authored
Oct 23, 2013
by
Antti Tonkyra
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'devel' of codecrew.fi:bortal into devel
2 parents
3bd71466
ce16315e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
58 additions
and
31 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/EventBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/RoleBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PermissionBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/ProductFlag.java
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/EventPermission.java
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/SpecialPermission.java
code/MoyaWeb/WebContent/food/foodShop.xhtml
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
code/MoyaWeb/src/fi/codecrew/moya/rest/RestApplicationEntrypoint.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/EventBean.java
View file @
1ad3bfc
...
...
@@ -6,6 +6,7 @@ import java.util.List;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.ejb.EJB
;
import
javax.ejb.EJBAccessException
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
...
...
@@ -14,17 +15,14 @@ import javax.persistence.PersistenceContext;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
fi.codecrew.moya.enums.apps.EventPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.facade.EventFacade
;
import
fi.codecrew.moya.facade.EventOrganiserFacade
;
import
fi.codecrew.moya.facade.LanEventDomainFacade
;
import
fi.codecrew.moya.facade.LanEventPrivatePropertyFacade
;
import
fi.codecrew.moya.facade.LanEventPropertyFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.LoggingBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
fi.codecrew.moya.enums.apps.EventPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.model.EventOrganiser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEventDomain
;
...
...
@@ -40,7 +38,7 @@ import fi.codecrew.moya.model.LanEventPropertyKey;
@LocalBean
@DeclareRoles
({
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
EventPermission
.
S_MANAGE_PROPERTIES
,
SpecialPermission
.
S_ORGANISATION_ADMIN
,
EventPermission
.
S_MANAGE_EVENT
,
SpecialPermission
.
S_SUPERADMIN
,
})
public
class
EventBean
implements
EventBeanLocal
{
...
...
@@ -138,14 +136,16 @@ public class EventBean implements EventBeanLocal {
}
@Override
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
EventPermission
.
S_MANAGE_EVENT
})
public
LanEvent
mergeChanges
(
LanEvent
event
)
{
if
(!
permbean
.
hasPermission
(
SpecialPermission
.
SUPERADMIN
)
&&
getCurrentEvent
().
equals
(
event
))
{
throw
new
EJBAccessException
(
"Trying to save another event."
);
}
return
eventFacade
.
merge
(
event
);
}
@Override
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
})
public
void
create
(
LanEvent
event
)
{
eventFacade
.
create
(
event
);
...
...
@@ -159,9 +159,8 @@ public class EventBean implements EventBeanLocal {
}
@Override
@RolesAllowed
({
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
public
List
<
LanEventPrivateProperty
>
getPrivateProperties
()
{
@RolesAllowed
({
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
EventPermission
.
S_MANAGE_EVENT
})
public
List
<
LanEventPrivateProperty
>
getPrivateProperties
()
{
return
eventPrivatePropertyFacade
.
findAllForEvent
();
}
...
...
@@ -203,7 +202,7 @@ public class EventBean implements EventBeanLocal {
}
@Override
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
EventPermission
.
S_MANAGE_EVENT
})
public
LanEventProperty
saveOrCreateProperty
(
LanEventProperty
property
)
{
LanEventProperty
ret
=
null
;
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]
{
property
.
getEvent
(),
property
.
getEventorg
(),
property
.
getKey
()
});
...
...
@@ -229,13 +228,13 @@ public class EventBean implements EventBeanLocal {
}
@Override
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
@RolesAllowed
({
SpecialPermission
.
S_SUPERADMIN
,
EventPermission
.
S_MANAGE_EVENT
})
public
EventOrganiser
mergeChanges
(
EventOrganiser
eventorg
)
{
return
eventOrganiserFacade
.
merge
(
eventorg
);
}
@Override
@RolesAllowed
({
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
SpecialPermission
.
S_ORGANISATION_ADMIN
})
@RolesAllowed
({
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
EventPermission
.
S_MANAGE_EVENT
})
public
LanEventPrivateProperty
saveOrCreatePrivateProperty
(
LanEventPrivateProperty
privateProperty
)
{
LanEventPrivateProperty
ret
=
null
;
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]
{
privateProperty
.
getEvent
(),
privateProperty
.
getEventorg
(),
privateProperty
.
getKey
()
});
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
View file @
1ad3bfc
...
...
@@ -117,10 +117,17 @@ public class PermissionBean implements PermissionBeanLocal {
private
EventBeanLocal
eventbean
;
@Override
public
boolean
hasPermission
(
SpecialPermission
perm
)
{
if
(
perm
==
null
)
{
return
false
;
}
return
context
.
isCallerInRole
(
perm
.
toString
());
}
@Override
public
boolean
hasPermission
(
IAppPermission
perm
)
{
if
(
perm
==
null
)
{
if
(
perm
==
null
)
{
return
false
;
}
return
context
.
isCallerInRole
(
perm
.
getFullName
());
...
...
@@ -207,4 +214,5 @@ public class PermissionBean implements PermissionBeanLocal {
throw
new
IllegalStateException
(
"Current security principal has no CN"
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/RoleBean.java
View file @
1ad3bfc
...
...
@@ -19,12 +19,10 @@ import javax.ejb.Stateless;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.facade.RoleFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.RoleBeanLocal
;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.RoleFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.model.ApplicationPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Role
;
...
...
@@ -53,8 +51,9 @@ public class RoleBean implements RoleBeanLocal {
@EJB
private
UserFacade
userFacade
;
// VIEW_ALL pitää olla että voidaan hakea roolien perusteella.
@Override
@RolesAllowed
(
UserPermission
.
S_READ_ROLES
)
@RolesAllowed
(
{
UserPermission
.
S_READ_ROLES
,
UserPermission
.
S_VIEW_ALL
}
)
public
List
<
Role
>
listRoles
()
{
return
roleFacade
.
findAll
();
}
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PermissionBeanLocal.java
View file @
1ad3bfc
...
...
@@ -4,6 +4,7 @@ import javax.ejb.Local;
import
javax.resource.spi.IllegalStateException
;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.User
;
...
...
@@ -39,6 +40,8 @@ public interface PermissionBeanLocal {
boolean
isCurrentUser
(
EventUser
user
);
boolean
hasPermission
(
SpecialPermission
superadmin
);
// boolean hasPermission(String perm);
}
code/MoyaDatabase/src/fi/codecrew/moya/model/ProductFlag.java
View file @
1ad3bfc
...
...
@@ -3,7 +3,8 @@ package fi.codecrew.moya.model;
public
enum
ProductFlag
{
// FOODWAVE_ITEM, Äy... Ei kai tämän täällä tarvitse olla....
PREPAID_CREDIT
,
PREPAID_CREDIT
,
// Tämä ei ole missään käytössä. Poistetaas jossain
// vaiheessa --tuomari
CREATE_NEW_PLACE_WHEN_BOUGHT
,
RESERVE_PLACE_WHEN_BOUGHT
,
PREPAID_INSTANT_CREATE
,
USER_SHOPPABLE
;
...
...
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/EventPermission.java
View file @
1ad3bfc
...
...
@@ -6,11 +6,13 @@ public enum EventPermission implements IAppPermission {
MANAGE_PROPERTIES
,
MANAGE_PRIVATE_PROPERTIES
,
MANAGE_EVENT
;
public
static
final
String
S_MANAGE_PROPERTIES
=
"EVENT/MANAGE_PROPERTIES"
;
public
static
final
String
S_MANAGE_PRIVATE_PROPERTIES
=
"EVENT/MANAGE_PRIVATE_PROPERTIES"
;
public
static
final
String
S_MANAGE_EVENT
=
"EVENT/MANAGE_EVENT"
;
private
final
String
fullName
;
private
final
String
key
;
...
...
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/SpecialPermission.java
View file @
1ad3bfc
...
...
@@ -4,14 +4,14 @@ public enum SpecialPermission {
SUPERADMIN
,
USER
,
ANONYMOUS
,
ORGANISATION_ADMIN
,
//
ORGANISATION_ADMIN,
VERKKOMAKSU_CHECKER
;
public
static
final
String
S_USER
=
"USER"
;
public
static
final
String
S_SUPERADMIN
=
"SUPERADMIN"
;
public
static
final
String
S_ANONYMOUS
=
"ANONYMOUS"
;
public
static
final
String
S_ORGANISATION_ADMIN
=
"ORGANISATION_ADMIN"
;
//
public static final String S_ORGANISATION_ADMIN = "ORGANISATION_ADMIN";
public
static
final
String
S_VERKKOMAKSU_CHECK
=
"VERKKOMAKSU_CHECKER"
;
}
code/MoyaWeb/WebContent/food/foodShop.xhtml
View file @
1ad3bfc
...
...
@@ -17,7 +17,8 @@
</ui:define>
<ui:define
name=
"content"
>
TÄTÄ EI KÄYTETÄ MISSÄÄN! (Toivottavasti... )
Ilmoita tuomarille jos asia on toisin...
<h:form
id=
"shoppingcartform"
>
...
...
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
View file @
1ad3bfc
...
...
@@ -46,8 +46,8 @@
<img
src=
"#{request.contextPath}/resources/templates/insomnia2/img/devel_logo.png"
/>
</c:when>
<c:otherwise>
<p:graphicImage
rendered=
"#{
!empty layoutView.headeri
mage}"
value=
"#{layoutView.headerimage}"
/>
<ui:fragment
rendered=
"#{
empty layoutView.headeri
mage}"
>
<p:graphicImage
rendered=
"#{
layoutView.isHeaderI
mage}"
value=
"#{layoutView.headerimage}"
/>
<ui:fragment
rendered=
"#{
!layoutView.isHeaderI
mage}"
>
<h1>
<h:outputText
value=
"#{layoutView.headertext}"
/>
</h1>
...
...
code/MoyaWeb/src/fi/codecrew/moya/rest/RestApplicationEntrypoint.java
0 → 100644
View file @
1ad3bfc
package
fi
.
codecrew
.
moya
.
rest
;
import
javax.ws.rs.ApplicationPath
;
import
javax.ws.rs.core.Application
;
@ApplicationPath
(
"/rest"
)
public
class
RestApplicationEntrypoint
extends
Application
{
}
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
View file @
1ad3bfc
...
...
@@ -75,9 +75,9 @@ public class LayoutView {
{
selectedSet
=
new
HashSet
<>();
selectedTop
=
menubean
.
findNavigation
(
getPagepath
());
while
(
selectedTop
!=
null
&&
selectedTop
.
getParent
()
!=
null
)
{
selectedTop
=
selectedTop
.
getParent
();
while
(
selectedTop
!=
null
)
{
selectedSet
.
add
(
selectedTop
);
selectedTop
=
selectedTop
.
getParent
();
}
List
<
MenuNavigation
>
tops
=
menubean
.
getTopmenus
();
...
...
@@ -150,6 +150,11 @@ public class LayoutView {
// return "";
// }
public
boolean
getIsHeaderImage
()
{
return
getHeaderimage
()
!=
null
;
}
public
StreamedContent
getHeaderimage
()
{
if
(
headertext
==
null
&&
headerimage
==
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