Ejemplo n.º 1
0
  public Object transformOutput(final ActionContext actionContext, final GraphObject source)
      throws FrameworkException {

    if (outputFunction == null) {
      return source.getProperty(sourceProperty);
    }

    // output transformation requested
    actionContext.setConstant("input", source);
    return Scripting.evaluate(actionContext, null, "${" + outputFunction + "}");
  }
Ejemplo n.º 2
0
  public void transformInput(final ActionContext actionContext, final Map<String, Object> source)
      throws FrameworkException {

    // move / rename input value
    Object inputValue = source.remove(targetName);
    if (inputValue != null) {

      if (inputFunction != null) {

        // input transformation requested
        actionContext.setConstant("input", inputValue);
        inputValue = Scripting.evaluate(actionContext, null, "${" + inputFunction + "}");
      }

      source.put(sourceName, inputValue);
    }
  }
Ejemplo n.º 3
0
  public static Object execute(
      final SecurityContext securityContext,
      final GraphObject entity,
      final String source,
      final Map<String, Object> parameters)
      throws FrameworkException {

    final ActionContext context = new ActionContext(securityContext, parameters);
    final Object result = Scripting.evaluate(context, entity, source);

    // check for errors raised by scripting
    if (context.hasError()) {
      throw new FrameworkException(422, "Server-side scripting error", context.getErrorBuffer());
    }

    return result;
  }