aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-command-executor/appc-command-executor-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-api/src')
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/CommandExecutor.java41
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/UnstableVNFException.java29
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/conv/Converter.java49
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandExecutorInput.java54
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandResponse.java38
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java112
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/Params.java57
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/UniqueRequestIdentifier.java123
8 files changed, 503 insertions, 0 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/CommandExecutor.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/CommandExecutor.java
new file mode 100644
index 000000000..ac5223b93
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/CommandExecutor.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ *
+ */
+package org.openecomp.appc.executor;
+
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.executor.objects.CommandExecutorInput;
+
+
+
+public interface CommandExecutor {
+ /**
+ * Execute given command
+ * Create command request and enqueue it for execution.
+ * @param commandHeaderInput Contains CommandHeader, command , target Id , payload and conf ID (optional)
+ * @throws APPCException in case of error.
+ */
+ void executeCommand(CommandExecutorInput commandHeaderInput) throws APPCException;
+}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/UnstableVNFException.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/UnstableVNFException.java
new file mode 100644
index 000000000..3727cdb40
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/UnstableVNFException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor;
+
+
+public class UnstableVNFException extends Exception{
+ public UnstableVNFException(String message){
+ super(message);
+ }
+}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/conv/Converter.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/conv/Converter.java
new file mode 100644
index 000000000..a9991e43e
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/conv/Converter.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.conv;
+
+import java.io.IOException;
+
+import org.openecomp.appc.executor.objects.Params;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class Converter {
+
+ public static Params convJsonStringToParams(String inObj) throws IOException {
+ Params outObj = null;
+ if(inObj != null) {
+ outObj = new ObjectMapper().readValue(inObj, Params.class);
+ }
+ return outObj;
+ }
+
+ public static String convParamsToJsonString(Params inObj) throws JsonProcessingException {
+ String outObj = null;
+ if(inObj != null) {
+ outObj = new ObjectMapper().writeValueAsString(inObj);
+ }
+ return outObj;
+ }
+}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandExecutorInput.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandExecutorInput.java
new file mode 100644
index 000000000..4cb5f1b99
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandExecutorInput.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.objects;
+
+import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
+
+public class CommandExecutorInput {
+ private RuntimeContext runtimeContext ;
+ private int ttl;
+
+
+ public RuntimeContext getRuntimeContext() {
+ return runtimeContext;
+ }
+
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ public int getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(int ttl) {
+ this.ttl = ttl;
+ }
+
+ @Override
+ public String toString() {
+ return "CommandExecutorInput{" +
+ "runtimeContext=" + runtimeContext +
+ ", ttl=" + ttl +
+ '}';
+ }
+}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandResponse.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandResponse.java
new file mode 100644
index 000000000..c973fcde1
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/CommandResponse.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.objects;
+
+import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
+
+
+public class CommandResponse {
+
+ private RuntimeContext runtimeContext;
+
+ public RuntimeContext getRuntimeContext() {
+ return runtimeContext;
+ }
+
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+}
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
new file mode 100644
index 000000000..4e3a40e75
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.objects;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.util.MessageFormatter;
+
+import java.util.Map;
+
+public enum LCMCommandStatus {
+
+ ACCEPTED(100,"ACCEPTED - request accepted"),
+
+ //ERROR(2xx) – request can’t be handled due to some technical error
+ UNEXPECTED_ERROR(200,"UNEXPECTED ERROR - ${errorMsg}"),
+
+ //REJECT(3xx) – request has been rejected due to some business reason (e.g. no such service-instance-id, command is not supported, etc)
+ REJECTED(300,"REJECTED - ${errorMsg}"),
+ INVALID_INPUT_PARAMETER(301,"INVALID INPUT PARAMETER - ${errorMsg}"),// TODO 77777777 to support "${paramName} with invalid value ${paramValue}"
+ MISSING_MANDATORY_PARAMETER(302,"MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ),
+ REQUEST_PARSING_FAILED(303,"REQUEST PARSING FAILED - ${errorMsg}"),
+ NO_TRANSITION_DEFINE(304,"ACTION IS NOT ALLOWED - Action ${actionName} is not allowed for VNF in state ${currentState}"),
+ ACTION_NOT_SUPPORTED(305,"ACTION NOT SUPPORTED - ${actionName} action is not supported" ),
+ VNF_NOT_FOUND(306,"VNF NOT FOUND - VNF with ID ${vnfId} was not found" ),
+ DG_WORKFLOW_NOT_FOUND(307,"DG WORKFLOW NOT FOUND - No DG workflow found for the combination of ${dgModule} module ${dgName} name and ${dgVersion} version"),//TODO need to support it
+ WORKFLOW_NOT_FOUND(308,"WORKFLOW NOT FOUND - No workflow found for VNF type ${vnfTypeVersion} and ${actionName} action"),
+ UNSTABLE_VNF(309,"UNSTABLE VNF - VNF ${vnfId} is not stable to accept the command"),
+ LOCKING_FAILURE(310,"LOCKING FAILURE - ${errorMsg}" ),
+ EXPIRED_REQUEST(311,"EXPIRED REQUEST"),
+ DUPLICATE_REQUEST(312,"DUPLICATE REQUEST"),
+
+ SUCCESS(400,"SUCCESS - request has been processed successfully"),
+
+
+ // FAILURE(5xx) – request processing results with failure. The FAILURE response is always transmitted asynchronously, via DMaaP.
+ DG_FAILURE(401,"DG FAILURE - ${errorMsg}"),
+ NO_TRANSITION_DEFINE_FAILURE(402,"NO TRANSITION DEFINE - No Transition Defined for ${actionName} action and ${currentState} state"),
+ UPDATE_AAI_FAILURE(403,"UPDATE_AAI_FAILURE - failed to update AAI. ${errorMsg}"),
+ EXPIRED_REQUEST_FAILURE(404,"EXPIRED REQUEST FAILURE - failed after accepted because TTL expired"),
+ UNEXPECTED_FAILURE(405,"UNEXPECTED FAILURE - ${errorMsg}"),
+ UNSTABLE_VNF_FAILURE(406,"UNSTABLE VNF FAILURE - VNF ${vnfId} is not stable to accept the command"),
+
+ ;
+
+
+ public static final String errorDgMessageParamName = "errorDgMessage";
+
+ private int responseCode;
+ private String responseMessage;
+
+
+
+
+ LCMCommandStatus(int responseCode, String responseMessage) {
+ this.responseCode = responseCode;
+ this.responseMessage = responseMessage;
+ }
+
+ public String getResponseMessage() {
+ return responseMessage;
+ }
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+
+ /**
+ *
+ * @return messageTemplate
+ */
+
+
+ public String getFormattedMessage(Params params){
+ Map<String,Object> paramsMap = params != null ? params.getParams() : null;
+ return MessageFormatter.format(getResponseMessage(),paramsMap);
+
+ }
+
+ public String getFormattedMessageWithCode(Params params){
+ return getResponseCode()+"-" + getFormattedMessage(params);
+ }
+
+ @Override
+ public String toString() {
+ return "LCMCommandStatus{" +
+ "responseCode=" + responseCode +
+ ", responseMessage='" + responseMessage + '\'' +
+ '}';
+ }
+}
+
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/Params.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/Params.java
new file mode 100644
index 000000000..8db4f6576
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/Params.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.objects;
+
+import java.lang.Object;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class Params {
+ public static final String paramDgNameSpace = "dg.status.message.param.";
+ public static final String errorDgMessageParamName = "errorDgMessage";
+ private Map<String, java.lang.Object> params;
+
+ public Params() {
+ }
+
+ public Map<String, java.lang.Object> getParams() {
+ return params;
+ }
+
+ public void setParams(Map<String, java.lang.Object> params) {
+ this.params = params;
+ }
+
+ public Params addParam(String paramName, java.lang.Object paramValue) {
+ params = params == null ? new HashMap<String, Object>() : params;
+ params.put(paramName, paramValue);
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "Params{" +
+ "params=" + params +
+ '}';
+ }
+}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/UniqueRequestIdentifier.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/UniqueRequestIdentifier.java
new file mode 100644
index 000000000..0e33ca4c2
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/UniqueRequestIdentifier.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.executor.objects;
+
+
+import org.apache.commons.lang3.StringUtils;
+
+
+public class UniqueRequestIdentifier {
+ private static final String IDENTIFIER_DELIMITER = "@";
+
+ private String originatorID;
+ private String requestID;
+ private String subRequestID;
+
+ private UniqueRequestIdentifier(){
+
+ }
+ public UniqueRequestIdentifier(String originatorID,
+ String requestID,
+ String subRequestID) {
+ this();
+ this.originatorID = originatorID;
+ this.requestID = requestID;
+ this.subRequestID = subRequestID;
+ }
+
+ public String toIdentifierString(){
+ StringBuilder stringBuilder = new StringBuilder();
+ if(originatorID != null){
+ stringBuilder.append(originatorID);
+ }
+ stringBuilder.append(IDENTIFIER_DELIMITER);
+
+ if(requestID != null){
+ stringBuilder.append(requestID);
+ }
+ stringBuilder.append(IDENTIFIER_DELIMITER);
+
+ if(subRequestID != null){
+ stringBuilder.append(subRequestID);
+ }
+ return stringBuilder.toString();
+ }
+
+ public static UniqueRequestIdentifier getUniqueRequestIdentifier(String identifierString){
+ String[] splitIdentifier = identifierString.split(IDENTIFIER_DELIMITER);
+ if(splitIdentifier == null || splitIdentifier.length <2){
+ throw new IllegalArgumentException("input identifierString is not valid "+identifierString);
+ }
+ String originatorID = splitIdentifier[0];
+ String requestID = StringUtils.isEmpty(splitIdentifier[1])? null :splitIdentifier[1];
+ String subRequestID = splitIdentifier.length>=3 ? splitIdentifier[2] : null;
+ return new UniqueRequestIdentifier(originatorID,requestID,subRequestID);
+ }
+ public String toString(){
+ return "originatorID = " + originatorID +
+ " , requestID = " + requestID +
+ " , subRequestID = " + subRequestID;
+ }
+ @Override
+ public boolean equals(Object obj){
+ if(obj ==null){
+ return false;
+ }
+ if(!(obj instanceof UniqueRequestIdentifier)){
+ return false;
+ }
+ UniqueRequestIdentifier identifier = (UniqueRequestIdentifier)obj;
+ if(this.originatorID == null){
+ if(identifier.originatorID !=null)
+ return false;
+ }
+ else if(!this.originatorID.equals(identifier.originatorID))
+ return false;
+
+ if(this.requestID == null){
+ if(identifier.requestID !=null)
+ return false;
+ }
+ else if(!this.requestID.equals(identifier.requestID))
+ return false;
+
+ if(this.subRequestID == null){
+ if(identifier.subRequestID !=null)
+ return false;
+ }
+ else if(!this.subRequestID.equals(identifier.subRequestID))
+ return false;
+
+ return true;
+ }
+ @Override
+ public int hashCode(){
+ final int prime = 31;
+ int result = 1;
+ result = result * prime + (this.originatorID == null ? 0 :this.originatorID.hashCode());
+ result = result * prime + (this.requestID == null ? 0 :this.requestID.hashCode());
+ result = result * prime + (this.subRequestID == null ? 0 :this.subRequestID.hashCode());
+ return result;
+ }
+
+
+}