|
|
@@ -0,0 +1,73 @@
|
|
|
+package com.psi.gabontel.mobileapp.helper;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.ejb.Remote;
|
|
|
+import javax.ejb.Stateless;
|
|
|
+
|
|
|
+import org.jboss.logging.Logger;
|
|
|
+
|
|
|
+import com.psi.applicationmanager.AppManagerFunction;
|
|
|
+import com.psi.applicationmanager.AppMessage;
|
|
|
+import com.psi.common.db.DbWrapper;
|
|
|
+import com.psi.common.transactions.McomSubscriber;
|
|
|
+import com.psi.common.transactions.Message;
|
|
|
+import com.psi.common.transactions.MessageId;
|
|
|
+import com.psi.common.transactions.Messanger;
|
|
|
+import com.psi.common.transactions.TransactionHelper;
|
|
|
+
|
|
|
+@Stateless
|
|
|
+@Remote(AppManagerFunction.class)
|
|
|
+public class EulaTransaction implements AppManagerFunction {
|
|
|
+ public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
|
+ return manageTransaction(refid, msisdn, message, syntax).getMessage();
|
|
|
+ }
|
|
|
+ private static final Logger log = Logger.getLogger(EulaTransaction.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AppMessage manageTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
|
+ String ret = null;
|
|
|
+ String key = syntax.get("key");
|
|
|
+ String token = syntax.get("token");
|
|
|
+ Message msg = null;
|
|
|
+ try {
|
|
|
+ McomSubscriber originator = McomSubscriber.getMcomSubscriber(msisdn);
|
|
|
+
|
|
|
+ if (!originator.isSubscribed()) {
|
|
|
+ msg = Messanger.getMessage(MessageId.UNAUTHORISED_ERROR, originator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"ACTIVE".equalsIgnoreCase(originator.getProperty("STATUS"))) {
|
|
|
+ msg = Messanger.getMessage(MessageId.INACTIVE_ERROR, originator);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ msg = TransactionHelper.allowedTransaction(originator, key);
|
|
|
+ if (msg != null) {
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ DbWrapper.getInstance().QueryUpdate("UPDATE TBLMOBILEACCOUNTINFO SET TOKEN = ? WHERE MSISDN = ? ", new Object[] {token, originator.getMsisdn() });
|
|
|
+ DbWrapper.getInstance().QueryUpdate("DELETE TBLNONCE WHERE MSISDN = ?", new Object[] { ret });
|
|
|
+
|
|
|
+ msg = Messanger.getMessage(1014, originator);
|
|
|
+
|
|
|
+
|
|
|
+ String type = DbWrapper.getInstance().QueryScalar("SELECT DECRYPT(TYPE,?,MSISDN)TYPE FROM TBLMOBILEACCOUNTINFO WHERE MSISDN = ? ", "", new Object[] { DbWrapper.getInstance().getCrypt(), msisdn });
|
|
|
+ String company = DbWrapper.getInstance().QueryScalar("SELECT COMPANY FROM TBLMOBILEACCOUNTINFO WHERE MSISDN = ? ", "", new Object[] { msisdn });
|
|
|
+ if (type.startsWith("AGNT") || type.startsWith("DLER") || type.equals("RETA") || type.equals("MERC") || type.equals("TRAD")) {
|
|
|
+ ret = "REGIS:" + msg.getId() + ":" + 0 + ":" + originator.getMsisdn() + ":" + originator.getProperty("FIRSTNAME") + ":" + originator.getProperty("LASTNAME") + ":" + 1 + ":" + 2 + ":" + 0 + ":" + company + ":" + originator.getAliasName() + ":" + "Success";
|
|
|
+ msg = new Message(0, 0, ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = msg.getMessage();
|
|
|
+ msg = new Message(0, 0, ret);
|
|
|
+ }catch(Exception e) {
|
|
|
+ log.error("Eula Error|Ref:"+refid +"|",e);
|
|
|
+ msg = Messanger.getMessage(MessageId.SYSTEM_BUSY);
|
|
|
+ }
|
|
|
+
|
|
|
+ return msg;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|