Commit 298fc0db by Antti Tonkyra

Merge branch 'devel' of codecrew.fi:bortal into devel

Conflicts:
	code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
2 parents df02733b 7011d55f
......@@ -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;
}
}
......@@ -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();
......
......@@ -36,4 +36,6 @@ public interface BillBeanLocal {
List<Bill> find(EventUser user);
Bill expireBill(Bill bill);
}
......@@ -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";
......
<!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>
......
......@@ -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
......@@ -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");
......
......@@ -223,14 +223,17 @@ resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password.
resetmailSent.header = Email sent
submenu.NotImplementedYet = Not implemented
submenu.NotImplementedYet = Not implemented
submenu.frontpage = Frontpage
subnavi.cards = \u0009\u0009
topnavi.license = Lisenssikoodit
user.cropImage = Crop
user.unauthenticated = Kirjautumaton
user.cropImage = Crop
user.imageUpload.imageNotFound = Select image to upload
user.unauthenticated = Kirjautumaton
usercart.downloadCsv = CSV
usercart.showoverview = Vie tarkastusn\u00E4kym\u00E4\u00E4n
......@@ -886,6 +886,7 @@ submenu.foodadmin.createTemplate = Luo tilauspohja
submenu.foodadmin.listTemplates = Muokkaa tilauspohjia
submenu.foodmanager.listFoodwaves = Aktiiviset ruokatilaukset
submenu.foodwave.list = Ruokatilaukset
submenu.frontpage = Etusivu
submenu.index = Etusivu
submenu.license.manageCodes = Hallinnoi lisenssej\u00E4
submenu.license.viewCodes = N\u00E4yt\u00E4 koodit
......@@ -1106,6 +1107,7 @@ user.foodwave.products.title = Valitse tuotteet
user.foodwavelist.title = Valitse Ruokatilaus
user.hasImage = Kuva
user.imageTooBig = Kuva on liian suuri
user.imageUpload.imageNotFound = Valitse ensin kuva jonka haluat l\u00E4hett\u00E4\u00E4
user.imageUploaded = Kuva l\u00E4hetetty.
user.imagelist = Tallennetut kuvat
user.imagesubmit = L\u00E4het\u00E4 kuva
......
......@@ -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()
......
......@@ -88,7 +88,8 @@ public class PlaceView extends GenericCDIView {
place = placebean.findPlace(getCurrentMap(), x, y);
logger.debug("Clicked place: {}", place);
if (place != null) {
//Don't try to calculate stuff is not logged in
if (permbean.isLoggedIn() && place != null) {
logger.info("placeinfo User {}, group {}", place.getCurrentUser(), place.getGroup());
......@@ -102,6 +103,7 @@ public class PlaceView extends GenericCDIView {
BigDecimal balance = user.getAccountBalance();
BigDecimal price = null;
if (permbean.isCurrentUser(user)) {
price = placebean.getTotalReservationPrice(place);
} else {
......
......@@ -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);
}
}
}
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<HttpSessionWrapper> 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<HttpSessionWrapper> getSessions() {
return sessions;
}
public void setSessions(ListDataModel<HttpSession> sessions) {
public void setSessions(ListDataModel<HttpSessionWrapper> sessions) {
this.sessions = sessions;
}
......
......@@ -234,7 +234,7 @@ public class UserView extends GenericCDIView {
}
public String sendImage() throws IOException {
if (image == null) {
if (image == null || image.getSize() < 1) {
super.addFaceMessage("user.imageUpload.imageNotFound");
} else {
......
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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!