diff options
author | Anand <ac204h@att.com> | 2018-01-04 19:35:51 -0500 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2018-01-08 22:09:50 +0000 |
commit | 36bcd566167f2f91c0e8e7a304fce5f6bc150776 (patch) | |
tree | 7ba7acfee7e520da83a2b6286ea464285bc8cf67 /appc-dispatcher/appc-command-executor/appc-command-executor-api | |
parent | 38d293d605b42f88c9c82319ba848b4b81e45b64 (diff) |
Include impacted changes for APPC-346,APPC-348
Issue-ID: APPC-347
Change-Id: I399bc2a1e0dfd481e103032a373bb80fce5baf41
Signed-off-by: Anand <ac204h@att.com>
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-api')
7 files changed, 141 insertions, 320 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml index d58c7bd6c..2dc3fdbf3 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml @@ -1,44 +1,64 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.appc</groupId> - <artifactId>appc-command-executor</artifactId> - <version>1.3.0-SNAPSHOT</version> - </parent> - <artifactId>appc-command-executor-api</artifactId> - <packaging>bundle</packaging> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Copyright (C) 2017 Amdocs + ============================================================================= + 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 - <name>appc-command-executor-api</name> - <url>http://maven.apache.org</url> + http://www.apache.org/licenses/LICENSE-2.0 - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> + 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. - <dependencies> - <dependency> - <groupId>org.onap.appc</groupId> - <artifactId>execution-queue-management-lib</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.appc</groupId> - <artifactId>domain-model-lib</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.appc</groupId> - <artifactId>appc-common</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - </dependency> - <!--<dependency>--> - <!--<groupId>org.apache.commons</groupId>--> - <!--<artifactId>commons-lang3</artifactId>--> - <!--<version>3.4</version>--> - <!--<scope>provided</scope>--> - <!--</dependency>--> - </dependencies> + ECOMP is a trademark and service mark of AT&T Intellectual Property. + ============LICENSE_END========================================================= + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.appc</groupId> + <artifactId>appc-command-executor</artifactId> + <version>1.3.0-SNAPSHOT</version> + </parent> + + <artifactId>appc-command-executor-api</artifactId> + <packaging>bundle</packaging> + <name>APPC Command Executor - API</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.onap.appc</groupId> + <artifactId>execution-queue-management-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc</groupId> + <artifactId>domain-model-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc</groupId> + <artifactId>appc-common</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> <build> <plugins> <plugin> @@ -48,7 +68,9 @@ <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Version>${project.version}</Bundle-Version> - <Export-Package>org.onap.appc.executor,org.onap.appc.executor.objects,org.onap.appc.executor.conv,org.onap.appc.executor.helper</Export-Package> + <Export-Package> + org.onap.appc.executor,org.onap.appc.executor.objects,org.onap.appc.executor.conv,org.onap.appc.executor.helper + </Export-Package> <Embed-Dependency> javax.json;scope=compile|runtime;inline=false </Embed-Dependency> diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/CommandExecutor.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/CommandExecutor.java index d6935b83a..635c7d265 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/CommandExecutor.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/CommandExecutor.java @@ -28,8 +28,8 @@ package org.onap.appc.executor; -import org.onap.appc.domainmodel.lcm.RuntimeContext; import org.onap.appc.exceptions.APPCException; +import org.onap.appc.executor.objects.CommandExecutorInput; @@ -40,5 +40,5 @@ public interface CommandExecutor { * @param commandHeaderInput Contains CommandHeader, command , target Id , payload and conf ID (optional) * @throws APPCException in case of error. */ - void executeCommand(RuntimeContext commandHeaderInput) throws APPCException; + void executeCommand(CommandExecutorInput commandHeaderInput) throws APPCException; } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/UnstableVNFException.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/UnstableVNFException.java deleted file mode 100644 index 634bd0f68..000000000 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/UnstableVNFException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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/onap/appc/executor/conv/Converter.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/conv/Converter.java deleted file mode 100644 index 3cfc7ece7..000000000 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/conv/Converter.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.executor.conv; - -import java.io.IOException; - -import org.onap.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/onap/appc/executor/objects/CommandResponse.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/CommandExecutorInput.java index 4e7b9b17f..7cd79ba2c 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/CommandResponse.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/CommandExecutorInput.java @@ -26,17 +26,32 @@ package org.onap.appc.executor.objects; import org.onap.appc.domainmodel.lcm.RuntimeContext; +public class CommandExecutorInput { + private RuntimeContext runtimeContext ; + private int ttl; -public class CommandResponse { - private final RuntimeContext runtimeContext; + public RuntimeContext getRuntimeContext() { + return runtimeContext; + } - public CommandResponse(RuntimeContext runtimeContext) { - super(); + public void setRuntimeContext(RuntimeContext runtimeContext) { this.runtimeContext = runtimeContext; } - public RuntimeContext getRuntimeContext() { - return 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/onap/appc/executor/objects/LCMCommandStatus.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/LCMCommandStatus.java index 849b5b08f..b9430cc97 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/LCMCommandStatus.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/LCMCommandStatus.java @@ -24,97 +24,91 @@ package org.onap.appc.executor.objects; - -import org.onap.appc.domainmodel.lcm.Status; import org.onap.appc.util.MessageFormatter; import java.util.Map; public enum LCMCommandStatus { - ACCEPTED(100,"ACCEPTED - request accepted"), + 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}"), - INVALID_VNF_STATE(305,"Request rejected because VNF status in A&AI is - ${currentState}" ), - 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"), - MISSING_VNF_DATA_IN_AAI(313,"MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"), - - SUCCESS(400,"SUCCESS - request has been processed successfully"), - + 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}"), + /* + * TODO: Change responseMessage from "INVALID INPUT PARAMETER" to "INVALID INPUT PARAMETER(S)" tracked ATTAPPC-4863 + * + * With consideration of updating integration test case effort, "INVALID INPUT PARAMETER" is used while the task + * ATTAPPC-4863 is tracking the need of this change when resource is available. + * + * However, when pushing this file to ONAP, responseMessage should be changed to "INVALID INPUT PARAMETER(S)", + * and this comments should be removed. + */ + // TODO 77777777 to support "${paramName} with invalid value ${paramValue}" + INVALID_INPUT_PARAMETER(301, "INVALID INPUT PARAMETER - ${errorMsg}"), + MISSING_MANDATORY_PARAMETER(302, "MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ), + REQUEST_PARSING_FAILED(303, "REQUEST PARSING FAILED - ${errorMsg}"), + 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"), + EXPIRED_REQUEST(311, "EXPIRED REQUEST"), + DUPLICATE_REQUEST(312, "DUPLICATE REQUEST"), + MISSING_VNF_DATA_IN_AAI(313, "MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"), + VSERVER_NOT_FOUND(314, "VSERVER NOT FOUND - vserver with ID ${id} was not found"), + MULTIPLE_REQUESTS_FOUND(315, "MULTIPLE REQUESTS FOUND - using search criteria: ${parameters}"), + POLICY_VALIDATION_FAILURE(316,"POLICY VALIDATION FAILURE - ${errorMsg}"), + EXLCUSIVE_REQUEST_IN_PROGRESS(317,"EXCLUSIVE REQUEST IN PROGRESS - ${errorMsg}"), + LOCKED_VNF_ID(318,"${errorMsg}"), + + SUCCESS(400, "SUCCESS - request has been processed successfully"), + + //ERROR(4xx) - failure for Async response + DG_FAILURE(401, "DG FAILURE - ${errorMsg}"), + EXPIRED_REQUEST_FAILURE(404, "EXPIRED REQUEST FAILURE - failed after accepted because TTL expired"); + + + //ERROR(5xx) - failure for Intermediate response // 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; - - + 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 responseMessage; + } + public int getResponseCode() { + return responseCode; + } - /** - * - * @return messageTemplate + /** + * @return messageTemplate */ + public String getFormattedMessage(Params params) { + Map<String, Object> paramsMap = params != null ? params.getParams() : null; + return MessageFormatter.format(getResponseMessage(), paramsMap); + } - - 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); + public String getFormattedMessageWithCode(Params params) { + return getResponseCode() + "-" + getFormattedMessage(params); } @Override public String toString() { return "LCMCommandStatus{" + - "responseCode=" + responseCode + - ", responseMessage='" + responseMessage + '\'' + - '}'; - } - - public Status toStatus(Params params) { - return new Status(responseCode, getFormattedMessage(params)); + "responseCode=" + responseCode + + ", responseMessage='" + responseMessage + '\'' + + '}'; } } - diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/UniqueRequestIdentifier.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/UniqueRequestIdentifier.java deleted file mode 100644 index b2f2a1d89..000000000 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/onap/appc/executor/objects/UniqueRequestIdentifier.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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; - } - - -} |