Exemplo n.º 1
0
  public ServiceEcaAction(Element action, String event) {
    this.eventName = event;
    this.serviceName = action.getAttribute("service");
    this.serviceMode = action.getAttribute("mode");
    this.runAsUser = action.getAttribute("run-as-user");
    // support the old, inconsistent attribute name
    if (UtilValidate.isEmail(this.runAsUser)) this.runAsUser = action.getAttribute("runAsUser");
    this.resultMapName = action.getAttribute("result-map-name");

    // default is true, so anything but false is true
    this.resultToContext = !"false".equals(action.getAttribute("result-to-context"));
    // default is false, so anything but true is false
    this.resultToResult = "true".equals(action.getAttribute("result-to-result"));
    this.newTransaction = !"false".equals(action.getAttribute("new-transaction"));
    this.ignoreFailure = !"false".equals(action.getAttribute("ignore-failure"));
    this.ignoreError = !"false".equals(action.getAttribute("ignore-error"));
    this.persist = "true".equals(action.getAttribute("persist"));
  }
Exemplo n.º 2
0
  public static String getJSONuiLabel(HttpServletRequest request, HttpServletResponse response) {
    String requiredLabels = request.getParameter("requiredLabel");

    JSONObject uiLabelObject = null;
    if (UtilValidate.isNotEmpty(requiredLabels)) {
      // Transform JSON String to Object
      uiLabelObject = (JSONObject) JSONSerializer.toJSON(requiredLabels);
    }

    JSONArray jsonUiLabel = new JSONArray();
    Locale locale = request.getLocale();
    if (!uiLabelObject.isEmpty()) {
      Set<String> resourceSet = UtilGenerics.checkSet(uiLabelObject.keySet());
      // Iterate over the resource set
      // here we need a keySet because we don't now which label resource to load
      // the key set should have the size one, if greater or empty error should returned
      if (UtilValidate.isEmpty(resourceSet)) {
        Debug.logError("No resource and labels found", module);
        return "error";
      } else if (resourceSet.size() > 1) {
        Debug.logError(
            "More than one resource found, please use the method: getJSONuiLabelArray", module);
        return "error";
      }

      for (String resource : resourceSet) {
        String label = uiLabelObject.getString(resource);
        if (UtilValidate.isEmail(label)) {
          continue;
        }

        String receivedLabel = UtilProperties.getMessage(resource, label, locale);
        jsonUiLabel.add(receivedLabel);
      }
    }

    writeJSONtoResponse(jsonUiLabel, response);
    return "success";
  }