19 package org.turro.financials.cart;
22 import java.io.IOException;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.jdom.Document;
26 import org.jdom.Element;
27 import org.jdom.JDOMException;
28 import org.jdom.input.SAXBuilder;
29 import org.turro.elephant.context.ElephantContext;
30 import org.turro.elephant.impl.context.DefaultConstructor;
31 import org.turro.file.FileWatch;
32 import org.turro.financials.cart.delivery.DeliveryContexts;
33 import org.turro.financials.db.FinancialsPU;
34 import org.turro.financials.entity.Contract;
35 import org.zkoss.lang.Strings;
43 private final static String
44 SHOP_FILE =
"/WEB-INF/elephant/conf/shop.xml";
46 private String cartPath, checkoutPath, notificationPath, OKPath, KOPath,
47 delivery, fiscal, logistic, contactPhone, locale, currency,
48 merchantCode, merchantTerminal, merchantCurrency, merchantKey,
49 merchantKeyType, merchantLanguage;
50 private boolean merchantTestScope, selfTestScope;
51 private long store, bank;
55 return !Strings.isBlank(cartPath);
67 return notificationPath;
123 return merchantTerminal;
127 return merchantCurrency;
135 return merchantKeyType;
139 return merchantLanguage;
143 return merchantTestScope;
147 return selfTestScope;
151 return deliveryContexts;
154 private void load() {
156 SAXBuilder builder =
new SAXBuilder();
160 if(confFile.exists()) {
161 doc = builder.build(confFile);
162 conf = doc.getRootElement();
165 cartPath = readAttribute(conf.getChild(
"CartPath"),
"value",
"/cart");
166 checkoutPath = readAttribute(conf.getChild(
"CheckoutPath"),
"value",
"/cart/checkout");
167 notificationPath = readAttribute(conf.getChild(
"NotificationPath"),
"value",
"/cart/notification");
168 OKPath = readAttribute(conf.getChild(
"OKPath"),
"value",
"/cart/OK");
169 KOPath = readAttribute(conf.getChild(
"KOPath"),
"value",
"/cart/KO");
170 store = Long.valueOf(readAttribute(conf.getChild(
"Store"),
"value",
"0"));
171 bank = Long.valueOf(readAttribute(conf.getChild(
"Bank"),
"value",
"0"));
172 delivery = readAttribute(conf.getChild(
"Delivery"),
"value",
"Delivery");
173 fiscal = readAttribute(conf.getChild(
"Fiscal"),
"value",
"Fiscal");
174 logistic = readAttribute(conf.getChild(
"Logistic"),
"value",
"");
175 contactPhone = readAttribute(conf.getChild(
"ContactPhone"),
"value",
"Contact phone");
176 locale = readAttribute(conf.getChild(
"Locale"),
"value",
"ca_ES");
177 currency = readAttribute(conf.getChild(
"Currency"),
"value",
"EUR");
178 merchantCode = readAttribute(conf.getChild(
"MerchantCode"),
"value",
"");
179 merchantTerminal = readAttribute(conf.getChild(
"MerchantTerminal"),
"value",
"");
180 merchantCurrency = readAttribute(conf.getChild(
"MerchantCurrency"),
"value",
"");
181 merchantKey = readAttribute(conf.getChild(
"MerchantKey"),
"value",
"");
182 merchantKeyType = readAttribute(conf.getChild(
"MerchantKeyType"),
"value",
"");
183 merchantLanguage = readAttribute(conf.getChild(
"MerchantKeyLanguage"),
"value",
"");
184 merchantTestScope =
"true".equals(readAttribute(conf.getChild(
"MerchantTestScope"),
"value",
"true"));
185 selfTestScope =
"true".equals(readAttribute(conf.getChild(
"SelfTestScope"),
"value",
"false"));
186 deliveryContexts =
new DeliveryContexts();
187 deliveryContexts.
readXML(conf);
189 }
catch (IOException | JDOMException ex) {
190 Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
194 private static String readAttribute(Element child, String attr, String def) {
195 return child !=
null ? child.getAttributeValue(attr) : def;
198 private ShopContext() {}
200 private static ShopContext _instance;
201 private static long _lastLoad;
static String getRealPath(String path)
String getMerchantLanguage()
DeliveryContexts getDeliveryContexts()
Contract getContractBank()
String getMerchantTerminal()
boolean isSelfTestScope()
boolean isMerchantTestScope()
String getMerchantCurrency()
String getNotificationPath()
String getMerchantKeyType()
Contract getContractStore()
static ShopContext getInstance()
void readXML(Element root)