Parcourir la source

enc json resp to base64, response for final req is normal SMS

Pat il y a 7 ans
Parent
commit
f117f08aa1

+ 24 - 10
GabonTelMobicashMobileAppHelper/src/main/java/com/psi/gabontel/mobileapp/thirdparty/helper/MobileAppThirdPartyHelper.java

@@ -1,5 +1,6 @@
 package com.psi.gabontel.mobileapp.thirdparty.helper;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 import javax.ejb.Remote;
@@ -33,27 +34,40 @@ public class MobileAppThirdPartyHelper  implements AppManagerFunction {
         String method  =  syntax.get("method");
         String password = syntax.get("password");
         String respmessage = key + ":" + method + ":";
+        String response = StringUtil.base64Encode(new JsonResponse(99,"System is busy").toString().getBytes());
         McomSubscriber originator = null;
+        boolean isfinal = false;
+        String finalmessage = "System Busy.";
+        if(!StringUtil.isNullOrEmpty(password)) {
+            isfinal = true;
+        }
         Message msg = Messanger.getMessage(MessageId.SYSTEM_BUSY, msisdn, "<refid>", refid);
 	    try {
-	        originator = McomSubscriber.getMcomSubscriber(msisdn);
-	        if(!StringUtil.isNullOrEmpty(password)) {
+	        if(isfinal) {
+	            originator = McomSubscriber.getMcomSubscriber(msisdn);
 	            msg = TransactionHelper.validateOriginator(originator, password);
 	            if (msg != null) {
-	                return new Message(99,0,respmessage + new JsonResponse(99,msg.getMessage()).toString());
+	                log.error("Error: Refid:"+refid+"|invalid originator!");
+	                return new Message(99,0,msg.getMessage().toString());
 	            }
 	        }
     		if(InitializerBean.containsKey(method)) {
-    			String[] paramarr = syntax.get("mparam").split("\\|");    			
-    			return new Message(0,0,respmessage + new JsonResponse(0,InitializerBean.callUssd(method, paramarr)).toString());
-    		}else {
-    			return new Message(99,0,respmessage + new JsonResponse(99,"System is busy").toString());
+    			String[] paramarr = syntax.get("mparam").split("\\|");
+    			String appmanresponse = InitializerBean.callUssd(method, paramarr).toString();
+    			response = StringUtil.base64Encode(new JsonResponse(0,appmanresponse).toString().getBytes());
+    			finalmessage = respmessage + response;
+    			if(isfinal) {
+    			    finalmessage = appmanresponse;
+    			}
+    			return new Message(0,0,finalmessage);
     		}
-		
+    		log.error("Error: Refid:"+refid+"|method not found!");
 		}catch(Exception e) {
 			log.error("Error: Refid:"+refid+"|" ,e);
 		}
-		return new Message(99,0,respmessage + new JsonResponse(99,"System is busy").toString());
-		
+	    if(!isfinal) {
+	        finalmessage = respmessage + response;
+	    }
+	    return new Message(99,0,finalmessage);
 	}
 }