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