Commit 705f45f5 by Juho Juopperi

Merge branch 'randomFixes' into 'master'

Random fixes and code cleanup

See merge request !302
2 parents 3139ac65 ab400bf1
...@@ -22,9 +22,9 @@ import java.util.List; ...@@ -22,9 +22,9 @@ import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.util.CheckoutBank; import fi.codecrew.moya.util.CheckoutBank;
import fi.codecrew.moya.util.CheckoutReturnType; import fi.codecrew.moya.util.CheckoutReturnType;
import fi.codecrew.moya.model.Bill;
@Local @Local
public interface CheckoutFiBeanLocal { public interface CheckoutFiBeanLocal {
...@@ -37,4 +37,6 @@ public interface CheckoutFiBeanLocal { ...@@ -37,4 +37,6 @@ public interface CheckoutFiBeanLocal {
boolean validateReturn(CheckoutReturnType returnType, String version, String stamp, String reference, String payment, String status, String algorithm, String mac); boolean validateReturn(CheckoutReturnType returnType, String version, String stamp, String reference, String payment, String status, String algorithm, String mac);
boolean isBillPaid(Bill bill);
} }
...@@ -110,6 +110,9 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -110,6 +110,9 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
* query. * query.
* *
*/ */
@Override
@RolesAllowed(BillPermission.S_READ_ALL)
public boolean isBillPaid(Bill bill) { public boolean isBillPaid(Bill bill) {
QueryBuilder cb = initQuerybuilder(CheckoutFiCheckParam.values()); QueryBuilder cb = initQuerybuilder(CheckoutFiCheckParam.values());
...@@ -162,8 +165,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -162,8 +165,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
} }
@Override @Override
public boolean isPaymentEnabled() public boolean isPaymentEnabled() {
{
final LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE); final LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE);
final String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID); final String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID);
final String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD); final String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD);
...@@ -191,8 +193,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -191,8 +193,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
@Override @Override
@RolesAllowed(BillPermission.S_CREATE_VERKKOMAKSU) @RolesAllowed(BillPermission.S_CREATE_VERKKOMAKSU)
public List<CheckoutBank> getToken(Bill bill) public List<CheckoutBank> getToken(Bill bill) {
{
if (bill.isFoowavePaymentOver()) { if (bill.isFoowavePaymentOver()) {
return null; return null;
} }
...@@ -338,8 +339,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -338,8 +339,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
boolean ret = false; boolean ret = false;
String[] splittedStamp = stamp.split(STAMP_SPLITCHAR); String[] splittedStamp = stamp.split(STAMP_SPLITCHAR);
if (splittedStamp.length != 2) if (splittedStamp.length != 2) {
{
logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Unable to split stamp '", stamp, "' with splitchar ", STAMP_SPLITCHAR); logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Unable to split stamp '", stamp, "' with splitchar ", STAMP_SPLITCHAR);
return false; return false;
} }
...@@ -348,10 +348,8 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -348,10 +348,8 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
String calculatedMac = PasswordFunctions.calculateMd5("&", merchantPass, version, stamp, reference, payment, status, algorithm); String calculatedMac = PasswordFunctions.calculateMd5("&", merchantPass, version, stamp, reference, payment, status, algorithm);
if (calculatedMac.equals(mac.toUpperCase())) { if (calculatedMac.equals(mac.toUpperCase())) {
Bill bill = billfacade.find(Integer.parseInt(splittedStamp[0])); Bill bill = billfacade.find(Integer.parseInt(splittedStamp[0]));
if (bill != null) if (bill != null) {
{ switch (returnType) {
switch (returnType)
{
case CANCEL: case CANCEL:
logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "received cancel for stamp ", stamp); logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "received cancel for stamp ", stamp);
// Return true when checksum was correct // Return true when checksum was correct
...@@ -399,8 +397,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -399,8 +397,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Valid mac, but Invalid return type: ", returnType, " for stamp ", stamp, " payment ", payment, " status ", status); logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Valid mac, but Invalid return type: ", returnType, " for stamp ", stamp, " payment ", payment, " status ", status);
throw new EJBException("Unknown return type!"); throw new EJBException("Unknown return type!");
} }
} } else {
else {
logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Validated mac, but bill not found for id: ", splittedStamp[0], " stamp ", stamp, " mac: ", mac); logbean.sendMessage(MoyaEventType.BANKING_ERROR, permbean.getCurrentUser(), "Validated mac, but bill not found for id: ", splittedStamp[0], " stamp ", stamp, " mac: ", mac);
} }
} else { } else {
......
...@@ -48,15 +48,14 @@ import javax.imageio.ImageIO; ...@@ -48,15 +48,14 @@ import javax.imageio.ImageIO;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import fi.codecrew.moya.entitysearch.UserSearchQuery;
import fi.codecrew.moya.enums.apps.MapPermission;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.entitysearch.UserSearchQuery;
import fi.codecrew.moya.enums.CardState; import fi.codecrew.moya.enums.CardState;
import fi.codecrew.moya.enums.apps.EventPermission; import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission; import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.AccountEventFacade; import fi.codecrew.moya.facade.AccountEventFacade;
...@@ -231,8 +230,7 @@ public class UserBean implements UserBeanLocal { ...@@ -231,8 +230,7 @@ public class UserBean implements UserBeanLocal {
Set<Role> checkedRoles = new HashSet<Role>(); Set<Role> checkedRoles = new HashSet<Role>();
if (u != null) if (u != null) {
{
addRecursive(checkedRoles, rolefacade.findForUser(u)); addRecursive(checkedRoles, rolefacade.findForUser(u));
addRecursive(checkedRoles, orgRoleFacade.findRolesForUser(u)); addRecursive(checkedRoles, orgRoleFacade.findRolesForUser(u));
if (permbean.isLoggedIn()) { if (permbean.isLoggedIn()) {
...@@ -246,11 +244,9 @@ public class UserBean implements UserBeanLocal { ...@@ -246,11 +244,9 @@ public class UserBean implements UserBeanLocal {
addRecursive(checkedRoles, productbean.getRolesFromAccountEvents(u)); addRecursive(checkedRoles, productbean.getRolesFromAccountEvents(u));
for (GroupMembership member : gmfacade.findMemberships(u)) { for (GroupMembership member : gmfacade.findMemberships(u)) {
if (member != null && member.getPlaceReservation() != null) if (member != null && member.getPlaceReservation() != null) {
{
addRecursive(checkedRoles, member.getPlaceReservation().getProvidesRole()); addRecursive(checkedRoles, member.getPlaceReservation().getProvidesRole());
if (member.getPlaceReservation().getProduct() != null) if (member.getPlaceReservation().getProduct() != null) {
{
addRecursive(checkedRoles, member.getPlaceReservation().getProduct().getProvides()); addRecursive(checkedRoles, member.getPlaceReservation().getProduct().getProvides());
} }
} }
...@@ -398,8 +394,7 @@ public class UserBean implements UserBeanLocal { ...@@ -398,8 +394,7 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public UserImage findUserimageFORCE(Integer id) public UserImage findUserimageFORCE(Integer id) {
{
return userimagefacade.find(id); return userimagefacade.find(id);
} }
...@@ -493,8 +488,7 @@ public class UserBean implements UserBeanLocal { ...@@ -493,8 +488,7 @@ public class UserBean implements UserBeanLocal {
return initPasswordReset(users.get(0), url); return initPasswordReset(users.get(0), url);
} }
private boolean initPasswordReset(User user, String url) private boolean initPasswordReset(User user, String url) {
{
String hash = PasswordFunctions.generateRandomString(25); String hash = PasswordFunctions.generateRandomString(25);
logger.info("Initializing password sending: {}, hash: {}", user, hash); logger.info("Initializing password sending: {}, hash: {}", user, hash);
...@@ -729,8 +723,7 @@ public class UserBean implements UserBeanLocal { ...@@ -729,8 +723,7 @@ public class UserBean implements UserBeanLocal {
ret.setDescription("Cropped by: [" + curruser.getId() + "] " + curruser.getWholeName() + " from image: " + currimage.getId()); ret.setDescription("Cropped by: [" + curruser.getId() + "] " + curruser.getWholeName() + " from image: " + currimage.getId());
ret.setImageData(naamaout.toByteArray()); ret.setImageData(naamaout.toByteArray());
// ret.setMimeType("image/jpeg"); // ret.setMimeType("image/jpeg");
if (user.getUserImageList() == null) if (user.getUserImageList() == null) {
{
user.setUserImageList(new ArrayList<UserImage>()); user.setUserImageList(new ArrayList<UserImage>());
} }
user.getUserImageList().add(ret); user.getUserImageList().add(ret);
...@@ -826,8 +819,7 @@ public class UserBean implements UserBeanLocal { ...@@ -826,8 +819,7 @@ public class UserBean implements UserBeanLocal {
EventUser ret = eventUserFacade.find(user); EventUser ret = eventUserFacade.find(user);
if (create && ret == null) if (create && ret == null) {
{
ret = new EventUser(user, eventBean.getCurrentEvent(), permbean.getCurrentUser()); ret = new EventUser(user, eventBean.getCurrentEvent(), permbean.getCurrentUser());
eventUserFacade.create(ret); eventUserFacade.create(ret);
eventUserFacade.flush(); eventUserFacade.flush();
...@@ -850,16 +842,14 @@ public class UserBean implements UserBeanLocal { ...@@ -850,16 +842,14 @@ public class UserBean implements UserBeanLocal {
private EventUser validateUser(String username, String password, boolean createEventUser) { private EventUser validateUser(String username, String password, boolean createEventUser) {
User user = userFacade.findByLogin(username); User user = userFacade.findByLogin(username);
EventUser ret = null; EventUser ret = null;
if (user != null && user.checkPassword(password)) if (user != null && user.checkPassword(password)) {
{
ret = this.getEventUser(user, createEventUser); ret = this.getEventUser(user, createEventUser);
} }
return ret; return ret;
} }
@Override @Override
public EventUser validateUser(String username, String password) public EventUser validateUser(String username, String password) {
{
return validateUser(username, password, false); return validateUser(username, password, false);
} }
...@@ -975,8 +965,7 @@ public class UserBean implements UserBeanLocal { ...@@ -975,8 +965,7 @@ public class UserBean implements UserBeanLocal {
@Override @Override
@RolesAllowed(EventPermission.S_MANAGE_EVENT) @RolesAllowed(EventPermission.S_MANAGE_EVENT)
public BigDecimal transferAccountSaldoFromPreviousEvent(List<User> users, LanEvent source) public BigDecimal transferAccountSaldoFromPreviousEvent(List<User> users, LanEvent source) {
{
if (source == null || users == null || users.isEmpty()) if (source == null || users == null || users.isEmpty())
return null; return null;
...@@ -998,8 +987,7 @@ public class UserBean implements UserBeanLocal { ...@@ -998,8 +987,7 @@ public class UserBean implements UserBeanLocal {
BigDecimal dstTotal = BigDecimal.ZERO; BigDecimal dstTotal = BigDecimal.ZERO;
for (User user : users) for (User user : users) {
{
EventUser dstUser = eventUserFacade.find(user); EventUser dstUser = eventUserFacade.find(user);
EventUser srcUser = eventUserFacade.getOtherOrganisationsEventuser(dstUser.getUser(), source); EventUser srcUser = eventUserFacade.getOtherOrganisationsEventuser(dstUser.getUser(), source);
...@@ -1064,8 +1052,7 @@ public class UserBean implements UserBeanLocal { ...@@ -1064,8 +1052,7 @@ public class UserBean implements UserBeanLocal {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (hex.length() < 5) { if (hex.length() < 5) {
hex = "X" + hex; hex = "X" + hex;
} } else
else
break; break;
} }
} else } else
...@@ -1146,7 +1133,7 @@ public class UserBean implements UserBeanLocal { ...@@ -1146,7 +1133,7 @@ public class UserBean implements UserBeanLocal {
if (eventUser != null) { if (eventUser != null) {
Integer eventId = eventUser.getEvent().getId(); Integer eventId = eventUser.getEvent().getId();
Integer currentEventId = eventBean.getCurrentEvent().getId(); Integer currentEventId = eventBean.getCurrentEvent().getId();
if (eventId != currentEventId) { if (!eventUser.getEvent().equals(eventBean.getCurrentEvent())) {
throw new IllegalStateException("Looked up code " + code + " and got EventUser " + eventUser.getId() + " from event " + eventId + " which is not the current event " + currentEventId); throw new IllegalStateException("Looked up code " + code + " and got EventUser " + eventUser.getId() + " from event " + eventId + " which is not the current event " + currentEventId);
} }
} }
......
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
\ No newline at end of file
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
\ No newline at end of file
...@@ -23,14 +23,11 @@ ...@@ -23,14 +23,11 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
...@@ -54,12 +51,12 @@ public class CardTemplate extends GenericEntity { ...@@ -54,12 +51,12 @@ public class CardTemplate extends GenericEntity {
@Column(name = "power", nullable = false) @Column(name = "power", nullable = false)
private int power = 0; private int power = 0;
//
@OneToMany(mappedBy = "cardTemplate") // @OneToMany(mappedBy = "cardTemplate")
private List<Role> roles; // private List<Role> roles;
//
@OneToMany(mappedBy = "template") // @OneToMany(mappedBy = "template")
private List<PrintedCard> cards; // private List<PrintedCard> cards;
public CardTemplate() { public CardTemplate() {
super(); super();
...@@ -90,22 +87,22 @@ public class CardTemplate extends GenericEntity { ...@@ -90,22 +87,22 @@ public class CardTemplate extends GenericEntity {
public void setName(String templateName) { public void setName(String templateName) {
this.name = templateName; this.name = templateName;
} }
//
public List<Role> getRoles() { // public List<Role> getRoles() {
return roles; // return roles;
} // }
//
public void setRoles(List<Role> roleList) { // public void setRoles(List<Role> roleList) {
this.roles = roleList; // this.roles = roleList;
} // }
//
public void setCards(List<PrintedCard> cards) { // public void setCards(List<PrintedCard> cards) {
this.cards = cards; // this.cards = cards;
} // }
//
public List<PrintedCard> getCards() { // public List<PrintedCard> getCards() {
return cards; // return cards;
} // }
public LanEvent getEvent() { public LanEvent getEvent() {
return event; return event;
......
...@@ -50,7 +50,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -50,7 +50,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@Entity @Entity
@Table(name = "lectures") @Table(name = "lectures")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Lecture extends GenericEntity { public class Lecture extends GenericEntity implements Cloneable {
private static final long serialVersionUID = 3L; private static final long serialVersionUID = 3L;
...@@ -66,15 +66,11 @@ public class Lecture extends GenericEntity { ...@@ -66,15 +66,11 @@ public class Lecture extends GenericEntity {
private LectureGroup lectureGroup; private LectureGroup lectureGroup;
@ManyToMany() @ManyToMany()
@JoinTable(name = "lecture_participants", @JoinTable(name = "lecture_participants", joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) }, inverseJoinColumns = { @JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN) })
joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN) })
private List<EventUser> participants; private List<EventUser> participants;
@ManyToMany() @ManyToMany()
@JoinTable(name = "lecture_roles", @JoinTable(name = "lecture_roles", joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) }, inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = Role.ID_COLUMN) })
joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = Role.ID_COLUMN) })
private List<Role> openForRoles; private List<Role> openForRoles;
@Column(name = "max_participants_count") @Column(name = "max_participants_count")
...@@ -208,7 +204,7 @@ public class Lecture extends GenericEntity { ...@@ -208,7 +204,7 @@ public class Lecture extends GenericEntity {
newLecture.setName(getName()); newLecture.setName(getName());
newLecture.setHours(getHours()); newLecture.setHours(getHours());
newLecture.setMaxParticipantsCount(getMaxParticipantsCount()); newLecture.setMaxParticipantsCount(getMaxParticipantsCount());
newLecture.setStartTime( (Date) getStartTime().clone()); newLecture.setStartTime((Date) getStartTime().clone());
newLecture.setOpenForRoles(new ArrayList<Role>(getOpenForRoles())); newLecture.setOpenForRoles(new ArrayList<Role>(getOpenForRoles()));
return newLecture; return newLecture;
......
...@@ -5,9 +5,6 @@ import java.util.Comparator; ...@@ -5,9 +5,6 @@ import java.util.Comparator;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NumericStringComparator implements Comparator<String> { public class NumericStringComparator implements Comparator<String> {
// \D non numeric // \D non numeric
...@@ -18,7 +15,6 @@ public class NumericStringComparator implements Comparator<String> { ...@@ -18,7 +15,6 @@ public class NumericStringComparator implements Comparator<String> {
Matcher m1 = NUMERIC_COMPARE_PATTERN.matcher(o1); Matcher m1 = NUMERIC_COMPARE_PATTERN.matcher(o1);
Matcher m2 = NUMERIC_COMPARE_PATTERN.matcher(o2); Matcher m2 = NUMERIC_COMPARE_PATTERN.matcher(o2);
Integer.compare(1, 2);
// Match fails only in end of either string // Match fails only in end of either string
while (m1.find() && m2.find()) { while (m1.find() && m2.find()) {
......
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
<f:selectItems value="#{eventorgView.event.organiser.events}" var="e" itemLabel="#{e.name}" /> <f:selectItems value="#{eventorgView.event.organiser.events}" var="e" itemLabel="#{e.name}" />
</p:selectOneMenu> </p:selectOneMenu>
<h:commandButton action="#{eventorgView.copySiteContent}"/> <h:commandButton action="#{eventorgView.copySiteContent}" value="#{i18n['event.copySiteContent']}" />
</h:form> </h:form>
</p:fieldset> </p:fieldset>
......
...@@ -18,19 +18,16 @@ ...@@ -18,19 +18,16 @@
*/ */
package fi.codecrew.moya.rest; package fi.codecrew.moya.rest;
import com.wordnik.swagger.config.ScannerFactory; import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import com.wordnik.swagger.jaxrs.config.BeanConfig; import com.wordnik.swagger.jaxrs.config.BeanConfig;
import com.wordnik.swagger.jaxrs.config.ReflectiveJaxrsScanner;
import com.wordnik.swagger.jaxrs.reader.DefaultJaxrsApiReader;
import com.wordnik.swagger.jersey.JerseyApiReader;
import com.wordnik.swagger.jersey.listing.ApiListingResourceJSON; import com.wordnik.swagger.jersey.listing.ApiListingResourceJSON;
import com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider; import com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider;
import com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider; import com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider;
import com.wordnik.swagger.reader.ClassReaders;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.ApplicationPath;
@ApplicationPath(RestApplicationEntrypoint.REST_PATH) @ApplicationPath(RestApplicationEntrypoint.REST_PATH)
public class RestApplicationEntrypoint extends ResourceConfig { public class RestApplicationEntrypoint extends ResourceConfig {
...@@ -64,6 +61,7 @@ public class RestApplicationEntrypoint extends ResourceConfig { ...@@ -64,6 +61,7 @@ public class RestApplicationEntrypoint extends ResourceConfig {
// packages to scan // packages to scan
packages("com.wordnik.swagger.jaxrs.json", "fi.codecrew.moya.rest"); packages("com.wordnik.swagger.jaxrs.json", "fi.codecrew.moya.rest");
registerInstances(new LoggingFilter());
} }
} }
...@@ -27,7 +27,6 @@ import java.util.Map; ...@@ -27,7 +27,6 @@ import java.util.Map;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
...@@ -46,7 +45,6 @@ import fi.codecrew.moya.model.LanEventProperty; ...@@ -46,7 +45,6 @@ import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ReaderEvent; import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView; import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
...@@ -73,8 +71,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -73,8 +71,7 @@ public class ProductShopView extends GenericCDIView {
@EJB @EJB
private transient EventBeanLocal eventbean; private transient EventBeanLocal eventbean;
public void cashChanged() public void cashChanged() {
{
payInstant = false; payInstant = false;
} }
...@@ -112,8 +109,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -112,8 +109,7 @@ public class ProductShopView extends GenericCDIView {
private boolean allowStatistics = true; private boolean allowStatistics = true;
private String otherInfo; private String otherInfo;
public String buyByCredit() public String buyByCredit() {
{
cash = BigDecimal.ZERO; cash = BigDecimal.ZERO;
payInstant = false; payInstant = false;
return null; return null;
...@@ -123,7 +119,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -123,7 +119,7 @@ public class ProductShopView extends GenericCDIView {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) && shoppingcart == null) { if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) && shoppingcart == null) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts(), userView.getSelectedUser())); shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts(), userView.getSelectedUser()));
for(ProductShopItem item : shoppingcart) { for (ProductShopItem item : shoppingcart) {
psiHelper.updateProductShopItemCount(item); psiHelper.updateProductShopItemCount(item);
} }
...@@ -136,10 +132,8 @@ public class ProductShopView extends GenericCDIView { ...@@ -136,10 +132,8 @@ public class ProductShopView extends GenericCDIView {
private Boolean checkAllowStats; private Boolean checkAllowStats;
public boolean isCheckAllowStats() public boolean isCheckAllowStats() {
{ if (checkAllowStats == null) {
if (checkAllowStats == null)
{
LanEventProperty re = eventbean.getProperty(LanEventPropertyKey.CHECK_BILL_STATS_PERMISSION); LanEventProperty re = eventbean.getProperty(LanEventPropertyKey.CHECK_BILL_STATS_PERMISSION);
if (re != null) { if (re != null) {
checkAllowStats = re.isBooleanValue(); checkAllowStats = re.isBooleanValue();
...@@ -152,10 +146,8 @@ public class ProductShopView extends GenericCDIView { ...@@ -152,10 +146,8 @@ public class ProductShopView extends GenericCDIView {
private Boolean gatherBillInfo; private Boolean gatherBillInfo;
public boolean isGatherBillInfo() public boolean isGatherBillInfo() {
{ if (gatherBillInfo == null) {
if (gatherBillInfo == null)
{
LanEventProperty re = eventbean.getProperty(LanEventPropertyKey.GATHER_OTHER_BILL_INFO); LanEventProperty re = eventbean.getProperty(LanEventPropertyKey.GATHER_OTHER_BILL_INFO);
if (re != null) { if (re != null) {
gatherBillInfo = re.isBooleanValue(); gatherBillInfo = re.isBooleanValue();
...@@ -181,16 +173,13 @@ public class ProductShopView extends GenericCDIView { ...@@ -181,16 +173,13 @@ public class ProductShopView extends GenericCDIView {
} }
} }
public void countBoughtChangeListener() {
public void countBoughtChangeListener()
{
ProductShopItem item = boughtItems.getRowData(); ProductShopItem item = boughtItems.getRowData();
psiHelper.setProductShopItemCount(item, item.getCount()); psiHelper.setProductShopItemCount(item, item.getCount());
updateCartLimits(item); updateCartLimits(item);
} }
public void countChangeListener() public void countChangeListener() {
{
ProductShopItem item = shoppingcart.getRowData(); ProductShopItem item = shoppingcart.getRowData();
psiHelper.setProductShopItemCount(item, item.getCount()); psiHelper.setProductShopItemCount(item, item.getCount());
updateCartLimits(item); updateCartLimits(item);
...@@ -286,11 +275,9 @@ public class ProductShopView extends GenericCDIView { ...@@ -286,11 +275,9 @@ public class ProductShopView extends GenericCDIView {
updateCartLimits(null); updateCartLimits(null);
} }
public BigDecimal getTransactionTotal() public BigDecimal getTransactionTotal() {
{
BigDecimal ret = getCartPrice().subtract(getAccountCredits()); BigDecimal ret = getCartPrice().subtract(getAccountCredits());
if (BigDecimal.ZERO.compareTo(ret) > 0) if (BigDecimal.ZERO.compareTo(ret) > 0) {
{
ret = BigDecimal.ZERO; ret = BigDecimal.ZERO;
} }
return ret; return ret;
...@@ -320,6 +307,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -320,6 +307,7 @@ public class ProductShopView extends GenericCDIView {
} }
public String commitBillCart() { public String commitBillCart() {
updateAllCartLimits();
logger.debug("Committing billCart"); logger.debug("Committing billCart");
...@@ -338,8 +326,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -338,8 +326,7 @@ public class ProductShopView extends GenericCDIView {
} }
} }
billbean.createBill(bill); billbean.createBill(bill);
if (isCheckAllowStats()) if (isCheckAllowStats()) {
{
userbean.setUserApproval(bill.getUser(), "bill_allow_stats", allowStatistics, "Automagically created"); userbean.setUserApproval(bill.getUser(), "bill_allow_stats", allowStatistics, "Automagically created");
} }
billEditView.setBill(bill); billEditView.setBill(bill);
...@@ -488,8 +475,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -488,8 +475,7 @@ public class ProductShopView extends GenericCDIView {
// the product count // the product count
int n = 0; int n = 0;
for (ProductShopItem a : shoppingcart) { for (ProductShopItem a : shoppingcart) {
if (a.getProduct().equals(product)) if (a.getProduct().equals(product)) {
{
// a.setCount(a.getCount().add(BigDecimal.ONE)); // a.setCount(a.getCount().add(BigDecimal.ONE));
// updateCartLimits(null); // updateCartLimits(null);
shoppingcart.setRowIndex(n); shoppingcart.setRowIndex(n);
......
...@@ -34,8 +34,6 @@ import org.slf4j.LoggerFactory; ...@@ -34,8 +34,6 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.CardTemplateBeanLocal; import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.enums.CardTemplateDataType; import fi.codecrew.moya.enums.CardTemplateDataType;
import fi.codecrew.moya.enums.CardTextAlignment;
import fi.codecrew.moya.enums.CardTextDataType;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.CardObjectData; import fi.codecrew.moya.model.CardObjectData;
import fi.codecrew.moya.model.CardTemplate; import fi.codecrew.moya.model.CardTemplate;
...@@ -87,7 +85,7 @@ public class CardView extends GenericCDIView { ...@@ -87,7 +85,7 @@ public class CardView extends GenericCDIView {
setCardTemplate(new CardTemplate(eventBean.getCurrentEvent())); setCardTemplate(new CardTemplate(eventBean.getCurrentEvent()));
cardTemplate.setPower(clonedTemplate.getPower()); cardTemplate.setPower(clonedTemplate.getPower());
cardTemplate.setImage(clonedTemplate.getImage()); cardTemplate.setImage(clonedTemplate.getImage());
cardTemplate.setRoles(clonedTemplate.getRoles()); //cardTemplate.setRoles(clonedTemplate.getRoles());
super.beginConversation(); super.beginConversation();
} }
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<slf4j.version>1.7.12</slf4j.version> <slf4j.version>1.7.12</slf4j.version>
<logback.version>1.1.3</logback.version> <logback.version>1.1.3</logback.version>
<testng.version>6.8.21</testng.version> <testng.version>6.8.21</testng.version>
<javamelody.version>1.55.0</javamelody.version> <javamelody.version>1.58.0</javamelody.version>
<primefaces.version>5.2</primefaces.version> <primefaces.version>5.2</primefaces.version>
<primefaces.themeversion>1.0.10</primefaces.themeversion> <primefaces.themeversion>1.0.10</primefaces.themeversion>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!