summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-javascript
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-javascript')
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java41
3 files changed, 27 insertions, 26 deletions
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
index 7b91c5975..bc3062d13 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java
@@ -70,17 +70,17 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor {
/**
* Executes the executor for the state finalizer logic in a sequential manner.
*
- * @param executionID the execution ID for the current APEX policy execution
+ * @param executionId the execution ID for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionID, final Map<String, Object> incomingFields)
+ public String execute(final long executionId, final Map<String, Object> incomingFields)
throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionID, incomingFields);
+ executePre(executionId, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
index 38be929c0..14e4ba384 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
@@ -69,17 +69,17 @@ public class JavascriptTaskExecutor extends TaskExecutor {
/**
* Executes the executor for the task in a sequential manner.
*
- * @param executionID the execution ID for the current APEX policy execution
+ * @param executionId the execution ID for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields)
+ public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionID, incomingFields);
+ executePre(executionId, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
index 570b33b2a..adeb73f88 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java
@@ -44,6 +44,10 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavascriptTaskSelectExecutor.class);
+ // Recurring string constants
+ private static final String TSL_FAILED_PREFIX =
+ "execute: task selection logic failed to set a return value for state \"";
+
// Javascript engine
private ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
private CompiledScript compiled = null;
@@ -61,9 +65,9 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
compiled = ((Compilable) engine).compile(getSubject().getTaskSelectionLogic().getLogic());
} catch (final ScriptException e) {
LOGGER.error("execute: task selection logic failed to compile for state \"" + getSubject().getKey().getId()
- + "\"");
- throw new StateMachineException(
- "task selection logic failed to compile for state \"" + getSubject().getKey().getId() + "\"", e);
+ + "\"");
+ throw new StateMachineException("task selection logic failed to compile for state \""
+ + getSubject().getKey().getId() + "\"", e);
}
}
@@ -71,17 +75,17 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
/**
* Executes the executor for the task in a sequential manner.
*
- * @param executionID the execution ID for the current APEX policy execution
+ * @param executionId the execution ID for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
+ throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionID, incomingEvent);
+ executePre(executionId, incomingEvent);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
@@ -95,27 +99,24 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
compiled.eval(engine.getContext());
}
} catch (final ScriptException e) {
- LOGGER.error(
- "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"");
+ LOGGER.error("execute: task selection logic failed to run for state \"" + getSubject().getKey().getId()
+ + "\"");
throw new StateMachineException(
- "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e);
+ "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
+ e);
}
try {
final Object ret = engine.get("returnValue");
if (ret == null) {
- LOGGER.error("execute: task selection logic failed to set a return value for state \""
- + getSubject().getKey().getId() + "\"");
- throw new StateMachineException(
- "execute: task selection logic failed to set a return value for state \""
- + getSubject().getKey().getId() + "\"");
+ LOGGER.error(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\"");
+ throw new StateMachineException(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\"");
}
returnValue = (Boolean) ret;
} catch (NullPointerException | ClassCastException e) {
LOGGER.error("execute: task selection logic failed to set a correct return value for state \""
- + getSubject().getKey().getId() + "\"", e);
- throw new StateMachineException("execute: task selection logic failed to set a return value for state \""
- + getSubject().getKey().getId() + "\"", e);
+ + getSubject().getKey().getId() + "\"", e);
+ throw new StateMachineException(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\"", e);
}
// Do the execution post work
@@ -137,8 +138,8 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor {
@Override
public void cleanUp() throws StateMachineException {
LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + ","
- + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
- + getSubject().getTaskSelectionLogic().getLogic());
+ + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
+ + getSubject().getTaskSelectionLogic().getLogic());
engine = null;
}
}