aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-command-executor
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-04-20 21:10:43 +0000
committerGerrit Code Review <gerrit@onap.org>2017-04-20 21:10:43 +0000
commitb06810bb67667edb0d9d9087cc1f978bda988c87 (patch)
tree3d5bdba464b3156a4ba24c03aa83897816985171 /appc-dispatcher/appc-command-executor
parentf061217a2cfe6030cf147c852a4d6d183e7fb2e0 (diff)
parentc9373d8f5809fe650c30832e9409282cb34688f8 (diff)
Merge "Refactor Status to be immutable"
Diffstat (limited to 'appc-dispatcher/appc-command-executor')
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java5
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java4
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java9
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java6
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java9
5 files changed, 13 insertions, 20 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
index 4e3a40e75..14bd8152c 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
@@ -23,6 +23,7 @@ package org.openecomp.appc.executor.objects;
import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.domainmodel.lcm.Status;
import org.openecomp.appc.util.MessageFormatter;
import java.util.Map;
@@ -108,5 +109,9 @@ public enum LCMCommandStatus {
", responseMessage='" + responseMessage + '\'' +
'}';
}
+
+ public Status toStatus(Params params) {
+ return new Status(responseCode, getFormattedMessage(params));
+ }
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
index 6418002c2..0037434ff 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
@@ -119,8 +119,4 @@ public abstract class CommandTask<M> implements Runnable {
this.onRequestCompletion(commandRequest,commandResponse);
}
- public static void fillStatus(Status status, LCMCommandStatus lcmCommandStatus, Params params) {
- status.setCode(lcmCommandStatus.getResponseCode());
- status.setMessage(lcmCommandStatus.getFormattedMessage(params));
- }
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
index 6e64a546b..9f7c13513 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
@@ -147,22 +147,19 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
isAAIUpdated= postVnfdata(vnfId, nextState,"onRequestExecutionStart",ctx);
} catch (NoTransitionDefinedException e) {
logger.error("Error getting Next State for AAI Update: " + e.getMessage(), e);
- Status status = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus();
Params params = new Params().addParam("actionName",e.event).addParam("currentState",e.currentState);
- fillStatus(status, LCMCommandStatus.NO_TRANSITION_DEFINE_FAILURE, params);
+ request.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.NO_TRANSITION_DEFINE_FAILURE.toStatus(params));
isAAIUpdated = false;
} catch (UnstableVNFException e) {
logger.error(e.getMessage(), e);
- Status status = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus();
Params params = new Params().addParam("vnfId",vnfId);
- fillStatus(status, LCMCommandStatus.UNSTABLE_VNF_FAILURE, params);
+ request.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params));
isAAIUpdated = false;
}catch (Exception e) {
logger.error("Error before Request Execution starts.", e);
- Status status = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus();
String errorMsg = StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage();
Params params = new Params().addParam("errorMsg",errorMsg);
- fillStatus(status, LCMCommandStatus.UNEXPECTED_FAILURE, params);
+ request.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
isAAIUpdated = false;
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java
index 137a2e4b5..201662a6c 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java
@@ -67,15 +67,13 @@ public class LCMReadonlyCommandTask extends CommandTask<LCMReadOnlyCommandReques
super.execute();
} catch (UnstableVNFException e) {
logger.error(e.getMessage(), e);
- Status status = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus();
Params params = new Params().addParam("vnfId",vnfId);
- fillStatus(status, LCMCommandStatus.UNSTABLE_VNF_FAILURE, params);
+ request.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params));
}catch (Exception e) {
logger.error("Error during runing LCMReadonlyCommandTask.", e);
- Status status = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus();
String errorMsg = StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage();
Params params = new Params().addParam("errorMsg",errorMsg);
- fillStatus(status, LCMCommandStatus.UNEXPECTED_FAILURE, params);
+ request.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
}
}
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
index cd0167934..3e01c758b 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
@@ -191,9 +191,7 @@ public class TestCommandExecutionTask {
requestContext.setAction(action);
runtimeContext.setRpcName(action.name().toLowerCase());
commonHeader.setApiVer(API_VERSION);
- Status status = new Status();
- status.setCode(100);
- responseContext.setStatus(status);
+ responseContext.setStatus(new Status(100, null));
commonHeader.setRequestId(responseId);
responseContext.setPayload(payload);
commonHeader.setTimestamp(new Date());
@@ -246,7 +244,7 @@ public class TestCommandExecutionTask {
ResponseContext responseContext = createResponseContextWithSuObjects();
wfResponse.setResponseContext(responseContext);
responseContext.setPayload("");
- wfResponse.getResponseContext().getStatus().setCode(100);
+ wfResponse.getResponseContext().setStatus(new Status(100, null));
return wfResponse;
}
@@ -300,9 +298,8 @@ public class TestCommandExecutionTask {
ResponseContext responseContext = new ResponseContext();
CommonHeader commonHeader = new CommonHeader();
Flags flags = new Flags();
- Status status = new Status();
responseContext.setCommonHeader(commonHeader);
- responseContext.setStatus(status);
+ responseContext.setStatus(new Status(0, null));
commonHeader.setFlags(flags);
return responseContext;
}