Commit 344933a5 by Tuomas Riihimäki

Event property editor

1 parent a515e62b
Showing with 492 additions and 36 deletions
......@@ -9,6 +9,7 @@ import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.EJBAccessException;
import javax.ejb.EJBException;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
......@@ -198,6 +199,11 @@ public class BillBean implements BillBeanLocal {
@RolesAllowed(BillPermission.S_WRITE_ALL)
public void markPaid(Bill bill, Calendar when) {
if (bill.getAccountEvent() != null || bill.getPaidDate() != null)
{
throw new EJBException("Bill already marked paid!");
}
Product creditproduct = productBean.findCreditProduct();
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), bill.getUser());
......
package fi.insomnia.bortal.beans;
import java.util.ArrayList;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
......@@ -157,4 +159,30 @@ public class EventBean implements EventBeanLocal {
}
return ret;
}
@Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, SpecialPermission.S_ORGANISATION_ADMIN })
public LanEventProperty saveOrCreateProperty(LanEventProperty property) {
LanEventProperty ret = null;
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { property.getEvent(), property.getEventorg(), property.getKey() });
if (property.getId() == null)
{
ret = property;
// eventPropertyFacade.create(property);
LanEvent event = eventFacade.reload(property.getEvent());
if (event.getProperties() == null)
{
event.setProperties(new ArrayList<LanEventProperty>());
}
event.getProperties().add(property);
}
else
{
ret = eventPropertyFacade.merge(property);
}
return ret;
}
}
......@@ -3,6 +3,7 @@ package fi.insomnia.bortal.beans;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
......@@ -37,13 +38,13 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.sun.xml.bind.StringInputStream;
import fi.insomnia.bortal.beanutil.DecimalXMLAdapter;
import fi.insomnia.bortal.clientutils.BortalLocalContextHolder;
import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.LanEventProperty;
import fi.insomnia.bortal.model.LanEventPropertyKey;
import fi.insomnia.bortal.util.SvmReturnType;
import fi.insomnia.bortal.util.VerkkomaksutReturnEntry;
import fi.insomnia.bortal.verkkomaksutfi.PaymentEntry;
......@@ -78,7 +79,7 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
}
@Override
public boolean validateReturn(String orderNumber, String timestamp, String paid, String method, String authcode)
public boolean validateReturn(SvmReturnType type, String orderNumber, String timestamp, String paid, String method, String authcode)
{
String merchantPassword = lanbean.getPropertyString(LanEventPropertyKey.VERKKOMAKSU_MERCHANT_PASSWORD);
......@@ -95,12 +96,22 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
final String calculatedHash = new String(Hex.encodeHex(resultByte));
logger.info("calculated checksum for svv message: {}, comparing to {}", calculatedHash, authcode);
if (authcode.toUpperCase().equals(calculatedHash.toUpperCase())) {
ret = true;
Bill bill = billBean.findById(Integer.parseInt(orderNumber));
if (bill != null)
{
billBean.markPaid(bill, Calendar.getInstance());
logbean.logMessage(SecurityLogType.verkkomaksu, permbean.getCurrentUser(), "Validated order number ", orderNumber, " bill ", bill == null ? "null" : bill.toString(), " with authcode: ", authcode);
// If bill is unpaid, mark it paid...
if (SvmReturnType.PENDING.equals(type) || paid.equals("0000000000")) {
logbean.logMessage(SecurityLogType.verkkomaksu, permbean.getCurrentUser(), "Received pending message ", orderNumber, " bill ", bill == null ? "null" : bill.toString(), " with authcode: ", authcode);
} else if (bill.getAccountEvent() == null
&& bill.getPaidDate() == null
&& (SvmReturnType.NOTIFICATION.equals(type) || SvmReturnType.SUCCESS.equals(type))) {
billBean.markPaid(bill, Calendar.getInstance());
logbean.logMessage(SecurityLogType.verkkomaksu, permbean.getCurrentUser(), "Validated order number ", orderNumber, " bill ", bill == null ? "null" : bill.toString(), " with authcode: ", authcode);
ret = true;
} else {
logbean.logMessage(SecurityLogType.verkkomaksu, permbean.getCurrentUser(), "Bill already marked paid or other error. ", orderNumber, " bill ", bill == null ? "null" : bill.toString(), " with authcode: ", authcode);
ret = true;
}
} else {
logbean.logMessage(SecurityLogType.verkkomaksu, permbean.getCurrentUser(), "Unable to find bill for order number ", orderNumber);
}
......@@ -133,6 +144,7 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
PaymentEntry message = new PaymentEntry(returnUrl);
message.setOrderNumber(bill.getId().toString());
message.setPrice(bill.totalPrice());
// message.setDescription();
......@@ -151,10 +163,14 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
JAXBContext context = JAXBContext.newInstance(PaymentEntry.class);
Marshaller m = context.createMarshaller();
m.setAdapter(new DecimalXMLAdapter());
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter st = new StringWriter();
m.marshal(payment, st);
return st.toString();
String ret = st.toString();
logger.info("Created xml to verkkomaksut {}", ret);
return ret;
}
......@@ -196,15 +212,22 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
}
public static void main(String[] foo) throws SAXException, IOException, ParserConfigurationException
public static void main(String[] foo) throws SAXException, IOException, ParserConfigurationException, JAXBException
{
String msg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<payment><orderNumber>12345678</orderNumber><token>SECRET TOKEN STRING GENRATED BY API</token><url>https://payment.verkkomaksut.fi/payment/load/token/SECRET TOKEN STRING GENRATED BY API</url></payment>";
System.out.println(msg);
StringInputStream istream = new StringInputStream(msg);
VerkkomaksutReturnEntry ret = parseMessageReturn(istream);
logger.info("URL: {}", ret.getUrl());
logger.info("ordernr: {}", ret.getOrderNumber());
logger.info("token: {}", ret.getToken());
// String msg =
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<payment><orderNumber>12345678</orderNumber><token>SECRET TOKEN STRING GENRATED BY API</token><url>https://payment.verkkomaksut.fi/payment/load/token/SECRET TOKEN STRING GENRATED BY API</url></payment>";
// System.out.println(msg);
// StringInputStream istream = new StringInputStream(msg);
// VerkkomaksutReturnEntry ret = parseMessageReturn(istream);
// logger.info("URL: {}", ret.getUrl());
// logger.info("ordernr: {}", ret.getOrderNumber());
// logger.info("token: {}", ret.getToken());
PaymentEntry message = new PaymentEntry("http://localhost:8080/LanBortalWeb/svm/");
message.setOrderNumber("123123");
message.setPrice(BigDecimal.valueOf(123.45));
System.out.println(outputPayment(message));
}
private static VerkkomaksutReturnEntry parseMessageReturn(InputStream inputStream) throws SAXException, IOException, ParserConfigurationException {
......@@ -228,7 +251,7 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
Node child = rootChildren.item(i);
String nodeName = child.getNodeName();
String nodeValue = child.getTextContent();
logger.debug("Setting node {} value {}", nodeName, nodeValue);
if (nodeName.equals("orderNumber")) {
ret.setOrderNumber(nodeValue);
} else if (nodeName.equals("token")) {
......
package fi.insomnia.bortal.beanutil;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class DecimalXMLAdapter extends XmlAdapter<String, BigDecimal> {
@Override
public String marshal(BigDecimal v) throws Exception {
NumberFormat format = NumberFormat.getNumberInstance(new Locale("en", "US"));
return format.format(v);
}
@Override
public BigDecimal unmarshal(String v) throws Exception {
return BigDecimal.valueOf(Double.parseDouble(v));
}
}
......@@ -17,6 +17,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.callbacks.FacadeCallback;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.utilities.SearchResult;
import fi.insomnia.bortal.utilities.jpa.ModelInterface;
......@@ -33,6 +34,10 @@ public abstract class GenericFacade<C extends ModelInterface> {
return entClass;
}
public C reload(C entity) {
return this.find(entity.getId());
}
protected abstract EntityManager getEm();
public void create(C entity) {
......
......@@ -5,6 +5,9 @@ import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import fi.insomnia.bortal.beanutil.DecimalXMLAdapter;
@XmlRootElement(name = "payment")
@XmlAccessorType(XmlAccessType.FIELD)
......@@ -27,6 +30,7 @@ public class PaymentEntry {
*
* Only either price or orderDetails can be set ( other must be null )
*/
@XmlJavaTypeAdapter(DecimalXMLAdapter.class)
private BigDecimal price;
public PaymentEntry(String url) {
......
......@@ -2,13 +2,20 @@ package fi.insomnia.bortal.verkkomaksutfi;
import java.math.BigDecimal;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import fi.insomnia.bortal.beanutil.DecimalXMLAdapter;
public class ProductEntry {
private String title;
private String code;
@XmlJavaTypeAdapter(DecimalXMLAdapter.class)
private BigDecimal amount = BigDecimal.ONE;
@XmlJavaTypeAdapter(DecimalXMLAdapter.class)
private BigDecimal price = BigDecimal.ZERO;
private Integer vat = 23;
@XmlJavaTypeAdapter(DecimalXMLAdapter.class)
private BigDecimal discount = BigDecimal.ZERO;
private Integer type = 1;
......
......@@ -7,10 +7,10 @@ public class UrlSetEntry {
}
public UrlSetEntry(String url) {
success = url + "/fail";
failure = url + "/failure";
pending = url + "/pending";
notification = url + "/notification";
success = url + "/success.jsf";
failure = url + "/failure.jsf";
pending = url + "/pending.jsf";
notification = url + "/notification.jsf";
}
......
......@@ -23,4 +23,6 @@ public interface EventBeanLocal {
LanEventProperty getProperty(LanEventPropertyKey property);
String getPropertyString(LanEventPropertyKey property);
LanEventProperty saveOrCreateProperty(LanEventProperty property);
}
......@@ -3,6 +3,7 @@ package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.util.SvmReturnType;
import fi.insomnia.bortal.util.VerkkomaksutReturnEntry;
@Local
......@@ -12,6 +13,6 @@ public interface VerkkomaksutFiBeanLocal {
VerkkomaksutReturnEntry getSvmToken(Bill bill);
boolean validateReturn(String orderNumber, String timestamp, String paid, String method, String authcode);
boolean validateReturn(SvmReturnType type, String orderNumber, String timestamp, String paid, String method, String authcode);
}
package fi.insomnia.bortal.util;
public enum SvmReturnType {
SUCCESS, FAILURE, PENDING, NOTIFICATION
}
package fi.insomnia.bortal.util;
public class VerkkomaksutReturnEntry {
import java.io.Serializable;
public class VerkkomaksutReturnEntry implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5421016087752752267L;
public boolean isError()
{
......
......@@ -25,12 +25,16 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
*
*/
@Entity
@Table(name = "group_memberships", uniqueConstraints = { @UniqueConstraint(columnNames = {
"user_id", "group_id" }) })
@Table(name = "group_memberships", uniqueConstraints = { @UniqueConstraint(columnNames = { GroupMembership.EVENTUSER_ID, GroupMembership.GROUP_ID }) })
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class GroupMembership extends GenericEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private static final long serialVersionUID = 2195875306960651526L;
protected static final String EVENTUSER_ID = "eventuser_id";
protected static final String GROUP_ID = "group_id";
@Column(name = "invite_token", unique = true, nullable = false)
private String inviteToken;
......@@ -46,14 +50,14 @@ public class GroupMembership extends GenericEntity {
private String inviteName;
@ManyToOne(optional = false, cascade = ALL)
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false)
@JoinColumn(name = GROUP_ID, referencedColumnName = "id", nullable = false)
private PlaceGroup placeGroup;
@OneToOne(optional = false)
@JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = true)
private Place placeReservation;
@JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN)
@JoinColumn(name = EVENTUSER_ID, referencedColumnName = EventUser.ID_COLUMN)
@ManyToOne
private EventUser user;
......
......@@ -58,7 +58,8 @@
</h:form>
<h2>Properties</h2>
<h:dataTable var="prop" value="#{eventorgView.event.properties}">
<h:form>
<h:dataTable var="prop" value="#{eventPropertyView.properties}">
<h:column>
<f:facet name="header">#{i18n['lanEventProperty.key']}</f:facet>
<h:outputText value="#{prop.key}" />
......@@ -71,18 +72,22 @@
</h:outputText>
<h:outputText rendered="#{prop.key.data}" value="#{i18n['lanEventProperty.valueIsRawdataWarning']}"/>
</h:column>
</h:column>
<h:column>
<h:commandButton action="#{eventPropertyView.editProperty}" value="#{i18n['lanEventProperty.editProperty']}" >
<!-- <f:ajax render="@all" execute="@form"/> -->
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
<h:form >
<h:selectOneMenu id="propval" value="#{eventPropertyView.createKey}">
<f:selectItems value="#{eventPropertyView.availablePropertyKeys}" />
</h:selectOneMenu>
<h:commandButton action="#{eventPropertyView.createPropertyKey}" value="#{i18n['lanEventProperty.createProperty']}" >
<!-- <f:ajax render="@all" execute="@form" /> -->
<h:commandButton action="#{eventPropertyView.initPropertyKeyCreate}" value="#{i18n['lanEventProperty.createProperty']}" >
<!-- <f:ajax render="@all" execute="@form" /> -->
</h:commandButton>
<h:message for="propval" />
</h:form>
......@@ -102,10 +107,11 @@
<h:message rendered="#{eventPropertyView.property.key.text}" for="textval" />
<h:outputLabel rendered="#{eventPropertyView.property.key.date}" for="textval" value="#{i18n['lanEventProperty.textValue']}" />
<p:calendar rendered="#{eventPropertyView.property.key.date}" value="#{eventPropertyView.property.datevalue}" pattern="#{sessionHandler.datetimeFormat}" />
<p:calendar rendered="#{eventPropertyView.property.key.date}" value="#{eventPropertyView.property.dateValue}" pattern="#{sessionHandler.datetimeFormat}" />
<h:message rendered="#{eventPropertyView.property.key.date}" for="textval" />
</h:panelGrid>
<h:commandButton action="#{eventPropertyView.saveProperty}" value="#{i18n['lanEventProperty.save']}" />
</h:form>
......
......@@ -19,8 +19,7 @@
</div>
<script type="text/javascript" src="//payment.verkkomaksut.fi/js/sv-widget.min.js"></script>
<script type="text/javascript">
SV.widget.initWithToken('svm-payment',
'#{billReviewBean.verkkomaksuToken.token}');
SV.widget.initWithToken('svm-payment', '#{billReviewView.verkkomaksuToken.token}');
</script>
</ui:fragment>
......
<!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:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="ORDER_NUMBER" value="#{svmView.orderNumber}" />
<f:viewParam name="TIMESTAMP" value="#{svmView.timestamp}" />
<f:viewParam name="PAID" value="#{svmView.paid}" />
<f:viewParam name="METHOD" value="#{svmView.method}" />
<f:viewParam name="RETURN_AUTHCODE" value="#{svmView.authcode}" />
<f:event type="preRenderView" listener="#{svmView.validateFailure}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.svm.failure.header']}</h1>
</ui:define>
<ui:define name="content">
<p>
<h:outputText rendered="#{svmView.validationResult}" value="#{i18n['svm.failure.successMessage']}" />
<h:outputText rendered="#{!svmView.validationResult}" value="#{i18n['svm.failure.errorMessage']}" />
</p>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!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:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="ORDER_NUMBER" value="#{svmView.orderNumber}" />
<f:viewParam name="TIMESTAMP" value="#{svmView.timestamp}" />
<f:viewParam name="PAID" value="#{svmView.paid}" />
<f:viewParam name="METHOD" value="#{svmView.method}" />
<f:viewParam name="RETURN_AUTHCODE" value="#{svmView.authcode}" />
<f:event type="preRenderView" listener="#{svmView.validateNotification}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.svm.notification.header']}</h1>
</ui:define>
<ui:define name="content">
<p>
<h:outputText rendered="#{svmView.validationResult}" value="#{i18n['svm.notification.successMessage']}" />
<h:outputText rendered="#{!svmView.validationResult}" value="#{i18n['svm.notification.errorMessage']}" />
</p>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!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:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="ORDER_NUMBER" value="#{svmView.orderNumber}" />
<f:viewParam name="TIMESTAMP" value="#{svmView.timestamp}" />
<f:viewParam name="PAID" value="#{svmView.paid}" />
<f:viewParam name="METHOD" value="#{svmView.method}" />
<f:viewParam name="RETURN_AUTHCODE" value="#{svmView.authcode}" />
<f:event type="preRenderView" listener="#{svmView.validatePending}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.svm.pending.header']}</h1>
</ui:define>
<ui:define name="content">
<p>
<h:outputText rendered="#{svmView.validationResult}" value="#{i18n['svm.pending.successMessage']}" />
<h:outputText rendered="#{!svmView.validationResult}" value="#{i18n['svm.pending.errorMessage']}" />
</p>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!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:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="ORDER_NUMBER" value="#{svmView.orderNumber}" />
<f:viewParam name="TIMESTAMP" value="#{svmView.timestamp}" />
<f:viewParam name="PAID" value="#{svmView.paid}" />
<f:viewParam name="METHOD" value="#{svmView.method}" />
<f:viewParam name="RETURN_AUTHCODE" value="#{svmView.authcode}" />
<f:event type="preRenderView" listener="#{svmView.validateSuccess}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.svm.success.header']}</h1>
</ui:define>
<ui:define name="content">
<p>
<h:outputText rendered="#{svmView.validationResult}" value="#{i18n['svm.success.successMessage']}" />
<h:outputText rendered="#{!svmView.validationResult}" value="#{i18n['svm.success.errorMessage']}" />
</p>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
package fi.insomnia.bortal.web.cdiview.organisation;
import java.util.ArrayList;
import java.util.Arrays;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.model.LanEventProperty;
import fi.insomnia.bortal.model.LanEventPropertyKey;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class EventPropertyView extends GenericCDIView {
private static final long serialVersionUID = 6278825570752203760L;
private LanEventPropertyKey createKey;
private LanEventProperty property;
@Inject
private EventOrgView eventorgview;
@EJB
private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(EventPropertyView.class);
private ListDataModel<LanEventProperty> properties;
public List<LanEventPropertyKey> getAvailablePropertyKeys()
{
List<LanEventPropertyKey> ret = new ArrayList<LanEventPropertyKey>(Arrays.asList(LanEventPropertyKey.values()));
if (createKey != null)
{
ret.remove(createKey);
}
if (eventorgview.getEvent() != null) {
for (LanEventProperty p : eventorgview.getEvent().getProperties()) {
ret.remove(p.getKey());
}
}
return ret;
}
public String editProperty()
{
property = properties.getRowData();
logger.info("Editing property {}", property);
return null;
}
public String initPropertyKeyCreate()
{
logger.info("Creating new key for event {}, key: {}", eventorgview.getEvent(), createKey);
property = new LanEventProperty();
property.setEventorg(eventorgview.getEvent().getOrganiser());
property.setEvent(eventorgview.getEvent());
property.setKey(createKey);
return null;
}
public String saveProperty()
{
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { property.getEvent(), property.getEventorg(), property.getKey() });
property = eventbean.saveOrCreateProperty(property);
eventorgview.setEvent(property.getEvent());
properties = null;
property = null;
return null;
}
public LanEventPropertyKey getCreateKey() {
return createKey;
}
public void setCreateKey(LanEventPropertyKey createKey) {
this.createKey = createKey;
}
public LanEventProperty getProperty() {
return property;
}
public void setProperty(LanEventProperty property) {
this.property = property;
}
public EventOrgView getEventorgview() {
return eventorgview;
}
public void setEventorgview(EventOrgView eventorgview) {
this.eventorgview = eventorgview;
}
public ListDataModel<LanEventProperty> getProperties() {
if (properties == null && eventorgview != null && eventorgview.getEvent() != null)
{
properties = new ListDataModel<LanEventProperty>(eventorgview.getEvent().getProperties());
}
return properties;
}
public void setProperties(ListDataModel<LanEventProperty> properties) {
this.properties = properties;
}
}
......@@ -4,6 +4,9 @@ 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.BillBeanLocal;
import fi.insomnia.bortal.beans.VerkkomaksutFiBeanLocal;
import fi.insomnia.bortal.model.Bill;
......@@ -25,6 +28,7 @@ public class BillReviewView extends GenericCDIView {
private Bill bill;
private VerkkomaksutReturnEntry vmreturn;
private static final Logger logger = LoggerFactory.getLogger(BillReviewView.class);
public Bill getBill() {
return bill;
......@@ -44,6 +48,7 @@ public class BillReviewView extends GenericCDIView {
if (bill != null && vmreturn == null)
{
vmreturn = vmbean.getSvmToken(bill);
logger.info("Vmtoken url {}, token {}", vmreturn.getUrl(), vmreturn.getToken());
}
return vmreturn;
}
......
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.VerkkomaksutFiBeanLocal;
import fi.insomnia.bortal.util.SvmReturnType;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class SvmView extends GenericCDIView {
private static final long serialVersionUID = 2131137241062741415L;
private String orderNumber;
private String timestamp;
private String paid;
private String method;
private String authcode;
private boolean validationResult;
@EJB
private VerkkomaksutFiBeanLocal vmbean;
public void validateSuccess()
{
validationResult = vmbean.validateReturn(SvmReturnType.SUCCESS, orderNumber, timestamp, paid, method, authcode);
}
public void validateFailure()
{
validationResult = vmbean.validateReturn(SvmReturnType.FAILURE, orderNumber, timestamp, paid, method, authcode);
}
public void validatePending()
{
validationResult = vmbean.validateReturn(SvmReturnType.PENDING, orderNumber, timestamp, paid, method, authcode);
}
public void validateNotification()
{
validationResult = vmbean.validateReturn(SvmReturnType.NOTIFICATION, orderNumber, timestamp, paid, method, authcode);
}
public String getOrderNumber() {
return orderNumber;
}
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getPaid() {
return paid;
}
public void setPaid(String paid) {
this.paid = paid;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getAuthcode() {
return authcode;
}
public void setAuthcode(String authcode) {
this.authcode = authcode;
}
public boolean isValidationResult() {
return validationResult;
}
public void setValidationResult(boolean validationResult) {
this.validationResult = validationResult;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!