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 90200b00
authored
Sep 16, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Random fixes...
1 parent
90bf9f43
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
207 additions
and
40 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BillBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BillBeanLocal.java
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/MapPermission.java
code/MoyaWeb/WebContent/auth/userSessionList.xhtml
code/MoyaWeb/pom.xml
code/MoyaWeb/src/fi/codecrew/moya/handler/SessionHandler.java
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceMap.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/BillEditView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserSessionView.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BillBean.java
View file @
90200b0
...
...
@@ -292,4 +292,17 @@ public class BillBean implements BillBeanLocal {
return
billFacade
.
find
(
user
);
}
@Override
@RolesAllowed
({
BillPermission
.
S_VIEW_OWN
,
BillPermission
.
S_WRITE_ALL
})
public
Bill
expireBill
(
Bill
bill
)
{
if
(!
permbean
.
isCurrentUser
(
bill
.
getUser
())
&&
!
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
))
{
loggingBean
.
logMessage
(
SecurityLogType
.
permissionDenied
,
permbean
.
getCurrentUser
(),
"Not enought rights to expire a bill for user "
);
throw
new
EJBAccessException
(
"Could not list bills for another user"
);
}
bill
=
billFacade
.
reload
(
bill
);
bill
.
markExpired
();
return
bill
;
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
90200b0
...
...
@@ -464,7 +464,7 @@ public class PlaceBean implements PlaceBeanLocal {
* @return true when successfull, on any erroro false.
*/
@Override
@RolesAllowed
({
MapPermission
.
S_
RELEASE_PLACE
,
MapPermission
.
S_MANAGE_OTHERS
})
@RolesAllowed
({
MapPermission
.
S_
BUY_PLACES
,
MapPermission
.
S_MANAGE_OTHERS
})
public
boolean
releasePlace
(
Place
place
)
{
place
=
placeFacade
.
find
(
place
.
getId
());
EventUser
user
=
permbean
.
getCurrentUser
();
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BillBeanLocal.java
View file @
90200b0
...
...
@@ -36,4 +36,6 @@ public interface BillBeanLocal {
List
<
Bill
>
find
(
EventUser
user
);
Bill
expireBill
(
Bill
bill
);
}
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/MapPermission.java
View file @
90200b0
...
...
@@ -6,12 +6,13 @@ public enum MapPermission implements IAppPermission {
MANAGE_OTHERS
,
// ("Manage other users reservations in map"),
BUY_PLACES
,
// ("Reserve and buy places from map"),
VIEW
,
// ("View maps"),
MANAGE_MAPS
,
RELEASE_PLACE
,
// ("Create and modify maps")
MANAGE_MAPS
,
//RELEASE_PLACE, // ("Create and modify maps")
;
public
static
final
String
S_MANAGE_OTHERS
=
"MAP/MANAGE_OTHERS"
;
public
static
final
String
S_BUY_PLACES
=
"MAP/BUY_PLACES"
;
//
public static final String S_BUY_PLACES = "MAP/BUY_PLACES";
public
static
final
String
S_VIEW
=
"MAP/VIEW"
;
public
static
final
String
S_MANAGE_MAPS
=
"MAP/MANAGE_MAPS"
;
public
static
final
String
S_RELEASE_PLACE
=
"MAP/RELEASE_PLACE"
;
...
...
code/MoyaWeb/WebContent/auth/userSessionList.xhtml
View file @
90200b0
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<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:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
...
...
@@ -30,13 +28,18 @@
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['httpsession.creationTime']}"
/>
</f:facet>
<h:outputText
value=
"#{sess.creationTime}"
/>
<h:outputText
value=
"#{sess.creationDateTime}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.shortDatetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['httpsession.lastAccessedTime']}"
/>
</f:facet>
<h:outputText
value=
"#{sess.lastAccessedTime}"
/>
<h:outputText
value=
"#{sess.lastAccessedDateTime}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.shortDatetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</h:column>
<h:column>
<f:facet
name=
"header"
>
...
...
@@ -59,7 +62,7 @@
<h:column>
<h:commandButton
action=
"#{userSessionView.invalidateSession}"
value=
"#{i18n['httpsession.invalidate']}"
/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
...
...
code/MoyaWeb/pom.xml
View file @
90200b0
...
...
@@ -54,11 +54,6 @@
<version>
0.2.0
</version>
</dependency>
<dependency>
<groupId>
org.primefaces
</groupId>
<artifactId>
primefaces
</artifactId>
<version>
4.0-20130828.122054-5
</version>
</dependency>
<dependency>
<groupId>
org.apache.sshd
</groupId>
<artifactId>
sshd-core
</artifactId>
<version>
0.8.0
</version>
...
...
@@ -83,5 +78,10 @@
<artifactId>
commons-fileupload
</artifactId>
<version>
1.3
</version>
</dependency>
<dependency>
<groupId>
org.primefaces
</groupId>
<artifactId>
primefaces
</artifactId>
<version>
4.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/handler/SessionHandler.java
View file @
90200b0
...
...
@@ -165,6 +165,11 @@ public class SessionHandler {
return
"dd.MM.yyyy HH:mm"
;
}
public
String
getShortDatetimeFormat
()
{
return
"dd.MM HH:MM:ss"
;
}
public
boolean
hasPermission
(
IAppPermission
permission
)
{
if
(
permission
==
null
)
{
logger
.
warn
(
"permission is null"
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceMap.java
View file @
90200b0
...
...
@@ -248,7 +248,9 @@ public class PlaceMap extends HttpServlet {
if
(!
p
.
isBuyable
())
{
color
=
LOCKED_COLOR
;
}
if
(
p
.
isReservedFor
(
user
))
{
logger
.
info
(
"Setting place selected {}"
,
p
);
color
=
SELECTED_COLOR
;
}
else
if
(
user
.
equals
(
p
.
getCurrentUser
())
||
(
p
.
getGroup
()
!=
null
&&
user
.
equals
(
p
.
getGroup
()
...
...
@@ -256,8 +258,12 @@ public class PlaceMap extends HttpServlet {
||
(
p
.
getPlaceReserver
()
!=
null
&&
user
.
equals
(
p
.
getPlaceReserver
().
getUser
())))
{
color
=
OWNED_COLOR
;
logger
.
info
(
"Setting place owned {}"
,
p
);
}
else
if
(
p
.
isTaken
())
{
color
=
RESERVED_COLOR
;
logger
.
info
(
"Setting place Reserved {}"
,
p
);
}
else
if
(
p
.
getProduct
().
getColor
()
!=
null
&&
!
p
.
getProduct
().
getColor
().
isEmpty
())
{
try
{
...
...
@@ -272,6 +278,7 @@ public class PlaceMap extends HttpServlet {
.
getHeight
()));
if
(
color
!=
null
)
{
logger
.
info
(
"Setting fill color: {} for p"
,
color
,
p
);
g
.
setColor
(
color
);
g
.
fill
(
new
Rectangle
(
p
.
getMapX
()
+
BORDER_WIDTH
,
p
.
getMapY
()
+
BORDER_WIDTH
,
p
.
getWidth
()
-
BORDER_WIDTH
,
p
.
getHeight
()
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/BillEditView.java
View file @
90200b0
...
...
@@ -116,24 +116,9 @@ public class BillEditView extends GenericCDIView {
public
void
setVmreturn
(
VerkkomaksutReturnEntry
vmreturn
)
{
this
.
vmreturn
=
vmreturn
;
}
public
void
expireBill
()
{
System
.
out
.
println
(
"EXPIRE BILL; WE ARE THERE"
);
bill
.
markExpired
();
System
.
out
.
println
(
""
+
bill
.
getExpires
().
getTime
());
this
.
save
();
bill
=
billbean
.
expireBill
(
bill
);
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserSessionView.java
View file @
90200b0
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
user
;
import
java.util.ArrayList
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
...
...
@@ -14,6 +12,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.beans.SessionMgmtBeanLocal
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.helper.HttpSessionWrapper
;
@Named
@ConversationScoped
...
...
@@ -22,10 +21,10 @@ public class UserSessionView extends GenericCDIView {
private
static
final
long
serialVersionUID
=
-
5305969666679378884L
;
@EJB
private
transient
SessionMgmtBeanLocal
sessionMgmt
;
private
transient
ListDataModel
<
HttpSession
>
sessions
;
private
transient
ListDataModel
<
HttpSession
Wrapper
>
sessions
;
private
transient
HttpSession
session
;
@SuppressWarnings
(
"unused"
)
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserSessionView
.
class
);
...
...
@@ -33,16 +32,16 @@ public class UserSessionView extends GenericCDIView {
{
if
(
super
.
requirePermissions
(
UserPermission
.
MANAGE_HTTP_SESSION
)
&&
sessions
==
null
)
{
sessions
=
new
ListDataModel
<
HttpSession
>(
new
ArrayList
<
HttpSession
>
(
sessionMgmt
.
getSessions
()));
sessions
=
new
ListDataModel
<
>(
HttpSessionWrapper
.
wrap
(
sessionMgmt
.
getSessions
()));
super
.
beginConversation
();
}
}
public
ListDataModel
<
HttpSession
>
getSessions
()
{
public
ListDataModel
<
HttpSession
Wrapper
>
getSessions
()
{
return
sessions
;
}
public
void
setSessions
(
ListDataModel
<
HttpSession
>
sessions
)
{
public
void
setSessions
(
ListDataModel
<
HttpSession
Wrapper
>
sessions
)
{
this
.
sessions
=
sessions
;
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
0 → 100644
View file @
90200b0
package
fi
.
codecrew
.
moya
.
web
.
helper
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Set
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSessionContext
;
public
class
HttpSessionWrapper
implements
HttpSession
{
private
final
HttpSession
session
;
public
HttpSessionWrapper
(
HttpSession
session
)
{
this
.
session
=
session
;
}
@Override
public
Object
getAttribute
(
String
attr
)
{
return
session
.
getAttribute
(
attr
);
}
@Override
public
Enumeration
<
String
>
getAttributeNames
()
{
return
session
.
getAttributeNames
();
}
@Override
public
long
getCreationTime
()
{
return
session
.
getCreationTime
();
}
public
Date
getCreationDateTime
()
{
Date
ret
=
null
;
try
{
ret
=
new
Date
(
session
.
getCreationTime
());
}
catch
(
Throwable
t
)
{
ret
=
null
;
}
return
ret
;
}
@Override
public
String
getId
()
{
return
session
.
getId
();
}
@Override
public
long
getLastAccessedTime
()
{
return
session
.
getLastAccessedTime
();
}
public
Date
getLastAccessedDateTime
()
{
Date
ret
=
null
;
try
{
ret
=
new
Date
(
session
.
getLastAccessedTime
());
}
catch
(
Throwable
t
)
{
ret
=
null
;
}
return
ret
;
}
@Override
public
int
getMaxInactiveInterval
()
{
return
session
.
getMaxInactiveInterval
();
}
@Override
public
ServletContext
getServletContext
()
{
return
session
.
getServletContext
();
}
@Override
public
HttpSessionContext
getSessionContext
()
{
return
session
.
getSessionContext
();
}
@Override
public
Object
getValue
(
String
arg0
)
{
return
session
.
getValue
(
arg0
);
}
@Override
public
String
[]
getValueNames
()
{
return
session
.
getValueNames
();
}
@Override
public
void
invalidate
()
{
session
.
invalidate
();
}
@Override
public
boolean
isNew
()
{
return
session
.
isNew
();
}
@Override
public
void
putValue
(
String
arg0
,
Object
arg1
)
{
session
.
putValue
(
arg0
,
arg1
);
}
@Override
public
void
removeAttribute
(
String
arg0
)
{
session
.
removeAttribute
(
arg0
);
}
@Override
public
void
removeValue
(
String
arg0
)
{
session
.
removeValue
(
arg0
);
}
@Override
public
void
setAttribute
(
String
arg0
,
Object
arg1
)
{
session
.
setAttribute
(
arg0
,
arg1
);
}
@Override
public
void
setMaxInactiveInterval
(
int
arg0
)
{
session
.
setMaxInactiveInterval
(
arg0
);
}
public
static
List
<
HttpSessionWrapper
>
wrap
(
Set
<
HttpSession
>
sessions
)
{
ArrayList
<
HttpSessionWrapper
>
ret
=
new
ArrayList
<>();
for
(
HttpSession
s
:
sessions
)
{
ret
.
add
(
new
HttpSessionWrapper
(
s
));
}
Collections
.
sort
(
ret
,
new
LastSeenComparator
());
return
ret
;
}
private
static
class
LastSeenComparator
implements
Comparator
<
HttpSessionWrapper
>
{
@Override
public
int
compare
(
HttpSessionWrapper
o1
,
HttpSessionWrapper
o2
)
{
return
Long
.
compare
(
o1
.
getLastAccessedTime
(),
o2
.
getLastAccessedTime
());
}
}
}
\ No newline at end of file
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