summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java92
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java4
-rw-r--r--examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java12
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js19
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js4
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js13
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js42
-rw-r--r--examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java6
8 files changed, 52 insertions, 140 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
index d53fdf8ff..95ea6b5d2 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +31,9 @@ import java.util.Properties;
import java.util.Random;
import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.core.engine.monitoring.EventMonitor;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
@@ -62,6 +66,8 @@ public class EnEvent extends HashMap<String, Object> {
private final transient EventMonitor eventMonitor = new EventMonitor();
// The stack of execution of this event, used for monitoring
+ @Getter
+ @Setter
private AxConcept[] userArtifactStack;
private static Random rand = new Random(System.nanoTime());
@@ -69,12 +75,18 @@ public class EnEvent extends HashMap<String, Object> {
// An identifier for the current event execution. The default value here will always be a random
// number, and should
// be reset
+ @Getter
+ @Setter
private long executionId = rand.nextLong();
// Event related properties used during processing of this event
+ @Getter
+ @Setter
private Properties executionProperties;
// A string holding a message that indicates why processing of this event threw an exception
+ @Getter
+ @Setter
private String exceptionMessage;
/**
@@ -138,86 +150,6 @@ public class EnEvent extends HashMap<String, Object> {
}
/**
- * Get the currently set value for the ExecutionID for this event. A ExecutionID in an EnEvent
- * is used identify all EnEvents (input, internal and output events) used in a single Engine
- * invocation. Therefore, a ExecutionID can be used to match which output event is the result of
- * a particular input event. The default initialized value for the ExecutionID is always unique
- * in a single JVM.
- *
- * @return the currently set value for the ExecutionID for this event.
- */
- public long getExecutionId() {
- return executionId;
- }
-
- /**
- * Set the value for the ExecutionID for this event. A ExecutionID in an EnEvent is used
- * identify all EnEvents (input, internal and output events) used in a single Engine invocation.
- * Therefore, a ExecutionID can be used to match which output event is the result of a
- * particular input event. The default initialised value for the ExecutionID is always unique in
- * a single JVM.
- *
- * @param executionId the new value for the ExecutionID for this event.
- */
- public void setExecutionId(final long executionId) {
- this.executionId = executionId;
- }
-
- /**
- * Get the event execution properties.
- *
- * @return the event execution properties
- */
- public Properties getExecutionProperties() {
- return executionProperties;
- }
-
- /**
- * Set the event execution properties.
- *
- * @param executionProperties the execution properties to set
- */
- public void setExecutionProperties(Properties executionProperties) {
- this.executionProperties = executionProperties;
- }
-
- /**
- * Gets the exception message explaining why processing of this event to fail.
- *
- * @return the exception message
- */
- public String getExceptionMessage() {
- return exceptionMessage;
- }
-
- /**
- * Sets the exception message explaining why processing of this event to fail.
- *
- * @param exceptionMessage the exception message
- */
- public void setExceptionMessage(final String exceptionMessage) {
- this.exceptionMessage = exceptionMessage;
- }
-
- /**
- * Get the user artifact stack of the event.
- *
- * @return the event user artifact stack
- */
- public AxConcept[] getUserArtifactStack() {
- return userArtifactStack;
- }
-
- /**
- * Store the user artifact stack of the event.
- *
- * @param usedArtifactStackArray the event user artifact stack
- */
- public void setUserArtifactStack(final AxConcept[] usedArtifactStackArray) {
- userArtifactStack = usedArtifactStackArray;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
index fa0b40e77..cb0cfabc4 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +114,8 @@ public interface Executor<I, O, S, C> {
*
* @return The parent executor of this executor
*/
- Executor<?, ?, ?, ?> getParent();
+ @SuppressWarnings("rawtypes")
+ Executor getParent();
/**
* Get the subject of the executor.
diff --git a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
index 939b104d1..e4186f131 100644
--- a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
+++ b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
@@ -70,11 +70,10 @@ public class WebClient {
* @param username Simple Username
* @param pass Simple password
* @param contentType http content type
- * @apram secureHttp flag indicating if HTTPS should be used
* @return String response message
*/
public String httpRequest(String requestUrl, String requestMethod, String outputStr, String username, String pass,
- String contentType, boolean secureHttp) {
+ String contentType) {
String result = "";
StringBuilder builder = new StringBuilder();
try {
@@ -82,13 +81,8 @@ public class WebClient {
disableCertificateValidation();
URL url = new URL(requestUrl);
- HttpURLConnection httpUrlConn = null;
- if (secureHttp) {
- httpUrlConn = (HttpsURLConnection) url.openConnection();
- }
- else {
- httpUrlConn = (HttpURLConnection) url.openConnection();
- }
+ HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection();
+
httpUrlConn.setDoOutput(true);
httpUrlConn.setDoInput(true);
httpUrlConn.setUseCaches(false);
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
index 6e72e618c..a4be3707f 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
@@ -84,7 +84,7 @@ try {
executor.logger.info("Query url" + urlGet);
- result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true);
+ result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json");
executor.logger.info("Data received From " + urlGet + " " + result);
jsonObj = JSON.parse(result.toString());
@@ -116,7 +116,7 @@ try {
executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4));
var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version;
result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Data received From " + urlPut + " " + result);
/* If failure to retrieve data proceed to Failure */
if (result != "") {
@@ -157,7 +157,7 @@ try {
/* 1. Get PNF */
var urlGetPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName;
- pnfResponse = client.httpRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true);
+ pnfResponse = client.httpRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json");
executor.logger.info("Data received From " + urlGetPnf + " " + pnfResponse);
/* If failure to retrieve data proceed to Failure */
if (result != "") {
@@ -166,7 +166,7 @@ try {
pnfUpdate = JSON.parse(pnfResponse.toString());
executor.logger.info(JSON.stringify(pnfUpdate, null, 4));
- /*2. Create logical link */
+ /* 2. Create logical link */
var link_name = attachmentPoint;
var logicalLink = {
"link-name" : link_name,
@@ -176,14 +176,14 @@ try {
var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION
+ "/network/logical-links/logical-link/" + link_name;
result = client.httpRequest(urlNewLogicalLink, "PUT", JSON.stringify(logicalLink), AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Data received From " + urlNewLogicalLink + " " + result);
/* If failure to retrieve data proceed to Failure */
if (result != "") {
aaiUpdateResult = false;
}
- /*3. Update pnf with new relation*/
+ /* 3. Update pnf with new relation */
for (var i = 0; i < pnfUpdate["relationship-list"]["relationship"].length; i++) {
if (pnfUpdate["relationship-list"]["relationship"][i]['related-to'] == 'logical-link') {
pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = "/aai/" + AAI_VERSION
@@ -202,7 +202,7 @@ try {
executor.logger.info("Put pnf to aai " + JSON.stringify(pnfUpdate, null, 4));
var urlPutPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName;
result = client.httpRequest(urlPutPnf, "PUT", JSON.stringify(pnfUpdate), AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Data received From " + urlPutPnf + " " + result);
/* If failure to retrieve data proceed to Failure */
@@ -215,8 +215,7 @@ try {
var linkResult;
var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION
+ "/network/logical-links/logical-link/" + oldLinkName;
- linkResult = client
- .httpRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true);
+ linkResult = client.httpRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json");
executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " "
+ linkResult.hasOwnProperty("link-name"));
oldLinkResult = JSON.parse(linkResult.toString());
@@ -225,7 +224,7 @@ try {
var urlDelOldLogicalLink = urlOldLogicalLink + "?resource-version=" + res_version;
executor.logger.info("Delete called for " + urlDelOldLogicalLink);
result = client.httpRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Delete called for " + urlDelOldLogicalLink + " result " + result);
}
}
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
index 7e116f0ea..a7809bf1b 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
@@ -78,7 +78,7 @@ try {
executor.logger.info("Query url" + urlGet);
- result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true);
+ result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json");
executor.logger.info("Data received From " + urlGet + " " + result);
jsonObj = JSON.parse(result);
@@ -110,7 +110,7 @@ try {
executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4));
var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version;
result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Data received From " + urlPut + " " + result);
/* If failure to retrieve data proceed to Failure */
if (result != "") {
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
index d588eaf48..02fc05839 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
@@ -1,7 +1,6 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Huawei. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,8 +123,7 @@ executor.logger.info(client.toPrettyString(xmlDeleteAccess, 4));
try {
var urlPost1 = HTTP_PROTOCOL + SDNC_URL + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
- result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml",
- false);
+ result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml");
executor.logger.info("Data received From " + urlPost1 + " " + result);
if (result == "") {
sdncUpdateResult = false;
@@ -190,8 +188,7 @@ try {
if (sdncUpdateResult == true) {
var urlPost2 = HTTP_PROTOCOL + SDNC_URL
+ "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
- result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml",
- false);
+ result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml");
executor.logger.info("Data received From " + urlPost2 + " " + result);
if (result == "") {
sdncUpdateResult = false;
@@ -265,8 +262,8 @@ try {
if (sdncUpdateResult == true) {
var urlPost3 = HTTP_PROTOCOL + SDNC_URL
+ "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
- result = client.httpRequest(urlPost3, "POST", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD,
- "application/xml", false);
+ result = client
+ .httpRequest(urlPost3, "POST", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD, "application/xml");
executor.logger.info("Data received From " + urlPost3 + " " + result);
if (result == "") {
sdncUpdateResult = false;
@@ -344,4 +341,4 @@ function IsValidJSONString(str) {
}
return true;
}
-/* Utility functions End */
+/* Utility functions End */ \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
index 90b1b0075..871e146a7 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
@@ -28,12 +28,10 @@ executor.logger.info("Begin Execution ServiceUpdateStateCpeAuthTask.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var clEventType = Java.type(
- "org.onap.policy.controlloop.VirtualControlLoopEvent");
+var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent");
var clEvent = executor.inFields.get("VirtualControlLoopEvent");
-var serviceInstanceId = clEvent.getAai().get(
- "service-information.hsia-cfs-service-instance-id");
+var serviceInstanceId = clEvent.getAai().get("service-information.hsia-cfs-service-instance-id");
var requestID = clEvent.getRequestId();
var jsonObj;
@@ -53,8 +51,7 @@ var putUrl;
var service_instance;
var AAI_VERSION = "v14";
try {
- var br = Files.newBufferedReader(Paths.get(
- "/home/apexuser/examples/config/ONAPBBS/config.txt"));
+ var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt"));
var line;
while ((line = br.readLine()) != null) {
if (line.startsWith("AAI_URL")) {
@@ -66,11 +63,11 @@ try {
} else if (line.startsWith("AAI_PASSWORD")) {
var str = line.split("=");
AAI_PASSWORD = str[str.length - 1];
- }else if (line.startsWith("AAI_VERSION")) {
+ } else if (line.startsWith("AAI_VERSION")) {
var str = line.split("=");
AAI_VERSION = str[str.length - 1];
- }
- }
+ }
+ }
} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
}
@@ -79,25 +76,21 @@ executor.logger.info("AAI_URL=>" + AAI_URL);
/* Get service instance Id from AAI */
try {
- var urlGet = HTTP_PROTOCOL + AAI_URL +
- "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" +
- SERVICE_INSTANCE_ID + "?format=resource_and_url"
+ var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/"
+ + SERVICE_INSTANCE_ID + "?format=resource_and_url"
executor.logger.info("Query url" + urlGet);
- result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json");
executor.logger.info("Data received From " + urlGet + " " + result);
jsonObj = JSON.parse(result);
-
/* Retrieve the service instance id */
results = jsonObj['results'][0];
putUrl = results["url"];
service_instance = results['service-instance'];
resource_version = service_instance['resource-version'];
- executor.logger.info("After Parse service_instance " + JSON.stringify(
- service_instance, null, 4) + "\n url " + putUrl +
- "\n Service instace Id " + SERVICE_INSTANCE_ID);
+ executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url "
+ + putUrl + "\n Service instace Id " + SERVICE_INSTANCE_ID);
if (result == "") {
aaiUpdateResult = false;
@@ -112,19 +105,15 @@ var putUpddateServInstance;
putUpddateServInstance = service_instance;
if (newState == 'inService') {
putUpddateServInstance['orchestration-status'] = "active";
-}
-else
-{
+} else {
putUpddateServInstance['orchestration-status'] = "inActive";
}
try {
if (aaiUpdateResult == true) {
- executor.logger.info("ready to put After Parse " + JSON.stringify(
- putUpddateServInstance, null, 4));
- var urlPut = HTTP_PROTOCOL + AAI_URL +
- putUrl + "?resource_version=" + resource_version;
+ executor.logger.info("ready to put After Parse " + JSON.stringify(putUpddateServInstance, null, 4));
+ var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version;
result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,
- "application/json", true);
+ "application/json");
executor.logger.info("Data received From " + urlPut + " " + result);
/* If failure to retrieve data proceed to Failure */
if (result != "") {
@@ -145,4 +134,3 @@ if (aaiUpdateResult == true) {
executor.logger.info(executor.outFields);
var returnValue = executor.isTrue;
executor.logger.info("End Execution ServiceUpdateStateCpeAuthTask.js");
-
diff --git a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
index 2ff9435b2..e7bba5905 100644
--- a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
+++ b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
@@ -53,8 +53,8 @@ public class WebClientTest {
@Test
public void httpsRequest() {
WebClient cl = new WebClient();
- String result = cl.httpRequest("https://some.random.url/data", "POST", null, "admin", "admin",
- "application/json", true);
+ String result =
+ cl.httpRequest("https://some.random.url/data", "POST", null, "admin", "admin", "application/json");
assertNotNull(result);
}
@@ -62,7 +62,7 @@ public class WebClientTest {
public void httpRequest() {
WebClient cl = new WebClient();
String result =
- cl.httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json", false);
+ cl.httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json");
assertNotNull(result);
}