aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-command-executor/appc-command-executor-api
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-api')
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/.gitignore1
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml60
-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
11 files changed, 568 insertions, 0 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/.gitignore b/appc-dispatcher/appc-command-executor/appc-command-executor-api/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-api/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
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
new file mode 100644
index 000000000..645f0b630
--- /dev/null
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml
@@ -0,0 +1,60 @@
+<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.openecomp.appc</groupId>
+ <artifactId>appc-command-executor</artifactId>
+ <version>1.0.0</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.openecomp.appc</groupId>
+ <artifactId>execution-queue-management-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>domain-model-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--<dependency>-->
+ <!--<groupId>org.apache.commons</groupId>-->
+ <!--<artifactId>commons-lang3</artifactId>-->
+ <!--<version>3.4</version>-->
+ <!--<scope>provided</scope>-->
+ <!--<type>bundle</type>-->
+ <!--</dependency>-->
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Version>${project.version}</Bundle-Version>
+ <Export-Package>org.openecomp.appc.executor,org.openecomp.appc.executor.objects,org.openecomp.appc.executor.conv,org.openecomp.appc.executor.helper</Export-Package>
+ <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic,javax.json;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ <Import-Package>!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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;
+ }
+
+
+}