summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/main')
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java2
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java2
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java3
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java28
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java44
5 files changed, 48 insertions, 31 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java
index a267baf2d..2eb75ff7a 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java
@@ -77,7 +77,7 @@ public class Transaction {
private String status = "PENDING";
- public String getuId() {
+ public String getId() {
return uId;
}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
index 011ac973a..2f64a21c6 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
@@ -65,7 +65,7 @@ public class RestExecutor implements FlowExecutorInterface {
HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(getHostnameVerifier(), sslContext));
client = createClient(defaultClientConfig);
- client.addFilter(new HTTPBasicAuthFilter(transaction.getuId(), transaction.getPswd()));
+ client.addFilter(new HTTPBasicAuthFilter(transaction.getId(), transaction.getPswd()));
WebResource webResource = client.resource(new URI(transaction.getExecutionEndPoint()));
webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
index 3cfea31a2..0745f20ea 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
@@ -21,8 +21,7 @@ class ResourceUriExtractor {
private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class);
- private ResourceUriExtractor() {
- }
+ private ResourceUriExtractor() {}
static String extractResourceUri(SvcLogicContext ctx, Properties prop) throws Exception {
String resourceUri = ctx.getAttribute(INPUT_URL);
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
index 9d7f6e879..3597e0d18 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
@@ -24,8 +24,6 @@ package org.onap.appc.flow.controller.node;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.APPC_FLOW_CONTROLLER;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PARAM_RESPONSE_PREFIX;
-import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
-import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_STATUS;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_STATUS_FAILURE;
@@ -85,31 +83,7 @@ public class RestServiceNode implements SvcLogicJavaPlugin {
String resourceUri = ResourceUriExtractor.extractResourceUri(ctx, prop);
log.info("Rest Constructed URL : " + resourceUri);
- Transaction transaction = new Transaction();
- transaction.setExecutionEndPoint(resourceUri);
- transaction
- .setExecutionRPC(ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE));
- transaction.setAction(INPUT_REQUEST_ACTION);
- if (ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE) == null
- || ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE).isEmpty()) {
- throw new Exception("Dont know REST operation for Action " + transaction.getExecutionRPC());
- }
- if (ctx.getAttribute(INPUT_REQUEST_ACTION) == null
- || ctx.getAttribute(INPUT_REQUEST_ACTION).isEmpty()) {
- throw new Exception("Dont know request-action " + transaction.getAction());
- }
-
- //This code need to get changed to get the UserID and pass from a common place.
- if (transaction.getuId() == null) {
- transaction
- .setuId(prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION)
- .concat(".default-rest-user")));
- }
- if (transaction.getPswd() == null) {
- transaction
- .setPswd(prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION)
- .concat(".default-rest-pass")));
- }
+ Transaction transaction = TransactionHandler.buildTransaction(ctx, prop, resourceUri);
RestExecutor restRequestExecutor = new RestExecutor();
Map<String, String> output = restRequestExecutor.execute(transaction, ctx);
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java
new file mode 100644
index 000000000..8d10b3c7f
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java
@@ -0,0 +1,44 @@
+package org.onap.appc.flow.controller.node;
+
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE;
+
+import java.util.Properties;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+/**
+ * Helper class for RestServiceNode
+ */
+class TransactionHandler {
+
+ private TransactionHandler() {}
+
+ static Transaction buildTransaction(SvcLogicContext ctx, Properties prop,
+ String resourceUri) throws Exception {
+
+ String inputRequestAction = ctx.getAttribute(INPUT_REQUEST_ACTION);
+ String inputRequestActionType = ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE);
+
+ if (StringUtils.isBlank(inputRequestActionType)) {
+ throw new IllegalArgumentException(
+ "Don't know REST operation for Action " + inputRequestActionType);
+ }
+ if (StringUtils.isBlank(inputRequestAction)) {
+ throw new IllegalArgumentException("Don't know request-action " + INPUT_REQUEST_ACTION);
+ }
+
+ Transaction transaction = new Transaction();
+ transaction.setExecutionEndPoint(resourceUri);
+ transaction.setExecutionRPC(inputRequestActionType);
+ transaction.setAction(INPUT_REQUEST_ACTION);
+
+ //This code need to get changed to get the UserID and pass from a common place.
+ transaction.setuId(prop.getProperty(inputRequestAction.concat(".default-rest-user")));
+ transaction.setPswd(prop.getProperty(inputRequestAction.concat(".default-rest-pass")));
+
+ return transaction;
+ }
+
+} \ No newline at end of file