Commit 47e28be6 by Tuomas Riihimäki

Muutettu oikeusjärjestelmä. Laskujen ja paikkojen varaus toteutettu ja testattu

1 parent e03df159
Showing with 4426 additions and 1345 deletions
......@@ -68,6 +68,7 @@ public class BortalLoginModule extends AppservPasswordLoginModule {
@Override
protected void authenticateUser() throws LoginException {
log((new StringBuilder()).append("CustomRealm Auth Info:_username:")
.append(_username)
// .append(";_password:").append(_passwd)
......
......@@ -75,7 +75,6 @@ public class BortalRealm extends AppservRealm {
throws BadRealmException, NoSuchRealmException {
super.init(properties);
log("Init BortalRealm");
String propJaasContext = properties.getProperty(JAAS_CONTEXT_PARAM);
if (propJaasContext != null) {
setProperty(JAAS_CONTEXT_PARAM, propJaasContext);
......
......@@ -12,7 +12,5 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="src" path="/LanBortalUtilities"/>
<classpathentry kind="src" path="/UtilClasses"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
Manifest-Version: 1.0
Class-Path: LanBortalBeansClient.jar
lib/LanBortalUtilities.jar
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<security-role-mapping>
<role-name>ANONYMOUS</role-name>
<group-name>ANONYMOUS</group-name>
<role-name>USER/READ_ROLES</role-name>
<group-name>USER/READ_ROLES</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ORGANIZATION_ROOT</role-name>
<group-name>ORGANIZATION_ROOT</group-name>
<role-name>USER/WRITE_ROLES</role-name>
<group-name>USER/WRITE_ROLES</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>SUPERADMIN</role-name>
<group-name>SUPERADMIN</group-name>
<role-name>USER/VIEW_ALL</role-name>
<group-name>USER/VIEW_ALL</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ADMIN_BASE</role-name>
<group-name>ADMIN_BASE</group-name>
<role-name>USER/VIEW_SELF</role-name>
<group-name>USER/VIEW_SELF</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USER_BASE</role-name>
<group-name>USER_BASE</group-name>
<role-name>USER/CREATE_NEW</role-name>
<group-name>USER/CREATE_NEW</group-name>
<principal-name>ANONYMOUS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>LOGIN/READ</role-name>
<group-name>LOGIN/READ</group-name>
<role-name>USER/MODIFY</role-name>
<group-name>USER/MODIFY</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>LOGIN/WRITE</role-name>
<group-name>LOGIN/WRITE</group-name>
<role-name>SUPERADMIN</role-name>
<group-name>SUPERADMIN</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>LOGIN/EXECUTE</role-name>
<group-name>LOGIN/EXECUTE</group-name>
<role-name>BILL/WRITE_ALL</role-name>
<group-name>BILL/WRITE_ALL</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USER_MANAGEMENT/READ</role-name>
<group-name>USER_MANAGEMENT/READ</group-name>
<role-name>POLL/ANSWER</role-name>
<group-name>POLL/ANSWER</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USER_MANAGEMENT/WRITE</role-name>
<group-name>USER_MANAGEMENT/WRITE</group-name>
<role-name>POLL/ANSWER</role-name>
<group-name>POLL/ANSWER</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USER_MANAGEMENT/EXECUTE</role-name>
<group-name>USER_MANAGEMENT/EXECUTE</group-name>
<role-name>POLL/VIEW_RESULTS</role-name>
<group-name>POLL/VIEW_RESULTS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ACCOUNT_MANAGEMENT/READ</role-name>
<group-name>ACCOUNT_MANAGEMENT/READ</group-name>
<role-name>POLL/CREATE</role-name>
<group-name>POLL/CREATE</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ACCOUNT_MANAGEMENT/WRITE</role-name>
<group-name>ACCOUNT_MANAGEMENT/WRITE</group-name>
<role-name>BILL/READ_ALL</role-name>
<group-name>BILL/READ_ALL</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ACCOUNT_MANAGEMENT/EXECUTE</role-name>
<group-name>ACCOUNT_MANAGEMENT/EXECUTE</group-name>
<role-name>BILL/CREATE_BILL</role-name>
<group-name>BILL/CREATE_BILL</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>BILL/READ</role-name>
<group-name>BILL/READ</group-name>
<role-name>LOGIN/LOGOUT</role-name>
<group-name>LOGIN/LOGOUT</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>BILL/WRITE</role-name>
<group-name>BILL/WRITE</group-name>
<role-name>LOGIN/LOGIN</role-name>
<group-name>LOGIN/LOGIN</group-name>
<principal-name>ANONUMOUS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>BILL/EXECUTE</role-name>
<group-name>BILL/EXECUTE</group-name>
<role-name>MAP/MANAGE_OTHERS</role-name>
<group-name>MAP/MANAGE_OTHERS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>MAP/READ</role-name>
<group-name>MAP/READ</group-name>
<role-name>MAP/BUY_PLACES</role-name>
<group-name>MAP/BUY_PLACES</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>MAP/WRITE</role-name>
<group-name>MAP/WRITE</group-name>
<role-name>MAP/VIEW</role-name>
<group-name>MAP/VIEW</group-name>
<principal-name>ANONUMOUS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>MAP/EXECUTE</role-name>
<group-name>MAP/EXECUTE</group-name>
<role-name>MAP/MANAGE_MAPS</role-name>
<group-name>MAP/MANAGE_MAPS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ROLE_MANAGEMENT/READ</role-name>
<group-name>ROLE_MANAGEMENT/READ</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ROLE_MANAGEMENT/WRITE</role-name>
<group-name>ROLE_MANAGEMENT/WRITE</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ROLE_MANAGEMENT/EXECUTE</role-name>
<group-name>ROLE_MANAGEMENT/EXECUTE</group-name>
<role-name>SHOP/LIST_ALL_PRODUCTS</role-name>
<group-name>SHOP/LIST_ALL_PRODUCTS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>PRODUCT/READ</role-name>
<group-name>PRODUCT/READ</group-name>
<role-name>SHOP/MANAGE_PRODUCTS</role-name>
<group-name>SHOP/MANAGE_PRODUCTS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>PRODUCT/WRITE</role-name>
<group-name>PRODUCT/WRITE</group-name>
<role-name>ROLE_MANAGEMENT/WRITE</role-name>
<group-name>ROLE_MANAGEMENT/WRITE</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>PRODUCT/EXECUTE</role-name>
<group-name>PRODUCT/EXECUTE</group-name>
<role-name>SHOP/SHOP_PRODUCTS</role-name>
<group-name>SHOP/SHOP_PRODUCTS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>SHOP/READ</role-name>
<group-name>SHOP/READ</group-name>
<role-name>SHOP/LIST_USERPRODUCTS</role-name>
<group-name>SHOP/LIST_USERPRODUCTS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>SHOP/WRITE</role-name>
<group-name>SHOP/WRITE</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>SHOP/EXECUTE</role-name>
<group-name>SHOP/EXECUTE</group-name>
<role-name>USER</role-name>
<group-name>USER</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>GAME/READ</role-name>
<group-name>GAME/READ</group-name>
<role-name>USER/LOGIN</role-name>
<group-name>USER/LOGIN</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>GAME/WRITE</role-name>
<group-name>GAME/WRITE</group-name>
<role-name>MAP/READ</role-name>
<group-name>MAP/READ</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>GAME/EXECUTE</role-name>
<group-name>GAME/EXECUTE</group-name>
<role-name>SHOP/SHOP_TO_OTHERS</role-name>
<group-name>SHOP/SHOP_TO_OTHERS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>POLL/READ</role-name>
<group-name>POLL/READ</group-name>
<role-name>ANONYMOUS</role-name>
<group-name>ANONYMOUS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>POLL/WRITE</role-name>
<group-name>POLL/WRITE</group-name>
<role-name>ANONYMOUS</role-name>
<group-name>ANONYMOUS</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>POLL/EXECUTE</role-name>
<group-name>POLL/EXECUTE</group-name>
<role-name>ANONYMOUS</role-name>
<group-name>ANONYMOUS</group-name>
</security-role-mapping>
<enterprise-beans/>
</sun-ejb-jar>
package fi.insomnia.bortal;
public interface PermissionStrings {
}
......@@ -15,6 +15,8 @@ import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.facade.AccountEventFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.EventPk;
......@@ -27,7 +29,7 @@ import fi.insomnia.bortal.model.User;
* Session Bean implementation class AccountEventBean
*/
@Stateless
@DeclareRoles({ "ACCOUNT_MANAGEMENT/READ", "ACCOUNT_MANAGEMENT/WRITE", "SHOP/EXECUTE" })
@DeclareRoles({ UserPermission.S_VIEW_ACCOUNTEVENTS })
public class AccountEventBean implements AccountEventBeanLocal {
@EJB
......@@ -53,13 +55,13 @@ public class AccountEventBean implements AccountEventBeanLocal {
}
@Override
@RolesAllowed("ACCOUNT_MANAGEMENT/WRITE")
@RolesAllowed(UserPermission.S_MODIFY_ACCOUNTEVENTS)
public AccountEvent merge(AccountEvent account) {
return accountfacade.merge(account);
}
@Override
@RolesAllowed("ACCOUNT_MANAGEMENT/WRITE")
@RolesAllowed(UserPermission.S_MODIFY_ACCOUNTEVENTS)
public void delete(AccountEvent account) {
AccountEvent acco = accountfacade.find(account.getId());
......@@ -84,29 +86,39 @@ public class AccountEventBean implements AccountEventBeanLocal {
return accountfacade.findProvidedRoles(eventBean.getCurrentEvent(), u);
}
/**
* Create accountevents for the products in the parameter shopMap
*/
@Override
@RolesAllowed("SHOP/EXECUTE")
@RolesAllowed(ShopPermission.S_SHOP_PRODUCTS)
public List<AccountEvent> shopCash(User shoppingUser, Map<Product, BigDecimal> shopMap, boolean buyInstant) throws PermissionDeniedException {
logger.debug("Shoping cash. buyinstant {}", buyInstant);
User seller = permbean.getCurrentUser();
shoppingUser = userbean.findById(shoppingUser.getId());
ArrayList<AccountEvent> ret = new ArrayList<AccountEvent>();
LanEvent ev = eventBean.getCurrentEvent();
User seller = permbean.getCurrentUser();
BigDecimal tot = BigDecimal.ZERO;
for (Entry<Product, BigDecimal> prodentry : shopMap.entrySet()) {
// Create account event for the product.
AccountEvent ac = new AccountEvent(ev, shoppingUser, prodentry.getKey(), prodentry.getKey().getPrice(), prodentry.getValue(), Calendar.getInstance());
ac.setSeller(seller);
shoppingUser.getAccountEvents().add(ac);
if (buyInstant && prodentry.getKey().getPrice().compareTo(BigDecimal.ZERO) > 0) {
tot = tot.add(prodentry.getValue().multiply(prodentry.getKey().getPrice()));
}
if (prodentry.getKey().isPrepaidInstant() && prodentry.getKey().getPlaces() != null && prodentry.getKey().getPlaces().size() > 0) {
if (prodentry.getKey().isPrepaidInstant() && prodentry.getKey().getPlaces() != null && !prodentry.getKey().getPlaces().isEmpty()) {
logger.debug("Prepaidplace");
placebean.lockPlaceProduct(shoppingUser, prodentry.getKey(), BigDecimal.ONE);
}
ac.setSeller(seller);
shoppingUser.getAccountEvents().add(ac);
}
logger.debug("ShopCash price {}", tot);
......
package fi.insomnia.bortal.beans;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
......@@ -23,20 +22,22 @@ import fi.insomnia.bortal.bortal.views.BillSummary;
import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.facade.BillFacade;
import fi.insomnia.bortal.facade.BillLineFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.util.MailMessage;
import fi.insomnia.bortal.utilities.I18n;
/**
* Session Bean implementation class BillBean
*/
@Stateless
@LocalBean
@DeclareRoles({ "BILL/READ", "USER_MANAGEMENT/EXECUTE", "USER_MANAGEMENT/READ" })
@DeclareRoles({ "USER", "BILL/WRITE_ALL", "BILL/READ_ALL", "BILL/CREATE_BILL" })
public class BillBean implements BillBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(BillBean.class);
......@@ -60,6 +61,10 @@ public class BillBean implements BillBeanLocal {
@EJB
private PermissionBeanLocal permissionbean;
@EJB
private UserFacade userfacade;
@EJB
private UtilBean utilbean;
/**
* Default constructor.
......@@ -69,7 +74,8 @@ public class BillBean implements BillBeanLocal {
}
@Override
public Bill findById(int id) throws PermissionDeniedException {
@RolesAllowed("USER")
public Bill findById(int id) {
LanEvent event = eventbean.getCurrentEvent();
if (id <= 0) {
return null;
......@@ -78,9 +84,8 @@ public class BillBean implements BillBeanLocal {
User currentuser = permbean.getCurrentUser();
logger.debug("bill {} user {}", bill, currentuser);
if (bill == null || !currentuser.equals(bill.getUser())) {
if (bill != null && !currentuser.equals(bill.getUser()) && !permbean.hasPermission(BillPermission.READ_ALL)) {
bill = null;
permbean.fatalPermission(BillPermission.READ_ALL, "No right to read bill: ", bill);
}
return bill;
......@@ -112,62 +117,75 @@ public class BillBean implements BillBeanLocal {
}
@Override
public Bill createEmptyBill(User shoppingUser) throws PermissionDeniedException {
if (permbean.isCurrentUser(shoppingUser)) {
permbean.fatalPermission(BillPermission.CREATE_BILL, "No permission to create empty bill for self");
} else {
permbean.fatalPermission(BillPermission.WRITE_ALL, "Trying to create bill to someone else without sufficient permission");
}
LanEvent event = eventbean.getCurrentEvent();
Bill ret = new Bill(event, shoppingUser);
billFacade.create(ret);
ret.setUser(shoppingUser);
em.flush();
logger.debug("Created bill with id {} and user {}", ret.getId(), ret.getUser());
return ret;
}
@Override
@RolesAllowed("SHOP/EXECUTE")
public BillLine addProductToBill(Bill bill, Product product, BigDecimal count) throws PermissionDeniedException {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
boolean iscurrent = permissionbean.isCurrentUser(bill.getUser());
Integer billnr = bill.getBillNumber();
if (!iscurrent || billnr != null) {
permbean.fatalPermission(BillPermission.WRITE_ALL, "User tried to modify bill ", bill, "without sufficient permissions");
}
BillLine line = new BillLine(bill, product.getName(), product.getUnitName(), count, product.getPrice(), product.getVat());
line.setLineProduct(product);
billLineFacade.create(line);
List<Discount> discounts = productBean.getActiveDiscounts(product, count);
for (Discount disc : discounts) {
BigDecimal unitPrice = product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
BigDecimal vatPrice = product.getVat().subtract(product.getVat().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
BillLine discountLine = new BillLine(bill, disc.getShortdesc(), product.getUnitName(), count, unitPrice, vatPrice);
billLineFacade.create(discountLine);
}
em.flush();
return line;
}
// @Override
// public Bill createEmptyBill(User shoppingUser) throws
// PermissionDeniedException {
// if (permbean.isCurrentUser(shoppingUser)) {
// permbean.fatalPermission(BillPermission.CREATE_BILL,
// "No permission to create empty bill for self");
// } else {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "Trying to create bill to someone else without sufficient permission");
// }
//
// LanEvent event = eventbean.getCurrentEvent();
// Bill ret = new Bill(event, shoppingUser);
// billFacade.create(ret);
// ret.setUser(shoppingUser);
// em.flush();
// logger.debug("Created bill with id {} and user {}", ret.getId(),
// ret.getUser());
// return ret;
// }
// @Override
// @RolesAllowed("SHOP/EXECUTE")
// public BillLine addProductToBill(Bill bill, Product product, BigDecimal
// count) throws PermissionDeniedException {
//
// // If bill number > 0 bill has been sent and extra privileges are needed
// // to modify.
// boolean iscurrent = permissionbean.isCurrentUser(bill.getUser());
// Integer billnr = bill.getBillNumber();
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill, "without sufficient permissions");
// }
// BillLine line = new BillLine(bill, product.getName(),
// product.getUnitName(), count, product.getPrice(), product.getVat());
// line.setLineProduct(product);
// billLineFacade.create(line);
//
// List<Discount> discounts = productBean.getActiveDiscounts(product,
// count);
//
// for (Discount disc : discounts) {
// BigDecimal unitPrice =
// product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(2,
// RoundingMode.HALF_UP);
// BigDecimal vatPrice =
// product.getVat().subtract(product.getVat().multiply(disc.getPercentage())).negate().setScale(2,
// RoundingMode.HALF_UP);
//
// BillLine discountLine = new BillLine(bill, disc.getShortdesc(),
// product.getUnitName(), count, unitPrice, vatPrice);
// billLineFacade.create(discountLine);
//
// }
//
// em.flush();
// return line;
// }
@Override
@RolesAllowed("BILL/WRITE")
@RolesAllowed("BILL/READ_ALL")
public List<Bill> findAll() {
return billFacade.findAll(eventbean.getCurrentEvent());
}
@Override
@RolesAllowed("BILL/READ")
@RolesAllowed("BILL/READ_ALL")
public Collection<BillSummary> getBillLineSummary() {
Collection<BillSummary> ret = billLineFacade.getLineSummary(eventbean.getCurrentEvent());
......@@ -175,7 +193,7 @@ public class BillBean implements BillBeanLocal {
}
@Override
@RolesAllowed("BILL/WRITE")
@RolesAllowed("BILL/WRITE_ALL")
public void markPaid(Bill bill, Calendar when) {
Product creditproduct = productBean.findCreditProduct();
......@@ -189,7 +207,7 @@ public class BillBean implements BillBeanLocal {
bill.setAccountEvent(ac);
bill.setPaidDate(when);
billFacade.merge(bill);
bill = billFacade.merge(bill);
for (BillLine bl : bill.getBillLines()) {
Product prod = bl.getLineProduct();
......@@ -205,6 +223,24 @@ public class BillBean implements BillBeanLocal {
}
}
}
MailMessage msg = new MailMessage();
msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject"));
msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString()));
msg.setTo(bill.getUser());
utilbean.sendMail(msg);
}
@Override
@RolesAllowed("BILL/CREATE_BILL")
public void createBill(Bill bill) throws PermissionDeniedException {
if (!permbean.isCurrentUser(bill.getUser())) {
permbean.fatalPermission(BillPermission.WRITE_ALL, "Not enought rights to create bill for user ", bill.getUser());
}
User user = userfacade.find(bill.getUser().getId());
if (user.getBills() == null) {
user.setBills(new ArrayList<Bill>());
}
user.getBills().add(bill);
}
}
......@@ -5,15 +5,19 @@ import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.LanEvent;
/**
* Session Bean implementation class EventMapBean
*/
@Stateless
@DeclareRoles({ "MAP/WRITE" })
@DeclareRoles({ "MAP/MANAGE_MAPS" })
public class EventMapBean implements EventMapBeanLocal {
@EJB
......@@ -22,15 +26,17 @@ public class EventMapBean implements EventMapBeanLocal {
@EJB
private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(EventMapBean.class);
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed("MAP/MANAGE_MAPS")
public EventMap saveMap(EventMap eventmap) {
return eventmapfacade.merge(eventmap);
}
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed("MAP/MANAGE_MAPS")
public EventMap create(String mapname) throws PermissionDeniedException {
EventMap ret = new EventMap(eventbean.getCurrentEvent());
ret.setName(mapname);
......@@ -42,13 +48,20 @@ public class EventMapBean implements EventMapBeanLocal {
}
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed("MAP/MANAGE_MAPS")
public void sendImage(int destId, byte[] imagedata) {
LanEvent event = eventbean.getCurrentEvent();
EventMap map = eventmapfacade.find(event.getId(), destId);
EventMap map = eventmapfacade.find(event, destId);
logger.debug("Setting mapdata for map {}", map);
if (map != null) {
map.setMapData(imagedata);
}
}
@Override
@RolesAllowed("MAP/MANAGE_MAPS")
public EventMap find(Integer mapId) {
return eventmapfacade.find(new EventPk(eventbean.getCurrentEvent(), mapId));
}
}
......@@ -2,6 +2,8 @@ package fi.insomnia.bortal.beans;
import java.util.List;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.Stateless;
......@@ -12,6 +14,7 @@ import fi.insomnia.bortal.model.EventOrganiser;
* Session Bean implementation class EventOrganiserBean
*/
@Stateless
@DeclareRoles({ "SUPERADMIN" })
public class EventOrganiserBean implements EventOrganiserBeanLocal {
@EJB
......@@ -30,27 +33,18 @@ public class EventOrganiserBean implements EventOrganiserBeanLocal {
}
@Override
public void save(EventOrganiser eventorg) throws PermissionDeniedException {
fatalPermission(eventorg);
public void save(EventOrganiser eventorg) {
eventorgfacade.merge(eventorg);
}
@Override
public void fatalPermission(EventOrganiser eventorg) throws PermissionDeniedException {
if (!permbean.isCurrentUser(eventorg.getAdmin()) && !permbean.getCurrentUser().isSuperadmin()) {
throw new PermissionDeniedException(loggingbean, permbean.getCurrentUser(), "Someone other than admin tried to access EventOrganiser: " + eventorg.toString());
}
}
@Override
public List<EventOrganiser> getEventOrganisers() throws PermissionDeniedException {
if (!permbean.getCurrentUser().isSuperadmin()) {
throw new PermissionDeniedException(loggingbean, permbean.getCurrentUser(), "Non-superadmin tried to list all EventOrganisers");
}
@RolesAllowed("SUPERADMIN")
public List<EventOrganiser> getEventOrganisers() {
return eventorgfacade.findAll();
}
@Override
@RolesAllowed("SUPERADMIN")
public EventOrganiser create(String name) {
EventOrganiser ret = new EventOrganiser();
ret.setAdmin(permbean.getCurrentUser());
......@@ -58,4 +52,10 @@ public class EventOrganiserBean implements EventOrganiserBeanLocal {
eventorgfacade.create(ret);
return ret;
}
@Override
@RolesAllowed("SUPERADMIN")
public EventOrganiser find(Integer orgId) {
return eventorgfacade.find(orgId);
}
}
......@@ -16,6 +16,7 @@ import fi.insomnia.bortal.enums.BortalApplication;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.ApplicationPermission;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.User;
......@@ -36,14 +37,18 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
private UserBean userbean;
@EJB
private PermissionBeanLocal permbean;
@EJB
private EventBeanLocal eventbean;
public User tryLogin(String username, String password) {
User user = userfacade.findByLogin(username.trim());
logger.debug("Trying to login as {}", username);
User ret = null;
if (user != null) {
if (user.checkPassword(password)) {
if (user.isAnonymous()) {
logger.info("logging in as anonymous!!!");
ret = user;
} else if (user.checkPassword(password)) {
ret = user;
} else {
secubean.logMessage(SecurityLogType.permissionDenied, user, "Login failed: wrong password for username ", username);
......@@ -58,6 +63,7 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
@Override
public boolean authenticate(String username, String password) {
logger.warn("Trying to login as {}", username);
boolean ret = (tryLogin(username, password) != null);
return ret;
......@@ -65,11 +71,13 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
@Override
public Enumeration<String> getGroupNames(String user) {
logger.info("Fetching groupNames for user {}", user);
User usr = userbean.getUser(user);
HashSet<String> roleset = new HashSet<String>();
if (usr != null) {
if (permbean.isLoggedIn()) {
if (usr == null) {
usr = permbean.getAnonUser();
}
if (usr != null && !usr.isAnonymous()) {
roleset.add("USER");
}
// TODO: EI NÄIN!!!!! Superadmin ei saa kaikkia oikkia!!
......@@ -87,12 +95,18 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
roleset.add(apperm.getPermission().getFullName());
}
}
LanEvent event = eventbean.getCurrentEvent();
if (event != null && !usr.isAnonymous() && event.getDefaultRole() != null) {
for (ApplicationPermission apperm : event.getDefaultRole().getPermissions()) {
roleset.add(apperm.getPermission().getFullName());
}
}
}
Vector<String> retvect = new Vector<String>();
retvect.addAll(roleset);
logger.debug("group names for user {}: {}", user, retvect);
logger.info("group names for user {}: {}", user, retvect);
return retvect.elements();
}
......
......@@ -11,22 +11,44 @@ import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.User;
@Stateless
@DeclareRoles({ "ANONYMOUS", "SUPERADMIN", "USER", "LOGIN/READ", "LOGIN/WRITE",
"LOGIN/EXECUTE", "USER_MANAGEMENT/READ", "USER_MANAGEMENT/WRITE",
"USER_MANAGEMENT/EXECUTE", "ACCOUNT_MANAGEMENT/READ",
"ACCOUNT_MANAGEMENT/WRITE", "ACCOUNT_MANAGEMENT/EXECUTE", "BILL/READ",
"BILL/WRITE", "BILL/EXECUTE", "MAP/READ", "MAP/WRITE", "MAP/EXECUTE",
"ROLE_MANAGEMENT/READ", "ROLE_MANAGEMENT/WRITE", "ROLE_MANAGEMENT/EXECUTE",
"PRODUCT/READ", "PRODUCT/WRITE", "PRODUCT/EXECUTE", "SHOP/READ",
"SHOP/WRITE", "SHOP/EXECUTE", "GAME/READ", "GAME/WRITE", "GAME/EXECUTE",
"POLL/READ", "POLL/WRITE", "POLL/EXECUTE" })
@DeclareRoles({
UserPermission.S_CREATE_NEW,
UserPermission.S_LOGIN,
UserPermission.S_LOGOUT,
UserPermission.S_MODIFY,
UserPermission.S_MODIFY_ACCOUNTEVENTS,
UserPermission.S_READ_ROLES,
UserPermission.S_VIEW_ACCOUNTEVENTS,
UserPermission.S_VIEW_ALL,
UserPermission.S_VIEW_SELF,
UserPermission.S_WRITE_ROLES,
MapPermission.S_VIEW,
MapPermission.S_MANAGE_MAPS,
MapPermission.S_MANAGE_OTHERS,
MapPermission.S_BUY_PLACES,
ShopPermission.S_LIST_ALL_PRODUCTS,
ShopPermission.S_LIST_USERPRODUCTS,
ShopPermission.S_SHOP_TO_OTHERS,
ShopPermission.S_MANAGE_PRODUCTS,
ShopPermission.S_SHOP_PRODUCTS,
BillPermission.S_CREATE_BILL,
BillPermission.S_READ_ALL,
BillPermission.S_WRITE_ALL,
"ANONYMOUS", "SUPERADMIN", "USER" })
public class PermissionBean implements PermissionBeanLocal {
public static final String DEFAULT_USER_LOGIN = "anonymous";
private static final Logger logger = LoggerFactory.getLogger(PermissionBean.class);
......@@ -53,54 +75,10 @@ public class PermissionBean implements PermissionBeanLocal {
return getCurrentUser().isSuperadmin()
|| context.isCallerInRole(perm.getFullName());
// User user = getCurrentUser();
//
// Boolean ret = BortalLocalContextHolder.hasPermission(target,
// permission);
// // Boolean ret = BortalLocalContextHolder.hasPermission(target,
// // permission);
// if (ret == null) {
// try {
// for (Role role : userbean.findUsersRoles(user)) {
// if (role == null) {
// continue;
// }
//
// for (RoleRight rr : role.getRoleRights()) {
// BortalLocalContextHolder.setPermission(rr);
//
// ret = BortalLocalContextHolder.hasPermission(target, permission);
// if (ret != null) {
// break;
// }
//
// }
// if (ret != null) {
// break;
// }
// }
// } catch (PermissionDeniedException e) {
// logger.warn("Permission denied when it should be allowed!!", e);
// }
// }
//
// // TODO: FIX THIS!! really bad idea....
//
// if (user.isSuperadmin()) {
// return true;
// }
//
// if (ret == null) {
// ret = false;
// BortalLocalContextHolder.setPermission(target, permission, ret);
// }
//
// return ret;
}
@Override
public void fatalPermission(IAppPermission permission, Object... failmessage) throws PermissionDeniedException {
public boolean fatalPermission(IAppPermission permission, Object... failmessage) throws PermissionDeniedException {
boolean ret = hasPermission(permission);
if (!ret) {
StringBuilder message = new StringBuilder().append(" permission: ").append(permission);
......@@ -116,6 +94,7 @@ public class PermissionBean implements PermissionBeanLocal {
throw new PermissionDeniedException(loggingbean, getCurrentUser(), message.toString());
}
return true;
}
@Override
......@@ -133,8 +112,6 @@ public class PermissionBean implements PermissionBeanLocal {
@Override
public boolean isLoggedIn() {
logger.info("Anonuser {}, currentuser {}", getAnonUser(), getCurrentUser());
logger.info("Is current superadmin {}", getCurrentUser().isSuperadmin());
return !getAnonUser().equals(getCurrentUser()) || getCurrentUser().isSuperadmin();
}
......@@ -155,14 +132,14 @@ public class PermissionBean implements PermissionBeanLocal {
*/
@Override
public User getAnonUser() {
User defaultUser = userfacade.findByLogin(DEFAULT_USER_LOGIN);
User defaultUser = userfacade.findByLogin(User.ANONYMOUS_LOGINNAME);
if (defaultUser == null) {
defaultUser = new User();
defaultUser.setLogin(DEFAULT_USER_LOGIN);
defaultUser.setNick(DEFAULT_USER_LOGIN);
defaultUser.setLogin(User.ANONYMOUS_LOGINNAME);
defaultUser.setNick(User.ANONYMOUS_LOGINNAME);
userfacade.create(defaultUser);
defaultUser.setSuperadmin(true);
// defaultUser.setSuperadmin(true);
}
return defaultUser;
}
......
......@@ -47,7 +47,9 @@ import fi.insomnia.bortal.model.User;
*/
@Stateless
@LocalBean
@DeclareRoles({ "MAP/READ", "MAP/WRITE", "MAP/EXECUTE", "SHOP/EXECUTE" })
@DeclareRoles({ MapPermission.S_BUY_PLACES,
"MAP/BUY_PLACES",
MapPermission.S_MANAGE_MAPS })
public class PlaceBean implements PlaceBeanLocal {
private static final String PLACE_RESERVE_TIMEOUTER = "Map reserve timeouter";
private static final Logger logger = LoggerFactory.getLogger(PlaceBean.class);
......@@ -75,7 +77,7 @@ public class PlaceBean implements PlaceBeanLocal {
private UserFacade userfacade;
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place mergeChanges(Place place) {
return placeFacade.merge(place);
}
......@@ -144,7 +146,7 @@ public class PlaceBean implements PlaceBeanLocal {
public Place findPlace(EventMap e, int x, int y) {
for (Place place : e.getPlaces()) {
if (place.isCoordinateInPlace(x, y)) {
return place;
return placeFacade.find(place.getId());
}
}
return null;
......@@ -160,9 +162,10 @@ public class PlaceBean implements PlaceBeanLocal {
* @return true when successfull. On any error false.
*/
@Override
@RolesAllowed("MAP/EXECUTE")
@RolesAllowed(MapPermission.S_BUY_PLACES)
public boolean reservePlace(Place place, User user) {
place = placeFacade.find(place.getId());
user = userfacade.find(user.getId());
boolean ret = false;
if (place.isBuyable() && !place.isTaken()) {
place.setCurrentUser(user);
......@@ -204,49 +207,57 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed("MAP/EXECUTE")
public boolean buySelectedPlaces(User user) throws BortalCatchableException, PermissionDeniedException {
permbean.fatalPermission(MapPermission.BUY_PLACES, "No rights to buy places from map");
@RolesAllowed(MapPermission.S_BUY_PLACES)
public PlaceGroup buySelectedPlaces(User user) throws BortalCatchableException, PermissionDeniedException {
if (user == null) {
user = permbean.getCurrentUser();
} else if (!user.equals(permbean.getCurrentUser())) {
} else {
if (!user.equals(permbean.getCurrentUser())) {
permbean.fatalPermission(MapPermission.MANAGE_OTHERS, "Can not buy places for user ", user);
}
user = userfacade.find(user.getId());
}
LanEvent event = eventBean.getCurrentEvent();
List<Place> places = placeFacade.findUsersReservations(event, user);
if (places.size() <= 0) {
return false;
return null;
}
for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
productBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user);
}
// PlaceGroup pg = pgbean.createPlaceGroup(user);
BigDecimal totalprice = totalReservationPrice(user, null);
BigDecimal balance = user.getAccountBalance();
if (balance.compareTo(totalprice) < 0) {
logger.debug("User {} Could not buy things because account balance is too low!", user);
return false;
return null;
}
PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true);
pg.setCreator(user);
user.getPlaceGroups().add(pg);
userfacade.flush();
for (Place p : places) {
if (!p.isReservedFor(user)) {
throw new BortalCatchableException("Trying to buy place not reserved for that user");
}
logger.info("Buying place {} for user {}", p.getName(), user.getLogin());
buy(p, pg, user);
}
for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
productBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user);
}
user.getPlaceGroups().add(pg);
return true;
// adding account event does funny stuff. evicting helps...
userfacade.evict(user);
return pg;
}
// This method should not be available in the local bean client
public void lockPlaceProduct(User user, Product prod, BigDecimal quantity) {
void lockPlaceProduct(User user, Product prod, BigDecimal quantity) {
int loop = quantity.intValue();
// BigDecimal loop = BigDecimal.ZERO;
......@@ -299,7 +310,7 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public int setBuyable(EventMap map, String like, boolean b) {
return placeFacade.setBuyable(map, like, b);
......@@ -385,7 +396,7 @@ public class PlaceBean implements PlaceBeanLocal {
* @return true when successfull, on any erroro false.
*/
@Override
@RolesAllowed("MAP/EXECUTE")
@RolesAllowed(MapPermission.S_BUY_PLACES)
public boolean releasePlace(Place place) {
place = placeFacade.find(place.getId());
User user = permbean.getCurrentUser();
......@@ -400,13 +411,13 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed("MAP/EXECUTE")
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place find(int placeId) {
return placeFacade.find(eventBean.getCurrentEvent(), placeId);
}
@Override
@RolesAllowed("MAP/WRITE")
@RolesAllowed(MapPermission.S_BUY_PLACES)
public void unbuyPlace(Place place) {
place = placeFacade.find(place.getId());
if (place.getGroup() != null) {
......
......@@ -81,8 +81,13 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
}
@Override
@RolesAllowed("USER")
public boolean associateToToken(User user, String token) {
@RolesAllowed(MapPermission.S_BUY_PLACES)
public boolean associateToToken(User user, String token) throws PermissionDeniedException {
if (!permbean.isCurrentUser(user)) {
permbean.fatalPermission(MapPermission.MANAGE_OTHERS);
}
token = token.trim();
GroupMembership mem = gmemfacade.findByToken(token);
boolean ret = false;
......
......@@ -26,7 +26,7 @@ import fi.insomnia.bortal.model.PossibleAnswer;
*/
@Stateless
@DeclareRoles("USER")
@DeclareRoles({ "POLL/ANSWER", "POLL/VIEW_RESULTS", "POLL/CREATE" })
public class PollBean implements PollBeanLocal {
@EJB
......@@ -57,7 +57,7 @@ public class PollBean implements PollBeanLocal {
}
@Override
@RolesAllowed("USER")
@RolesAllowed("POLL/ANSWER")
public List<Poll> findPolls() {
List<Poll> list = new ArrayList<Poll>();
......@@ -102,7 +102,7 @@ public class PollBean implements PollBeanLocal {
}
@Override
@RolesAllowed("USER")
@RolesAllowed("POLL/ANSWER")
public boolean createAnswers(List<PollAnswer> answers) {
for (PollAnswer answer : answers) {
......@@ -123,13 +123,21 @@ public class PollBean implements PollBeanLocal {
}
@Override
@RolesAllowed("POLL/CREATE")
public void createPoll(Poll poll) {
pollFacade.create(poll);
}
@Override
@RolesAllowed("POLL/ANSWER")
public void createAnswers(PollQuestion q) {
pqfacade.create(q);
}
@Override
@RolesAllowed("POLL/ANSWER")
public Poll find(Integer pollId) {
return pollFacade.find(eventBean.getCurrentEvent(), pollId);
}
}
......@@ -2,7 +2,6 @@ package fi.insomnia.bortal.beans;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
......@@ -12,12 +11,14 @@ import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.AccountEventFacade;
import fi.insomnia.bortal.facade.DiscountFacade;
import fi.insomnia.bortal.facade.DiscountInstanceFacade;
import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.DiscountInstance;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
......@@ -25,7 +26,8 @@ import fi.insomnia.bortal.model.User;
* Session Bean implementation class ProductBean
*/
@Stateless
@DeclareRoles({ "PRODUCT/WRITE", "PRODUCT/READ", "SHOP/EXECUTE" })
@DeclareRoles({ "SHOP/LIST_USERPRODUCTS", "SHOP/LIST_ALL_PRODUCTS", "SHOP/LIST_USERPRODUCTS",
"SHOP/MANAGE_PRODUCTS" })
public class ProductBean implements ProductBeanLocal {
private static final String DEFAULT_CREDIT_PRODCT = "Automagic Credit product";
......@@ -41,6 +43,8 @@ public class ProductBean implements ProductBeanLocal {
@EJB
private DiscountInstanceFacade discountinstancefacade;
@EJB
private DiscountFacade discountfacade;
@EJB
private UserFacade userFacade;
@EJB
......@@ -54,40 +58,42 @@ public class ProductBean implements ProductBeanLocal {
}
@Override
@RolesAllowed("SHOP/EXECUTE")
@RolesAllowed("SHOP/LIST_USERPRODUCTS")
public List<Product> listUserShoppableProducts() {
return productFacade.findPrepaidProducts(eventBean.getCurrentEvent());
}
@Override
@RolesAllowed("PRODUCT/WRITE")
public Product createProduct(String name, BigDecimal price) {
Product entity = new Product(eventBean.getCurrentEvent(), name, price);
productFacade.create(entity);
return entity;
@RolesAllowed("SHOP/MANAGE_PRODUCTS")
public void create(Product prod) {
productFacade.create(prod);
}
@Override
@RolesAllowed("PRODUCT/READ")
@RolesAllowed("SHOP/LIST_ALL_PRODUCTS")
public List<Product> getProducts() {
return productFacade.findAll(eventBean.getCurrentEvent());
}
@Override
@RolesAllowed("PRODUCT/WRITE")
@RolesAllowed("SHOP/MANAGE_PRODUCTS")
public Product mergeChanges(Product product) {
return productFacade.merge(product);
}
@Override
public Product findCreditProduct() {
Product ret = productFacade.findProductByPrice(eventBean.getCurrentEvent(), BigDecimal.ONE.negate());
if (ret == null) {
ret = new Product(eventBean.getCurrentEvent(), DEFAULT_CREDIT_PRODCT, BigDecimal.ONE.negate());
productFacade.create(ret);
List<Product> ret = productFacade.findProductsByPrice(eventBean.getCurrentEvent(), BigDecimal.ONE.negate());
Product retProd = null;
if (ret == null || ret.isEmpty()) {
retProd = new Product(eventBean.getCurrentEvent());
retProd.setName(DEFAULT_CREDIT_PRODCT);
retProd.setPrice(BigDecimal.ONE.negate());
productFacade.create(retProd);
} else {
retProd = ret.get(0);
}
return ret;
return retProd;
}
@Override
......@@ -96,32 +102,35 @@ public class ProductBean implements ProductBeanLocal {
throw new RuntimeException("Some parameter is null!");
}
BigDecimal total = product.getPrice();
for (Discount d : getActiveDiscounts(product, quantity)) {
for (Discount d : product.getActiveDiscounts(quantity)) {
total = total.multiply(d.getPercentage());
}
return total.setScale(2, RoundingMode.HALF_UP).multiply(quantity);
}
// TODO: alennukset lasketaan täällä. HUOMHUOM!!
@Override
public List<Discount> getActiveDiscounts(Product product, BigDecimal quantity) {
ArrayList<Discount> ret = new ArrayList<Discount>();
for (Discount d : product.getDiscounts()) {
if (d.isActive() && quantity.compareTo(d.getAmountMax()) <= 0 && quantity.compareTo(d.getAmountMin()) >= 0) {
ret.add(d);
}
}
return ret;
}
// // TODO: alennukset lasketaan täällä. HUOMHUOM!!
// @Override
// public List<Discount> getActiveDiscounts(Product product, BigDecimal
// quantity) {
// ArrayList<Discount> ret = new ArrayList<Discount>();
// for (Discount d : product.getDiscounts()) {
// if (d.isActive() && quantity.compareTo(d.getAmountMax()) <= 0 &&
// quantity.compareTo(d.getAmountMin()) >= 0) {
// ret.add(d);
// }
// }
// return ret;
// }
@Override
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, User user) {
BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = getActiveDiscounts(product, quantity);
List<Discount> discounts = product.getActiveDiscounts(quantity);
for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage());
}
user = userFacade.find(user.getId());
AccountEvent ret = new AccountEvent(eventBean.getCurrentEvent(), user, product, unitPrice, quantity, Calendar.getInstance());
......@@ -147,9 +156,21 @@ public class ProductBean implements ProductBeanLocal {
}
@Override
@RolesAllowed("SHOP/EXECUTE")
@RolesAllowed("SHOP/LIST_ALL_PRODUCTS")
public List<Product> findForStaffshop() {
return productFacade.findAll(eventBean.getCurrentEvent());
}
@RolesAllowed("SHOP/MANAGE_PRODUCTS")
@Override
public Discount findDiscount(Integer discountid) {
return discountfacade.find(new EventPk(eventBean.getCurrentEvent(), discountid));
}
@Override
@RolesAllowed("SHOP/MANAGE_PRODUCTS")
public Discount save(Discount discount) {
return discountfacade.merge(discount);
}
}
......@@ -19,7 +19,9 @@ import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.facade.RoleFacade;
import fi.insomnia.bortal.model.ApplicationPermission;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Role;
......@@ -28,7 +30,7 @@ import fi.insomnia.bortal.model.Role;
* @author tuukka
*/
@Stateless
@DeclareRoles({ "ROLE_MANAGEMENT/READ", "ROLE_MANAGEMENT/WRITE" })
@DeclareRoles({ "USER/READ_ROLES", "USER/WRITE_ROLES" })
public class RoleBean implements RoleBeanLocal {
// private static final String PUBLIC_ROLE_NAME =
......@@ -42,31 +44,30 @@ public class RoleBean implements RoleBeanLocal {
private RoleFacade roleFacade;
@Override
@RolesAllowed("ROLE_MANAGEMENT/READ")
@RolesAllowed("USER/READ_ROLES")
public List<Role> listRoles() {
return listRoles(eventBean.getCurrentEvent());
}
@RolesAllowed("ROLE_MANAGEMENT/READ")
@RolesAllowed("USER/READ_ROLES")
public List<Role> listRoles(LanEvent event) {
return roleFacade.findAll(event);
}
@Override
@RolesAllowed("ROLE_MANAGEMENT/WRITE")
@RolesAllowed("USER/WRITE_ROLES")
public Role mergeChanges(Role role) {
return roleFacade.merge(role);
}
@Override
@RolesAllowed("ROLE_MANAGEMENT/WRITE")
public Role create(Role role) {
@RolesAllowed("USER/WRITE_ROLES")
public void create(Role role) {
roleFacade.create(role);
return role;
}
@Override
@RolesAllowed("ROLE_MANAGEMENT/READ")
@RolesAllowed("USER/READ_ROLES")
public List<Role> getPossibleParents(Role role) {
List<Role> roleList = listRoles();
......@@ -132,9 +133,37 @@ public class RoleBean implements RoleBeanLocal {
// }
@Override
@RolesAllowed("ROLE_MANAGEMENT/READ")
public Role find(int id) {
return roleFacade.find(id);
}
@Override
@RolesAllowed("USER/WRITE_ROLES")
public Role setPermissions(Role role, List<IAppPermission> newPerms) {
role = roleFacade.find(role.getId());
List<ApplicationPermission> permissions = role.getPermissions();
HashSet<ApplicationPermission> rmlist = new HashSet<ApplicationPermission>();
for (ApplicationPermission appPerm : permissions) {
// If role contains permission not in parameter newPerms remove
// it.
if (!newPerms.contains(appPerm.getPermission())) {
rmlist.add(appPerm);
}
// remove handled permission from newPerms
newPerms.remove(appPerm.getPermission());
}
// Concurrent modification prevention!!
if (!rmlist.isEmpty()) {
permissions.removeAll(rmlist);
}
// Add permissions not existing in role
for (IAppPermission perm : newPerms) {
permissions.add(new ApplicationPermission(role, perm));
}
roleFacade.flush();
return role;
}
}
......@@ -3,7 +3,6 @@ package fi.insomnia.bortal.beans;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.List;
......@@ -26,7 +25,6 @@ import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.Compo;
import fi.insomnia.bortal.model.CompoEntry;
import fi.insomnia.bortal.model.EventMap;
......@@ -151,53 +149,56 @@ public class TestDataBean implements TestDataBeanLocal {
return u;
}
@Override
public Bill createBill(User u) {
Bill b = new Bill(eventBean.getCurrentEvent());
b.setUser(u);
b.setAddr1("Kalle Kävijä");
b.setAddr2("co / Pelivieroitus Ry");
b.setAddr3("Pallokorvankatu 1");
b.setAddr4("696969 Keikyä");
b.setAddr5("FINLAND! \\o/");
b.setBillNumber(123123);
b.setDelayIntrest(11);
b.setDeliveryTerms("Toimitetaan, ehkä...");
Calendar duedate = Calendar.getInstance();
duedate.add(Calendar.DATE, 14);
b.setNotes("Some notes...");
b.setNoticetime("14 vrk");
b.setOurReference("Meitin viite ( Insomnia XII )");
b.setPaymentTime(14);
b.setSentDate(Calendar.getInstance());
b.setTheirReference("Niitten viite ( tyhjä? )");
billFacade.create(b);
createBillLine(b, "Tuote1", 1239.3, "kpl", 11.0, 0.22);
createBillLine(b, "Tuote2", 0.3, "pss", 11.0, 0.22);
createBillLine(b, "Tuote3", 9.3, "l", 11.0, 0.22);
createBillLine(b, "Tuote4", 9, "kWh", 99931911.0, 0);
createBillLine(b, "Tuote5", 33, "mol", 11.0, 0.22);
createBillLine(b, "Tuote6", 39939.23123123, "rad", 122.0, 0.18);
return b;
}
private BillLine createBillLine(Bill b, String line, double d, String qname, double e, double f) {
return createBillLine(b, line, new BigDecimal(d), qname, new BigDecimal(e), new BigDecimal(f));
}
// @Override
// public Bill createBill(User u) {
// Bill b = new Bill(eventBean.getCurrentEvent());
// b.setUser(u);
// b.setAddr1("Kalle Kävijä");
// b.setAddr2("co / Pelivieroitus Ry");
// b.setAddr3("Pallokorvankatu 1");
// b.setAddr4("696969 Keikyä");
// b.setAddr5("FINLAND! \\o/");
// b.setBillNumber(123123);
// b.setDelayIntrest(11);
// b.setDeliveryTerms("Toimitetaan, ehkä...");
// Calendar duedate = Calendar.getInstance();
// duedate.add(Calendar.DATE, 14);
// b.setNotes("Some notes...");
// b.setNoticetime("14 vrk");
// b.setOurReference("Meitin viite ( Insomnia XII )");
// b.setPaymentTime(14);
// b.setSentDate(Calendar.getInstance());
// b.setTheirReference("Niitten viite ( tyhjä? )");
// billFacade.create(b);
// createBillLine(b, "Tuote1", 1239.3, "kpl", 11.0, 0.22);
// createBillLine(b, "Tuote2", 0.3, "pss", 11.0, 0.22);
// createBillLine(b, "Tuote3", 9.3, "l", 11.0, 0.22);
// createBillLine(b, "Tuote4", 9, "kWh", 99931911.0, 0);
// createBillLine(b, "Tuote5", 33, "mol", 11.0, 0.22);
// createBillLine(b, "Tuote6", 39939.23123123, "rad", 122.0, 0.18);
//
// return b;
// }
private BillLine createBillLine(Bill b, String line, BigDecimal q, String qname, BigDecimal price, BigDecimal vat) {
BillLine bl = new BillLine(b);
bl.setName(line);
bl.setQuantity(q);
bl.setUnitName(qname);
bl.setUnitPrice(price);
bl.setVat(vat);
// private BillLine createBillLine(Bill b, String line, double d, String
// qname, double e, double f) {
// return createBillLine(b, line, new BigDecimal(d), qname, new
// BigDecimal(e), new BigDecimal(f));
//
// }
billLineFacade.create(bl);
return bl;
}
// private BillLine createBillLine(Bill b, String line, BigDecimal q, String
// qname, BigDecimal price, BigDecimal vat) {
// BillLine bl = new BillLine(b);
// bl.setName(line);
// bl.setQuantity(q);
// bl.setUnitName(qname);
// bl.setUnitPrice(price);
// bl.setVat(vat);
//
// billLineFacade.create(bl);
// return bl;
// }
@Override
public EventMap generateTestMap() {
......@@ -298,4 +299,10 @@ public class TestDataBean implements TestDataBeanLocal {
q.executeUpdate();
}
@Override
public Bill createBill(User u) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -31,13 +31,14 @@ import fi.insomnia.bortal.model.UserImage;
import fi.insomnia.bortal.util.MailMessage;
import fi.insomnia.bortal.utilities.I18n;
import fi.insomnia.bortal.utilities.PasswordFunctions;
import fi.insomnia.bortal.utilities.SearchResult;
/**
* Session Bean implementation class UserBean
*/
@LocalBean
@Stateless
@DeclareRoles({ "USER/EXECUTE" })
@DeclareRoles({ "USER/EXECUTE", "USER/VIEW_ALL", "USER" })
public class UserBean implements UserBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(UserBean.class);
......@@ -74,7 +75,7 @@ public class UserBean implements UserBeanLocal {
private GroupMembershipFacade gmfacade;
@Override
@RolesAllowed("USER_MANAGEMENT/READ")
@RolesAllowed("USER/VIEW_ALL")
public List<User> getUsers() {
List<User> ret = userFacade.findAll();
......@@ -192,10 +193,10 @@ public class UserBean implements UserBeanLocal {
return ret;
}
@Override
public List<User> searchName(String name) {
return userFacade.searchForName(name);
}
// @Override
// public List<User> searchName(String name) {
// return userFacade.searchForName(name);
// }
@Override
public User createNewUser(User user, String password) {
......@@ -233,21 +234,23 @@ public class UserBean implements UserBeanLocal {
}
@Override
public boolean initPasswordReset(User user, String hash, String mailpath) {
logger.debug("sending mail! user {} hash {} path {}", new Object[] { user, hash, mailpath });
public User initPasswordReset(User user, String hash, String mailpath) {
if (hash == null || hash.length() < 20 || user == null || user.getEmail() == null || user.getEmail().length() <= 5) {
return false;
logger.info("Not sending email with params {} {} {}", new Object[] { user, user.getEmail(), hash });
return null;
}
logger.info("sending mail! user {} hash {} path {}", new Object[] { user, hash, mailpath });
MailMessage msg = new MailMessage();
msg.setTo(user);
msg.setSubject(I18n.get("passwordreset.mailSubject"));
msg.setMessage(I18n.get("passwordreset.mailBody", mailpath));
logger.info("sending mail! user {} hash {} path {}", new Object[] { user, hash, mailpath });
utilbean.sendMail(msg);
user = userFacade.find(user.getId());
user.setConfirmHash(hash);
userFacade.merge(user);
return true;
return user;
}
......@@ -257,14 +260,14 @@ public class UserBean implements UserBeanLocal {
}
@Override
public List<User> getUsers(int page, int pagesize, String sort, String search) {
public SearchResult<User> getUsers(int page, int pagesize, String sort, String search) {
return userFacade.searchUser(page, pagesize, sort, search);
}
@Override
public long getUsersCount(String search) {
return userFacade.searchUserCount(search);
}
// @Override
// public long getUsersCount(String search) {
// return userFacade.searchUserCount(search);
// }
@Override
@RolesAllowed("USER/EXECUTE")
......@@ -299,7 +302,6 @@ public class UserBean implements UserBeanLocal {
gm.setInviteAccepted(Calendar.getInstance());
userFacade.create(user);
}
}
package fi.insomnia.bortal.beans;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.User;
/**
* Session Bean implementation class UserUtilBean
*/
@Stateless
// @TransactionManagement(TransactionManagementType.BEAN)
@LocalBean
public class UserUtilBean implements UserUtilBeanLocal {
/**
* Default constructor.
*/
public UserUtilBean() {
// TODO Auto-generated constructor stub
}
@EJB
private UserBeanLocal userbean;
private static final Logger logger = LoggerFactory.getLogger(UserUtilBean.class);
@EJB
private UserFacade userfacade;
@Override
public void convertUsernames() {
for (User u : userbean.getUsers()) {
if (u.getLogin().trim().isEmpty()) {
logger.warn("User {} has empty login...");
continue;
}
User testU = userfacade.findByLogin(u.getLogin().toLowerCase());
if (testU == null || testU.equals(u)) {
u.setLogin(u.getLogin().toLowerCase());
logger.info("Converted user {}", u.getLogin());
} else {
logger.warn("Could not convert user {}", u.getLogin(), testU.getLogin());
}
}
}
}
......@@ -11,6 +11,8 @@ import java.math.RoundingMode;
import java.util.Date;
import javax.annotation.Resource;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
......@@ -34,6 +36,7 @@ import fi.insomnia.bortal.util.MailMessage;
*/
@Stateless
@LocalBean
@DeclareRoles("SUPERADMIN")
public class UtilBean implements UtilBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(UtilBean.class);
......@@ -57,6 +60,7 @@ public class UtilBean implements UtilBeanLocal {
@Override
public boolean sendMail(MailMessage message) {
logger.info("Sending mail message {} ", message);
Date d = new Date();
try {
QueueConnection conn = mailQuefactory.createQueueConnection();
......@@ -66,13 +70,14 @@ public class UtilBean implements UtilBeanLocal {
session.createProducer(mailQueue).send(objmessage);
conn.close();
} catch (JMSException e) {
logger.debug("Got exception sending mail", e);
logger.warn("Got exception sending mail", e);
}
logger.debug("Message time {}", new Date().getTime() - d.getTime());
return true;
}
@Override
@RolesAllowed("SUPERADMIN")
public void checkAllUsersImages() throws PermissionDeniedException {
for (User usr : userbean.getUsers()) {
......@@ -137,4 +142,5 @@ public class UtilBean implements UtilBeanLocal {
}
return true;
}
}
......@@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.EventPk_;
import fi.insomnia.bortal.model.GenericEventChild;
import fi.insomnia.bortal.model.GenericEventChild_;
import fi.insomnia.bortal.model.LanEvent;
......@@ -41,7 +42,8 @@ public abstract class EventChildGenericFacade<T extends GenericEventChild> exten
Root<T> root = cq.from(getEntityClass());
cq.where(cb.equal(root.get(GenericEventChild_.event), event));
cq.orderBy(cb.asc(root.get(GenericEventChild_.id)));
cq.orderBy(cb.asc(root.get(GenericEventChild_.id).get(EventPk_.id)));
return getEm().createQuery(cq).getResultList();
}
......
......@@ -4,38 +4,50 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.LanEvent_;
@Stateless
@LocalBean
public class EventFacade extends GenericFacade<Integer, LanEvent> {
// private static final Logger logger = LoggerFactory.getLogger(EventFacade.class);
// private static final Logger logger =
// LoggerFactory.getLogger(EventFacade.class);
@PersistenceContext
private EntityManager em;
public EventFacade() {
super(LanEvent.class);
}
@Override
protected EntityManager getEm() {
return em;
}
public LanEvent findByHostname(String hostname) {
TypedQuery<LanEvent> q = em.createNamedQuery("LanEvent.findByReferer", LanEvent.class);
q.setParameter("referer", hostname);
return getSingleNullableResult(q);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<LanEvent> cq = cb.createQuery(LanEvent.class);
Root<LanEvent> root = cq.from(LanEvent.class);
cq.where(cb.equal(root.get(LanEvent_.eventEnabled), true));
// TypedQuery<LanEvent> q =
// em.createNamedQuery("LanEvent.findByReferer", LanEvent.class);
// q.setParameter("referer", hostname);
return getSingleNullableResult(em.createQuery(cq));
}
public LanEvent findByName(String name) {
// TypedQuery<LanEvent> q = em.createNamedQuery("LanEvent.findByName", LanEvent.class);
// q.setParameter("name", name);
// return getSingleNullableResult(q);
// TypedQuery<LanEvent> q = em.createNamedQuery("LanEvent.findByName",
// LanEvent.class);
// q.setParameter("name", name);
// return getSingleNullableResult(q);
return this.find(1);
}
......@@ -45,5 +57,4 @@ public class EventFacade extends GenericFacade<Integer, LanEvent> {
}
}
......@@ -13,26 +13,27 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.iki.tuomari.utils.beans.callbacks.FacadeCallback;
import fi.iki.tuomari.utils.jpa.IntegerModelInterface;
import fi.insomnia.bortal.facade.callbacks.FacadeCallback;
import fi.insomnia.bortal.utilities.SearchResult;
import fi.insomnia.bortal.utilities.jpa.ModelInterface;
public abstract class GenericFacade<I extends Serializable, C extends ModelInterface<I>> {
protected static <T, C extends IntegerModelInterface> List<SingularAttribute<C, T>> mkAttrlist(SingularAttribute<C, T>... types) {
List<SingularAttribute<C, T>> ret = new ArrayList<SingularAttribute<C, T>>();
for (SingularAttribute<C, T> a : types) {
ret.add(a);
}
return Collections.unmodifiableList(ret);
}
// protected static <T, C extends ModelInterface<T>>
// List<SingularAttribute<C, T>> mkAttrlist(SingularAttribute<C, T>...
// types) {
// List<SingularAttribute<C, T>> ret = new ArrayList<SingularAttribute<C,
// T>>();
// for (SingularAttribute<C, T> a : types) {
// ret.add(a);
// }
// return Collections.unmodifiableList(ret);
//
// }
private final Class<C> entClass;
private static final Logger logger = LoggerFactory.getLogger(GenericFacade.class);
......@@ -61,6 +62,10 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
}
public void refresh(C usr) {
getEm().refresh(usr);
}
public C find(I id) {
if (id == null) {
return null;
......@@ -267,4 +272,7 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
getEm().flush();
}
public void evict(C clz) {
getEm().getEntityManagerFactory().getCache().evict(getEntityClass(), clz.getId());
}
}
......@@ -156,6 +156,9 @@ public class PlaceFacade extends EventChildGenericFacade<Place> {
}
public int setBuyable(EventMap map, String like, boolean b) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Place> cq = cb.createQuery(Place.class);
Root<Place> root = cq.from(Place.class);
Query q = em.createQuery("UPDATE Place p set p.buyable = :b where p.name like :like");
q.setParameter("b", b);
......
......@@ -8,11 +8,13 @@ import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.model.Product_;
@Stateless
@LocalBean
......@@ -25,6 +27,7 @@ public class ProductFacade extends EventChildGenericFacade<Product> {
super(Product.class);
}
@Override
protected EntityManager getEm() {
return em;
}
......@@ -33,17 +36,15 @@ public class ProductFacade extends EventChildGenericFacade<Product> {
throw new RuntimeException();
}
public Product findProductByPrice(LanEvent event, BigDecimal price) {
// EventPk id = new EventPk(event);
TypedQuery<Product> q = em.createQuery("select p from Product p where p.id.eventId = :eventid and p.price = :price", Product.class);
q.setParameter("price", price);
q.setParameter("eventid", event.getId());
public List<Product> findProductsByPrice(LanEvent event, BigDecimal price) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Product> cq = cb.createQuery(Product.class);
Root<Product> root = cq.from(Product.class);
List<Product> results = q.getResultList();
if (results.size() > 0) {
return results.get(0);
}
return null;
cq.where(cb.equal(root.get(Product_.event), event),
cb.equal(root.get(Product_.price), price));
return em.createQuery(cq).getResultList();
}
public List<Product> findPrepaidProducts(LanEvent e) {
......
......@@ -6,10 +6,13 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.Role_;
import fi.insomnia.bortal.model.User;
@Stateless
......@@ -28,18 +31,21 @@ public class RoleFacade extends GenericFacade<Integer, Role> {
return em;
}
public Role findByName(String name, LanEvent event) {
TypedQuery<Role> q = em.createNamedQuery("Role.findByRoleName", Role.class);
q.setParameter("name", name);
q.setParameter("event", event);
return getSingleNullableResult(q);
}
// public Role findByName(String name, LanEvent event) {
// TypedQuery<Role> q = em.createNamedQuery("Role.findByRoleName",
// Role.class);
// q.setParameter("name", name);
// q.setParameter("event", event);
// return getSingleNullableResult(q);
// }
public List<Role> findForUser(User user, LanEvent event) {
TypedQuery<Role> q = getEm().createNamedQuery("Role.findForUser", Role.class);
q.setParameter("user", user);
q.setParameter("event", event);
return q.getResultList();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Role> cq = cb.createQuery(Role.class);
Root<Role> root = cq.from(Role.class);
cq.where(cb.equal(root.get(Role_.event), event), cb.isMember(user, root.get(Role_.users)));
return em.createQuery(cq).getResultList();
}
public Role createRole(LanEvent event, String rolename) {
......@@ -50,9 +56,12 @@ public class RoleFacade extends GenericFacade<Integer, Role> {
}
public List<Role> findAll(LanEvent event) {
TypedQuery<Role> q = getEm().createNamedQuery("Role.findForEvent", Role.class);
q.setParameter("event", event);
return q.getResultList();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Role> cq = cb.createQuery(Role.class);
Root<Role> root = cq.from(Role.class);
cq.where(cb.equal(root.get(Role_.event), event));
return em.createQuery(cq).getResultList();
}
}
......@@ -6,12 +6,20 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.callbacks.OrderCallback;
import fi.insomnia.bortal.facade.callbacks.StringPredicateField;
import fi.insomnia.bortal.facade.callbacks.StringSearchPredicateCreator;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.model.User_;
import fi.insomnia.bortal.utilities.SearchResult;
@Stateless
@LocalBean
......@@ -19,10 +27,28 @@ public class UserFacade extends GenericFacade<Integer, User> {
private static final Logger logger = LoggerFactory.getLogger(UserFacade.class);
public enum UserField {
id, nick, login, firstname, lastname
private enum Userfields implements StringPredicateField<User> {
nick(User_.nick), login(User_.login), firstnames(User_.firstnames), lastname(User_.lastname), email(User_.email);
private SingularAttribute<User, String> field;
Userfields(SingularAttribute<User, String> f) {
field = f;
}
@Override
public SingularAttribute<User, String> getField() {
return field;
}
}
// final String[] NAMEFIELDS = { "nick", "login", "firstnames", "lastname",
// "email" };
//
// public enum UserField {
// id, nick, login, firstname, lastname
// }
@PersistenceContext
private EntityManager em;
......@@ -36,24 +62,28 @@ public class UserFacade extends GenericFacade<Integer, User> {
}
/**
* Find user by username. Username is converted to lowercase before
* searching.
* Find user by username.
*
* @param login
* @return
*/
public User findByLogin(String login) {
TypedQuery<User> q = em.createNamedQuery("User.findByLogin", User.class);
q.setParameter("login", login.toLowerCase());
return getSingleNullableResult(q);
}
private static final String[] NAMEFIELDS = { "nick", "login", "firstnames", "lastname", "email" };
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class);
cq.where(cb.equal(root.get(User_.login), login));
public List<User> searchForName(String name) {
return this.search(name, NAMEFIELDS, "login");
return getSingleNullableResult(em.createQuery(cq));
}
// public SearchResult<User> searchForName(String name) {
// return super.searcher(0, 0,
// new StringSearchPredicateCreator<User>(name, Userfields.values()),
// new OrderCallback<User>(true, User_.login)
// );
// // return this.search(name, NAMEFIELDS, "login");
// }
@Override
public void create(User user) {
user.setLogin(user.getLogin().toLowerCase().trim());
......@@ -66,29 +96,36 @@ public class UserFacade extends GenericFacade<Integer, User> {
return super.merge(user);
}
public List<User> searchUser(int page, int pagesize, String sort, String search) {
String query = null;
public SearchResult<User> searchUser(int page, int pagesize, String sort, String search) {
if (sort == null || sort.isEmpty()) {
sort = "nick";
}
if (search != null) {
query = new StringBuilder().append("%").append(search).append('%').toString();
}
return this.search(page, pagesize, query, NAMEFIELDS, sort);
}
public long searchUserCount(String search) {
String query = null;
if (search != null) {
query = new StringBuilder().append("%").append(search).append('%').toString();
}
return this.searchCount(query, NAMEFIELDS);
return super.searcher(page, pagesize,
new StringSearchPredicateCreator<User>(search, Userfields.values()),
new OrderCallback<User>(true, sort)
);
// return this.search(page, pagesize, query, NAMEFIELDS, sort);
}
// public long searchUserCount(String search) {
// String query = null;
// if (search != null) {
// query = new
// StringBuilder().append("%").append(search).append('%').toString();
// }
// return this.searchCount(query, NAMEFIELDS);
// }
public List<User> findByEmail(String email) {
TypedQuery<User> q = em.createQuery("SELECT u from User u where u.email = :usr", User.class);
q.setParameter("usr", email);
return q.getResultList();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class);
cq.where(cb.equal(root.get(User_.email), email));
return em.createQuery(cq).getResultList();
}
}
package fi.iki.tuomari.utils.beans.callbacks;
package fi.insomnia.bortal.facade.callbacks;
import java.util.Collections;
import java.util.List;
......
package fi.iki.tuomari.utils.beans.callbacks;
package fi.insomnia.bortal.facade.callbacks;
import java.util.List;
......@@ -31,9 +31,6 @@ public class OrderCallback<T extends ModelInterface<?>> implements FacadeCallbac
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (sort == null) {
return;
}
Expression<?> path = null;
if (sort == null) {
if (sortstr == null) {
......@@ -47,6 +44,7 @@ public class OrderCallback<T extends ModelInterface<?>> implements FacadeCallbac
} else {
path = root.get(sort);
}
if (path == null) {
return;
}
......
package fi.insomnia.bortal.facade.callbacks;
import javax.persistence.metamodel.SingularAttribute;
import fi.insomnia.bortal.utilities.jpa.ModelInterface;
public interface StringPredicateField<T extends ModelInterface<?>> {
SingularAttribute<T, String> getField();
}
package fi.iki.tuomari.utils.beans.callbacks;
package fi.insomnia.bortal.facade.callbacks;
import java.util.Collections;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -14,17 +13,25 @@ import fi.insomnia.bortal.utilities.jpa.ModelInterface;
public class StringSearchPredicateCreator<T extends ModelInterface<?>> implements FacadeCallback<T> {
private static final String WILDCARD = "%";
private String searchstr = null;
private List<SingularAttribute<T, String>> attributes = null;
private StringPredicateField<T>[] attributes = null;
private SingularAttribute<T, String> attr;
public StringSearchPredicateCreator(String search, List<SingularAttribute<T, String>> attrs) {
// public StringSearchPredicateCreator(String search,
// List<SingularAttribute<T, String>> attrs) {
// if (addSearch(search)) {
// attributes = attrs.;
// }
// }
public StringSearchPredicateCreator(String search, SingularAttribute<T, String> from) {
if (addSearch(search)) {
attributes = attrs;
from = attr;
}
}
public StringSearchPredicateCreator(String search, SingularAttribute<T, String> from) {
if (addSearch(search)) {
attributes = Collections.singletonList(from);
public StringSearchPredicateCreator(String name, StringPredicateField<T>[] values) {
if (addSearch(name)) {
attributes = values;
}
}
......@@ -43,14 +50,18 @@ public class StringSearchPredicateCreator<T extends ModelInterface<?>> implement
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (searchstr == null || attributes == null || attributes.isEmpty()) {
if (searchstr == null || (attr == null && (attributes == null || attributes.length == 0))) {
return;
}
Predicate[] preds = new Predicate[attributes.size()];
if (attr == null) {
predicates.add(cb.equal(root.get(attr), searchstr));
} else {
Predicate[] preds = new Predicate[attributes.length];
int i = 0;
for (SingularAttribute<T, String> attr : attributes) {
preds[i++] = cb.equal(root.get(attr), searchstr);
for (StringPredicateField<T> attr : attributes) {
preds[i++] = cb.equal(root.get(attr.getField()), searchstr);
}
predicates.add(cb.and(preds));
}
}
}
......@@ -23,6 +23,7 @@ public interface AccountEventBeanLocal {
List<Role> getRolesFromAccountEvents(User u);
List<AccountEvent> shopCash(User shoppingUser, Map<Product, BigDecimal> shopMap, boolean buyInstant) throws PermissionDeniedException;
List<AccountEvent> shopCash(User shoppingUser, Map<Product, BigDecimal>
shopMap, boolean buyInstant) throws PermissionDeniedException;
}
package fi.insomnia.bortal.beans;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
......@@ -10,18 +9,17 @@ import javax.ejb.Local;
import fi.insomnia.bortal.bortal.views.BillSummary;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
@Local
public interface BillBeanLocal {
Bill findById(int id) throws PermissionDeniedException;
Bill createEmptyBill(User shoppingUser) throws PermissionDeniedException;
BillLine addProductToBill(Bill bill, Product product, BigDecimal count) throws PermissionDeniedException;
//
// Bill createEmptyBill(User shoppingUser) throws PermissionDeniedException;
//
// BillLine addProductToBill(Bill bill, Product product, BigDecimal count)
// throws PermissionDeniedException;
List<Bill> findAll();
......@@ -31,4 +29,6 @@ public interface BillBeanLocal {
void getPdfBillStream(Bill bill, OutputStream ostream);
void createBill(Bill bill) throws PermissionDeniedException;
}
......@@ -13,4 +13,6 @@ public interface EventMapBeanLocal {
void sendImage(int destId, byte[] imagedata);
EventMap find(Integer mapId);
}
......@@ -11,10 +11,10 @@ public interface EventOrganiserBeanLocal {
void save(EventOrganiser eventorg) throws PermissionDeniedException;
void fatalPermission(EventOrganiser eventorg) throws PermissionDeniedException;
List<EventOrganiser> getEventOrganisers() throws PermissionDeniedException;
List<EventOrganiser> getEventOrganisers();
EventOrganiser create(String createorgname);
EventOrganiser find(Integer orgId);
}
......@@ -7,6 +7,7 @@ import fi.insomnia.bortal.model.User;
@Local
public interface PermissionBeanLocal {
boolean hasPermission(IAppPermission perm);
User getCurrentUser();
......@@ -15,7 +16,7 @@ public interface PermissionBeanLocal {
boolean isCurrentUser(User thisuser);
void fatalPermission(IAppPermission perm, Object... failmessage) throws PermissionDeniedException;
boolean fatalPermission(IAppPermission perm, Object... failmessage) throws PermissionDeniedException;
void fatalNotLoggedIn() throws PermissionDeniedException;
......
......@@ -12,6 +12,7 @@ import javax.ejb.Local;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User;
/**
......@@ -34,7 +35,7 @@ public interface PlaceBeanLocal {
Place mergeChanges(Place place);
boolean buySelectedPlaces(User user) throws BortalCatchableException, PermissionDeniedException;
PlaceGroup buySelectedPlaces(User user) throws BortalCatchableException, PermissionDeniedException;
BigDecimal totalReservationPrice(User user, Place newPlace) throws PermissionDeniedException;
......
......@@ -17,7 +17,7 @@ public interface PlaceGroupBeanLocal {
// List<GroupMembership> getMemberships(User user);
boolean associateToToken(User user, String token);
boolean associateToToken(User user, String token) throws PermissionDeniedException;
void releaseAndGenerateToken(GroupMembership gmem) throws PermissionDeniedException;
......
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.Local;
......@@ -13,16 +14,14 @@ public interface PollBeanLocal {
List<Poll> findPolls();
boolean createAnswers(List<PollAnswer> answers);
PossibleAnswer findPossibleAnwerById(int id);
void createPoll(Poll poll);
void createAnswers(PollQuestion q1);
Poll find(Integer pollId);
}
......@@ -15,7 +15,7 @@ public interface ProductBeanLocal {
List<Product> listUserShoppableProducts();
Product createProduct(String name, BigDecimal price);
void create(Product prod);
List<Product> getProducts();
......@@ -27,10 +27,14 @@ public interface ProductBeanLocal {
AccountEvent createAccountEvent(Product product, BigDecimal quantity, User user);
List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
// List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
Product findById(int parseInt);
List<Product> findForStaffshop();
Discount findDiscount(Integer discountid);
Discount save(Discount discount);
}
......@@ -9,6 +9,7 @@ import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.model.Role;
/**
......@@ -22,10 +23,12 @@ public interface RoleBeanLocal {
public Role mergeChanges(Role role);
public Role create(Role role);
public void create(Role role);
public List<Role> getPossibleParents(Role role);
public Role find(int val);
public Role setPermissions(Role role, List<IAppPermission> newPerms);
}
......@@ -8,15 +8,16 @@ import fi.insomnia.bortal.model.GroupMembership;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.model.UserImage;
import fi.insomnia.bortal.utilities.SearchResult;
@Local
public interface UserBeanLocal {
List<User> getUsers();
List<User> getUsers(int page, int pagesize, String sort, String search);
SearchResult<User> getUsers(int page, int pagesize, String sort, String search);
User getUser(String nick);
User getUser(String login);
User mergeChanges(User currentUser) throws PermissionDeniedException;
......@@ -32,7 +33,7 @@ public interface UserBeanLocal {
UserImage findUserImage(int id) throws PermissionDeniedException;
List<User> searchName(String name);
// List<User> searchName(String name);
User createNewUser(User user, String password);
......@@ -40,14 +41,12 @@ public interface UserBeanLocal {
boolean resetPassword(User user, String password, String hash);
boolean initPasswordReset(User user, String hash, String mailpath);
User initPasswordReset(User user, String hash, String mailpath);
List<Role> findUsersRoles(User u) throws PermissionDeniedException;
User findById(Integer integer);
long getUsersCount(String search);
boolean invite(String invitemail);
GroupMembership findToken(String token);
......
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
@Local
public interface UserUtilBeanLocal {
void convertUsernames();
}
......@@ -134,6 +134,7 @@ public class AccountEvent extends GenericEventChild {
public AccountEvent(LanEvent event, User u, Product prod, BigDecimal unitPrice, BigDecimal quantity, Calendar eventTime) {
setId(new EventPk(event));
this.setEvent(event);
this.setUnitPrice(unitPrice);
this.setQuantity(quantity);
this.product = prod;
......
......@@ -92,14 +92,15 @@ public class ApplicationPermission extends GenericEntity {
public IAppPermission getPermission() {
if (privatePerm == null && application != null && permission != null) {
for (IAppPermission appPerm : BortalApplication.valueOf(application).getPermissions()) {
if (appPerm.equals(permission)) {
for (IAppPermission appPerm : getApplication().getPermissions()) {
if (appPerm.toString().equals(permission)) {
privatePerm = appPerm;
break;
}
}
}
return privatePerm;
}
}
......@@ -7,6 +7,7 @@ package fi.insomnia.bortal.model;
import static javax.persistence.TemporalType.DATE;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
......@@ -28,6 +29,8 @@ import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.PrivateOwned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The system can send bills to the users. When user pays bill a AccountEvent
......@@ -133,13 +136,11 @@ public class Bill extends GenericEventChild {
@ManyToOne(optional = false)
private User user;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
private static final Logger logger = LoggerFactory.getLogger(Bill.class);
public Integer getReferenceNumberBase() {
if (event != null && event.getReferenceNumberBase() != null && billNumber != null) {
return event.getReferenceNumberBase() + billNumber;
if (getEvent() != null && getEvent().getReferenceNumberBase() != null && getBillNumber() != null) {
return getEvent().getReferenceNumberBase() + getBillNumber();
}
return null;
}
......@@ -246,14 +247,6 @@ public class Bill extends GenericEventChild {
this.user = usersId;
}
public LanEvent getEvent() {
return event;
}
public void setBillNumber(Integer billNumber) {
this.billNumber = billNumber;
}
public Integer getBillNumber() {
return billNumber;
}
......@@ -354,4 +347,29 @@ public class Bill extends GenericEventChild {
return delayIntrest;
}
public void addProduct(Product product, BigDecimal count) {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill,
// "without sufficient permissions");
// }
if (this.billLines == null) {
billLines = new ArrayList<BillLine>();
}
logger.info("Adding billine: {}", this.getEvent());
this.getBillLines().add(new BillLine(this, product, count));
logger.info("Adding billine2: {}", this.getEvent());
for (Discount disc : product.getActiveDiscounts(count)) {
this.getBillLines().add(new BillLine(this, product, disc, count));
}
}
public void setBillNumber(Integer billNumber) {
this.billNumber = billNumber;
}
}
......@@ -6,6 +6,7 @@
package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import java.math.RoundingMode;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -109,20 +110,27 @@ public class BillLine extends GenericEventChild {
super();
}
public BillLine(Bill bill) {
super();
setId(new EventPk(bill.getId().getEventId()));
this.bill = bill;
}
public BillLine(Bill bill, String product, String unitName, BigDecimal units,
BigDecimal unitPrice, BigDecimal vat) {
this(bill);
this.unitName = unitName;
this.name = product;
this.setQuantity(units);
this.setUnitPrice(unitPrice);
this.setVat(vat);
public BillLine(Bill bill2, Product product, BigDecimal count) {
super(bill2.getEvent());
this.bill = bill2;
this.lineProduct = product;
this.name = product.getName();
this.setUnitName(product.getUnitName());
this.setQuantity(count);
this.setUnitPrice(product.getPrice());
this.setVat(product.getVat());
}
public BillLine(Bill bill2, Product product, Discount disc, BigDecimal count) {
super(bill2.getEvent());
this.bill = bill2;
BigDecimal unitPrice = product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
BigDecimal vatPrice = product.getVat().subtract(product.getVat().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
this.name = disc.getShortdesc();
this.unitName = product.getUnitName();
this.quantity = count;
this.unitPrice = unitPrice;
this.vat = vatPrice;
}
public String getName() {
......
......@@ -11,9 +11,7 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
......@@ -95,10 +93,6 @@ public class Compo extends GenericEventChild {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "compo")
private List<CompoEntry> compoEntries;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "id", insertable = false, updatable = false)
private LanEvent event;
public Compo(LanEvent event, String compoName, boolean holdVoting) {
this(event);
this.name = compoName;
......@@ -199,9 +193,4 @@ public class Compo extends GenericEventChild {
public void setMaxParticipantCount(int maxParticipantCount) {
this.maxParticipantCount = maxParticipantCount;
}
public LanEvent getEvent() {
return event;
}
}
......@@ -6,6 +6,7 @@
package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
......@@ -81,6 +82,12 @@ public class Discount extends GenericEventChild {
super(ev);
}
public Discount(Product product) {
this(product.getEvent());
this.products = new ArrayList<Product>();
products.add(product);
}
public BigDecimal getAmountMin() {
return amountMin;
}
......
......@@ -10,9 +10,7 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
......@@ -44,9 +42,6 @@ public class EventMap extends GenericEventChild {
@OrderBy("name")
@OneToMany(cascade = CascadeType.ALL, mappedBy = "map")
private List<Place> places = new ArrayList<Place>();
@ManyToOne(optional = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", insertable = false, updatable = false, nullable = false)
private LanEvent event;
@OneToMany(mappedBy = "eventMap")
private List<Reader> readers;
......@@ -97,10 +92,6 @@ public class EventMap extends GenericEventChild {
this.readers = readers;
}
public LanEvent getEvent() {
return event;
}
public void setMapData(byte[] mapData) {
this.mapData = mapData;
}
......
......@@ -34,6 +34,10 @@ public class EventPk implements Serializable {
this.setEventId(event.getId());
}
public EventPk(LanEvent event, Integer id) {
this(event.getId(), id);
}
public EventPk(Integer eventId) {
super();
this.setEventId(eventId);
......
......@@ -28,6 +28,7 @@ public abstract class GenericEventChild extends EntityEquals implements ModelInt
public GenericEventChild(LanEvent event) {
id = new EventPk(event);
this.event = event;
}
public GenericEventChild() {
......@@ -58,11 +59,11 @@ public abstract class GenericEventChild extends EntityEquals implements ModelInt
this.jpaVersionField = jpaVersionField;
}
public void setEvent(LanEvent event) {
public final void setEvent(LanEvent event) {
this.event = event;
}
public LanEvent getEvent() {
public final LanEvent getEvent() {
return event;
}
......
......@@ -12,8 +12,6 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
......@@ -25,12 +23,14 @@ import javax.persistence.TemporalType;
*/
@Entity
@Table(name = "events")
@NamedQueries({
@NamedQuery(name = "LanEvent.findAll", query = "SELECT e FROM LanEvent e"),
@NamedQuery(name = "LanEvent.findByStartTime", query = "SELECT e FROM LanEvent e WHERE e.startTime = :startTime"),
@NamedQuery(name = "LanEvent.findByEndTime", query = "SELECT e FROM LanEvent e WHERE e.endTime = :endTime"),
@NamedQuery(name = "LanEvent.findByName", query = "SELECT e FROM LanEvent e WHERE e.name = :name"),
@NamedQuery(name = "LanEvent.findByReferer", query = "SELECT e FROM LanEvent e WHERE e.referer = :referer") })
// @NamedQueries({
// @NamedQuery(name = "LanEvent.findAll", query = "SELECT e FROM LanEvent e"),
// @NamedQuery(name = "LanEvent.findByStartTime", query =
// "SELECT e FROM LanEvent e WHERE e.startTime = :startTime"),
// @NamedQuery(name = "LanEvent.findByEndTime", query =
// "SELECT e FROM LanEvent e WHERE e.endTime = :endTime"),
// @NamedQuery(name = "LanEvent.findByName", query =
// "SELECT e FROM LanEvent e WHERE e.name = :name") })
public class LanEvent extends GenericEntity {
/**
......@@ -52,6 +52,9 @@ public class LanEvent extends GenericEntity {
@Column(name = "referer", unique = true, nullable = true)
private String referer;
@Column(nullable = false, name = "event_enabled")
private boolean eventEnabled = false;
/**
* Bill's reference number will be formed by adding this number to the bill
* number and adding the checksum of that number as the last digit
......@@ -237,4 +240,13 @@ public class LanEvent extends GenericEntity {
public int getNextBillNumber() {
return nextBillNumber;
}
public boolean isEventEnabled() {
return eventEnabled;
}
public void setEventEnabled(boolean eventEnabled) {
this.eventEnabled = eventEnabled;
}
}
......@@ -70,7 +70,7 @@ public class Place extends GenericEventChild {
* Which group has bought the place
*/
@JoinColumns({
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "group_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne
private PlaceGroup group;
......
......@@ -5,6 +5,7 @@
package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
......@@ -39,7 +40,7 @@ public class Product extends GenericEventChild {
private String name;
@Column(name = "price", nullable = false, precision = 24, scale = 4)
private BigDecimal price;
private BigDecimal price = BigDecimal.ZERO;
@Column(name = "sort", nullable = false)
private int sort;
......@@ -88,10 +89,8 @@ public class Product extends GenericEventChild {
super();
}
public Product(LanEvent event, String name, BigDecimal price) {
public Product(LanEvent event) {
super(event);
this.price = price;
this.name = name;
}
......@@ -115,6 +114,19 @@ public class Product extends GenericEventChild {
return tot;
}
// TODO: alennukset lasketaan täällä. HUOMHUOM!!
public List<Discount> getActiveDiscounts(BigDecimal quantity) {
ArrayList<Discount> ret = new ArrayList<Discount>();
for (Discount d : getDiscounts()) {
if (d.isActive() &&
quantity.compareTo(d.getAmountMax()) <= 0 &&
quantity.compareTo(d.getAmountMin()) >= 0) {
ret.add(d);
}
}
return ret;
}
public String getName() {
return name;
}
......
......@@ -73,10 +73,6 @@ public class Reader extends GenericEventChild {
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
private EventMap eventMap;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
@Column(name = "map_x")
private Integer mapX;
@Column(name = "map_y")
......@@ -154,10 +150,6 @@ public class Reader extends GenericEventChild {
this.eventMap = eventMap;
}
public LanEvent getEvent() {
return event;
}
public void setGamepoints(Integer gamepoints) {
this.gamepoints = gamepoints;
}
......
......@@ -13,28 +13,19 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.PrivateOwned;
/**
*
*/
@Entity
@Table(name = "roles", uniqueConstraints = { @UniqueConstraint(columnNames = { Role.EVENT_ID_COLUMN, Role.NAME_COLUMN }) })
@NamedQueries({
@NamedQuery(name = "Role.findForEvent", query = "SELECT r FROM Role r where r.event = :event"),
@NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name and r.event = :event"),
// @NamedQuery(name="Role.findParentsExcluding", query="select r from
// Role r, RoleRight rr where :user member of r.users ),
@NamedQuery(name = "Role.findForUser", query = "SELECT r FROM Role r WHERE :user MEMBER OF r.users and r.event = :event") })
public class Role extends GenericEntity {
/**
*
*/
private static final long serialVersionUID = -4602863502464505404L;
protected static final String NAME_COLUMN = "role_name";
......@@ -60,7 +51,8 @@ public class Role extends GenericEntity {
private List<Role> parents = new ArrayList<Role>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<ApplicationPermission> permissions;
@PrivateOwned
private List<ApplicationPermission> permissions = new ArrayList<ApplicationPermission>();
@ManyToOne
private CardTemplate cardTemplate;
......
......@@ -19,8 +19,6 @@ import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
......@@ -29,7 +27,6 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.persistence.annotations.ConversionValue;
import org.eclipse.persistence.annotations.Convert;
......@@ -50,14 +47,8 @@ import fi.insomnia.bortal.utilities.PasswordFunctions;
@ConversionValue(objectValue = "FEMALE", dataValue = "F"),
@ConversionValue(objectValue = "UNDEFINED", dataValue = "U"),
})
@NamedQueries({
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u order by u.created"),
@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User extends GenericEntity {
/**
*
*/
public static final String ANONYMOUS_LOGINNAME = "anonymous";
private static final long serialVersionUID = -1632200627103418206L;
@Column(name = "created", nullable = false)
......@@ -65,6 +56,10 @@ public class User extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP)
private Calendar created = Calendar.getInstance();
@NotNull
@Column(name = "login", unique = true, nullable = false)
private String login = "";
@Column(name = "active", nullable = false, columnDefinition = "boolean default true")
private boolean active = true;
......@@ -81,8 +76,6 @@ public class User extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP)
private Calendar birthday;
@NotNull
@Size(min = 2, message = "{user.nickSizeMessage}")
@Column(name = "nick")
private String nick = "";
......@@ -112,9 +105,6 @@ public class User extends GenericEntity {
@Column(name = "gender", nullable = false)
private Gender gender = Gender.UNDEFINED;
@Column(name = "login", unique = true)
private String login;
@Column(name = "confirm_hash")
private String confirmHash;
......@@ -308,11 +298,14 @@ public class User extends GenericEntity {
}
public void setLogin(String login) {
// Do not allow anonymous userchange
if (!isAnonymous()) {
if (login != null) {
this.login = login.trim();
this.login = login.trim().toLowerCase();
} else {
login = null;
}
}
}
......@@ -508,4 +501,14 @@ public class User extends GenericEntity {
public List<PollAnswer> getPollAnswers() {
return pollAnswers;
}
@Transient
private Boolean isAnon;
public boolean isAnonymous() {
if (isAnon == null) {
isAnon = ANONYMOUS_LOGINNAME.equals(login);
}
return isAnon;
}
}
package fi.insomnia.bortal.enums;
import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.enums.apps.LoginPermission;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.enums.apps.PollPermission;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.enums.apps.UserPermission;
public enum BortalApplication {
// NOTE. add conversion Value to RoleRight
// PERMISSION("Description"),
LOGIN("Login related permissions", LoginPermission.class),
// LOGIN("Login related permissions", LoginPermission.class),
USER("User management related", UserPermission.class),
USER_MANAGEMENT("View all users(r), modify users(w), execute actions for user(x) "),
ACCOUNT_MANAGEMENT("Manage others account events. view(r), modify(w) and create (shop)(x)"),
BILL("View all bills(r), Mark paid & modify(w), and create own bills (x)", BillPermission.class),
MAP("view maps(r), Modify(w), reserve places from maps(x)"),
ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"),
PRODUCT("View(r), modify(w), and shop(x) products"),
SHOP("View own shopped events(r), Modify own AccountEvents() and Shop(x)"),
GAME("View(r) own, modify(w), view all(X)"),
POLL("View answers(r), create polls (w), answer to polls(x)");
private String description;
private Class<? extends IAppPermission> permissions;
// s ROLE("Role management", RolePermission.class),
BILL("Creating, and managing bills", BillPermission.class),
POLL("Poll stuff", PollPermission.class),
MAP("Map management ", MapPermission.class),
SHOP("Product & shop management", ShopPermission.class);
// BILL("View all bills(r), Mark paid & modify(w), and create own bills (x)",
// BillPermission.class)
// USER_MANAGEMENT("View all users(r), modify users(w), execute actions for user(x) "),
// ACCOUNT_MANAGEMENT("Manage others account events. view(r), modify(w) and create (shop)(x)"),
// MAP("view maps(r), Modify(w), reserve places from maps(x)"),
// ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"),
// PRODUCT("View(r), modify(w), and shop(x) products"),
// SHOP("View own shopped events(r), Modify own AccountEvents() and Shop(x)"),
// GAME("View(r) own, modify(w), view all(X)"),
// POLL("View answers(r), create polls (w), answer to polls(x)");
private final String description;
private final Class<? extends IAppPermission> permissions;
private BortalApplication(String descr, Class<? extends IAppPermission> perms) {
this.permissions = perms;
this.setDescription(descr);
description = descr;
}
public IAppPermission[] getPermissions() {
return permissions.getEnumConstants();
}
private BortalApplication(String descr) {
this.permissions = FixPerm.class;
this.setDescription(descr);
}
return permissions.getEnumConstants();
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
......
......@@ -3,11 +3,18 @@ package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum BillPermission implements IAppPermission {
READ_ALL("Read all bills"), WRITE_ALL("Modify all bills"), CREATE_BILL("Create bills for self")
READ_ALL("Read all bills"),
WRITE_ALL("Modify all bills"),
CREATE_BILL("Create bills for self")
;
private String description;
private String fullName;
public static final String S_READ_ALL = "BILL/READ_ALL";
public static final String S_CREATE_BILL = "BILL/CREATE_BILL";
public static final String S_WRITE_ALL = "BILL/WRITE_ALL";
private final String description;
private final String fullName;
private BillPermission(String desc) {
description = desc;
......
......@@ -14,4 +14,7 @@ public interface IAppPermission extends Serializable {
public String getFullName();
@Override
public String toString();
}
......@@ -3,7 +3,16 @@ package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
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_OTHERS("Manage other users reservations in map"),
BUY_PLACES("Reserve and buy places from map"),
VIEW("View maps"),
MANAGE_MAPS("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_VIEW = "MAP/VIEW";
public static final String S_MANAGE_MAPS = "MAP/MANAGE_MAPS";
private String description;
private String fullName;
......@@ -15,7 +24,7 @@ public enum MapPermission implements IAppPermission {
@Override
public BortalApplication getParent() {
return BortalApplication.USER;
return BortalApplication.MAP;
}
@Override
......
......@@ -2,21 +2,20 @@ package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum LoginPermission implements IAppPermission {
LOGIN("Can login"), LOGOUT("Can logout");
public enum NewsPermission implements IAppPermission {
MANAGE("Manage newsgroups");
private String description;
private String fullName;
private LoginPermission(String desc) {
private NewsPermission(String desc) {
this.description = desc;
fullName = new StringBuilder().append(getParent().toString()).append(DELIMITER).append(toString()).toString();
}
@Override
public BortalApplication getParent() {
return BortalApplication.LOGIN;
return BortalApplication.SHOP;
}
@Override
......
......@@ -2,20 +2,23 @@ package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum FixPerm implements IAppPermission {
FIX("FIX THIS");
public enum PollPermission implements IAppPermission {
ANSWER("Can answer and view availabe polls"),
VIEW_RESULTS("View anonymized poll results"),
CREATE("Create and manage polls")
private final String description;
private final String fullName;
;
private String description;
private String fullName;
private FixPerm(String desc) {
private PollPermission(String desc) {
this.description = desc;
fullName = new StringBuilder().append(getParent().toString()).append(DELIMITER).append(toString()).toString();
}
@Override
public BortalApplication getParent() {
return BortalApplication.LOGIN;
return BortalApplication.POLL;
}
@Override
......
package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum ShopPermission implements IAppPermission {
LIST_USERPRODUCTS("List products for users in shop"),
LIST_ALL_PRODUCTS("List all products in shop"),
SHOP_TO_OTHERS("Shop to other users"),
SHOP_PRODUCTS("Shop products to self"),
MANAGE_PRODUCTS("Create and modify products");
public static final String S_LIST_USERPRODUCTS = "SHOP/LIST_USERPRODUCTS";
public static final String S_LIST_ALL_PRODUCTS = "SHOP/LIST_ALL_PRODUCTS";
public static final String S_SHOP_TO_OTHERS = "SHOP/SHOP_TO_OTHERS";
public static final String S_SHOP_PRODUCTS = "SHOP/SHOP_PRODUCTS";
public static final String S_MANAGE_PRODUCTS = "SHOP/MANAGE_PRODUCTS";
private String description;
private String fullName;
private ShopPermission(String desc) {
this.description = desc;
fullName = new StringBuilder().append(getParent().toString()).append(DELIMITER).append(toString()).toString();
}
@Override
public BortalApplication getParent() {
return BortalApplication.SHOP;
}
@Override
public String getDescription() {
return this.description;
}
@Override
public String getFullName() {
return fullName;
}
}
......@@ -3,7 +3,27 @@ package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum UserPermission implements IAppPermission {
VIEW("View all users"), MODIFY("Modify users");
VIEW_ALL("View all users"),
MODIFY("Modify users"),
CREATE_NEW("Create new user"),
VIEW_SELF("Can view self"),
LOGIN("Can login"),
LOGOUT("Can logout"),
READ_ROLES("View all roles."),
WRITE_ROLES("Modify roles"),
VIEW_ACCOUNTEVENTS("Show other users account events"),
MODIFY_ACCOUNTEVENTS("Modify Account events");
public static final String S_VIEW_ALL = "USER/VIEW_ALL";
public static final String S_MODIFY = "USER/MODIFY";
public static final String S_CREATE_NEW = "USER/CREATE_NEW";
public static final String S_VIEW_SELF = "USER/VIEW_SELF";
public static final String S_LOGIN = "USER/LOGIN";
public static final String S_LOGOUT = "USER/LOGOUT";
public static final String S_READ_ROLES = "USER/READ_ROLES";
public static final String S_WRITE_ROLES = "USER/WRITE_ROLES";
public static final String S_VIEW_ACCOUNTEVENTS = "USER/VIEW_ACCOUNTEVENTS";
public static final String S_MODIFY_ACCOUNTEVENTS = "USER/MODIFY_ACCOUNTEVENTS";
private String description;
private String fullName;
......
......@@ -24,6 +24,7 @@ public class I18n {
}
public static String get(String key, Object... params) {
return MessageFormat.format(get(key), params);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<pageflow:Pageflow xmlns:pageflow="http://www.sybase.com/suade/pageflow" id="pf13012981621060" configfile="/LanBortalWeb/WebContent/WEB-INF/faces-config.xml"/>
<pageflow:Pageflow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pageflow="http://www.sybase.com/suade/pageflow" id="pf13012981621060" configfile="/LanBortalWeb/WebContent/WEB-INF/faces-config.xml">
<nodes xsi:type="pageflow:PFPage" name="place/placemap" x="180" y="137" id="pf13156916815477" outlinks="pf13156916815478" inlinks="pf13156916815478" path="/place/placemap.xhtml"/>
<links id="pf13156916815478" target="pf13156916815477" source="pf13156916815477" outcome="placesReserved" redirect="true">
<bendPoints d1Height="-36" d2Height="-36"/>
<bendPoints d1Width="3" d1Height="-86" d2Width="3" d2Height="-86"/>
<bendPoints d1Width="-65" d1Height="-88" d2Width="-65" d2Height="-88"/>
<bendPoints d1Width="-64" d2Width="-64"/>
</links>
</pageflow:Pageflow>
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
......@@ -22,93 +20,75 @@
</locale-config>
</application>
<navigation-rule>
<from-view-id>/role/create.xhtml</from-view-id>
<navigation-case>
<from-outcome>roleCreated</from-outcome>
<to-view-id>/role/edit.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/user/list.xhtml</from-view-id>
<navigation-case>
<from-outcome>userEdit</from-outcome>
<to-view-id>/user/edit.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/user/edit.xhtml</from-view-id>
<navigation-case>
<from-outcome>userSave</from-outcome>
<to-view-id>/user/edit.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/role/list.xhtml</from-view-id>
<navigation-case>
<from-outcome>roleEdit</from-outcome>
<to-view-id>/role/edit.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<!-- <navigation-rule> -->
<!-- <from-view-id>/user/list.xhtml</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>userEdit</from-outcome> -->
<!-- <to-view-id>/user/edit.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- </navigation-rule> -->
<!-- <navigation-rule> -->
<!-- <from-view-id>/user/edit.xhtml</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>userSave</from-outcome> -->
<!-- <to-view-id>/user/edit.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- </navigation-rule> -->
<!-- <navigation-rule> -->
<!-- <from-view-id>/role/list.xhtml</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>roleEdit</from-outcome> -->
<!-- <to-view-id>/role/edit.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- </navigation-rule> -->
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>frontpage</from-outcome>
<to-view-id>/news/frontpage.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>userprefs</from-outcome>
<to-view-id>/news/edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>shopfrontpage</from-outcome>
<to-view-id>/product/createBill.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>adminfront</from-outcome>
<to-view-id>/admin/frontpage.xhtml</to-view-id>
</navigation-case>
<!-- <navigation-rule> -->
<!-- <from-view-id>*</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>frontpage</from-outcome> -->
<!-- <to-view-id>/news/frontpage.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- <navigation-case> -->
<!-- <from-outcome>userprefs</from-outcome> -->
<!-- <to-view-id>/news/edit.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- <navigation-case> -->
<!-- <from-outcome>shopfrontpage</from-outcome> -->
<!-- <to-view-id>/product/createBill.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- <navigation-case> -->
<!-- <from-outcome>adminfront</from-outcome> -->
<!-- <to-view-id>/admin/frontpage.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<navigation-case>
<from-outcome>permissionDenied</from-outcome>
<to-view-id>/permissionDenied.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>viewExpired</from-outcome>
<to-view-id>/viewExpired.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>logout</from-outcome>
<to-view-id>/auth/logout.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>loginSuccess</from-outcome>
<to-view-id>/NotImplementedYet.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>loginFailed</from-outcome>
<to-view-id>/NotImplementedYet.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/role/edit.xhtml</from-view-id>
<navigation-case>
<from-outcome>roleSaved</from-outcome>
<to-view-id>/role/edit.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<!-- </navigation-rule> -->
<!-- <navigation-rule> -->
<!-- <from-view-id>/role/edit.xhtml</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>roleSaved</from-outcome> -->
<!-- <to-view-id>/role/edit.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- </navigation-rule> -->
<!-- <navigation-rule> -->
<from-view-id>/product/createBill.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/bill/list.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<!-- <from-view-id>/product/createBill.xhtml</from-view-id> -->
<!-- <navigation-case> -->
<!-- <from-outcome>success</from-outcome> -->
<!-- <to-view-id>/bill/list.xhtml</to-view-id> -->
<!-- </navigation-case> -->
<!-- </navigation-rule> -->
<factory>
<exception-handler-factory>fi.insomnia.bortal.exceptions.BortalExceptionHandlerFactory</exception-handler-factory>
</factory>
<navigation-rule>
<display-name>place/placemap</display-name>
<from-view-id>/place/placemap.xhtml</from-view-id>
<navigation-case>
<from-outcome>placesReserved</from-outcome>
<to-view-id>/place/placemap.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
......
......@@ -3,7 +3,7 @@
"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:login="http://java.sun.com/jsf/composite/tools/login" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:head>
<title></title>
......
......@@ -5,7 +5,7 @@
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:login="http://java.sun.com/jsf/composite/tools/login"
xmlns:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
......
<!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:users="http://java.sun.com/jsf/composite/tools/user" 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:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.auth.logout" />
<f:metadata>
<f:event type="preRenderView" listener="#{authView.executeLogout}" />
</f:metadata>
<ui:define name="content">
<h:outputText value="#{i18n['login.logoutmessage']}" />
<h:outputScript>
window.location="#{request.contextPath}"
</h:outputScript>
</ui:define>
</ui:composition>
</h:body>
......
<!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:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.auth.logoutsuccess" />
<ui:define name="content">
<h:outputText value="#{i18n['login.logoutmessage']}" />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -4,36 +4,34 @@
<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:login="http://java.sun.com/jsf/composite/tools/login" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/${sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.auth.resetPassword" />
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{pwdResetView.id}" />
<f:viewParam name="hash" value="#{pwdResetView.hash}" />
<f:event type="preRenderView" listener="#{pwdResetView.initView}" />
</f:metadata>
</ui:define>
<ui:define name="content">
<h:form rendered="#{pwdResetView.hashMatch()}">
<h:inputHidden value="#{pwdResetView.user.id}" />
<h:form rendered="#{!empty pwdResetView.user}">
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['user.password']}:" for="password" />
<h:inputSecret id="password" value="#{pwdResetView.password}" />
<h:inputSecret validator="#{userValidator.password}" id="password" value="#{pwdResetView.password}" />
<h:message for="password" />
<h:outputLabel value="#{i18n['user.passwordcheck']}:" for="passwordcheck" />
<h:inputSecret id="passwordcheck" value="#{pwdResetView.confirm}" />
<h:inputSecret validator="#{userValidator.password}" id="passwordcheck" value="#{pwdResetView.confirm}" />
<h:message for="passwordcheck" />
</h:panelGrid>
<h:commandButton id="changePassword" value="#{i18n['user.changePassword']}" action="#{pwdResetView.change()}" />
</h:form>
<h:outputText rendered="#{!pwdResetView.hashMatch() }" value="#{i18n['passwordReset.hashNotFound']}" />
<h:outputText rendered="#{empty pwdResetView.user}" value="#{i18n['passwordReset.hashNotFound']}" />
</ui:define>
</ui:composition>
</h:body>
......
<!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:users="http://java.sun.com/jsf/composite/tools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<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:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.edit" />
<ui:define name="content">
<h:form id="orgform">
<h:inputHidden value="#{eventorgView.eventorg.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['eventorg.organisation']}:" /><h:inputText value="#{eventorgView.eventorg.organisation}" />
<h:outputLabel value="#{i18n['eventorg.bundleCountry']}:" /><h:inputText value="#{eventorgView.eventorg.bundleCountry}" />
<h:outputLabel value="#{i18n['eventorg.billAddress1']}:" /><h:inputText value="#{eventorgView.eventorg.billAddress1}" />
<h:outputLabel value="#{i18n['eventorg.billAddress2']}:" /><h:inputText value="#{eventorgView.eventorg.billAddress2}" />
<h:outputLabel value="#{i18n['eventorg.billAddress3']}:" /><h:inputText value="#{eventorgView.eventorg.billAddress3}" />
<h:outputLabel value="#{i18n['eventorg.billAddress4']}:" /><h:inputText value="#{eventorgView.eventorg.billAddress4}" />
<h:outputLabel value="#{i18n['eventorg.bankNumber1']}:" /><h:inputText value="#{eventorgView.eventorg.bankNumber1}" />
<h:outputLabel value="#{i18n['eventorg.bankNumber2']}:" /><h:inputText value="#{eventorgView.eventorg.bankNumber2}" />
<h:outputLabel value="#{i18n['eventorg.bankName1']}:" /><h:inputText value="#{eventorgView.eventorg.bankName1}" />
<h:outputLabel value="#{i18n['eventorg.bankName2']}:" /><h:inputText value="#{eventorgView.eventorg.bankName2}" />
<h:outputLabel value="#{i18n['eventorg.organisation']}:" />
<h:inputText value="#{eventorgView.eventorg.organisation}" />
<h:outputLabel value="#{i18n['eventorg.bundleCountry']}:" />
<h:inputText value="#{eventorgView.eventorg.bundleCountry}" />
<h:outputLabel value="#{i18n['eventorg.billAddress1']}:" />
<h:inputText value="#{eventorgView.eventorg.billAddress1}" />
<h:outputLabel value="#{i18n['eventorg.billAddress2']}:" />
<h:inputText value="#{eventorgView.eventorg.billAddress2}" />
<h:outputLabel value="#{i18n['eventorg.billAddress3']}:" />
<h:inputText value="#{eventorgView.eventorg.billAddress3}" />
<h:outputLabel value="#{i18n['eventorg.billAddress4']}:" />
<h:inputText value="#{eventorgView.eventorg.billAddress4}" />
<h:outputLabel value="#{i18n['eventorg.bankNumber1']}:" />
<h:inputText value="#{eventorgView.eventorg.bankNumber1}" />
<h:outputLabel value="#{i18n['eventorg.bankNumber2']}:" />
<h:inputText value="#{eventorgView.eventorg.bankNumber2}" />
<h:outputLabel value="#{i18n['eventorg.bankName1']}:" />
<h:inputText value="#{eventorgView.eventorg.bankName1}" />
<h:outputLabel value="#{i18n['eventorg.bankName2']}:" />
<h:inputText value="#{eventorgView.eventorg.bankName2}" />
<h:commandButton id="commitbtn" action="#{eventorgView.save()}" value="#{i18n['eventorg.save']}" />
</h:panelGrid>
</h:form>
<h2>#{i18n['eventorg.createevent']}</h2>
<h:form id="createevent" >
<h:form id="createevent">
<h:outputLabel for="createEventName" value="#{i18n['event.name']}" />
<h:inputText id="createEventName" value="#{eventorgView.eventname}" />
<h:commandButton action="#{eventorgView.createEvent()}" value="#{i18n['eventorg.createEvent']}" />
......@@ -42,7 +49,7 @@
</f:facet>
<h:outputText value="#{event.name}" />
</h:column>
<h:column >
<h:column>
<h:commandButton action="#{eventorgView.editEvent()}" value="#{i18n['eventorg.editEvent']}" />
</h:column>
......
......@@ -33,6 +33,8 @@
<br />
<h:commandButton value="Generate test poll data" action="#{TestDataView.generatePollData()}" />
<br />
<h:commandButton value="convert usernames" action="#{TestDataView.convertUsernames()}" />
<br />
</h:form>
</h:body>
</html>
......
......@@ -3,65 +3,62 @@
"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" xmlns:tools="http://java.sun.com/jsf/composite/cditools">
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
>
<h:body>
<ui:composition rendered="#{sessionHandler.loggedIn}" template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="true" />
<ui:define name="sidebarcontent">
<ul>
<tools:canRead target="ROLE_MANAGEMENT">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.roles']}" />
<ul>
<li><h:link outcome="/role/create" value="#{i18n['sidebar.role.create']}" /></li>
<li><h:link outcome="/role/list" value="#{i18n['sidebar.role.list']}" /></li>
<li><h:link outcome="/user/createCardTemplate" value="#{i18n['sidebar.cardTemplate.create']}" /></li>
<li><h:link outcome="/user/listCardTemplates" value="#{i18n['sidebar.cardTemplate.list']}" /></li>
</ul>
<li><h:link outcome="/role/create" value="#{i18n['sidebar.role.create']}" />
</li>
<li><h:link outcome="/role/list" value="#{i18n['sidebar.role.list']}" />
</li>
<li><h:link outcome="/user/createCardTemplate" value="#{i18n['sidebar.cardTemplate.create']}" />
</li>
<li><h:link outcome="/user/listCardTemplates" value="#{i18n['sidebar.cardTemplate.list']}" />
</li>
</tools:canRead>
<tools:canRead target="BILL">
</ul></li>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.bills']}" />
<ul>
<li><h:link outcome="/bill/list" value="#{i18n['sidebar.bill.listAll']}" /></li>
<li><h:link outcome="/bill/billSummary" value="#{i18n['sidebar.bill.summary']}" /></li>
</ul>
<li><h:link outcome="/bill/list" value="#{i18n['sidebar.bill.listAll']}" />
</li>
<li><h:link outcome="/bill/billSummary" value="#{i18n['sidebar.bill.summary']}" />
</li>
</tools:canRead>
<tools:canRead target="USER_MANAGEMENT">
</ul></li>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.users']}" />
<ul>
<li><h:link outcome="/user/create" value="#{i18n['sidebar.user.create']}" /></li>
<li><h:link outcome="/user/list" value="#{i18n['sidebar.user.list']}" /></li>
</ul>
<li><h:link outcome="/user/create" value="#{i18n['sidebar.user.create']}" />
</li>
<li><h:link outcome="/user/list" value="#{i18n['sidebar.user.list']}" />
</li>
</tools:canRead>
<tools:canRead target="PRODUCT">
</ul></li>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.products']}" />
<ul>
<li><h:link outcome="/product/create" value="#{i18n['sidebar.product.create']}" /></li>
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}" /></li>
</ul>
<li><h:link outcome="/product/create" value="#{i18n['sidebar.product.create']}" />
</li>
</tools:canRead>
<tools:canRead target="MAP">
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}" />
</li>
</ul></li>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.maps']}" />
<ul>
<li><h:link outcome="/map/list" value="#{i18n['sidebar.map.list']}" /></li>
</ul>
<li><h:link outcome="/map/list" value="#{i18n['sidebar.map.list']}" />
</li>
</tools:canRead>
</ul></li>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.other']}" />
<ul>
<li><h:link outcome="/eventorg/list" value="#{i18n['sidebar.eventorg.list']}" /></li>
<li><h:link outcome="/utils/flushCache" value="#{i18n['sidebar.utils.flushCache']}" /></li>
<li><h:link outcome="/generateTestData" value="#{i18n['sidebar.utils.testdata']}" /></li>
</ul>
<li><h:link outcome="/eventorg/list" value="#{i18n['sidebar.eventorg.list']}" />
</li>
<li><h:link outcome="/utils/flushCache" value="#{i18n['sidebar.utils.flushCache']}" />
</li>
<li><h:link outcome="/generateTestData" value="#{i18n['sidebar.utils.testdata']}" />
</li>
</ul></li>
</ul>
</ui:define>
</ui:composition>
......
......@@ -13,6 +13,7 @@
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/user/create.xhtml" value="#{i18n['sidebar.createuser']}"/></li>
<li><h:link outcome="/auth/sendResetMail" value="#{i18n['loginerror.resetpassword']}" /></li>
</ul>
</ui:define>
......
<!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:tools="http://java.sun.com/jsf/composite/tools"
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:tools="http://java.sun.com/jsf/composite/tools" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="#{sessionHandler.isLoggedIn()}" />
<ui:define name="sidebarcontent">
<h1>
<h:link outcome="/user/edit" value="#{userView.selectedUser.wholeName}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link>
</h1>
<ul>
<li><h:link outcome="/user/sendPicture" value="#{i18n['user.sendPicture']}"/></li>
<li><h:link outcome="/user/changePassword" value="#{i18n['user.changePassword']}"/></li>
<li><h:link outcome="/user/accountEvents" value="#{i18n['user.accountEvents']}"/></li>
<li><h:link outcome="/place/myGroups" value="#{i18n['user.myGroups']}"/></li>
<li><h:link outcome="/place/insertToken" value="#{i18n['user.insertToken']}"/></li>
<!-- <li><h:link outcome="/user/sendPicture" value="#{i18n['user.sendPicture']}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link></li>
-->
<li><h:link outcome="/user/changePassword" value="#{i18n['user.changePassword']}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link></li>
<li><h:link outcome="/user/accountEvents" value="#{i18n['user.accountEvents']}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link></li>
<li><h:link outcome="/place/myGroups" value="#{i18n['user.myGroups']}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link>
</li>
<li><h:link outcome="/place/insertToken" value="#{i18n['user.insertToken']}">
<f:param name="userid" value="#{userView.selectedUser.id}" />
</h:link>
</li>
</ul>
......
......@@ -7,12 +7,10 @@
<f:view locale="#{sessionHandler.locale}">
<ui:insert name="metadata" />
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><h:outputText value="#{i18n['global.eventname']}" /> - <h:outputText
value="#{i18n[util.concat(thispage,'.header') ] }"
/></title>
<title><h:outputText value="#{layoutView.getHeader(thispage)}" />
</title>
<meta name="description" content="Insomnia lippukauppa" />
<meta name="author" content="Niko Juusela, csharp" />
<meta http-equiv="Content-Language" content="fi" />
......@@ -26,7 +24,10 @@
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
</div>
<div id="login">
<tools:isLoggedIn>#{sessionHandler.currentUser.nick}</tools:isLoggedIn>
<h:outputText rendered="#{sessionHandler.loggedIn}"
value="Olet kirjautunut käyttäjällä: #{sessionHandler.currentUser.nick}"
/>
<tools:loginLogout />
</div>
</div>
......@@ -37,18 +38,33 @@
<li><h:link outcome="/index" value="#{i18n['topmenu.frontpage']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'frontpage'?'active':''}"
/></li>
<li>
<h:link outcome="/user/edit" value="#{i18n['topmenu.usersPreferences']}" styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'user'?'active':''}" />
<c:if test="#{sessionHandler.isLoggedIn()}">
<li><h:link outcome="/user/edit" value="#{i18n['topmenu.usersPreferences']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'user'?'active':''}"
/>
</li>
<li><h:link outcome="/poll/start" value="#{i18n['topmenu.poll']}" styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'poll'?'active': ''}" /></li>
<!--
<li><h:link outcome="/poll/start" value="#{i18n['topmenu.poll']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'poll'?'active': ''}"
/></li>
-->
</c:if>
<c:if test="#{mapView.canView()}">
<li><h:link outcome="/place/placemap" value="#{i18n['topmenu.placemap']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'placemap'?'active':''}"
/>
</li>
<li><h:link outcome="/product/list" value="#{i18n['topmenu.adminfront']}"
</c:if>
<c:if test="#{sessionHandler.isLoggedIn()}">
<!--<li><h:link outcome="/product/list" value="#{i18n['topmenu.adminfront']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'admin'?'active':''}"
/></li>
<li><h:link outcome="/shop/showReaderEvents" value="#{i18n['topmenu.rfidshop']}"
/>
</li>-->
<li><h:link outcome="/shop/createBill" value="#{i18n['sidebar.product.createBill']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'admin'?'active':''}"
/>
</li>
<!-- <li><h:link outcome="/shop/showReaderEvents" value="#{i18n['topmenu.rfidshop']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'rfidshop'?'active':''}"
/>
</li>
......@@ -56,6 +72,8 @@
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'game'?'active':''}"
/>
</li>
-->
</c:if>
</ul>
</div>
<div id="container" class="top"></div>
......
<!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:map="http://java.sun.com/jsf/composite/tools/map"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
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:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.role.edit" />
<ui:define name="content">
<map:create />
<h:form>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['map.name']}" />
<h:inputText value="#{mapManageView.mapname}" />
<h:commandButton id="createrole" value="#{i18n['map.create']}" action="#{mapManageView.createMap}" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
<!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"
<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:map="http://java.sun.com/jsf/composite/tools/map"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="mapid" value="#{mapManageView.mapId}" />
<f:event type="preRenderView" listener="#{mapManageView.initView}" />
</f:metadata>
<ui:param name="thispage" value="page.role.edit" />
<ui:define name="content">
<map:edit commitaction="#{mapManageView.saveMap()}" commitvalue="#{i18n['mapEdit.save']}"/>
<map:edit commitaction="#{mapManageView.saveMap()}" commitvalue="#{i18n['mapEdit.save']}" />
<map:setBuyable />
<img width="600" src="#{request.contextPath}#{mapView.selectPlaceMapUrl}"
alt="placeimage" />
<img width="600" src="#{request.contextPath}/PlaceMap?mapid=#{mapView.activeMap.id.id}" alt="placeimage" />
<map:genplaces />
<map:submitBg />
......
<!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:map="http://java.sun.com/jsf/composite/tools/map"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
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:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.role.list" />
......
......@@ -48,6 +48,8 @@
<h:outputLabel value="#{i18n['place.product']}:" />
<h:outputText value="#{placeView.place.product.name}" />
<h:outputLabel value="#{i18n['place.buyable']}" />
<h:selectBooleanCheckbox value="#{plaveView.place.buyable}"/>
<h:outputLabel value="#{i18n['place.description']}:" />
<h:inputTextarea value="#{placeView.place.description}" />
......
......@@ -3,18 +3,24 @@
"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:c="http://java.sun.com/jsp/jstl/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:f="http://java.sun.com/jsf/core">
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.place.insertToken" />
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" />
</f:metadata>
<ui:define name="content">
<h1>#{i18n['placetoken.pageHeader']}</h1>
<p>#{i18n['placetoken.topText']}</p>
<h:form id="placeTokenForm">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['placetoken.token']}:" />
<h:inputText value="#{placeGroupView.token}" />
<h:commandButton id="commitbtn" action="#{placeGroupView.saveToken()}" value="#{i18n['placetoken.commit']}" />
<h:inputText value="#{tokenView.token}" />
<h:commandButton id="commitbtn" action="#{tokenView.saveToken()}" value="#{i18n['placetoken.commit']}" />
</h:panelGrid>
</h:form>
</ui:define>
......
......@@ -8,12 +8,11 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.place.mygroups" />
<ui:define name="content">
#{placeGroupView.editSelf()}
<h1>#{i18n['placegroupview.header']}</h1>
<p>#{i18n['placegroupview.toptext']}</p>
<h:outputText rendered="#{!(placeGroupView.groupMemberships.rowCount gt 0)}"
<h:outputText rendered="#{empty placeGroupView.groupMemberships}"
value="#{i18n['placegroupview.noMemberships']}" />
<h:form rendered="#{placeGroupView.groupMemberships.rowCount gt 0}" id="placelistform">
<h:form rendered="#{!empty placeGroupView.groupMemberships}" id="placelistform">
<p><a href="#{request.contextPath}/PlaceGroupPdf">#{i18n['placegroup.printPdf']}</a></p>
<h:dataTable value="#{placeGroupView.groupMemberships}" var="member">
......
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/tools/map" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
......
<!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"
xmlns:products="http://java.sun.com/jsf/composite/tools/products"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<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" xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{productView.initCreateView}" />
</f:metadata>
<ui:param name="thispage" value="page.product.create" />
<ui:define name="content">
<tools:fatalPermission target="PRODUCT" permission="WRITE" />
<products:create />
<products:edit commitaction="#{productView.createProduct()}" commitvalue="#{i18n['products.create']}" />
</ui:define>
</ui:composition>
</h:body>
......
<!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" xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content">
<products:manageDiscount commitaction="#{productView.createDiscount()}" commitvalue="#{i18n['discount.create']}" />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -5,17 +5,19 @@
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"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:products="http://java.sun.com/jsf/composite/tools/products">
xmlns:products="http://java.sun.com/jsf/composite/cditools/products">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="productid" value="#{productView.productId}" />
<f:event type="preRenderView" listener="#{productView.initEditView}" />
</f:metadata>
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content">
<tools:fatalPermission target="PRODUCT" permission="WRITE" />
<products:edit commitaction="#{productView.saveProduct()}"
commitvalue="#{i18n['products.save']}" />
......
<!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"
<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"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content">
<tools:fatalPermission target="PRODUCT" permission="WRITE" />
<h:form id="discountform">
<h:inputHidden name="#{productView.discount.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['discount.shortdesc']}:" />
<h:inputText value="#{productView.discount.shortdesc}" />
<h:outputLabel value="#{i18n['discount.percentage']}:" />
<h:inputText value="#{productView.discount.percentage}" />
<h:outputLabel value="#{i18n['discount.code']}:" />
<h:inputText value="#{productView.discount.code}" />
<h:outputLabel value="#{i18n['discount.amountMin']}:" />
<h:inputText value="#{productView.discount.amountMin}" />
<h:outputLabel value="#{i18n['discount.amountMax']}:" />
<h:inputText value="#{productView.discount.amountMax}" />
<h:outputLabel value="#{i18n['discount.maxNum']}:" />
<h:inputText value="#{productView.discount.maxNum}" />
<h:outputLabel value="#{i18n['discount.active']}" />
<h:selectBooleanCheckbox value="#{productView.discount.active}" />
<h:outputLabel value="#{i18n['discount.role']}:" />
<products:manageDiscount commitaction="#{productView.save()}" commitvalue="#{i18n['discount.save']}" />
<h:commandButton id="commitbtn" action="#{productView.saveDiscount()}"
value="#{i18n['discount.save']}" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
......
<!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:products="http://java.sun.com/jsf/composite/tools/products"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:f="http://java.sun.com/jsf/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:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{productListView.initView}" />
</f:metadata>
<ui:param name="thispage" value="page.product.list" />
<ui:define name="content">
<products:list />
......
<?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"
>
<composite:interface>
<composite:attribute name="accountevents" required="true" />
</composite:interface>
<composite:implementation>
<h:form id="accountEventForm">
<h:dataTable border="1" id="ac" value="#{cc.attrs.accountevents}" var="ac">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.productname']}" />
</f:facet>
<h:outputText value="#{ac.product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.quantity']}" />
</f:facet>
<h:outputText value="#{ac.quantity}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.unitPrice']}" />
</f:facet>
<h:outputText value="#{ac.unitPrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.total']}" />
</f:facet>
<h:outputText value="#{ac.total}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.eventTime']}" />
</f:facet>
<h:outputText value="#{ac.eventTime.time}">
<f:convertDateTime type="both" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.delivered']}" />
</f:facet>
<h:outputText value="#{ac.delivered.time}">
<f:convertDateTime type="both" />
</h:outputText>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canExecute(cc.attrs.target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<composite:renderFacet required="false" name="errormessage" />
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
<?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:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canRead(cc.attrs.target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<composite:renderFacet required="false" name="errormessage" />
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
<?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:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canWrite(cc.attrs.target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<composite:renderFacet required="false" name="errormessage" />
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
......@@ -16,9 +16,9 @@
<c:choose>
<c:when test="#{not empty cc.attrs.isOneliner}">
<h:inputText id="linelogin" value="#{authView.login}" />
<h:inputSecret id="linepwd" value="#{authView.password}" />
<h:commandButton id="onelinesubmit" action="#{authView.executeLogin()}" value="#{i18n['login.submit']}" />
<h:inputText styleClass="form" id="linelogin" value="#{authView.login}" />
<h:inputSecret styleClass="form" id="linepwd" value="#{authView.password}" />
<h:commandButton styleClass="button" id="onelinesubmit" action="#{authView.executeLogin()}" value="#{i18n['login.submit']}" />
</c:when>
<c:otherwise>
......
<?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:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<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:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
>
<composite:interface>
</composite:interface>
<composite:interface>
</composite:interface>
<composite:implementation>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.isLoggedIn() }'>
<login:logout />
<h:link value="#{i18n['login.logout']}" outcome="/auth/logout" />
</c:when>
<c:otherwise>
<login:login isOneliner="true" />
</c:otherwise>
</c:choose>
</composite:implementation>
</composite:implementation>
</html>
\ No newline at end of file
<?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"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form id="productform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['map.tablesHorizontal']}:" />
<h:selectBooleanCheckbox value="#{mapManageView.tablesHorizontal}" />
<h:outputLabel value="#{i18n['map.oneRowTable']}:" />
<h:selectBooleanCheckbox value="#{mapManageView.oneRowTable}" />
<h:outputLabel value="#{i18n['map.width']}:" />
<h:inputText value="#{mapManageView.width}" />
<h:outputLabel value="#{i18n['map.height']}:" />
<h:inputText value="#{mapManageView.height}" />
<h:outputLabel value="#{i18n['map.startX']}:" />
<h:inputText value="#{mapManageView.startX}" />
<h:outputLabel value="#{i18n['map.startY']}:" />
<h:inputText value="#{mapManageView.startY}" />
<h:outputLabel value="#{i18n['map.placesInRow']}:" />
<h:inputText value="#{mapManageView.placesInRow}" />
<h:outputLabel value="#{i18n['map.tableCount']}:" />
<h:inputText value="#{mapManageView.tableCount}" />
<h:outputLabel value="#{i18n['map.tableXdiff']}:" />
<h:inputText value="#{mapManageView.tableXdiff}" />
<h:outputLabel value="#{i18n['map.tableYdiff']}:" />
<h:inputText value="#{mapManageView.tableYdiff}" />
<h:outputLabel value="#{i18n['map.namebase']}:" />
<h:inputText value="#{mapManageView.namebase}" />
<h:outputLabel value="#{i18n['map.product']}:" />
<h:selectOneMenu converter="#{productConverter}" value="#{mapManageView.mapproduct}">
<f:selectItems var="prod" itemLabel="#{prod.name}" value="#{mapManageView.productlist}" />
</h:selectOneMenu>
<h:commandButton id="commitbtn" action="#{mapManageView.generatePlaces()}" value="#{i18n['map.generate']}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
<?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/cditools"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:dataTable border="1" id="productListTable" value="#{mapManageView.maps}" var="map">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['map.id']}" />
</f:facet>
<h:outputText value="#{map.id.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['map.name']}" />
</f:facet>
<h:outputText value="#{map.name}" />
</h:column>
<h:column>
<h:link value="#{i18n['map.edit']}" outcome="/map/edit">
<f:param name="mapid" value="#{map.id.id}" />
</h:link>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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"
xmlns:role="http://java.sun.com/jsf/composite/tools/role"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form id="placeselectform">
<h:commandButton rendered="#{mapView.canUserBuy()}" value="#{i18n['mapView.buyPlaces']}"
action="#{placeView.buySelectedPlaces()}"
/>
<h:commandButton styleClass="imgcenter" id="commandbutton" image="/PlaceMap?mapid=#{mapView.activeMap.id.id}"
actionListener="#{placeView.placeSelectActionListener}"
/>
<h:panelGrid styleClass="placeSelectInfotable" columns="3">
<h:panelGrid columns="2">
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: grey; width: 10px; height: 10px;"
>&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.grey']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: white; width: 10px; height: 10px;"
>&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.white']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: red; width: 10px; height: 10px;"
>&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.red']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: green; width: 10px; height: 10px;"
>&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.green']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: blue; width: 10px; height: 10px;"
>&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.blue']}" />
</h:panelGrid>
<h:panelGroup>
<h:panelGrid columnClasses=",rightalign" columns="2">
<h:outputLabel value="#{i18n['placeSelect.totalPlaces']}:" />
<h:outputText value="#{mapView.activeMap.places.size()}" />
<h:outputLabel value="#{i18n['placeSelect.placesleft']}:" />
<h:outputText value="#{mapView.placeLeftToSelect()}" />
<h:outputLabel rendered="#{mapView.canUserBuy()}" value="#{i18n['user.accountBalance']}:" />
<h:outputText rendered="#{mapView.canUserBuy()}" value="#{mapView.user.accountBalance}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:outputLabel rendered="#{mapView.canUserBuy()}" value="#{i18n['placeSelect.reservationPrice']}:" />
<h:outputText rendered="#{mapView.canUserBuy()}" value="#{mapView.reservationPrice}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</h:panelGrid>
</h:panelGroup>
<h:panelGrid columnClasses=",rightalign" columns="2" rendered="#{not empty placeView.place }">
<h:outputLabel value="#{i18n['placeSelect.placeName']}:" />
<h:outputText value="#{placeView.place.name}" />
<h:outputLabel value="#{i18n['placeSelect.placeProductName']}:" />
<h:outputText value="#{placeView.place.product.name}" />
<h:outputLabel value="#{i18n['placeSelect.placePrice']}:" />
<h:outputText class="" value="#{placeView.place.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:commandButton rendered="#{placeView.canEdit()}" value="#{i18n['place.edit']}" action="/place/edit" />
</h:panelGrid>
</h:panelGrid>
</h:form>
<div>
<h:outputText escape="false" value="#{mapView.activeMap.notes}" />
</div>
</composite:implementation>
</html>
<?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"
xmlns:role="http://java.sun.com/jsf/composite/cditools/role">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<p><input type="hidden" name="id" value="#{mapManageView.map.id.id}" /></p>
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['setBuyable.like']}" />
<h:inputText value="#{mapManageView.buyableLike}" />
<h:commandButton id="lockbtn" action="#{mapManageView.lockBuyable}" value="#{i18n['setBuyable.lock']}" />
<h:commandButton id="releasebtn" action="#{mapManageView.releaseBuyable}" value="#{i18n['setBuyable.release']}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
<?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:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:form id="productform">
<h:inputHidden value="#{productView.product.id.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['product.name']}:" />
<h:inputText value="#{productView.product.name}" />
<h:outputLabel value="#{i18n['product.price']}:" />
<h:inputText value="#{productView.product.price}" />
<h:outputLabel value="#{i18n['product.unitName']}:" />
<h:inputText value="#{productView.product.unitName}" />
<h:outputLabel value="#{i18n['product.vat']}:" />
<h:inputText value="#{productView.product.vat}" />
<h:outputLabel value="#{i18n['product.sort']}:" />
<h:inputText value="#{productView.product.sort}" />
<h:outputLabel value="#{i18n['product.barcode']}:" />
<h:inputText value="#{productView.product.barcode}" />
<h:outputLabel value="#{i18n['product.prepaid']}" />
<h:selectBooleanCheckbox value="#{productView.product.prepaid}" />
<h:outputLabel value="#{i18n['product.prepaidInstant']}" />
<h:selectBooleanCheckbox value="#{productView.product.prepaidInstant}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
<h:commandButton rendered="#{!empty productView.product.id.id}" action="#{productView.createDiscount}"
value="#{i18n['product.createDiscount']}"
/>
<h:form id="discounts" rendered="#{!empty productView.product.id.id and !empty productView.product.discounts}">
<h:dataTable border="1" id="discount" value="#{productView.product.discounts}" var="discount">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.percentage']}" />
</f:facet>
<h:outputText value="#{discount.percentage}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.code']}" />
</f:facet>
<h:outputText value="#{discount.code}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.details']}" />
</f:facet>
<h:outputText value="#{discount.details}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.shortdesc']}" />
</f:facet>
<h:outputText value="#{discount.shortdesc}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.amountMin']}" />
</f:facet>
<h:outputText value="#{discount.amountMin}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.amountMax']}" />
</f:facet>
<h:outputText value="#{discount.amountMax}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.maxNum']}" />
</f:facet>
<h:outputText value="#{discount.maxNum}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.perUser']}" />
</f:facet>
<h:outputText value="#{discount.perUser}" />
</h:column>
<h:column>
<h:link outcome="/product/editDiscount" value="#{i18n['discount.edit']}">
<f:param name="discountid" value="#{discount.id.id}" />
</h:link>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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>
<h:dataTable border="1" id="product" value="#{productListView.products}" var="product">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
<h:column>
<h:link outcome="/product/edit" value="#{i18n['product.edit']}">
<f:param name="productid" value="#{product.id.id}" />
</h:link>
</h:column>
<h:column>
<f:facet name="header">
#{i18n['product.cashed']}
</f:facet>
<h:outputText value="#{product.soldCash}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
#{i18n['product.billed']}
</f:facet>
<h:outputText value="#{product.soldBill}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:form id="discountform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['discount.shortdesc']}:" />
<h:inputText value="#{productView.discount.shortdesc}" />
<h:outputLabel value="#{i18n['discount.percentage']}:" />
<h:inputText value="#{productView.discount.percentage}" />
<h:outputLabel value="#{i18n['discount.code']}:" />
<h:inputText value="#{productView.discount.code}" />
<h:outputLabel value="#{i18n['discount.amountMin']}:" />
<h:inputText value="#{productView.discount.amountMin}" />
<h:outputLabel value="#{i18n['discount.amountMax']}:" />
<h:inputText value="#{productView.discount.amountMax}" />
<h:outputLabel value="#{i18n['discount.maxNum']}:" />
<h:inputText value="#{productView.discount.maxNum}" />
<h:outputLabel value="#{i18n['discount.active']}" />
<h:selectBooleanCheckbox value="#{productView.discount.active}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
......@@ -19,7 +19,7 @@
<h:form>
<ui:include src="form.xhtml" />
<h:commandButton id="createrole" value="#{i18n['role.create']}" action="#{roleView.create}" />
<h:commandButton id="createrole" value="#{i18n['role.create']}" action="#{roleView.create()}" />
</h:form>
......
......@@ -15,52 +15,47 @@
<p>
<h:form id="roleform">
<h:inputHidden id="id" value="roleView.role.id.id" />
<h:inputHidden id="id" value="roleView.role.id" />
<f:facet name="errorMessage">
<h:outputText value="#{i18n['nasty.user']}" />
</f:facet>
<ui:include src="form.xhtml" />
<h:commandButton id="saverole" value="#{i18n['save']}" action="#{roleView.save}" />
<h:commandButton rendered="#{roleView.canWriteRoles()}" id="saverole" value="#{i18n['save']}"
action="#{roleView.save}"
/>
</h:form>
</p>
<p>
<h:form>
<h:dataTable border="1" id="rights" value="#{roleView.roleRights}" var="rr">
<h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.name']}" />
<h:outputText value="#{i18n['applicationPermission.name']}" />
</f:facet>
<h:outputText value="#{rr.permission.name}" />
<h:outputText value="#{bapp.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.description']}" />
<h:outputText value="#{i18n['applicationPermission.description']}" />
</f:facet>
<h:outputText value="#{rr.permission.description}" />
<h:outputText value="#{bapp.description}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.read']}" />
</f:facet>
<h:selectBooleanCheckbox id="readrole" value="#{rr.read}" />
<ui:repeat id="permDescs" var="perm" value="#{bapp.permissions}">
<div>#{perm.name} / #{perm.description}</div>
</ui:repeat>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.write']}" />
</f:facet>
<h:selectBooleanCheckbox id="writerole" value="#{rr.write}" />
<ui:repeat id="permissions" var="perm" value="#{bapp.permissions}">
<div>
<h:selectBooleanCheckbox value="#{perm.canHas}" />
</div>
</ui:repeat>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.execute']}" />
</f:facet>
<h:selectBooleanCheckbox id="executerole" value="#{rr.execute}" />
</h:column>
</h:dataTable>
<h:commandButton id="save" value="#{i18n['role.edit.save']}" action="#{roleView.saveRoleRight}" />
<h:commandButton id="save" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
</h:form>
</p>
......
......@@ -18,7 +18,7 @@
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{role.id.id}" />
<h:outputText value="#{role.id}" />
</h:column>
<h:column>
<f:facet name="header">
......@@ -28,7 +28,7 @@
</h:column>
<h:column>
<h:link outcome="/role/edit" value="#{i18n['role.edit']}">
<f:param name="roleid" value="#{role.id.id}" />
<f:param name="roleid" value="#{role.id}" />
</h:link>
</h:column>
</h:dataTable>
......
......@@ -3,7 +3,8 @@
"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">
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
......@@ -18,14 +19,17 @@
<h:form id="userform">
<h:inputHidden rendered="#{!cc.attrs.creating}" value="#{userView.selectedUser.id}" />
<h:panelGrid columns="3">
<h:outputLabel rendered="#{!cc.attrs.creating}" value="#{i18n['user.login']}:" for="viewlogin" />
<h:outputText rendered="#{!cc.attrs.creating}" disabled="#{!cc.attrs.creating and !userView.canSave()}" id="viewlogin" value="#{userView.selectedUser.login}" />
<h:outputText rendered="#{!cc.attrs.creating}" disabled="#{!cc.attrs.creating and !userView.canSave()}"
id="viewlogin" value="#{userView.selectedUser.login}"
/>
<h:message rendered="#{!cc.attrs.creating}" for="viewlogin" />
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.login']}:" for="login" />
<h:inputText rendered="#{cc.attrs.creating}" disabled="#{!cc.attrs.creating and !userView.canSave()}" id="login" value="#{userView.selectedUser.login}" />
<h:inputText rendered="#{cc.attrs.creating}" validator="#{userValidator.login}" disabled="#{!cc.attrs.creating and !userView.canSave()}"
id="login" value="#{userView.selectedUser.login}"
/>
<h:message rendered="#{cc.attrs.creating}" for="login" />
<h:outputLabel value="#{i18n['user.nick']}:" for="nick" />
......@@ -34,19 +38,27 @@
<h:outputLabel value="#{i18n['user.email']}:" for="email" />
<h:inputText id="email" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.selectedUser.email}" />
<h:inputText id="email" disabled="#{!cc.attrs.creating and !userView.canSave()}"
value="#{userView.selectedUser.email}"
/>
<h:message for="email" />
<h:outputLabel value="#{i18n['user.firstNames']}:" for="firstnames" />
<h:inputText id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.selectedUser.firstnames}" />
<h:inputText id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave()}"
value="#{userView.selectedUser.firstnames}"
/>
<h:message for="firstnames" />
<h:outputLabel value="#{i18n['user.lastName']}:" for="lastname" />
<h:inputText id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.selectedUser.lastname}" />
<h:inputText id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave()}"
value="#{userView.selectedUser.lastname}"
/>
<h:message for="lastname" />
<h:outputLabel value="#{i18n['user.address']}:" for="address" />
<h:inputText id="address" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.selectedUser.address}" />
<h:inputText id="address" disabled="#{!cc.attrs.creating and !userView.canSave()}"
value="#{userView.selectedUser.address}"
/>
<h:message for="address" />
<h:outputLabel value="#{i18n['user.zipCode']}:" for="zip" />
......@@ -59,7 +71,9 @@
<h:outputLabel rendered="#{sessionHandler.superadmin}" value="#{i18n['user.superadmin']}:" for="superadmin" />
<h:selectBooleanCheckbox disabled="#{!cc.attrs.creating and !userView.canSave()}" rendered="#{sessionHandler.superadmin}" id="superadmin" value="#{userView.selectedUser.superadmin}" />
<h:selectBooleanCheckbox disabled="#{!cc.attrs.creating and !userView.canSave()}"
rendered="#{sessionHandler.superadmin}" id="superadmin" value="#{userView.selectedUser.superadmin}"
/>
<h:message rendered="#{sessionHandler.superadmin}" for="superadmin" />
<!--
......@@ -69,7 +83,9 @@
</h:selectOneMenu>
-->
<h:outputLabel value="#{i18n['user.sex']}:" for="sex" />
<h:selectOneRadio disabled="#{!cc.attrs.creating and !userView.canSave()}" id="sex" value="#{userView.selectedUser.gender}">
<h:selectOneRadio disabled="#{!cc.attrs.creating and !userView.canSave()}" id="sex"
value="#{userView.selectedUser.gender}"
>
<f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" />
......@@ -78,24 +94,24 @@
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.password']}:" for="password" />
<h:inputSecret rendered="#{cc.attrs.creating}" id="password" value="#{createUserView.password}" />
<h:inputSecret validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" />
<h:message rendered="#{cc.attrs.creating}" for="password" />
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}:" for="passwordcheck" />
<h:inputSecret rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{createUserView.passwordcheck}" />
<h:inputSecret validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" />
<h:message rendered="#{cc.attrs.creating}" for="passwordcheck" />
<h:outputLabel rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" value="#{i18n['user.roles']}:"
for="roles" />
<h:selectManyCheckbox converter="#{roleConverter}"
rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}"
disabled="#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}" layout="pageDirection" id="roles"
value="#{userView.selectedUser.roles}">
<h:outputLabel rendered="#{roleView.canReadRoles()}" value="#{i18n['user.roles']}:" for="roles" />
<h:selectManyCheckbox converter="#{roleConverter}" rendered="#{roleView.canReadRoles()}"
disabled="#{!roleView.canWriteRoles()}" layout="pageDirection" id="roles" value="#{userView.selectedUser.roles}"
>
<f:selectItems var="roleitem" itemLabel="#{roleitem.name}" value="#{roleDataView.roles}" />
</h:selectManyCheckbox>
<h:message rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" for="roles" />
<h:message rendered="#{roleView.canReadRoles()}" for="roles" />
<h:commandButton rendered="#{cc.attrs.creating or userView.canSave()}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
<h:commandButton rendered="#{cc.attrs.creating or userView.canSave()}" id="commitbtn"
action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}"
/>
</h:panelGrid>
</h:form>
......
......@@ -9,8 +9,7 @@
</composite:interface>
<composite:implementation>
<h:form id="userlistform">
<h:dataTable styleClass="bordertable" id="user" value="#{userSearchView.users}" var="user">
<h:dataTable styleClass="bordertable" id="user" value="#{userSearchView.results}" var="user">
<h:column>
<f:facet name="header">
<h:link value="ID" includeViewParams="true">
......@@ -77,7 +76,7 @@
<f:convertNumber />
</h:outputText>
</h:column>
<h:column>
<!-- <h:column>
<f:facet name="header">
<h:outputText value="#{i18n['user.image']}" />
</f:facet>
......@@ -85,16 +84,16 @@
value="#{(empty user.currentImage)?i18n['user.noImage']:i18n['user.hasImage']}"
/>
</h:column>
-->
<h:column>
<h:link outcome="/user/edit" value="#{i18n['user.edit']}">
<f:param name="userid" value="#{user.id}" />
</h:link>
</h:column>
<h:column>
<!-- <h:column>
<h:commandButton action="#{userView.shop()}" value="#{i18n['user.shop']}" />
</h:column>
</h:column> -->
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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"
xmlns:role="http://java.sun.com/jsf/composite/tools/role">
<composite:interface>
<composite:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:form id="productform">
<h:inputHidden value="#{mapManageView.map.id.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['eventmap.name']}:" />
<h:inputText value="#{mapManageView.map.name}" />
<h:outputLabel value="#{i18n['eventmap.notes']}:" />
<h:inputTextarea cols="40" rows="5" value="#{mapManageView.map.notes}" />
<h:outputLabel value="#{i18n['eventmap.active']}:" />
<h:selectBooleanCheckbox value="#{mapManageView.map.active}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
<?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>
<h:dataTable border="1" id="Placelist" value="#{mapManageView.map.places}"
var="place">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['place.id']}" />
</f:facet>
<h:outputText value="#{place.id.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['place.name']}" />
</f:facet>
<h:outputText value="#{place.name}" />
</h:column>
<h:column>
<h:commandButton id="saverole" action="#{mapManageView.editplace()}"
value="#{i18n['place.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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"
xmlns:role="http://java.sun.com/jsf/composite/tools/role"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<form id="bgsubmit"
onsubmit="window.open('', 'imagesubmitpopup', 'height=200,width=400'); this.target='imagesubmitpopup'; return true; "
action="#{request.contextPath}/UploadServlet?type=mapimage" enctype="multipart/form-data" method="post"
>
<p>
<input type="hidden" name="id" value="#{mapManageView.map.id.id}" /> Lähetä kartan taustakuva
</p>
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['imagefile.file']}" />
<input type="file" name="file" />
<!-- <h:outputLabel value="#{i18n['imagefile.description']}"/><input type="text" name="description" /> -->
<h:panelGroup>
<input type="submit" name="submit" value="#{i18n['user.imagesubmit']}" />
</h:panelGroup>
</h:panelGrid>
</form>
</composite:implementation>
</html>
<?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:attribute name="items" required="true" />
<composite:attribute name="commitValue" required="true" />
<composite:attribute name="commitaction" method-signature="java.lang.String action()" required="true" />
</composite:interface>
<composite:implementation>
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="script" name="shopscript.js" />
<h:dataTable styleClass="bordertable" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:column>
<f:facet name="header">
<h:outputText id="name" value="${i18n['product.name']}" />
</f:facet>
<h:outputText value="#{cart.product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText id="price" value="#{cart.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText id="count" value="${i18n['product.cart.count']}" />
</f:facet>
<a href="#" onclick="return changeCartCount($(this).next().next(), -1)">-1</a>
<a href="#" onclick="return changeCartCount($(this).next(), -10)">-10</a>
<h:inputText size="4" id="cartcount" value="#{cart.count}" />
<a href="#" onclick="return changeCartCount($(this).prev(), +1)">+1</a>
<a href="#" onclick="return changeCartCount($(this).prev().prev(), +10)">+10</a>
<h:inputHidden value="#{cart.id}" />
</h:column>
</h:dataTable>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton" value="#{cc.attrs.commitValue}" />
</composite:implementation>
</html>
......@@ -7,15 +7,22 @@
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:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/tools/role">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:commandLink immediate="true" action="#{sessionHandler.logout}" value="#{i18n['login.logout']}" />
<ui:include src="form.xhtml" />
<h:commandButton id="createrole" value="#{i18n['role.create']}" action="#{roleView.create()}" />
</h:form>
</composite:implementation>
</composite:implementation>
</html>
<?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:role="http://java.sun.com/jsf/composite/cditools/role"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<p>
<h:form id="roleform">
<h:inputHidden id="id" value="roleView.role.id" />
<f:facet name="errorMessage">
<h:outputText value="#{i18n['nasty.user']}" />
</f:facet>
<ui:include src="form.xhtml" />
<h:commandButton rendered="#{roleView.canWriteRoles()}" id="saverole" value="#{i18n['save']}"
action="#{roleView.save}"
/>
</h:form>
</p>
<p>
<h:form>
<h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['applicationPermission.name']}" />
</f:facet>
<h:outputText value="#{bapp.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['applicationPermission.description']}" />
</f:facet>
<h:outputText value="#{bapp.description}" />
</h:column>
<h:column>
<ui:repeat id="permDescs" var="perm" value="#{bapp.permissions}">
<div>#{perm.name} / #{perm.description}</div>
</ui:repeat>
</h:column>
<h:column>
<ui:repeat id="permissions" var="perm" value="#{bapp.permissions}">
<div>
<h:selectBooleanCheckbox value="#{perm.canHas}" />
</div>
</ui:repeat>
</h:column>
</h:dataTable>
<h:commandButton id="save" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
</h:form>
</p>
</composite:implementation>
</html>
<?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">
<ui:composition>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['role.name']}" />
<h:inputText value="#{roleView.role.name}" />
<h:outputText value="#{i18n['role.parents']}" />
<h:selectManyCheckbox converter="#{roleConverter}" layout="pageDirection" id="roleparents"
value="#{roleView.role.parents}">
<f:selectItems var="par" itemLabel="#{par.name}" value="#{roleView.possibleParents}" />
</h:selectManyCheckbox>
<h:outputLabel value="#{i18n['role.cardtemplate']}" />
<h:selectOneMenu converter="#{cardTemplateConverter}" value="#{roleView.role.cardTemplate}">
<f:selectItems var="role" itemLabel="#{role.name}" value="#{cardView.templatesWithNull}" />
</h:selectOneMenu>
</h:panelGrid>
</ui:composition>
</html>
<?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="rolelist">
<h:dataTable border="1" id="user" value="#{roleDataView.roles}" var="role">
<h:column>
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{role.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['role.name']}" />
</f:facet>
<h:outputText value="#{role.name}" />
</h:column>
<h:column>
<h:link outcome="/role/edit" value="#{i18n['role.edit']}">
<f:param name="roleid" value="#{role.id}" />
</h:link>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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>
<h:dataTable border="1" id="productListTable"
value="#{productView.userShoppableProducts}" var="product">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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>
<h1>#{readerView.readername}</h1>
<h:form>
<h:dataTable border="1" id="event" value="#{readerView.readerEvents}" var="event">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.tag']}" />
</f:facet>
<h:outputText id="tag" value="#{event.tag}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.user']}" />
</f:facet>
<h:outputText rendered="#{!empty event.event}"
value="#{event.event.printedCard.user.wholeName} (#{event.event.printedCard.user.nick})"
/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.tag']}" />
</f:facet>
<h:dataTable value="#{event.actions}" var="action">
<h:column>
<h:outputText value="#{action}" />
</h:column>
</h:dataTable>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['readerevent.seenSince']}" />
</f:facet>
<h:outputText value="#{event.seenSince}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['gamepoints']}" />
</f:facet>
<h:outputText value="#{event.event.gamePoint}" />
</h:column>
<h:column>
<h:link outcome="/rfid/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param value="#{event.tag}" var="tag" />
</h:link>
<h:commandButton rendered="#{empty event.event}" action="#{readerView.selectEvent()}"
value="#{i18n['readerevent.associateToUser']}"
/>
<h:commandButton rendered="#{!empty event.event}" action="#{readerView.selectEvent()}"
value="#{i18n['readerevent.shopToUser']}"
/>
</h:column>
<h:column>
<h:commandButton rendered="#{!empty event.event}" action="#{readerView.editUser()}" value="#{i18n['user.edit']}" />
</h:column>
<h:column rendered="#{sessionHandler.hasPermission('GAME','WRITE')}">
<h:commandButton action="#{readerView.editGameEvent()}" value="Game" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<?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:dataTable border="1" id="reader" value="#{rfidContainer.readers}" var="rr">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.name']}" />
</f:facet>
<h:outputText value="#{rr}" />
</h:column>
<h:column>
<h:link outcome="/shop/showReaderEvents" value="#{i18n['reader.select']}">
<f:param value="#{rr}" name="reader"/>
</h:link>
</h:column>
</h:dataTable>
</composite:implementation>
</html>
......@@ -93,12 +93,12 @@
<h:inputSecret rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" />
<h:message rendered="#{cc.attrs.creating}" for="passwordcheck" />
<h:outputLabel rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" value="#{i18n['user.roles']}:"
<h:outputLabel rendered="#{roleView.canReadRoles()}" value="#{i18n['user.roles']}:"
for="roles"
/>
<h:selectManyCheckbox converter="#{roleConverter}"
rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}"
disabled="#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}" layout="pageDirection" id="roles"
rendered="#{roleView.canReadRoles()}"
disabled="#{!roleView.canModifyRoles()}" layout="pageDirection" id="roles"
value="#{userView.user.roles}"
>
<f:selectItems var="roleitem" itemLabel="#{roleitem.name}" value="#{userView.userRoles}" />
......
......@@ -3,7 +3,7 @@
"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"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
>
<composite:interface>
</composite:interface>
......
body, html {width: 100%; height: 100%; color: #343434; font-family: trebuchet ms; background:url('../img/tausta.png') repeat-x #fff; margin: 0px;}
#header {width: 970px; height: 52px; margin: 0 auto;}
#logo {width: 255px; height: 52px; float: left;}
#login {width: 290px; height: 23px; float: right; margin-top: 15px;}
#login input {background:url('../img/input.png') no-repeat; width: 130px; height: 23px; color:#fff; border:0px;padding-left: 10px;}
#login {width: 400px; height: 23px; float: right; margin-top: 15px; color:#fff;}
.form {background:url('../img/input.png') no-repeat; width: 130px; height: 23px; color:#fff; border:0px;padding-left: 10px;}
.button {background:url('../img/button.png') no-repeat; width: 100px; text-align: center; border:0px; height:23px;color:#fff; padding:0px;}
.button:hover {background:url('../img/button2.png') no-repeat; cursor:pointer;}
#wrapper {width: 970px; margin: 0 auto;}
#navigation {margin: 15px 0px; height: 33px; width: 100%;}
#navigation ul {list-style-type:none; margin: 0px; padding: 0px;}
......@@ -17,7 +19,8 @@ a:hover {color: #7dac0c;}
#left h2 {color:#7dac0c; font-size: 18px;}
#left h3 {color:#7dac0c; font-size: 16px;}
#right {float:left; border-left: 1px dotted #c0c0c0; padding: 10px 20px; width: 200px;}
#right h2 {color:#7dac0c; font-size: 18px; padding-top: 0px; margin-top:0px;}
#right h1, #right h1 a {color:#7dac0c; font-size: 18px; padding-top: 0px; margin-top:0px; text-decoration:none;}
#container.top {width: 100%; background:url(../img/container-top.png) no-repeat; height: 15px;}
#container.bottom {width: 100%; background:url(../img/container-bottom.png) no-repeat; height: 16px;}
......
......@@ -3,7 +3,7 @@
"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:role="http://java.sun.com/jsf/composite/tools/role" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/cditools/role"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
......
......@@ -3,7 +3,7 @@
"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:role="http://java.sun.com/jsf/composite/tools/role" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/cditools/role"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
......
......@@ -3,7 +3,7 @@
"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:role="http://java.sun.com/jsf/composite/tools/role" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/cditools/role"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
......
......@@ -3,7 +3,7 @@
"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:tools="http://java.sun.com/jsf/composite/tools"
xmlns:products="http://java.sun.com/jsf/composite/tools/products" xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
......
......@@ -3,19 +3,23 @@
"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:products="http://java.sun.com/jsf/composite/tools/products" xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.list" />
<f:metadata>
<f:event type="preRenderView" listener="#{productShopView.initView}" />
</f:metadata>
<ui:define name="content">
#{productShopView.initShoppableProducts()}
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.user']}" />
<h:outputText value="#{productShopView.shoppingUser.wholeName} #{productShopView.shoppingUser.nick}" />
<h:outputText value="#{productShopView.user.wholeName} #{productShopView.user.nick}" />
<h:outputLabel value="#{i18n['shop.accountBalance']}" />
<h:outputText value="#{productShopView.shoppingUser.accountBalance}">
<h:outputText value="#{productShopView.user.accountBalance}">
<f:convertNumber />
</h:outputText>
</h:panelGrid>
......@@ -25,8 +29,9 @@
<h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}" />
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.billCart}"
commitValue="#{i18n['productshop.commit']}" />
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}"
commitValue="#{i18n['productshop.commit']}"
/>
</h:form>
</ui:define>
......
......@@ -15,8 +15,8 @@
<ui:define name="content">
<h:outputLabel value="#{i18n['user.accountBalance']}: " for="accountbalance" />
<h:outputText id="accountbalance" value="#{accountView.user.accountBalance}" />
<h:dataTable border="1" id="ac" value="#{userview.user.accountEvents}" var="ac">
<h:outputText id="accountbalance" value="#{userView.user.accountBalance}" />
<h:dataTable border="1" id="ac" value="#{userView.user.accountEvents}" var="ac">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['accountEvent.productname']}" />
......@@ -65,11 +65,11 @@
</h:column>
<h:column>
<h:link outcome="/user/editAccountevent" value="#{i18n['accountEvent.edit']}">
<f:param name="accountid" value="#{ac.id}" />
</h:link>
</h:column>
<!-- <h:column> -->
<!-- <h:link outcome="/user/editAccountevent" value="#{i18n['accountEvent.edit']}"> -->
<!-- <f:param name="accountid" value="#{ac.id}" /> -->
<!-- </h:link> -->
<!-- </h:column> -->
</h:dataTable>
</ui:define>
</ui:composition>
......
......@@ -2,17 +2,17 @@
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:users="http://java.sun.com/jsf/composite/tools/user"
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{userCreateView.initView}" />
<f:event type="preRenderView" listener="#{userView.initCreateView}" />
</f:metadata>
<ui:param name="thispage" value="page.user.create" />
<ui:define name="content">
<users:edit creating="true" commitaction="#{createUserView.create()}" commitvalue="#{i18n['user.create']}" />
<users:edit creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" />
......
......@@ -4,7 +4,7 @@
<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:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:account="http://java.sun.com/jsf/composite/tools/account" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:account="http://java.sun.com/jsf/composite/cditools/account" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
......@@ -18,21 +18,19 @@
<ui:define name="content">
<users:edit commitaction="#{userView.saveUser()}" commitvalue="#{i18n['user.save']}" />
<tools:canRead target="SHOP">
<!--
<h2>#{i18n['user.accountEventHeader']}</h2>
<h:outputText rendered="#{userView.user.accountEvents.size() le 0}" value="#{i18n['user.noAccountevents']}" />
#{accountView.setUser(userView.user)}
<account:list rendered="#{userView.user.accountEvents.size() gt 0}" accountview="#{accountView}" />
</tools:canRead>
<tools:canWrite target="MAP">
<account:list rendered="#{!empty userView.user.accountEvents}" accountevents="#{userView.user.accountEvents}" />
<h1>#{i18n['user.placegroups']}</h1>
<h:form id="placegrouplist">
<h:dataTable border="1" id="placegroup" value="#{placegroupView.placegroups}" var="placegroup">
<h2>#{i18n['user.placegroups']}</h2>
<h:outputText value="#{i18n['user.noPlacegroups']}" rendered="#{empty userView.user.placeGroups}" />
<h:form id="placegrouplist" rendered="#{!empty userView.user.placeGroups}">
<h:dataTable border="1" id="placegroup" value="#{userView.user.placeGroups}" var="placegroup">
<h:column>
<f:facet name="header">
<h:outputText value="ID" />
......@@ -94,7 +92,7 @@
</h:column>
</h:dataTable>
</h:form>
</tools:canWrite>
-->
</ui:define>
</ui:composition>
......
......@@ -30,7 +30,7 @@ import fi.insomnia.bortal.model.User;
*
* @author tuukka
*/
@ManagedBean(name = "mapView")
@ManagedBean(name = "old_mapView")
@SessionScoped
public class MapView extends GenericView {
......
......@@ -32,6 +32,9 @@ public class PlaceGroupView extends GenericView {
@EJB
private PlaceBeanLocal placebean;
@EJB
private PlaceGroupBeanLocal placegroupBean;
private PlaceGroup group;
private String token;
......@@ -60,23 +63,13 @@ public class PlaceGroupView extends GenericView {
return user;
}
public ListDataModel<GroupMembership> getGroupMemberships() {
userBean.fatalNotLoggedIn();
memberlist = new ListDataModel<GroupMembership>(placegroupBean.getMembershipsAndCreations(user));
return memberlist;
}
public String saveToken() {
userBean.fatalNotLoggedIn();
User thisuser = userBean.getCurrentUser();
String ret = "myGroups";
if (!placegroupBean.associateToToken(thisuser, getToken())) {
this.addFaceMessage("placetoken.tokenNotFound");
ret = null;
}
return ret;
}
public void setToken(String token) {
this.token = token;
......
......@@ -30,7 +30,7 @@ import fi.insomnia.bortal.view.helpers.ProductShopItem;
*
* @author jkj
*/
@ManagedBean(name = "productView")
@ManagedBean(name = "oldproductView")
@SessionScoped
public class ProductView {
private static final Logger logger = LoggerFactory.getLogger(ProductView.class);
......
......@@ -62,11 +62,15 @@ public class TestDataView {
User user = testdatabean.createUser();
User admin = testdatabean.createAdmin();
testdatabean.createBill(user);
testdwatabean.createBill(user);
// testdatabean.generateTestCompos(event);
}
public void convertUsernames() {
utilbean.convertUsernames();
}
public void generateTestMap() {
EventMap map = testdatabean.generateTestMap();
......
......@@ -58,7 +58,8 @@ public class UserView extends GenericView {
private UtilBeanLocal utilbean;
private ListDataModel<UserImage> userImageList;
public void initCreateuser() {
public void initCreateUser() {
user = new User();
}
......
......@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.clientutils.BortalLocalContextHolder;
import fi.insomnia.bortal.model.User;
/**
* Servlet Filter implementation class HostnameFilter
......@@ -50,6 +51,7 @@ public class HostnameFilter implements Filter {
if (request != null && request instanceof HttpServletRequest) {
httpRequest = ((HttpServletRequest) request);
StringBuffer url = httpRequest.getRequestURL();
Subject subj = Subject.getSubject(AccessController.getContext());
int beginindex = 7; // Let's skip http://
......@@ -69,6 +71,15 @@ public class HostnameFilter implements Filter {
httpRequest.getSession().setAttribute(EventBeanLocal.HTTP_URL_HOSTNAME, hostname);
BortalLocalContextHolder.setHostname(hostname);
if (httpRequest.getUserPrincipal() == null) {
try {
httpRequest.login(User.ANONYMOUS_LOGINNAME, null);
} catch (Throwable t) {
logger.warn("Error logging in as anonymous... ignoring.. {}", t.getCause());
}
}
}
// pass the request along the filter chain
......
......@@ -47,7 +47,8 @@ public class NavigationHandler implements Serializable {
public void forward(String navigation) {
FacesContext fcont = FacesContext.getCurrentInstance();
fcont.getApplication().getNavigationHandler().handleNavigation(fcont, null, navigation);
javax.faces.application.NavigationHandler navihand = fcont.getApplication().getNavigationHandler();
navihand.handleNavigation(fcont, null, navigation);
}
}
......@@ -9,11 +9,9 @@ import java.util.TimeZone;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -51,7 +49,7 @@ public class SessionHandler {
public String getLocale() {
// TODO: Locale selection code missing
// return "en_ST_v7";
return "en_ST_v7";
return "fi_IN_XIII";
}
public String getLayout() {
......@@ -104,17 +102,6 @@ public class SessionHandler {
return ret;
}
public String logout() {
FacesContext ctx = FacesContext.getCurrentInstance();
HttpSession sess = (HttpSession) ctx.getExternalContext().getSession(false);
if (sess != null) {
sess.invalidate();
}
return "logout";
}
public boolean isLoggedIn() {
boolean ret = permbean.isLoggedIn();
......
......@@ -17,6 +17,7 @@ page.auth.login.pagegroup=login
page.auth.loginerror.pagegroup=frontpage
page.auth.logout.pagegroup=login
page.auth.logoutsuccess.pagegroup=frontpage
page.auth.notauthorized.pagegroup=frontpage
......
......@@ -62,6 +62,7 @@ eventorgView.eventname=Tapahtuman nimi
game.gamepoints=Insomnia Game pisteet:
global.cancel=Peruuta
global.notauthorized=Sinulla ei ole riitt\u00e4vi\u00e4 oikeuksia t\u00e4lle sivulle.
global.notAuthorizedExecute=Sinulla ei ole riitt\u00e4v\u00e4sti oikeuksia suorittaa t\u00e4t\u00e4 toimenpidett\u00e4!
global.save=Tallenna
imagefile.description=Kuvaus
imagefile.file=Kuvatiedosto
......@@ -103,6 +104,7 @@ page.auth.loginerror.header=kirjautuminen ep\u00e4onnistui
passwordChanged.body=Voit nyt kirjautua k\u00e4ytt\u00e4j\u00e4tunnuksella ja uudella salasanalla sis\u00e4\u00e4n j\u00e4rjestelm\u00e4\u00e4n.
passwordChanged.header=Salasana vaihdettu onnistuneesti
passwordReset.hashNotFound=Salasanan vaihto on vanhentunut. Jos haluat vaihtaa salasanan l\u00e4het\u00e4 vaihtopyynt\u00f6 uudelleen.
passwordReset.errorChanging=Odotamaton virhe. Ota yhteytt\u00e4 yll\u00e4pitoon.
passwordreset.mailBody=Voit vaihtaa salasanasi osoitteessa {0}\n\nJos et ole pyyt\u00e4nyt unohtuneen salasanan vaihtamista, ei t\u00e4h\u00e4n viestiin tarvitse reagoida.\n\nTerveisin,\nInsomnia lippupalvelu\nwww.insomnia.fi
passwordreset.mailSubject=[INSOMNIA] Salasanan vaihtaminen
passwordreset.usernotfound=Annettua k\u00e4ytt\u00e4j\u00e4tunnusta ei l\u00f6ydy. Huomioi ett\u00e4 isot ja pienet kirjaimet ovat merkitsevi\u00e4.
......@@ -150,6 +152,7 @@ placegroupview.placeReleased=Paikka {0} vapautettu
placegroupview.releasePlace=Vapauta
placegroupview.reservationName=Paikka
placegroupview.token=Paikkakoodi / k\u00e4ytt\u00e4j\u00e4
placegroupview.toptext=
placetoken.commit=Liit\u00e4
placetoken.pageHeader=Lis\u00e4\u00e4 konepaikkakoodi
placetoken.token=Paikkakoodi
......@@ -175,6 +178,7 @@ product.vat=ALV
products.save=Tallenna
productshop.commit=Osta
productshop.noItemsInCart=Ostoskorissa ei ole tuotteita
productshop.billCreated=Lasku luotu
reader.assocToCard=Yhdist\u00e4 korttiin
reader.name=Lukijan nimi
reader.tag=Tag
......@@ -189,15 +193,16 @@ resetMail.send=L\u00e4het\u00e4 s\u00e4hk\u00f6posti
resetMail.username=K\u00e4ytt\u00e4j\u00e4tunnus
resetmailSent.body=Antamasi k\u00e4ytt\u00e4j\u00e4tunnuksen s\u00e4hk\u00f6postiosoitteeseen on l\u00e4hetetty osoite jossa voit vaihtaa tunnuksen salasanan.
resetmailSent.header=S\u00e4hk\u00f6posti l\u00e4hetetty
role.create=Luo rooli
role.description=Kuvaus
role.edit.save=Tallenna
role.edit=Muokkaa
role.execute=(X)
role.name=Nimi
role.parents=Periytyy
role.read=(R)
role.write=(W)
role.cardtemplate=Korttipohja
role.savePermissions=Tallenna oikeudet
shop.accountBalance=Tilin saldo
shop.user=Myyd\u00e4\u00e4n
sidebar.bill.list=Omat laskut
......@@ -281,14 +286,32 @@ user.username=K\u00e4ytt\u00e4j\u00e4tunnus
user.validate.notUniqueUsername=K\u00e4ytt\u00e4j\u00e4tunnus on jo olemassa. Ole hyv\u00e4 ja valitse toinen tunnus
user.wholeName=Nimi
user.zipCode=Postinumero
user.placegroups=Omat paikkaryhm\u00e4t
user.noPlacegroups
userimage.webcam=Ota kuva webkameralla
userview.loginstringFaulty=K\u00e4ytt\u00e4j\u00e4tunnus virheellinen. Pit\u00e4\u00e4 olla v\u00e4hint\u00e4\u00e4n kaksi merkki\u00e4 pitk\u00e4.
userview.passwordTooShort=Salasana liian lyhyt. Pit\u00e4\u00e4 olla v\u00e4hint\u00e4\u00e4n 5 merkki\u00e4 pitk\u00e4.
userview.passwordTooShort=Salasana liian lyhyt. Pit\u00e4\u00e4 olla v\u00e4hint\u00e4\u00e4n {0} merkki\u00e4 pitk\u00e4.
userview.passwordsChanged=Salasana vaihdettu
userview.passwordsDontMatch=Salasanat eiv\u00e4t ole samat! Ole hyv\u00e4 ja sy\u00f6t\u00e4 salasanat uudelleen.
userview.userExists=K\u00e4ytt\u00e4j\u00e4tunnus on jo olemassa. Ole hyv\u00e4 ja valitse toinen tunnus.
viewexpired.body=Ole hyv\u00e4 ja kirjaudu sis\u00e4\u00e4n uudelleen.
viewexpired.title=N\u00e4kym\u00e4 on vanhentunut
page.auth.logout.header=Uloskirjautuminen
page.bill.billSummary.header=Laskujen yhteenveto
bill.markedPaid=Lasku merkitty maksetuksi.
page.product.createBill.header=Osta tuotteita
page.index.header=Etusivu
page.user.edit.header=Omat tiedot
page.place.placemap.header=Paikkakartta
page.bill.list.header=Laskut
page.bill.edit.header=Laskun tiedot
page.auth.logoutsuccess.header=Logout
page.user.create.header=Luo uusi k\u00e4ytt\u00e4j\u00e4
page.auth.resetPassword.header=Nollaa salasana
page.place.mygroups.header=Paikkaryhm\u00e4t
page.place.insertToken.header=Sy\u00f6t\u00e4 paikkakoodi
page.account.list.header=Tilitapahtumat
applicationPermission.name=Oikeusryhm\u00e4
applicationPermission.description=kuvaus
#Bill number
# Validationmessages
global.eventname=Insomnia XIII
......@@ -84,10 +84,10 @@ public class PlaceMap extends HttpServlet {
logger.debug("Mapid: {}", mapId);
ostream = response.getOutputStream();
if (map.getMapData() == null) {
logger.debug("Map does not have background!");
if (map == null || map.getMapData() == null) {
logger.info("Error handling map {}!", map);
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
ostream.print("Map has no background!");
ostream.print("Map error!");
} else {
response.setContentType("image/jpeg");
......
......@@ -87,7 +87,7 @@ public class UploadServlet extends HttpServlet {
FileItem fi = (FileItem) ti;
if (fi.getFieldName().equals("id")) {
logger.debug("Parsing int ", fi.getString());
logger.debug("Parsing int {}", fi.getString());
destId = Integer.parseInt(fi.getString());
} else if (fi.getFieldName().equals("description")) {
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.web;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.CardTemplateBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PollBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.beans.TestDataBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.beans.UserUtilBeanLocal;
/**
*
* @author tuukka
*/
@ManagedBean(name = "TestDataView")
@RequestScoped
public class TestDataView {
private static final Logger logger = LoggerFactory.getLogger(TestDataView.class);
@EJB
private TestDataBeanLocal testdatabean;
@EJB
private UserBeanLocal userbean;
@EJB
private RoleBeanLocal rolebean;
@EJB
private UserUtilBeanLocal utilbean;
@EJB
private CardTemplateBeanLocal ctbean;
@EJB
private EventBeanLocal eventbean;
@EJB
private PollBeanLocal pollbean;
public void convertUsernames() {
utilbean.convertUsernames();
}
// public void generateTestMap() {
// EventMap map = testdatabean.generateTestMap();
//
// testdatabean.generateTestPlaces(map);
// }
//
// public void executeMapTests() {
// for (long i = 100; i < 1024 * 100; i += 100) {
// logger.debug("Trying to read {} chars", i);
// EventMap map = testdatabean.readMap(i);
// // logger.debug("Got map {} with {} chars", new Object[] { map,
// // map.getMapData().length() });
// }
//
// logger.warn("All succeded Testing for original image");
// EventMap map = testdatabean.readMap(0);
// logger.info("Got orig image: {}", map);
// }
//
// /** Creates a new instance of TestDataView */
// public TestDataView() {
// }
//
// public String printPlacesInfo() {
// testdatabean.printPlacesInfo();
//
// return null;
// }
//
// public void roletest() {
// User usr = userbean.getCurrentUser();
// List<Role> roles = rolebean.listRoles();
// Role role = roles.get(roles.size() - 1);
// role.getUsers().add(usr);
// logger.debug("roles before: {}", role.getUsers());
// rolebean.mergeChanges(role);
// logger.debug("roles after: {}", usr.getRoles());
//
// }
//
// public void checkCards() {
// ctbean.checkAllUsersCardRights();
// }
//
// public String checkImages() {
// logger.debug("Cheking all users images");
// utilbean.checkAllUsersImages();
// return null;
// }
//
// public String convertImages() {
// for (User u : userbean.getUsers()) {
// utilbean.convertImage(u);
// }
//
// return null;
// }
//
// public String generatePollData() {
// LanEvent ev = eventbean.getCurrentEvent();
// Poll poll = new Poll(ev, "Tapahtumakysely");
// Calendar end = Calendar.getInstance();
// end.add(Calendar.MONTH, 1);
// poll.setEnd(end);
//
// createTextQuestion(poll, 10,
// "Millainen oli yleinen fiilis tapahtumassa?");
// createTextQuestion(poll, 20, "Mitä pidit tapahtuman kilpailuista?");
// createTextQuestion(poll, 30,
// "Mitä mieltä olit tapahtuman kilpailujen aikataulusta ja oliko neljäpäiväinen tapahtuma hyvä juttu?");
// createTextQuestion(poll, 40, "Muu palaute tapahtumasta:");
//
// createTextQuestion(poll, 60, "Mikä InsomniaGamessa oli parasta?");
// createTextQuestion(poll, 70, "Mikä InsomniaGamessa oli huonointa?");
// createTextQuestion(poll, 80,
// "Miten olisit halunnut saada tietoa InsomniaGameen liittyvistä tehtävistä?");
// createTextQuestion(poll, 90, "Palautteesi InsomniaGamen järjestäjille:");
//
// pollbean.createPoll(poll);
//
// Poll poll2 = new Poll(ev, "Gallup");
// Calendar end2 = Calendar.getInstance();
// end2.add(Calendar.MONTH, 1);
// poll2.setEnd(end);
//
// createTextQuestion(poll2, 10, "Syntymävuotesi?", 8);
// createMulticoice(poll2, 50, "Omistatko älypuhelimen?", "En", "Kyllä",
// "Olen hankkimassa seuraavaksi älypuhelmen");
//
// createMulticoice(poll2, 60, "Miten usein pelaat mobiilipelejä?",
// "En pelaa mobiilipelejä", "Olen joskus kokeillut ",
// "Pelaan lähes viikottain", "Pelaan lähes päivittäin");
//
// createMulticoice(poll2, 70,
// "Miten usein pelaat pelikonsolilla tai tietokoneella?", "En pelaa",
// "Pelaan harvoin", "Pelaan kerran, pari viikossa", "Pelaan päivittäin");
//
// createMulticoice(poll2, 80,
// "Oletko kokeillut opetuspelejä? Esimerkiksi nettiselaimella tai kännykällä?",
// "En ole kokeillut", "Olen kokeillut", "Käytän usein");
//
// createTextQuestion(poll2, 90,
// "Millaisen opetuspelin kokisit sekä hyödyllisenä että hauskana?");
//
// createMulticoice(poll2, 95,
// "Kokisitko roolipeleistä tutut kokemuspisteet ja kokemustasojen tavoittelun motivaatiota kasvattanava asiana oppimispeleissä?",
// "Kyllä", "Ei");
//
// createMulticoice(poll2, 100,
// "Oletko käyttänyt sijaintitietoon perustuvia palveluja, kuten Google Latitude tai Foursquare?",
// "En ole kokeillut", "Olen kokeillut", "Käytän usein");
//
// createTextQuestion(poll2, 110,
// "Millaisia käyttötapoja näkisit sijaintitietoon perustuvilla peleillä tai palveluilla oppimiskäytössä?");
//
// createMulticoice(poll2, 120,
// "Käytätkö sosiaalisen median palveluita, kuten Facebookia tai IRC-Galleriaa?",
// "En ole kokeillut", "Olen kokeillut", "Käytän usein");
//
// createTextQuestion(poll2, 130,
// "Millaisia käyttötapoja näkisit sosiaalisen mediaan perustuvilla palveluilla oppimiskäytössä?");
//
// createTextQuestion(poll2, 140,
// "Olet ehkä kuullut termin \"pilvipalvelut\". Miltä kuulostaisi ajatus siitä että pelikonsoli ei fyysisesti olisikaan kotonasi, vaan pelien sisältö tulisi suoraan verkkopalvelusta?");
//
// pollbean.createPoll(poll2);
//
// return null;
// }
//
// private void createMulticoice(Poll poll2, Integer sort, String question,
// String... answers) {
// PollQuestion pollq = new PollQuestion(poll2, question);
// pollq.setSort(sort);
// poll2.getQuestions().add(pollq);
// Integer anssort = 10;
// for (String ans : answers) {
// PossibleAnswer pans = new PossibleAnswer(pollq, ans);
// pans.setSort(anssort);
// pollq.getAnswers().add(pans);
// anssort += 10;
// }
// }
//
// private PollQuestion createTextQuestion(Poll poll, int sort, String
// string, int chars) {
// PollQuestion ret = createTextQuestion(poll, sort, string);
// ret.setCharacters(chars);
// return ret;
// }
//
// private PollQuestion createTextQuestion(Poll poll, int sort, String
// question) {
// PollQuestion q1 = new PollQuestion(poll, question);
// q1.setSort(sort);
// poll.getQuestions().add(q1);
//
// PossibleAnswer vapaa = new PossibleAnswer(q1, "");
//
// vapaa.setTextanswer(true);
// q1.getAnswers().add(vapaa);
// return q1;
// }
}
package fi.insomnia.bortal.web.cdiview;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
@Named
@ConversationScoped
public class CreateUserView extends GenericCDIView {
private static final long serialVersionUID = 3117825896643562324L;
@SelectedUser
private User user;
@Inject
private UserView userview;
@EJB
private UserBeanLocal userbean;
private String password;
public String create() {
user = userbean.createNewUser(user, password);
userview.setUser(user);
return "/user/edit";
}
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
}
......@@ -53,7 +53,12 @@ public abstract class GenericCDIView implements Serializable {
if (externalChecks.length == 0) {
System.arraycopy(externalChecks, 0, perms, 1, externalChecks.length);
}
return requirePermissions(perms);
boolean ret = requirePermissions(perms);
if (!ret) {
logger.info("Permission required failed for {} / {}", perm.getParent(), perm);
}
return ret;
}
protected boolean requirePermissions(boolean... externalChecks) {
......
package fi.insomnia.bortal.web.cdiview;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.model.User;
@Named
@RequestScoped
public class UserSearchView extends GenericCDIView implements IPaginationView {
/**
*
*/
private static final long serialVersionUID = -7131921062890234604L;
private int page;
private int pagesize = 20;
private long resultcount;
private long pagecount;
private String sort;
private String search;
import java.util.List;
@EJB
private UserBeanLocal userbean;
private ListDataModel<User> users;
import fi.insomnia.bortal.utilities.SearchResult;
import fi.insomnia.bortal.utilities.jpa.ModelInterface;
public void initView() {
if (requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
users = new ListDataModel<User>(userbean.getUsers(page, pagesize, sort, search));
resultcount = userbean.getUsersCount(search);
pagecount = ((resultcount + pagesize - 1) / pagesize);
}
}
public abstract class PaginationView<T extends ModelInterface<?>> extends GenericCDIView implements IPaginationView {
public String newSearch() {
page = 0;
return null;
private static final long serialVersionUID = -673649175435129349L;
protected int page;
protected int pagesize = 20;
protected long resultcount;
private long pagecount;
protected String sort;
protected String search;
private List<T> results;
public abstract void initView();
public void setResult(SearchResult<T> products) {
resultcount = products.getResultcount();
results = products.getResults();
}
@Override
......@@ -52,6 +34,9 @@ public class UserSearchView extends GenericCDIView implements IPaginationView {
@Override
public int getPagesize() {
if (pagesize < 1) {
pagesize = 20;
}
return pagesize;
}
......@@ -66,6 +51,16 @@ public class UserSearchView extends GenericCDIView implements IPaginationView {
public void setResultcount(long resultcount) {
this.resultcount = resultcount;
pagecount = ((resultcount + pagesize - 1) / pagesize);
}
@Override
public long getPagecount() {
return pagecount;
}
public void setPagecount(long pagecount) {
this.pagecount = pagecount;
}
public String getSort() {
......@@ -84,21 +79,18 @@ public class UserSearchView extends GenericCDIView implements IPaginationView {
this.search = search;
}
public ListDataModel<User> getUsers() {
return users;
public void setResults(List<T> results) {
this.results = results;
}
public void setUsers(ListDataModel<User> users) {
this.users = users;
public List<T> getResults() {
return results;
}
public void setPagecount(long pagecount) {
this.pagecount = pagecount;
}
@Override
public long getPagecount() {
return pagecount;
public String newSearch() {
page = 0;
results = null;
return null;
}
}
package fi.insomnia.bortal.web.cdiview.map;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.EventMapBeanLocal;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class MapManageView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -3276250982780044688L;
private static final Logger logger = LoggerFactory.getLogger(MapManageView.class);
@EJB
private UserBeanLocal userBean;
@EJB
private EventBeanLocal eventBean;
@EJB
private EventMapBeanLocal eventmapBean;
@EJB
private PlaceBeanLocal placebean;
@EJB
private ProductBeanLocal productbean;
private List<EventMap> eventmaps;
private EventMap map;
private String mapname;
private String buyableLike;
private boolean tablesHorizontal = false;
private boolean oneRowTable = false;
private int placesInRow = 1;
private int width;
private int height;
private int startX;
private int startY;
private int tableCount = 1;
private int tableXdiff;
private int tableYdiff;
private Product mapproduct;
private String namebase;
private Integer mapId;
private List<Product> productlist;
public void initView() {
if (super.requirePermissions(MapPermission.MANAGE_MAPS)) {
map = eventmapBean.find(getMapId());
setProductlist(productbean.getProducts());
super.beginConversation();
}
}
public List<EventMap> getMaps() {
if (eventmaps == null) {
eventmaps = eventBean.getCurrentEvent().getEventMaps();
}
return eventmaps;
}
public String lockBuyable() {
int count = placebean.setBuyable(map, buyableLike, false);
this.addFaceMessage("mapManage.lockedPlaces", count);
return null;
}
public String releaseBuyable() {
int count = placebean.setBuyable(map, buyableLike, true);
this.addFaceMessage("mapManage.releasedPlaces", count);
return null;
}
public String saveMap() {
eventmapBean.saveMap(getMap());
return null;
}
public String createMap() {
try {
map = eventmapBean.create(getMapname());
} catch (PermissionDeniedException e) {
logger.info("Permission denied", e);
}
return "edit";
}
public void generatePlaces() {
String[] tablenames = getNamebase().split(";");
List<Place> mapplaces = map.getPlaces();
logger.debug("places in map before {}", mapplaces.size());
if (mapplaces == null || mapplaces.isEmpty()) {
mapplaces = new ArrayList<Place>();
map.setPlaces(mapplaces);
}
for (int tableI = 0; tableI < tableCount; ++tableI) {
int tableXStart = tableI * tableXdiff;
int tableYStart = tableI * tableYdiff;
int rows = isOneRowTable() ? 1 : 2;
for (int rowI = 0; rowI < rows; ++rowI) {
int rowXStart = tableXStart + (tablesHorizontal ? 0 : width * rowI);
int rowYStart = tableYStart + (tablesHorizontal ? height * rowI : 0);
logger.debug("row start {} {}", rowXStart, rowYStart);
for (int placeI = 1; placeI <= placesInRow; ++placeI) {
Place place = new Place(map);
place.setHeight(Math.abs(height));
place.setWidth(Math.abs(width));
int xpos = startX + rowXStart + (tablesHorizontal ? placeI * width : 0);
int ypos = startY + rowYStart + (tablesHorizontal ? 0 : placeI * height);
logger.debug("Creating map in {} {}", xpos, ypos);
place.setMapX(xpos);
place.setMapY(ypos);
place.setProduct(mapproduct);
place.setName(tablenames[tableI] + (placeI + placesInRow * rowI));
mapplaces.add(place);
}
}
}
logger.debug("places in map after {}", mapplaces.size());
map = eventmapBean.saveMap(map);
logger.debug("places in map merge {}", map.getPlaces().size());
}
public void setMapname(String mapname) {
this.mapname = mapname;
}
public String getMapname() {
return mapname;
}
public void setMap(EventMap map) {
this.map = map;
}
public EventMap getMap() {
return map;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getStartX() {
return startX;
}
public void setStartX(int startX) {
this.startX = startX;
}
public int getStartY() {
return startY;
}
public void setStartY(int startY) {
this.startY = startY;
}
public Product getMapproduct() {
return mapproduct;
}
public void setMapproduct(Product mapproduct) {
this.mapproduct = mapproduct;
}
public String getNamebase() {
return namebase;
}
public int getTableCount() {
return tableCount;
}
public void setTableCount(int tableCount) {
this.tableCount = tableCount;
}
public int getTableXdiff() {
return tableXdiff;
}
public void setTableXdiff(int tableXdiff) {
this.tableXdiff = tableXdiff;
}
public int getTableYdiff() {
return tableYdiff;
}
public void setTableYdiff(int tableYdiff) {
this.tableYdiff = tableYdiff;
}
public void setTablesHorizontal(boolean tablesHorizontal) {
this.tablesHorizontal = tablesHorizontal;
}
public boolean isTablesHorizontal() {
return tablesHorizontal;
}
public void setPlacesInRow(int placesInRow) {
this.placesInRow = placesInRow;
}
public int getPlacesInRow() {
return placesInRow;
}
public void setOneRowTable(boolean oneRowTable) {
this.oneRowTable = oneRowTable;
}
public boolean isOneRowTable() {
return oneRowTable;
}
public void setNamebase(String namebase) {
this.namebase = namebase;
}
public void setBuyableLike(String buyableLike) {
this.buyableLike = buyableLike;
}
public String getBuyableLike() {
return buyableLike;
}
public void setMapId(Integer mapId) {
this.mapId = mapId;
}
public Integer getMapId() {
return mapId;
}
public void setProductlist(List<Product> productlist) {
this.productlist = productlist;
}
public List<Product> getProductlist() {
return productlist;
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.map;
import java.math.BigDecimal;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -15,14 +15,15 @@ import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceBeanLocal;
import fi.insomnia.bortal.beans.PlaceMapBeanLocal;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
@RequestScoped
public class MapView extends GenericCDIView {
private static final long serialVersionUID = 2374905512998240551L;
......@@ -42,6 +43,10 @@ public class MapView extends GenericCDIView {
private static final Logger logger = LoggerFactory.getLogger(MapView.class);
public boolean canView() {
return permbean.hasPermission(MapPermission.VIEW);
}
public boolean canUserBuy() {
if (user == null) {
return false;
......@@ -49,16 +54,6 @@ public class MapView extends GenericCDIView {
return user.getAccountBalance().compareTo(BigDecimal.ZERO) > 0;
}
public String buySelectedPlaces() throws PermissionDeniedException {
try {
placeBean.buySelectedPlaces(user);
} catch (BortalCatchableException e) {
addFaceMessage("mapView.errorWhileBuyingPlaces");
placeBean.releaseUsersPlaces(user);
}
return "";
}
public BigDecimal getReservationPrice() throws PermissionDeniedException {
return placeBean.totalReservationPrice(user, null);
}
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.map;
import java.math.BigDecimal;
import java.util.Map;
......@@ -17,12 +17,13 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......@@ -51,6 +52,21 @@ public class PlaceView extends GenericCDIView {
private String searchuser;
private ListDataModel<User> userlist;
public boolean canEdit() {
return permbean.hasPermission(MapPermission.MANAGE_MAPS);
}
public String buySelectedPlaces() throws PermissionDeniedException {
try {
placebean.buySelectedPlaces(user);
return "/place/myGroups";
} catch (BortalCatchableException e) {
addFaceMessage("mapView.errorWhileBuyingPlaces");
placebean.releaseUsersPlaces(user);
}
return null;
}
public void placeSelectActionListener(ActionEvent e) throws PermissionDeniedException {
super.beginConversation();
......@@ -68,8 +84,10 @@ public class PlaceView extends GenericCDIView {
if (place != null) {
logger.info("placeinfo User {}, group {}", place.getCurrentUser(), place.getGroup());
if (place.isReservedFor(user)) {
logger.debug("Place {} was reserved for user. Removing reservation!", place);
logger.info("Place {} was reserved for user. Removing reservation!", place);
if (!placebean.releasePlace(place)) {
this.addFaceMessage("mapView.errorWhenReleasingPlace");
}
......@@ -96,7 +114,7 @@ public class PlaceView extends GenericCDIView {
}
public void initView() {
if (super.requirePermissions(FixPerm.FIX)) {
if (super.requirePermissions(MapPermission.MANAGE_OTHERS)) {
if (getPlaceId() != null) {
this.place = placebean.find(getPlaceId());
}
......@@ -123,7 +141,7 @@ public class PlaceView extends GenericCDIView {
}
public String searchUser() {
userlist = new ListDataModel<User>(userbean.searchName(searchuser));
userlist = new ListDataModel<User>(userbean.getUsers(0, 0, null, searchuser).getResults());
return null;
}
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.map;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceGroupBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.model.GroupMembership;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named("placeGroupView")
@ConversationScoped
......@@ -25,6 +31,10 @@ public class PlacegroupView extends GenericCDIView {
@Inject
@SelectedUser
private User user;
@EJB
private PlaceGroupBeanLocal placegroupBean;
@EJB
private UserBeanLocal userbean;
private Place place;
private PlaceGroup group;
......@@ -32,6 +42,8 @@ public class PlacegroupView extends GenericCDIView {
private ListDataModel<PlaceGroup> placegroups;
private ListDataModel<Place> placelist;
private ListDataModel<GroupMembership> memberlist;
public String editGroup() {
setGroup(placegroups.getRowData());
setPlacelist(new ListDataModel<Place>(group.getPlaces()));
......@@ -39,6 +51,35 @@ public class PlacegroupView extends GenericCDIView {
return "/place/editGroup";
}
public boolean canModify(GroupMembership row) {
boolean ret = false;
if (row != null && (
permbean.isCurrentUser(row.getPlaceGroup().getCreator()) ||
permbean.hasPermission(MapPermission.MANAGE_OTHERS))) {
ret = true;
}
return ret;
}
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(placegroupBean.getMembershipsAndCreations(user));
return memberlist;
}
public String releasePlace() throws PermissionDeniedException {
GroupMembership row = memberlist.getRowData();
if (row != null && (permbean.isCurrentUser(row.getPlaceGroup().getCreator()) ||
permbean.hasPermission(MapPermission.MANAGE_OTHERS))) {
placegroupBean.releaseAndGenerateToken(row);
this.addFaceMessage("placegroupview.placeReleased", row.getPlaceReservation().getName());
} else {
this.addFaceMessage("placegroupview.placeReleaseFailed", row.getPlaceReservation().getName());
}
return null;
}
public ListDataModel<PlaceGroup> getPlacegroups() {
if (placegroups == null) {
List<PlaceGroup> retlist = new ArrayList<PlaceGroup>();
......
package fi.insomnia.bortal.web.cdiview.map;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceGroupBeanLocal;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class TokenView extends GenericCDIView {
private static final long serialVersionUID = -2371506803749823158L;
private String token;
@Inject
@SelectedUser
private User user;
@EJB
private PlaceGroupBeanLocal placegroupbean;
public String saveToken() throws PermissionDeniedException {
super.requirePermissions();
if (!permbean.hasPermission(MapPermission.BUY_PLACES) && !permbean.isCurrentUser(user) && permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
this.addFaceMessage("permission.denied");
return null;
}
String ret = "myGroups";
if (!placegroupbean.associateToToken(user, getToken())) {
this.addFaceMessage("placetoken.tokenNotFound");
ret = null;
}
return ret;
}
public void setToken(String token) {
this.token = token;
}
public String getToken() {
return token;
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.news;
import java.util.List;
......@@ -7,8 +7,9 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.NewsBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.NewsPermission;
import fi.insomnia.bortal.model.NewsGroup;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
......@@ -25,7 +26,7 @@ public class NewsListView extends GenericCDIView {
private List<NewsGroup> newsgroups;
public void initView() {
if (super.requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
if (super.requirePermissions(permbean.hasPermission(NewsPermission.MANAGE))) {
setNewsgroups(newsbean.findAll());
}
}
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.news;
import javax.ejb.EJB;
import javax.inject.Named;
import fi.insomnia.bortal.beans.NewsBeanLocal;
import fi.insomnia.bortal.model.NewsGroup;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
public class NewsView extends GenericCDIView {
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.news;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.NewsBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.NewsPermission;
import fi.insomnia.bortal.model.NewsGroup;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......@@ -22,7 +23,7 @@ public class NewsgroupView extends GenericCDIView {
private NewsGroup newsgroup;
public void initView() {
if (super.requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
if (super.requirePermissions(permbean.hasPermission(NewsPermission.MANAGE))) {
super.beginConversation();
if (newsgroupid == 0 && newsgroup == null) {
newsgroup = new NewsGroup();
......
package fi.insomnia.bortal.web.cdiview.organisation;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.EventOrganiserBeanLocal;
import fi.insomnia.bortal.model.EventOrganiser;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.LoggedIn;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named("eventorgView")
@ConversationScoped
public class EventOrgView extends GenericCDIView {
private static final long serialVersionUID = -1351272199807699797L;
@EJB
private EventOrganiserBeanLocal eventorgbean;
@EJB
private EventBeanLocal eventbean;
@LoggedIn
@Inject
private User user;
private EventOrganiser eventorg;
private Integer orgId;
private List<EventOrganiser> organisations;
public void initEditView() {
if (orgId != null) {
eventorg = eventorgbean.find(orgId);
} else {
eventorg = eventbean.getCurrentEvent().getOrganiser();
}
if (!super.requirePermissions(user.isSuperadmin() || (eventorg.getAdmin().equals(user)))) {
eventorg = null;
}
}
public void initListView() {
if (super.requirePermissions(user.isSuperadmin() || (eventbean.getCurrentEvent().getOrganiser().getAdmin().equals(user)))) {
if (getUser().isSuperadmin()) {
setOrganisations(eventorgbean.getEventOrganisers());
} else {
setOrganisations(getUser().getEventOrganiser());
}
}
}
public void setEventorg(EventOrganiser eventorg) {
this.eventorg = eventorg;
}
public EventOrganiser getEventorg() {
return eventorg;
}
public void setOrgId(Integer orgId) {
this.orgId = orgId;
}
public Integer getOrgId() {
return orgId;
}
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
public void setOrganisations(List<EventOrganiser> organisations) {
this.organisations = organisations;
}
public List<EventOrganiser> getOrganisations() {
return organisations;
}
}
package fi.insomnia.bortal.web.cdiview.poll;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PollBeanLocal;
import fi.insomnia.bortal.enums.apps.PollPermission;
import fi.insomnia.bortal.model.Poll;
import fi.insomnia.bortal.model.PollAnswer;
import fi.insomnia.bortal.model.PollQuestion;
import fi.insomnia.bortal.model.PossibleAnswer;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class PollView extends GenericCDIView {
private static final long serialVersionUID = -7636682120192671958L;
@EJB
private PollBeanLocal pollBean;
private List<Poll> polls;
private HashMap<Integer, List<QuestionWrapper>> pages;
private Integer thisPage = 1;
private Integer pollId;
private Poll poll;
private static final Logger logger = LoggerFactory.getLogger(PollView.class);
public void initPollList() {
if (super.requirePermissions(PollPermission.ANSWER)) {
setPolls(pollBean.findPolls());
}
}
public void initPoll() {
if (super.requirePermissions(PollPermission.ANSWER)) {
poll = pollBean.find(pollId);
setPages(new HashMap<Integer, List<QuestionWrapper>>());
for (PollQuestion q : getPoll().getQuestions()) {
if (!getPages().containsKey(q.getPage())) {
getPages().put(q.getPage(), new LinkedList<QuestionWrapper>());
}
getPages().get(q.getPage()).add(new QuestionWrapper(q));
}
super.beginConversation();
}
}
public String nextPage() {
++thisPage;
return null;
}
public List<QuestionWrapper> getCurrentPage() {
return getPages().get(thisPage);
}
public String savePoll() {
if (validate(this)) {
pollBean.createAnswers(createAnswers());
}
return "/poll/thankYou";
}
private List<PollAnswer> createAnswers() {
ArrayList<PollAnswer> ret = new ArrayList<PollAnswer>();
for (List<QuestionWrapper> qw : getPages().values()) {
for (QuestionWrapper wrapper : qw) {
ret.addAll(wrapper.getAnswers());
}
}
return ret;
}
public boolean validate(PollView pollView) {
boolean ret = true;
// TODO: VALIDOI POLLIVASTAUKSET!
return ret;
}
public void setPoll(Poll poll) {
this.poll = poll;
}
public Poll getPoll() {
return poll;
}
public void setPollId(Integer pollId) {
this.pollId = pollId;
}
public Integer getPollId() {
return pollId;
}
public void setPolls(List<Poll> polls) {
this.polls = polls;
}
public List<Poll> getPolls() {
return polls;
}
public void setPages(HashMap<Integer, List<QuestionWrapper>> pages) {
this.pages = pages;
}
public HashMap<Integer, List<QuestionWrapper>> getPages() {
return pages;
}
public class QuestionWrapper {
private PollQuestion question;
private ArrayList<PollAnswer> answers;
public QuestionWrapper(PollQuestion q) {
question = q;
answers = new ArrayList<PollAnswer>();
for (PossibleAnswer possible : q.getAnswers()) {
answers.add(new PollAnswer(possible));
}
}
public boolean isFreeText() {
return question.isFreeText();
}
public PollAnswer getTextAnswer() {
if (!isFreeText()) {
throw new RuntimeException("IS not freetext!! !!BUG!!BUG!!");
}
return answers.get(0);
}
public void setOneSelected(PollAnswer ans) {
if (ans != null) {
for (PollAnswer possibleAns : answers) {
if (possibleAns.getChoice().equals(ans.getChoice())) {
possibleAns.setAnswerBoolean(true);
} else {
possibleAns.setAnswerBoolean(false);
}
}
}
}
public PollAnswer getOneSelected() {
for (PollAnswer possibleAns : answers) {
if (possibleAns.getAnswerBoolean()) {
return possibleAns;
}
}
return null;
}
public PollQuestion getQuestion() {
return question;
}
public void setQuestion(PollQuestion question) {
this.question = question;
}
public void setAnswers(ArrayList<PollAnswer> answers) {
this.answers = answers;
}
public ArrayList<PollAnswer> getAnswers() {
return answers;
}
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -7,6 +7,7 @@ import javax.inject.Named;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import java.util.Calendar;
......@@ -13,6 +13,7 @@ import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......
package fi.insomnia.bortal.web.cdiview.shop;
import java.util.ArrayList;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class DiscountView extends GenericCDIView {
private static final long serialVersionUID = 7495651955338109909L;
private Integer discountid;
private Integer productId;
private Product product;
private Discount discount;
@EJB
private ProductBeanLocal prodbean;
public void initEditView() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && discount == null) {
discount = prodbean.findDiscount(discountid);
super.beginConversation();
}
}
public void initCreateView() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS)) {
product = prodbean.findById(productId);
discount = new Discount(product);
}
}
public String save() {
discount = prodbean.save(discount);
super.addFaceMessage("discount.saved");
return null;
}
public String create() {
if (product.getDiscounts() == null) {
product.setDiscounts(new ArrayList<Discount>());
}
product.getDiscounts().add(discount);
product = prodbean.mergeChanges(product);
super.addFaceMessage("discount.created");
return "/product/editDiscount";
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.inject.Inject;
......@@ -8,6 +8,7 @@ import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.model.GroupMembership;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
public class InviteAcceptView extends GenericCDIView {
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import java.util.List;
......@@ -7,7 +7,10 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.cdiview.IPaginationView;
@Named
@RequestScoped
......@@ -28,8 +31,10 @@ public class ProductListView extends GenericCDIView implements IPaginationView {
private ProductBeanLocal prodbean;
public void initView() {
if (super.requirePermissions(ShopPermission.LIST_ALL_PRODUCTS)) {
products = prodbean.getProducts();
}
}
public void setProducts(List<Product> products) {
this.products = products;
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.Iterator;
......@@ -16,10 +16,11 @@ import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.helpers.ProductShopItem;
@Named
......@@ -42,15 +43,22 @@ public class ProductShopView extends GenericCDIView {
@Inject
@SelectedUser
private User user;
private boolean payInstant;
private ListDataModel<ProductShopItem> shoppingcart;
public void initView() {
this.beginConversation();
if (permbean.hasPermission(FixPerm.FIX)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
} else if (requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
boolean ok = true;
if (!permbean.isCurrentUser(user)) {
ok = requirePermissions(ShopPermission.SHOP_TO_OTHERS);
}
if (ok) {
if (permbean.hasPermission(ShopPermission.LIST_ALL_PRODUCTS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.getProducts()));
} else if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
}
this.beginConversation();
}
}
......@@ -65,26 +73,26 @@ public class ProductShopView extends GenericCDIView {
Iterator<ProductShopItem> cartIter = shoppingcart.iterator();
Bill bill = null;
try {
bill = billbean.createEmptyBill(user);
Bill bill = new Bill(eventbean.getCurrentEvent(), user);
bill.setOurReference(eventbean.getCurrentEvent().getName());
while (cartIter.hasNext()) {
ProductShopItem shopitem = cartIter.next();
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
billbean.addProductToBill(bill, shopitem.getProduct(), shopitem.getCount());
bill.addProduct(shopitem.getProduct(), shopitem.getCount());
}
}
billbean.createBill(bill);
addFaceMessage("productshop.billCreated");
} catch (PermissionDeniedException e) {
logger.info("Error committing bill cart", e);
addFaceMessage("productshop.errorCreatingBill");
return "failure";
}
return "/bills/list";
return "/bill/list";
}
public void setUser(User user) {
......@@ -112,4 +120,12 @@ public class ProductShopView extends GenericCDIView {
}
return false;
}
public void setPayInstant(boolean payInstant) {
this.payInstant = payInstant;
}
public boolean isPayInstant() {
return payInstant;
}
}
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class ProductView extends GenericCDIView {
private static final long serialVersionUID = -7042949133729016773L;
@EJB
private EventBeanLocal eventbean;
@EJB
private ProductBeanLocal prodbean;
private Product product;
private Discount discount;
private Integer productId;
public void initEditView() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && product == null) {
product = prodbean.findById(getProductId());
super.beginConversation();
}
}
public void initCreateView() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS)) {
setProduct(new Product(eventbean.getCurrentEvent()));
super.beginConversation();
}
}
public String saveProduct() {
product = prodbean.mergeChanges(product);
super.addFaceMessage("product.saved");
return null;
}
public String createProduct() {
prodbean.create(product);
super.addFaceMessage("product.created");
return "/product/edit";
}
public void setProduct(Product product) {
this.product = product;
}
public Product getProduct() {
return product;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getProductId() {
return productId;
}
public void setDiscount(Discount discount) {
this.discount = discount;
}
public Discount getDiscount() {
return discount;
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import java.util.List;
......@@ -6,7 +6,8 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.helpers.RfidEvent;
@Named
......@@ -24,7 +25,7 @@ public class ReaderView extends GenericCDIView {
private RfidContainer container;
public void initView() {
super.requirePermissions(permbean.hasPermission(FixPerm.FIX));
super.requirePermissions(permbean.hasPermission(ShopPermission.SHOP_TO_OTHERS));
}
public List<RfidEvent> getReaderEvents() {
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import java.util.ArrayList;
import java.util.Collections;
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
......@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.ReaderBeanLocal;
import fi.insomnia.bortal.model.ReaderEvent;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -7,6 +7,7 @@ import javax.inject.Named;
import fi.insomnia.bortal.beans.AccountEventBeanLocal;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......@@ -27,10 +28,12 @@ public class AccountEventView extends GenericCDIView {
public void initView() {
canSave = permbean.hasPermission(UserPermission.VIEW);
if (requirePermissions(permbean.isLoggedIn(), canSave)) {
beginConversation();
accountevent = accounteventbean.find(getPk(accountid));
if (requirePermissions(permbean.isCurrentUser(accountevent.getUser()) || permbean.hasPermission(UserPermission.VIEW_ACCOUNTEVENTS))) {
beginConversation();
setCanSave(permbean.hasPermission(UserPermission.MODIFY_ACCOUNTEVENTS));
} else {
accountevent = null;
}
}
......@@ -50,4 +53,12 @@ public class AccountEventView extends GenericCDIView {
public AccountEvent getAccountevent() {
return accountevent;
}
public void setCanSave(boolean canSave) {
this.canSave = canSave;
}
public boolean isCanSave() {
return canSave;
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import java.security.Principal;
......@@ -14,10 +14,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.handler.NavigationHandler;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class AuthView {
public class AuthView extends GenericCDIView {
private static final Logger logger = LoggerFactory.getLogger(AuthView.class);
private String login;
......@@ -35,31 +37,60 @@ public class AuthView {
(HttpServletRequest) request : null;
}
public void executeLogout() {
HttpServletRequest req = getRequest();
if (permbean.isLoggedIn()) {
try {
req.logout();
} catch (ServletException e) {
logger.warn("Error executing logout", e);
}
}
req.getSession().invalidate();
navihandler.forward("logoutDone");
}
public void executeLogin() {
if (login == null || password == null || login.isEmpty() || password.isEmpty()) {
return;
}
HttpServletRequest request = getRequest();
if (request.getUserPrincipal() != null) {
navihandler.redirectNavigation("/");
} else {
logger.info("Principal not empty. need to logout first");
try {
request.login(login, password);
request.logout();
} catch (ServletException e) {
logger.info("Error logging out before logging in...");
}
}
try {
request.login(login.toLowerCase(), password);
} catch (Throwable e) {
logger.info("Error while trying to login {}", e.getMessage());
} finally {
Principal principal = request.getUserPrincipal();
logger.info("Logged in principal: {}", principal);
if (principal != null) {
navihandler.redirectToSaved();
}
} else {
navihandler.forward("/auth/loginError");
try {
request.login(User.ANONYMOUS_LOGINNAME, null);
} catch (ServletException e) {
logger.info("Error while trying to login {}", e.getCause());
logger.warn("Error while trying to relogin as anonymous", e);
}
}
}
}
public String getLogin() {
return login;
}
......
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.PasswordFunctions;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named("pwdResetView")
@ConversationScoped
public class PasswordResetView extends GenericCDIView {
private static final long serialVersionUID = -8376057094610871784L;
private Integer id;
private String hash;
private String password;
private String confirm;
private User user;
private String mailuser;
@EJB
private UserBeanLocal userbean;
private static final Logger logger = LoggerFactory.getLogger(PasswordResetView.class);
public void initView() {
if (id != null && id > 0 && hash != null && hash.length() > 5) {
user = userbean.findPasswordResetUser(id, hash);
}
if (user != null) {
super.beginConversation();
}
}
public String change() {
String ret = null;
if (userbean.resetPassword(user, password, hash)) {
ret = "/auth/passwordChanged";
} else {
super.addFaceMessage("passwordReset.errorChanging");
}
return ret;
}
public String sendMail() {
User userObj = userbean.getUser(mailuser);
if (userObj != null) {
String hashStr = PasswordFunctions.generateRandomString(25);
ExternalContext extcontext = FacesContext.getCurrentInstance().getExternalContext();
StringBuilder path = new StringBuilder();
String servername = extcontext.getRequestServerName();
logger.info("Serverport secure: {}", extcontext.getRequestServerPort(), extcontext.isSecure());
if (extcontext.getRequestServerPort() != 80) {
if (extcontext.getRequestServerPort() == 443) {
path.append("https://").append(servername.replace(":443", ""));
} else {
path.append("http://").append(servername);
path.append(":").append(extcontext.getRequestServerPort());
}
} else {
path.append("http://").append(servername);
}
path.append("/")
.append(FacesContext.getCurrentInstance().getExternalContext().getContextName())
.append("/auth/resetPassword.jsf?id=")
.append(userObj.getId()).append("&hash=")
.append(hashStr);
logger.info("Initializing password sending: {}, hash: {}", userObj, hashStr);
userbean.initPasswordReset(userObj, hashStr, path.toString());
return "/auth/resetmailSent";
}
mailuser = null;
this.addFaceMessage("passwordreset.usernotfound");
return null;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getConfirm() {
return confirm;
}
public void setConfirm(String confirm) {
this.confirm = confirm;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getMailuser() {
return mailuser;
}
public void setMailuser(String mailuser) {
this.mailuser = mailuser;
}
public UserBeanLocal getUserbean() {
return userbean;
}
public void setUserbean(UserBeanLocal userbean) {
this.userbean = userbean;
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -7,9 +7,10 @@ import javax.inject.Named;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
......@@ -31,7 +32,7 @@ public class PasswordView extends GenericCDIView {
private String passwordcheck;
public String changePassword() {
if (permbean.isCurrentUser(user) || permbean.hasPermission(FixPerm.FIX)) {
if (permbean.isCurrentUser(user) || permbean.hasPermission(UserPermission.MODIFY)) {
if (password != null && password.equals(passwordcheck)) {
user.resetPassword(password);
try {
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
......@@ -7,6 +7,7 @@ import javax.inject.Named;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
......
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -11,8 +15,14 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.BortalApplication;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.ApplicationPermission;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.helpers.ApplicationPermissionWrapper;
import fi.insomnia.bortal.web.helpers.BortalApplicationWrapper;
@ConversationScoped
@Named
......@@ -31,65 +41,100 @@ public class RoleView extends GenericCDIView {
@EJB
private EventBeanLocal eventbean;
private ArrayList<BortalApplicationWrapper> rolePermissions;
private static final Logger logger = LoggerFactory.getLogger(RoleView.class);
public void permissionCreate() {
requirePermissions(permbean.hasPermission(FixPerm.FIX));
requirePermissions(permbean.hasPermission(UserPermission.WRITE_ROLES));
}
public void permissionRead() {
requirePermissions(permbean.hasPermission(FixPerm.FIX));
requirePermissions(permbean.hasPermission(UserPermission.READ_ROLES));
}
public void initForCreate() {
if (role == null && requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
role = new Role(eventbean.getCurrentEvent());
if (requirePermissions(permbean.hasPermission(UserPermission.WRITE_ROLES))) {
setRole(new Role(eventbean.getCurrentEvent()));
super.beginConversation();
}
}
//
// public String saveRoleRight() {
//
// for (RoleRight rr : rolerights) {
// rolebean.mergeChanges(rr);
// }
// rolerights = null;
//
// return "editRoleright";
// }
//
// public DataModel<RoleRight> getRoleRights() {
//
// if (rolerights == null && role != null) {
// rolerights = new ListDataModel<RoleRight>(rolebean.getRoleRights(role));
// }
// return rolerights;
// }
public boolean canReadRoles() {
return permbean.hasPermission(UserPermission.READ_ROLES);
}
public boolean canWriteRoles() {
return permbean.hasPermission(UserPermission.WRITE_ROLES);
}
public void initViewFromId() {
if (requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
if (requirePermissions(permbean.hasPermission(UserPermission.READ_ROLES)) && role == null) {
super.beginConversation();
role = rolebean.find(getRoleid());
logger.debug("Initialized role: {} from id ", role, getRoleid());
setRole(rolebean.find(getRoleid()));
logger.debug("Initialized role: {} from id ", getRole(), getRoleid());
}
}
private void initPermissions() {
logger.info("Initializing permissions for role {}", role);
EnumMap<BortalApplication, Set<IAppPermission>> rolePermissionMap = new EnumMap<BortalApplication, Set<IAppPermission>>(BortalApplication.class);
if (role.getPermissions() == null) {
role.setPermissions(new ArrayList<ApplicationPermission>());
}
for (ApplicationPermission perm : role.getPermissions()) {
Set<IAppPermission> permlist = rolePermissionMap.get(perm.getApplication());
if (permlist == null) {
permlist = new HashSet<IAppPermission>();
rolePermissionMap.put(perm.getApplication(), permlist);
logger.info("Initing Role permisions App {}, role {}", perm.getApplication(), perm.getPermission());
}
permlist.add(perm.getPermission());
}
setRolePermissions(new ArrayList<BortalApplicationWrapper>());
for (BortalApplication bApp : BortalApplication.values()) {
getRolePermissions().add(new BortalApplicationWrapper(bApp, rolePermissionMap.get(bApp)));
}
}
public String create() {
super.requirePermissions(permbean.hasPermission(FixPerm.FIX));
role = rolebean.create(getRole());
return "roleCreated";
super.requirePermissions(permbean.hasPermission(UserPermission.WRITE_ROLES));
rolebean.create(getRole());
return "/role/edit";
}
public String save() {
role = rolebean.mergeChanges(getRole());
setRole(rolebean.mergeChanges(getRole()));
return "roleSaved";
}
public void setRole(Role role) {
this.role = role;
public String savePermissions() {
if (canWriteRoles()) {
ArrayList<IAppPermission> newPerms = new ArrayList<IAppPermission>();
for (BortalApplicationWrapper appWrap : rolePermissions) {
for (ApplicationPermissionWrapper apWrap : appWrap.getPermissions()) {
if (apWrap.isCanHas()) {
newPerms.add(apWrap.getPermission());
}
}
}
setRole(rolebean.setPermissions(getRole(), newPerms));
this.addFaceMessage("role.permissionsSaved");
} else {
this.addFaceMessage("global.notAuthorizedExecute");
}
return null;
}
public Role getRole() {
......@@ -111,4 +156,18 @@ public class RoleView extends GenericCDIView {
return roleid;
}
public void setRolePermissions(ArrayList<BortalApplicationWrapper> rolePermissions) {
this.rolePermissions = rolePermissions;
}
public ArrayList<BortalApplicationWrapper> getRolePermissions() {
return rolePermissions;
}
public void setRole(Role role) {
this.role = role;
initPermissions();
}
}
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.cdiview.IPaginationView;
import fi.insomnia.bortal.web.cdiview.PaginationView;
@Named
@RequestScoped
public class UserSearchView extends PaginationView<User> implements IPaginationView {
/**
*
*/
private static final long serialVersionUID = -7131921062890234604L;
// private int page;
// private int pagesize = 20;
// private long resultcount;
// private long pagecount;
// private String sort;
// private String search;
@EJB
private UserBeanLocal userbean;
// private ListDataModel<User> users;
@Override
public void initView() {
if (requirePermissions(permbean.hasPermission(UserPermission.VIEW_ALL))) {
super.setResult(userbean.getUsers(page, pagesize, sort, search));
// resultcount = userbean.getUsersCount(search);
// pagecount = ((resultcount + pagesize - 1) / pagesize);
}
}
// @Override
// public String newSearch() {
// page = 0;
// return null;
// }
//
// @Override
// public int getPage() {
// return page;
// }
//
// @Override
// public void setPage(int page) {
// this.page = page;
// }
//
// @Override
// public int getPagesize() {
// return pagesize;
// }
//
// @Override
// public void setPagesize(int pagesize) {
// this.pagesize = pagesize;
// }
//
// @Override
// public long getResultcount() {
// return resultcount;
// }
//
// @Override
// public void setResultcount(long resultcount) {
// this.resultcount = resultcount;
// }
//
// @Override
// public String getSort() {
// return sort;
// }
//
// @Override
// public void setSort(String sort) {
// this.sort = sort;
// }
//
// @Override
// public String getSearch() {
// return search;
// }
//
// @Override
// public void setSearch(String search) {
// this.search = search;
// }
//
// public ListDataModel<User> getUsers() {
// return users;
// }
//
// public void setUsers(ListDataModel<User> users) {
// this.users = users;
// }
//
// @Override
// public void setPagecount(long pagecount) {
// this.pagecount = pagecount;
// }
//
// @Override
// public long getPagecount() {
// return pagecount;
// }
}
package fi.insomnia.bortal.web.cdiview.user;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.utilities.I18n;
@Named
@RequestScoped
public class UserValidator implements Serializable {
private String firstpwd;
/**
*
*/
private static final long serialVersionUID = 8081093389856720678L;
private static final Integer PASSWORD_MIN_LENGTH = 8;
@EJB
private UserBeanLocal userbean;
private static final Logger logger = LoggerFactory.getLogger(UserValidator.class);
public void login(FacesContext context, UIComponent ui, Object object) {
String login = object.toString().trim();
if (login.length() < 3) {
message("userview.loginstringFaulty");
} else if (userbean.getUser(login) != null) {
message("userview.userExists");
}
}
public void password(FacesContext context, UIComponent ui, Object object) {
logger.info("Executing pwd, firstpwd {}", firstpwd);
if (object == null) {
message("user.passwordlengthMessage");
return;
}
if (firstpwd == null) {
firstpwd = object.toString();
if (PASSWORD_MIN_LENGTH.compareTo(firstpwd.length()) > 0) {
message("userview.passwordTooShort", PASSWORD_MIN_LENGTH);
}
logger.info("Setting firstpwd to {} as {}", firstpwd, object.getClass());
return;
}
logger.info("Checking length");
if (!firstpwd.equals(object)) {
message("userview.passwordsDontMatch");
}
logger.info("Done pwd");
}
private void message(String msg, Object... obj) {
message(new FacesMessage(I18n.get(msg, obj)));
}
private void message(FacesMessage msg) {
throw new ValidatorException(msg);
}
}
package fi.insomnia.bortal.web.cdiview;
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -10,10 +10,11 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.FixPerm;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.LoggedIn;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named("userView")
@ConversationScoped
......@@ -30,7 +31,9 @@ public class UserView extends GenericCDIView {
private User user;
private boolean canSave;
private boolean canSave = false;
private String password;
private String passwordcheck;
@Produces
@LoggedIn
......@@ -42,7 +45,7 @@ public class UserView extends GenericCDIView {
@SelectedUser
public User getSelectedUser() {
if (user == null) {
if (userid > 0 && permbean.hasPermission(FixPerm.FIX)) {
if (userid > 0 && permbean.hasPermission(UserPermission.VIEW_ALL)) {
user = userbean.findById(userid);
} else {
user = getCurrentUser();
......@@ -52,10 +55,8 @@ public class UserView extends GenericCDIView {
}
public void initCreateView() {
if (super.requirePermissions(permbean.hasPermission(FixPerm.FIX))) {
if (user == null) {
if (super.requirePermissions(permbean.hasPermission(UserPermission.CREATE_NEW))) {
user = new User();
}
super.beginConversation();
}
}
......@@ -66,22 +67,23 @@ public class UserView extends GenericCDIView {
* Require logged in user AND userid is own userid OR has enought bits.
* permissions.
*/
if (super.requirePermissions(permbean.isLoggedIn())) {
if (super.requirePermissions(UserPermission.VIEW_SELF)) {
getSelectedUser();
canSave = getCurrentUser().equals(user) || permbean.hasPermission(FixPerm.FIX);
canSave = getCurrentUser().equals(user) || permbean.hasPermission(UserPermission.MODIFY);
this.beginConversation();
}
}
public String saveUser() {
if (permbean.getCurrentUser().getId().equals(userid) || permbean.hasPermission(FixPerm.FIX)) {
this.addFaceMessage("user.saveSuccessfull");
if (permbean.getCurrentUser().equals(user) || permbean.hasPermission(UserPermission.MODIFY)) {
this.addFaceMessage("user.successfullySaved");
try {
user = userbean.mergeChanges(user);
} catch (PermissionDeniedException e) {
logger.warn("Permission denied", e);
this.requirePermissions(false);
}
} else {
this.addFaceMessage("user.saveFailed");
}
......@@ -89,6 +91,11 @@ public class UserView extends GenericCDIView {
return "edit";
}
public String createUser() {
userbean.createNewUser(user, getPassword());
return "/user/created";
}
public void setUserid(int userid) {
this.userid = userid;
}
......@@ -108,4 +115,20 @@ public class UserView extends GenericCDIView {
public boolean canSave() {
return canSave;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setPasswordcheck(String passwordcheck) {
this.passwordcheck = passwordcheck;
}
public String getPasswordcheck() {
return passwordcheck;
}
}
package fi.insomnia.bortal.web.helper;
import java.util.Map;
import java.util.Map.Entry;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.enterprise.context.RequestScoped;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Named
@RequestScoped
public class LayoutView {
@Inject
private FacesContext context;
private ResourceBundle rb;
private String pagename;
private static final Logger logger = LoggerFactory.getLogger(LayoutView.class);
public void init() {
logger.info("Initialized layoutView");
}
private String localize(String key) {
String value = null;
try {
value = getResourcebundle().getString(key);
} catch (MissingResourceException e) {
value = null;
}
if (key == null) {
value = "########";
} else if (value == null) {
value = "???" + key + "???";
}
return value;
}
private ResourceBundle getResourcebundle() {
if (rb == null) {
rb = context.getApplication().getResourceBundle(context, "i18n");
}
return rb;
}
public String getHeader(String page) {
this.pagename = page;
return new StringBuilder().append(localize("global.eventname")).append(" - ")
.append(localize(new StringBuilder(page).append(".header").toString())).toString();
}
public String header() {
logger.info("Context {}", context);
UIViewRoot root = context.getViewRoot();
Map<String, Object> viewmap = root.getViewMap(false);
if (viewmap != null) {
for (Entry<String, Object> entry : viewmap.entrySet()) {
logger.info("Got entry {}: {}", entry.getKey(), entry.getValue());
}
}
logger.info("Attrmap");
if (context.getAttributes() != null) {
for (Entry<Object, Object> e : context.getAttributes().entrySet()) {
logger.info("Got attr {}: {}", e.getKey(), e.getValue());
}
}
return "";
}
}
package fi.insomnia.bortal.web.helpers;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.IAppPermission;
public class ApplicationPermissionWrapper implements Serializable {
/**
*
*/
private static final long serialVersionUID = 335937780506254218L;
private final IAppPermission permission;
private boolean canHas = false;
private static final Logger logger = LoggerFactory.getLogger(ApplicationPermissionWrapper.class);
public ApplicationPermissionWrapper(IAppPermission ap, boolean canHasPerm) {
permission = ap;
logger.info("Seting canHas for {}: {}", ap, canHasPerm);
this.canHas = canHasPerm;
}
public String getName() {
return permission.toString();
}
public String getDescription() {
return permission.getDescription();
}
public void setCanHas(boolean canHas) {
this.canHas = canHas;
}
public boolean isCanHas() {
return canHas;
}
public IAppPermission getPermission() {
return permission;
}
}
package fi.insomnia.bortal.web.helpers;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.BortalApplication;
import fi.insomnia.bortal.enums.apps.IAppPermission;
public class BortalApplicationWrapper implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5552828911388714876L;
private final ArrayList<ApplicationPermissionWrapper> permissions;
private final BortalApplication app;
private static final Logger logger = LoggerFactory.getLogger(BortalApplicationWrapper.class);
public BortalApplicationWrapper(BortalApplication bApp, Set<IAppPermission> set) {
app = bApp;
permissions = new ArrayList<ApplicationPermissionWrapper>();
for (IAppPermission ap : bApp.getPermissions()) {
if (set != null) {
logger.info("App Match {}, {}", ap, set.contains(ap));
}
permissions.add(new ApplicationPermissionWrapper(ap, set != null && set.contains(ap)));
}
}
public String getName() {
return app.toString();
}
public String getDescription() {
return app.getDescription();
}
public List<ApplicationPermissionWrapper> getPermissions() {
return permissions;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!