Exemplo n.º 1
0
  @Override
  public T getObject(MethodContext methodContext) {
    T fieldVal = null;

    if (!mapAcsr.isEmpty()) {
      Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext);
      if (fromMap == null) {
        Debug.logWarning(
            "Map not found with name " + mapAcsr + ", not getting Object value, returning null.",
            module);
        return null;
      }
      fieldVal = fieldAcsr.get(fromMap, methodContext);
    } else {
      // no map name, try the env
      fieldVal = fieldAcsr.get(methodContext);
    }

    if (fieldVal == null) {
      if (Debug.infoOn())
        Debug.logInfo(
            "Field value not found with name "
                + fieldAcsr
                + " in Map with name "
                + mapAcsr
                + ", not getting Object value, returning null.",
            module);
      return null;
    }

    return fieldVal;
  }
Exemplo n.º 2
0
  @Override
  public boolean exec(MethodContext methodContext) {
    Object fieldVal = null;

    if (!mapAcsr.isEmpty()) {
      Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext);

      if (fromMap == null) {
        if (Debug.infoOn())
          Debug.logInfo(
              "Map not found with name " + mapAcsr + ", not copying from this map", module);
        return true;
      }

      fieldVal = fieldAcsr.get(fromMap, methodContext);
    } else {
      // no map name, try the env
      fieldVal = fieldAcsr.get(methodContext);
    }

    if (fieldVal == null) {
      if (Debug.verboseOn())
        Debug.logVerbose(
            "Field value not found with name "
                + fieldAcsr
                + " in Map with name "
                + mapAcsr
                + ", not copying field",
            module);
      return true;
    }

    // note that going to an env field will only work if it came from an env
    // field because if not specified the to-map-name will be set to the map-name
    // to go from a map field to an env field, use the field-to-env operation
    Map<String, Object> toMap = null;

    if (!toMapAcsr.isEmpty()) {
      toMap = toMapAcsr.get(methodContext);
      if (toMap == null) {
        if (Debug.verboseOn())
          Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module);
        toMap = FastMap.newInstance();
        toMapAcsr.put(methodContext, toMap);
      }
      toFieldAcsr.put(toMap, fieldVal, methodContext);
    } else {
      // no to-map, so put in env
      toFieldAcsr.put(methodContext, fieldVal);
    }

    return true;
  }
Exemplo n.º 3
0
  protected static Element getRootElement(HttpServletRequest request) {
    if (Debug.infoOn()) {
      Debug.log("Applet config file: " + ldapConfig);
    }
    File configFile = new File(ldapConfig);
    FileInputStream configFileIS = null;
    Element rootElement = null;
    try {
      configFileIS = new FileInputStream(configFile);
      Document configDoc =
          UtilXml.readXmlDocument(configFileIS, "LDAP configuration file " + ldapConfig);
      rootElement = configDoc.getDocumentElement();
    } catch (FileNotFoundException e) {
      Debug.logError(e, "Error calling userLogin service", module);
      Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
      String errMsg =
          UtilProperties.getMessage(
              resourceWebapp,
              "loginevents.following_error_occurred_during_login",
              messageMap,
              UtilHttp.getLocale(request));
      request.setAttribute("_ERROR_MESSAGE_", errMsg);
    } catch (SAXException e) {
      Debug.logError(e, "Error calling userLogin service", module);
      Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
      String errMsg =
          UtilProperties.getMessage(
              resourceWebapp,
              "loginevents.following_error_occurred_during_login",
              messageMap,
              UtilHttp.getLocale(request));
      request.setAttribute("_ERROR_MESSAGE_", errMsg);
    } catch (ParserConfigurationException e) {
      Debug.logError(e, "Error calling userLogin service", module);
      Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
      String errMsg =
          UtilProperties.getMessage(
              resourceWebapp,
              "loginevents.following_error_occurred_during_login",
              messageMap,
              UtilHttp.getLocale(request));
      request.setAttribute("_ERROR_MESSAGE_", errMsg);
    } catch (IOException e) {
      Debug.logError(e, "Error calling userLogin service", module);
      Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
      String errMsg =
          UtilProperties.getMessage(
              resourceWebapp,
              "loginevents.following_error_occurred_during_login",
              messageMap,
              UtilHttp.getLocale(request));
      request.setAttribute("_ERROR_MESSAGE_", errMsg);
    } finally {
      if (configFileIS != null) {
        try {
          configFileIS.close();
        } catch (IOException e) {
        }
      }
    }

    return rootElement;
  }