|
@@ -0,0 +1,110 @@
|
|
|
|
|
+package com.psi.gabontel.mobileapp.thirdparty.helper;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.Hashtable;
|
|
|
|
|
+import java.util.Iterator;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+import javax.ejb.EJB;
|
|
|
|
|
+import javax.ejb.Remote;
|
|
|
|
|
+import javax.ejb.Stateless;
|
|
|
|
|
+import javax.lang.model.element.ModuleElement.UsesDirective;
|
|
|
|
|
+import javax.naming.Context;
|
|
|
|
|
+import javax.naming.InitialContext;
|
|
|
|
|
+
|
|
|
|
|
+import org.jboss.logging.Logger;
|
|
|
|
|
+
|
|
|
|
|
+import com.psi.applicationmanager.AppManagerFunction;
|
|
|
|
|
+import com.psi.applicationmanager.AppMessage;
|
|
|
|
|
+import com.psi.common.db.DataRow;
|
|
|
|
|
+import com.psi.common.db.DataRowCollection;
|
|
|
|
|
+import com.psi.common.db.DbWrapper;
|
|
|
|
|
+import com.psi.common.transactions.Message;
|
|
|
|
|
+import com.psi.common.transactions.MessageId;
|
|
|
|
|
+import com.psi.common.transactions.Messanger;
|
|
|
|
|
+import com.psi.gabontel.mobileapp.helper.GetMobileAppExternalData;
|
|
|
|
|
+import com.psi.ussd.interfaces.UssdReceiverFunction;
|
|
|
|
|
+
|
|
|
|
|
+@Stateless
|
|
|
|
|
+@Remote(AppManagerFunction.class)
|
|
|
|
|
+public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
|
|
+ private static final Logger log = Logger.getLogger(MobileAppThirdPartyHelper.class);
|
|
|
|
|
+ private static Hashtable<String,String> ussdgwmenuejb = new Hashtable<String,String>();
|
|
|
|
|
+
|
|
|
|
|
+ static {
|
|
|
|
|
+
|
|
|
|
|
+ DbWrapper db = new DbWrapper("java:jboss/datasources/UssdDbClient");
|
|
|
|
|
+ DbWrapper.setInstance(db);
|
|
|
|
|
+
|
|
|
|
|
+ // LOAD EJB
|
|
|
|
|
+
|
|
|
|
|
+ DataRowCollection rows = db.QueryDataRows("SELECT PARAMNAME,EJBNAME FROM TBLUSSDGWMENUEJB WHERE STATUS = 1");
|
|
|
|
|
+ Iterator iterator = rows.iterator();
|
|
|
|
|
+
|
|
|
|
|
+ while(iterator.hasNext()) {
|
|
|
|
|
+ DataRow row = (DataRow) iterator.next();
|
|
|
|
|
+
|
|
|
|
|
+ String paramname = row.getString("PARAMNAME");
|
|
|
|
|
+ String ejbname = row.getString("EJBNAME");
|
|
|
|
|
+
|
|
|
|
|
+ ussdgwmenuejb.put(paramname, ejbname);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
|
|
|
+ return manageTransaction(refid, msisdn, message, syntax).getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public AppMessage manageTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ String method = syntax.get("method");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ UssdReceiverFunction clazz = null;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(ussdgwmenuejb.containsKey(method)) {
|
|
|
|
|
+
|
|
|
|
|
+ Object obj = InitialContext.doLookup(ussdgwmenuejb.get(method));
|
|
|
|
|
+ clazz = (UssdReceiverFunction)obj;
|
|
|
|
|
+
|
|
|
|
|
+ String[] paramarr = syntax.get("param").split("\\|");
|
|
|
|
|
+ List<String> listarr = Arrays.asList(paramarr);
|
|
|
|
|
+
|
|
|
|
|
+ //SPECIAL CASE
|
|
|
|
|
+ if(method.equals("postpaidinvoices")){
|
|
|
|
|
+
|
|
|
|
|
+ String arisreturn = clazz.requestFunc(listarr);
|
|
|
|
|
+
|
|
|
|
|
+ obj = InitialContext.doLookup(ussdgwmenuejb.get("displayinvoices"));
|
|
|
|
|
+ clazz = (UssdReceiverFunction)obj;
|
|
|
|
|
+
|
|
|
|
|
+ listarr = Arrays.asList(arisreturn);
|
|
|
|
|
+ clazz.requestFunc(listarr);
|
|
|
|
|
+
|
|
|
|
|
+ return new Message(0,0,new JsonResponse(0,clazz.requestFunc(listarr)).toString());
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return new Message(0,0,new JsonResponse(0,clazz.requestFunc(listarr)).toString());
|
|
|
|
|
+
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return new Message(99,0,new JsonResponse(99,"System is busy").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
|
+ log.error("Error: Refid:"+refid+"|" ,e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return new Message(99,0,new JsonResponse(99,"System is busy").toString());
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|