Advertisement
tko_pb

CalloutUtility

Aug 7th, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. package org.wirabumi.gen.oez.utility;
  2. import java.util.Enumeration;
  3. import java.util.HashMap;
  4.  
  5. import org.apache.log4j.Logger;
  6. import org.codehaus.jettison.json.JSONException;
  7. import org.codehaus.jettison.json.JSONObject;
  8. import org.openbravo.base.filter.RequestFilter;
  9. import org.openbravo.base.secureApp.VariablesSecureApp;
  10. import org.openbravo.erpCommon.ad_callouts.CalloutConstants;
  11. import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
  12.  
  13. public class CalloutUtility {
  14.  
  15.     public static HashMap<String, String> GetCalloutUtility() {
  16.         VariablesSecureApp vars = null;
  17.         HashMap<String, String> CalloutInfoHashmap = new HashMap<>();
  18.         Enumeration<String> Params =  vars.getEnumerationString(); // hasil dari get
  19.         while(Params.hasMoreElements())
  20.         {
  21.             String paramsKey = Params.nextElement();
  22.             String value = getStringParameter(paramsKey, null);
  23.             CalloutInfoHashmap.put(paramsKey, value);
  24.         }
  25.         return CalloutInfoHashmap;
  26.     }
  27.        
  28.     public static String getStringParameter(String param, RequestFilter filter) {
  29.         VariablesSecureApp vars = null;
  30.         String value = "";
  31.         JSONObject result = null;
  32.         Logger log = Logger.getLogger(SimpleCallout.class);
  33.        
  34.         Enumeration<String> params = vars.getParameterNames();
  35.         while(params.hasMoreElements())
  36.             System.err.println(params.nextElement());
  37.         try {
  38.             // if a parent callout modified any value, updated value is returned.
  39.             if (result.has(param)) {
  40.                 value = result.getJSONObject(param).get(CalloutConstants.CLASSIC_VALUE).toString();
  41.             } else {
  42.                 value = vars.getStringParameter(param, filter);
  43.             }
  44.         } catch (JSONException e) {
  45.             log.error("Error parsing JSON Object.", e);
  46.         }
  47.         return value;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement