aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java68
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java71
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java49
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java47
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java)70
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java24
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java167
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java11
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java29
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java51
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java27
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java27
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java33
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java54
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java147
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java226
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java40
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java30
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java31
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java74
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java109
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java69
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java76
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java58
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java58
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java166
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java96
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java94
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java133
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java39
43 files changed, 2352 insertions, 66 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
index 214ae28b70..49e42acaf6 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
@@ -108,7 +108,7 @@ public abstract class AbstractCallbackService {
protected boolean correlate(String messageEventName, String correlationVariable,
String correlationValue, Map<String, Object> variables, String logMarker)
throws Exception {
-
+ try{
LOGGER.debug(logMarker + " Attempting to find process waiting"
+ " for " + messageEventName + " with " + correlationVariable
+ " = '" + correlationValue + "'");
@@ -240,6 +240,16 @@ public abstract class AbstractCallbackService {
LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
MsoLogger.ErrorCode.UnknownError, msg, e);
}
+ } catch (Exception e) {
+ // This must be an exception from the flow itself. Log it, but don't
+ // report it back to the client.
+ String msg = "Caught " + e.getClass().getSimpleName() + " after receiving " + messageEventName
+ + " with " + correlationVariable + " = '" + correlationValue
+ + "': " + e;
+ LOGGER.debug(msg);
+ LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN CORRELATION ERROR -", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, msg, e);
+ }
return true;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
index 1bd1dfde70..382d2b7feb 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -21,8 +21,6 @@ package org.openecomp.mso.bpmn.common.workflow.service;
import java.util.HashMap;
import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
import java.util.UUID;
import javax.ws.rs.Consumes;
@@ -33,6 +31,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.ProcessEngines;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
@@ -53,15 +52,15 @@ import org.slf4j.MDC;
* For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process
*/
@Path("/async")
-public abstract class WorkflowAsyncResource {
+public class WorkflowAsyncResource {
- private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
- protected Optional<ProcessEngineServices> pes4junit = Optional.empty();
+ private WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
+ protected ProcessEngineServices pes4junit = null;
- private final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
private static final String logMarker = "[WRKFLOW-RESOURCE]";
- private static final long DEFAULT_WAIT_TIME = 30000; //default wait time
+ private static final int DEFAULT_WAIT_TIME = 30000; //default wait time
/**
* Asynchronous JAX-RS method that starts a process instance.
@@ -76,6 +75,7 @@ public abstract class WorkflowAsyncResource {
public void startProcessInstanceByKey(final @Suspend(180000) AsynchronousResponse asyncResponse,
@PathParam("processKey") String processKey, VariableMapImpl variableMap) {
+ WorkflowResponse response = new WorkflowResponse();
long startTime = System.currentTimeMillis();
Map<String, Object> inputVariables = null;
WorkflowContext workflowContext = null;
@@ -107,7 +107,6 @@ public abstract class WorkflowAsyncResource {
}
msoLogger.debug(logMarker + "Exception in startProcessInstance by key");
- WorkflowResponse response = new WorkflowResponse();
response.setMessage("Fail" );
response.setResponse("Error occurred while executing the process: " + e);
response.setMessageCode(500);
@@ -206,28 +205,29 @@ public abstract class WorkflowAsyncResource {
return contextHolder.processCallback(processKey, processInstanceId, requestId, callbackResponse);
}
- private static String getOrCreate(Map<String, Object> inputVariables, String key) {
- String value = Objects.toString(inputVariables.get(key), null);
- if (value == null) {
- value = UUID.randomUUID().toString();
- inputVariables.put(key, value);
- }
- return value;
- }
-
// Note: the business key is used to identify the process in unit tests
- private static String getBusinessKey(Map<String, Object> inputVariables) {
- return getOrCreate(inputVariables, "mso-business-key");
+ private String getBusinessKey(Map<String, Object> inputVariables) {
+ Object businessKey = inputVariables.get("mso-business-key");
+ if (businessKey == null ) {
+ businessKey = UUID.randomUUID().toString();
+ inputVariables.put("mso-business-key", businessKey);
+ }
+ return businessKey.toString();
}
- private static String getRequestId(Map<String, Object> inputVariables) {
- return getOrCreate(inputVariables, "mso-request-id");
+ private String getRequestId(Map<String, Object> inputVariables) {
+ Object requestId = inputVariables.get("mso-request-id");
+ if (requestId == null ) {
+ requestId = UUID.randomUUID().toString();
+ inputVariables.put("mso-request-id", requestId);
+ }
+ return requestId.toString();
}
private long getWaitTime(Map<String, Object> inputVariables)
{
-
- String timeout = Objects.toString(inputVariables.get("mso-service-request-timeout"), null);
+ String timeout = inputVariables.get("mso-service-request-timeout") == null
+ ? null : inputVariables.get("mso-service-request-timeout").toString();
if (timeout != null) {
try {
@@ -252,7 +252,7 @@ public abstract class WorkflowAsyncResource {
}
- private static void setLogContext(String processKey,
+ private void setLogContext(String processKey,
Map<String, Object> inputVariables) {
MsoLogger.setServiceName("MSO." + processKey);
if (inputVariables != null) {
@@ -260,24 +260,32 @@ public abstract class WorkflowAsyncResource {
}
}
- private static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
+ private String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
if (inputVariables == null) return "";
- return Objects.toString(inputVariables.get(key), "N/A");
+ Object requestId = inputVariables.get(key);
+ if (requestId != null) return requestId.toString();
+ return "N/A";
}
private boolean isProcessEnded(String processInstanceId) {
ProcessEngineServices pes = getProcessEngineServices();
- return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null;
+ return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
}
- protected abstract ProcessEngineServices getProcessEngineServices();
+ protected ProcessEngineServices getProcessEngineServices() {
+ if (pes4junit == null) {
+ return ProcessEngines.getDefaultProcessEngine();
+ } else {
+ return pes4junit;
+ }
+ }
public void setProcessEngineServices4junit(ProcessEngineServices pes) {
- pes4junit = Optional.ofNullable(pes);
+ pes4junit = pes;
}
- private static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
+ private Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
Map<String, Object> inputVariables = new HashMap<String,Object>();
@SuppressWarnings("unchecked")
Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java
index 93aa15c59a..3d7e333fdf 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java
@@ -72,7 +72,7 @@ public class WorkflowContext implements Delayed {
@Override
public long getDelay(TimeUnit unit) {
// 0 or negative means this object is considered to be expired
- return unit.convert(startTime + timeout - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+ return unit.convert(startTime + timeout - System.currentTimeMillis(), unit);
}
/**
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
index a9a9f4b12d..8d049634c7 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
@@ -255,7 +255,11 @@ public class WorkflowResource {
*/
private boolean isProcessEnded(String processInstanceId) {
ProcessEngineServices pes = getProcessEngineServices();
- return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
+ try {
+ return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
+ } catch (Exception e) {
+ return true;
+ }
}
private void processResponseMap(WorkflowResponse workflowResponse, Map<String, Object> responseMap) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
index d6c9b51cd6..89f9f28901 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
@@ -41,7 +41,7 @@ public class WorkflowResourceApplication extends Application {
public WorkflowResourceApplication() {
singletons.add(new WorkflowResource());
- singletons.add(new WorkflowAsyncCommonResource());
+ singletons.add(new WorkflowAsyncResource());
singletons.add(new WorkflowMessageResource());
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
new file mode 100644
index 0000000000..3189d4467d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
@@ -0,0 +1,71 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.NotSupportedException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+import org.openecomp.mso.client.aai.entities.AAIError;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+@Priority(value = 1)
+public class AAIClientResponseExceptionMapper implements ClientResponseFilter {
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ if (responseContext.getStatus() != Response.Status.OK.getStatusCode() && responseContext.hasEntity()) {
+ AAIError error = new ObjectMapper().readValue(responseContext.getEntityStream(), AAIError.class);
+ String message = error.getRequestError().getServiceException().getText();
+
+ Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus());
+ WebApplicationException webAppException;
+ switch (status) {
+ case BAD_REQUEST:
+ webAppException = new BadRequestException(message);
+ break;
+ case UNAUTHORIZED:
+ webAppException = new NotAuthorizedException(message);
+ break;
+ case FORBIDDEN:
+ webAppException = new ForbiddenException(message);
+ break;
+ case NOT_FOUND:
+ webAppException = new NotFoundException(message);
+ break;
+ case METHOD_NOT_ALLOWED:
+ webAppException = new NotAllowedException(message);
+ break;
+ case NOT_ACCEPTABLE:
+ webAppException = new NotAcceptableException(message);
+ break;
+ case UNSUPPORTED_MEDIA_TYPE:
+ webAppException = new NotSupportedException(message);
+ break;
+ case INTERNAL_SERVER_ERROR:
+ webAppException = new InternalServerErrorException(message);
+ break;
+ case SERVICE_UNAVAILABLE:
+ webAppException = new WebApplicationException(message);
+ break;
+ default:
+ webAppException = new WebApplicationException(message);
+ }
+ throw webAppException;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java
new file mode 100644
index 0000000000..83435a8c69
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.mso.client.aai;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+@Provider
+public class AAICommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
+
+ final ObjectMapper mapper;
+
+ public AAICommonObjectMapperProvider() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java
new file mode 100644
index 0000000000..a6d693b02a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.mso.client.aai;
+
+import javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+
+@Provider
+public class AAIQueryObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIQueryObjectMapperProvider() {
+ super();
+ AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+ AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
+ // first Jaxb, second Jackson annotations
+ mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
index f3ad810a3e..339fea5067 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
@@ -1,32 +1,38 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * 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.mso.bpmn.common.workflow.service;
-
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.ProcessEngines;
-
-
-public class WorkflowAsyncCommonResource extends WorkflowAsyncResource {
-
- protected ProcessEngineServices getProcessEngineServices() {
- return pes4junit.orElse(ProcessEngines.getProcessEngine("common"));
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.mso.client.aai;
+
+import javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIResourcesObjectMapperProvider() {
+ super();
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
new file mode 100644
index 0000000000..8d96437e68
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
@@ -0,0 +1,24 @@
+package org.openecomp.mso.client.aai;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.openecomp.aai.domain.yang.Pservers;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public interface AAIRestClient {
+
+ Pservers getPhysicalServers(String hostName, String uuid);
+
+ List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException;
+
+ void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws Exception;
+
+ void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception;
+
+ GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception;
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
new file mode 100644
index 0000000000..99024490a3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
@@ -0,0 +1,167 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.GenericVnfs;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.openecomp.aai.domain.yang.Pservers;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.entities.Results;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.springframework.stereotype.Service;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Service
+public class AAIRestClientImpl implements AAIRestClient {
+
+ private final WebTarget webTarget;
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+
+ private static final String ENDPOINT_VERSION = "v10";
+ private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers";
+ private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs";
+ private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query";
+ private static final String PSERVER_BY_VNF_QUERY = "g.V().has('aai-node-type', 'generic-vnf').has('vnf-name','USAUTOUFTIL2001UJDM02').out('runsOnPserver').has('aai-node-type', 'pserver')";
+ private static final String PSERVER_VNF_QUERY = "pservers-fromVnf";
+ private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf";
+ private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union("
+ + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’),"
+ + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
+ + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union("
+ + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’),"
+ + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’),"
+ + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
+ + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()";
+
+ public AAIRestClientImpl() throws NoSuchAlgorithmException {
+
+ Logger logger = Logger.getLogger(getClass().getName());
+ Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ Client client = this.getSSLClient();
+ webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper())
+ .target(properties.get("aai.endpoint") + "/aai");
+ }
+
+ public AAIRestClientImpl(final String host) throws NoSuchAlgorithmException {
+ Logger logger = Logger.getLogger(getClass().getName());
+ Client client = this.getSSLClient();
+ Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper()).target(host + "/aai");
+ }
+
+ @Override
+ public Pservers getPhysicalServers(String hostName, String uuid) {
+ return webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", uuid)
+ .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).get()
+ .readEntity(Pservers.class);
+ }
+
+ @Override
+ public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid)
+ throws JsonParseException, JsonMappingException, IOException {
+ List<String> startNodes = new ArrayList<String>();
+ startNodes.add("network/generic-vnfs/generic-vnf/" + vnfId);
+ String jsonInput = webTarget.register(AAIQueryObjectMapperProvider.class).path(ENDPOINT_CUSTOM_QUERY)
+ .queryParam("format", "resource").request().header("X-FromAppId", "MSO")
+ .header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.entity(new CustomQuery(startNodes, PSERVER_VNF_QUERY), MediaType.APPLICATION_JSON))
+ .readEntity(String.class);
+
+
+ return this.getListOfPservers(jsonInput);
+ }
+
+ protected List<Pserver> getListOfPservers(String jsonInput) throws JsonParseException, JsonMappingException, IOException
+ {
+ ObjectMapper mapper = new AAIQueryObjectMapperProvider().getContext(Object.class);
+ Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput,
+ new TypeReference<Results<Map<String, Pserver>>>() {
+ });
+ List<Pserver> results = new ArrayList<>();
+ for (Map<String, Pserver> m : resultsFromJson.getResult()) {
+ results.add(m.get("pserver"));
+ }
+ return results;
+ }
+
+ protected List<Pserver> getListOfPservers(File jsonInput) throws JsonParseException, JsonMappingException, IOException
+ {
+ ObjectMapper mapper = new AAIQueryObjectMapperProvider().getContext(Object.class);
+ Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput,
+ new TypeReference<Results<Map<String, Pserver>>>() {
+ });
+ List<Pserver> results = new ArrayList<>();
+ for (Map<String, Pserver> m : resultsFromJson.getResult()) {
+ results.add(m.get("pserver"));
+ }
+ return results;
+ }
+
+ @Override
+ public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws Exception {
+ GenericVnfs genericVnfs = webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL_VNFS)
+ .queryParam("vnf-name", vnfName).request().header("X-FromAppId", "MSO")
+ .header("X-TransactionId", transactionLoggingUuid).header("Content-Type", "application/json")
+ .accept(MediaType.APPLICATION_JSON_TYPE).get().readEntity(GenericVnfs.class);
+
+ if (genericVnfs.getGenericVnf().size() > 1)
+ throw new Exception("Multiple Generic Vnfs Returned");
+
+ GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
+ updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid);
+ }
+
+ @Override
+ public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid)
+ throws Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setInMaint(inMaint);
+ webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", "application/merge-patch+json")
+ .header("Accept", MediaType.APPLICATION_JSON_TYPE).header("X-HTTP-Method-Override", "PATCH")
+ .put(Entity.entity(genericVnf, MediaType.valueOf("application/merge-patch+json")));
+ }
+
+ @Override
+ public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception {
+ return webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", "application/json").accept(MediaType.APPLICATION_JSON_TYPE).get()
+ .readEntity(GenericVnf.class);
+ }
+
+ protected Client getSSLClient() throws NoSuchAlgorithmException {
+ return ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build();
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java
new file mode 100644
index 0000000000..787158f8c6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java
@@ -0,0 +1,11 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+
+public interface AAIUpdator {
+
+ void updateVnfToLocked(String vnfName, String uuid) throws IOException, Exception;
+
+ void updateVnfToUnLocked(String vnfName, String uuid) throws IOException, Exception;
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
new file mode 100644
index 0000000000..50b3e61d96
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
@@ -0,0 +1,29 @@
+package org.openecomp.mso.client.aai;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class AAIUpdatorImpl implements AAIUpdator {
+
+ @Autowired
+ protected AAIRestClient client;
+
+ public AAIRestClient getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void updateVnfToLocked(String vnfId, String uuid) throws Exception {
+ client.updateMaintenceFlagVnfId(vnfId, true, uuid);
+ }
+
+ @Override
+ public void updateVnfToUnLocked(String vnfId, String uuid) throws Exception {
+ client.updateMaintenceFlagVnfId(vnfId, false, uuid);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java
new file mode 100644
index 0000000000..5ec2dd679d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java
@@ -0,0 +1,12 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+
+public interface AAIValidator {
+
+ boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException;
+
+ boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception;
+
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java
new file mode 100644
index 0000000000..be39c5fb8b
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java
@@ -0,0 +1,51 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+@Service
+public class AAIValidatorImpl implements AAIValidator {
+
+
+ @Autowired
+ protected AAIRestClient client;
+
+ public AAIRestClient getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException {
+ List<Pserver> pservers;
+ boolean isLocked = false;
+ pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid);
+ for (Pserver pserver : pservers)
+ if (pserver.isInMaint())
+ isLocked = true;
+
+ return isLocked;
+ }
+
+ @Override
+ public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception {
+ boolean isLocked = false;
+ GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid);
+ if (genericVnf.isInMaint())
+ isLocked = true;
+
+ return isLocked;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java
new file mode 100644
index 0000000000..a34b96efce
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java
@@ -0,0 +1,5 @@
+package org.openecomp.mso.client.aai.entities;
+
+public class AAIEntity {
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java
new file mode 100644
index 0000000000..900587224f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java
@@ -0,0 +1,27 @@
+
+package org.openecomp.mso.client.aai.entities;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "requestError"
+})
+public class AAIError {
+
+ @JsonProperty("requestError")
+ private RequestError requestError;
+
+ @JsonProperty("requestError")
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ @JsonProperty("requestError")
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java
new file mode 100644
index 0000000000..fb37899e0d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java
@@ -0,0 +1,48 @@
+package org.openecomp.mso.client.aai.entities;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CustomQuery {
+
+ List<String> start;
+
+ public String getGremlin() {
+ return gremlin;
+ }
+
+ public void setGremlin(String gremlin) {
+ this.gremlin = gremlin;
+ }
+ String query;
+ String gremlin;
+
+ public CustomQuery(List<String>start, String query){
+ this.start=start;
+ this.query= "query/" + query;
+ }
+
+ public CustomQuery(String gremlin) throws UnsupportedEncodingException{
+ this.gremlin=gremlin;
+ }
+
+ public List<String> getStart() {
+ return start;
+ }
+
+ public void setStart(List<String> start) {
+ this.start = start;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java
new file mode 100644
index 0000000000..525d983940
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java
@@ -0,0 +1,27 @@
+
+package org.openecomp.mso.client.aai.entities;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "serviceException"
+})
+public class RequestError {
+
+ @JsonProperty("serviceException")
+ private ServiceException serviceException;
+
+ @JsonProperty("serviceException")
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ @JsonProperty("serviceException")
+ public void setServiceException(ServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java
new file mode 100644
index 0000000000..384ac25246
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java
@@ -0,0 +1,33 @@
+package org.openecomp.mso.client.aai.entities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "results"
+})
+@XmlRootElement(name = "results")
+public class Results<T> {
+
+ @XmlElement(name="results")
+ protected List<T> result;
+
+ public List<T> getResult() {
+ if (result == null) {
+ result = new ArrayList<T>();
+ }
+ return this.result;
+ }
+
+ public void setResult(List<T> result) {
+ this.result=result;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java
new file mode 100644
index 0000000000..0ea3ebb061
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java
@@ -0,0 +1,54 @@
+
+package org.openecomp.mso.client.aai.entities;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "messageId",
+ "text",
+ "variables"
+})
+public class ServiceException {
+
+ @JsonProperty("messageId")
+ private String messageId;
+ @JsonProperty("text")
+ private String text;
+ @JsonProperty("variables")
+ private List<String> variables = null;
+
+ @JsonProperty("messageId")
+ public String getMessageId() {
+ return messageId;
+ }
+
+ @JsonProperty("messageId")
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ @JsonProperty("text")
+ public String getText() {
+ return text;
+ }
+
+ @JsonProperty("text")
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @JsonProperty("variables")
+ public List<String> getVariables() {
+ return variables;
+ }
+
+ @JsonProperty("variables")
+ public void setVariables(List<String> variables) {
+ this.variables = variables;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java
new file mode 100644
index 0000000000..794f112fa9
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java
@@ -0,0 +1,19 @@
+package org.openecomp.mso.client.appc;
+import org.openecomp.appc.client.lcm.api.ResponseHandler;
+import org.openecomp.appc.client.lcm.exceptions.AppcClientException;
+
+public class ApplicationControllerCallback<T> implements ResponseHandler<T> {
+
+ @Override
+ public void onResponse(T response) {
+ System.out.println("ON RESPONSE");
+
+ }
+
+ @Override
+ public void onException(AppcClientException exception) {
+ System.out.println("ON EXCEPTION");
+
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
new file mode 100644
index 0000000000..e8dc5af90c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
@@ -0,0 +1,147 @@
+package org.openecomp.mso.client.appc;
+
+import java.beans.BeanInfo;
+
+import java.util.Map;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.time.Instant;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.openecomp.appc.client.lcm.api.AppcClientServiceFactoryProvider;
+import org.openecomp.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory;
+import org.openecomp.appc.client.lcm.api.ApplicationContext;
+import org.openecomp.appc.client.lcm.api.LifeCycleManagerStateful;
+import org.openecomp.appc.client.lcm.api.ResponseHandler;
+import org.openecomp.appc.client.lcm.exceptions.AppcClientException;
+import org.openecomp.appc.client.lcm.model.Action;
+import org.openecomp.appc.client.lcm.model.ActionIdentifiers;
+import org.openecomp.appc.client.lcm.model.AuditOutput;
+import org.openecomp.appc.client.lcm.model.CommonHeader;
+import org.openecomp.appc.client.lcm.model.Flags;
+import org.openecomp.appc.client.lcm.model.Flags.Force;
+import org.openecomp.appc.client.lcm.model.Flags.Mode;
+import org.openecomp.appc.client.lcm.model.Payload;
+import org.openecomp.appc.client.lcm.model.Status;
+import org.openecomp.appc.client.lcm.model.ZULU;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+public class ApplicationControllerClient {
+
+ private static final int ACCEPT_SERIES = 100;
+ private static final int ERROR_SERIES = 200;
+ private static final int REJECT_SERIES = 300;
+ private static final int SUCCESS_SERIES = 400;
+ private static final int SUCCESS_STATUS = SUCCESS_SERIES + 0;
+ private static final int PARTIAL_SERIES = 500;
+ private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES + 0;
+
+ private final boolean useLCMBypass = false;
+
+ private final String apiVer = "2.00";
+ private final String originatorId = "MSO";
+ private final int flagsTTL = 65000;
+ private final static String clientName = "MSO";
+
+ @Autowired
+ public ApplicationControllerSupport appCSupport;
+
+ private LifeCycleManagerStateful client;
+
+ public Status runCommand(Action action, ActionIdentifiers identifier, Flags flags, Payload payload,
+ String requestID) throws Exception {
+ Object requestObject = createRequest(action, identifier, flags, payload, requestID);
+ client = getAppCClient();
+ Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false);
+ appCSupport.logLCMMessage(requestObject);
+ Object response = lcmMethod.invoke(client, requestObject);
+ return appCSupport.getStatusFromGenericResponse(response);
+ }
+
+ public void shutdownclient() {
+ AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
+ .shutdownLifeCycleManager(false);
+ }
+
+ public LifeCycleManagerStateful getAppCClient() throws AppcClientException {
+ if (client == null)
+ client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
+ .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties());
+ return client;
+ }
+
+ private Properties getLCMProperties() {
+ return getLCMPropertiesHelper();
+ }
+
+ protected Properties getLCMPropertiesHelper() {
+ Properties properties = new Properties();
+ Map<String, String> globalProperties = PropertyConfiguration.getInstance()
+ .getProperties("mso.bpmn.urn.properties");
+
+ properties.put("topic.read", globalProperties.get("appc.topic.read"));
+ properties.put("topic.read.timeout", globalProperties.get("appc.topic.read.timeout"));
+ properties.put("client.response.timeout", globalProperties.get("appc.client.response.timeout"));
+ properties.put("topic.write", globalProperties.get("appc.topic.write"));
+ properties.put("poolMembers", globalProperties.get("appc.pool.members"));
+ properties.put("client.key", globalProperties.get("appc.client.key"));
+ properties.put("client.secret", globalProperties.get("appc.client.secret"));
+ properties.put("client.name", clientName);
+ return properties;
+ }
+
+ public Object createRequest(Action action, ActionIdentifiers identifier, Flags flags, Payload payload,
+ String requestId) throws Exception {
+ Object requestObject = appCSupport.getInput(action.name());
+ try {
+ org.openecomp.appc.client.lcm.model.CommonHeader commonHeader = buildCommonHeader(requestId);
+ requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject,
+ commonHeader);
+ requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
+ requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class)
+ .invoke(requestObject, identifier);
+ } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
+ throw new Exception("Error Building AppC Request: " + e.getMessage());
+ }
+ return requestObject;
+ }
+
+ private org.openecomp.appc.client.lcm.model.CommonHeader buildCommonHeader(String requestId) {
+ org.openecomp.appc.client.lcm.model.CommonHeader commonHeader = new org.openecomp.appc.client.lcm.model.CommonHeader();
+ commonHeader.setApiVer(apiVer);
+ commonHeader.setOriginatorId(originatorId);
+ commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId);
+ commonHeader.setSubRequestId(requestId);
+ org.openecomp.appc.client.lcm.model.Flags flags = new org.openecomp.appc.client.lcm.model.Flags();
+ String flagsMode = "NORMAL";
+ Mode mode = Mode.valueOf(flagsMode);
+ flags.setMode(mode);
+ String flagsForce = "FALSE";
+ Force force = Force.valueOf(flagsForce);
+ flags.setForce(force);
+ flags.setTtl(flagsTTL);
+ commonHeader.setFlags(flags);
+ Instant timestamp = Instant.now();
+ ZULU zulu = new ZULU(timestamp.toString());
+ commonHeader.setTimestamp(zulu);
+ return commonHeader;
+ }
+
+ public Flags createRequestFlags() {
+ Flags flags = new Flags();
+ flags.setTtl(6000);
+ return flags;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java
new file mode 100644
index 0000000000..c0f1a2067e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java
@@ -0,0 +1,226 @@
+package org.openecomp.mso.client.appc;
+
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PropertiesLoaderUtils;
+import org.springframework.stereotype.Component;
+
+import org.openecomp.appc.client.lcm.api.AppcClientServiceFactoryProvider;
+import org.openecomp.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory;
+import org.openecomp.appc.client.lcm.api.ApplicationContext;
+import org.openecomp.appc.client.lcm.api.LifeCycleManagerStateful;
+import org.openecomp.appc.client.lcm.api.ResponseHandler;
+import org.openecomp.appc.client.lcm.exceptions.AppcClientException;
+import org.openecomp.appc.client.lcm.model.Status;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+
+@Component
+public class ApplicationControllerSupport {
+
+ private static final int ACCEPT_SERIES = 100;
+ private static final int ERROR_SERIES = 200;
+ private static final int REJECT_SERIES = 300;
+ private static final int SUCCESS_SERIES = 400;
+ private static final int SUCCESS_STATUS = SUCCESS_SERIES + 0;
+ private static final int PARTIAL_SERIES = 500;
+ private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES + 0;
+ private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1;
+
+ @Value("${lcm.model.package:org.openecomp.appc.client.lcm.model}")
+ private String lcmModelPackage;
+
+ public LifeCycleManagerStateful createService() throws AppcClientException, IOException {
+ AppcLifeCycleManagerServiceFactory factory = AppcClientServiceFactoryProvider
+ .getFactory(AppcLifeCycleManagerServiceFactory.class);
+ return factory.createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties());
+ }
+
+ /**
+ * @param inputClass
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public Object getInput(String action) {
+ try {
+ return getInputClass(action).newInstance();
+ } catch (IllegalAccessException | InstantiationException e) {
+ throw new RuntimeException(
+ String.format("%s : %s", "Unable to instantiate viable LCM Kit input class for action", action), e);
+ }
+ }
+
+ /**
+ * @param action
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public Method getAPIMethod(String action, LifeCycleManagerStateful lcmStateful, boolean async) {
+ Method[] methods = lcmStateful.getClass().getMethods();
+ for (Method method : methods) {
+ if (method.getName().equalsIgnoreCase(action)) {
+ Class<?>[] methodParameterTypes = method.getParameterTypes();
+ if (methodParameterTypes.length > 0) {
+ if (getInputClass(action).equals(methodParameterTypes[0])) {
+ if (async) {
+ if (methodParameterTypes.length == 2
+ && ResponseHandler.class.isAssignableFrom(methodParameterTypes[1])) {
+ return method;
+ }
+ } else if (methodParameterTypes.length == 1) {
+ return method;
+ }
+ }
+ }
+ }
+ }
+ throw new RuntimeException(String.format("%s : %s, async=%b",
+ "Unable to derive viable LCM Kit API method for action", action, async));
+ }
+
+ public Method getCommonHeaderSetterMethod(String action) {
+ return getBeanPropertyMethodFor(getInputClass(action), "commonHeader", true);
+ }
+
+ public Method getPayloadSetterMethod(String action) {
+ return getBeanPropertyMethodFor(getInputClass(action), "payload", true);
+ }
+
+ public Status getStatusFromGenericResponse(Object response) {
+ Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false);
+ if (statusReader != null) {
+ try {
+ return (Status) statusReader.invoke(response);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new RuntimeException(String.format("Unable to obtain status from LCM Kit response", e));
+ }
+ }
+ return new Status();
+ }
+
+ public static StatusCategory getCategoryOf(Status status) {
+ int codeSeries = status.getCode() - (status.getCode() % 100);
+ switch (codeSeries) {
+ case ACCEPT_SERIES:
+ return StatusCategory.NORMAL;
+ case ERROR_SERIES:
+ case REJECT_SERIES:
+ return StatusCategory.ERROR;
+ case SUCCESS_SERIES:
+ return status.getCode() == SUCCESS_STATUS ? StatusCategory.NORMAL : StatusCategory.ERROR;
+ case PARTIAL_SERIES:
+ switch (status.getCode()) {
+ case PARTIAL_SUCCESS_STATUS:
+ return StatusCategory.NORMAL;
+ case PARTIAL_FAILURE_STATUS:
+ return StatusCategory.ERROR;
+ default:
+ return StatusCategory.WARNING;
+ }
+ default:
+ return StatusCategory.WARNING;
+ }
+ }
+
+ public static boolean getFinalityOf(Status status) {
+ int codeSeries = status.getCode() - (status.getCode() % 100);
+ switch (codeSeries) {
+ case ACCEPT_SERIES:
+ case PARTIAL_SERIES:
+ return false;
+ case ERROR_SERIES:
+ case REJECT_SERIES:
+ case SUCCESS_SERIES:
+ return true;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * @return
+ * @throws IOException
+ */
+ private Properties getLCMProperties() throws IOException {
+ Resource resource = new ClassPathResource("/lcm.properties");
+ Properties properties = PropertiesLoaderUtils.loadProperties(resource);
+ return properties;
+ }
+
+ private Method getBeanPropertyMethodFor(Class<?> clazz, String propertyName, boolean isWriter) {
+ BeanInfo beanInfo;
+ try {
+ beanInfo = Introspector.getBeanInfo(clazz, Object.class);
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(
+ String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b",
+ clazz.getName(), propertyName, isWriter),
+ e);
+ }
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ if (propertyDescriptor.getName().equals(propertyName)) {
+ return isWriter ? propertyDescriptor.getWriteMethod() : propertyDescriptor.getReadMethod();
+ }
+ }
+ throw new RuntimeException(
+ String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b",
+ clazz.getName(), propertyName, isWriter));
+ }
+
+ /**
+ * @param action
+ * @return
+ * @throws ClassNotFoundException
+ */
+ private Class<?> getInputClass(String action) {
+ try {
+ return Class.forName(lcmModelPackage + '.' + action + "Input");
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(String.format("%s : %s using package : ",
+ "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e);
+ }
+ }
+
+ public static enum StatusCategory {
+ NORMAL("normal"),
+ WARNING("warning"),
+ ERROR("error");
+
+ private final String category;
+
+ private StatusCategory(final String category) {
+ this.category = category;
+ }
+
+ @Override
+ public String toString() {
+ return category;
+ }
+ }
+
+ public void logLCMMessage(Object message) throws JsonProcessingException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
+ String inputAsJSON = writer.writeValueAsString(message);
+ System.out.println("LCM Kit input message follows.");
+ System.out.println(inputAsJSON);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java
new file mode 100644
index 0000000000..6c0b3ac633
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java
@@ -0,0 +1,34 @@
+package org.openecomp.mso.client.dmaap;
+
+public interface Consumer {
+
+ /**
+ * Should this consumer continue to consume messages from the topic?
+ * @return
+ */
+ public boolean continuePolling();
+ /**
+ * Process a message from a DMaaP topic
+ *
+ * @param message
+ * @throws Exception
+ */
+ public void processMessage(String message) throws Exception;
+ /**
+ * Has the request been accepted by the receiving system?
+ * Should the consumer move to processing messages?
+ *
+ * @param message
+ * @return
+ */
+ public boolean isAccepted(String message);
+ /**
+ * The request id to filter messages on
+ * @return
+ */
+ public String getRequestId();
+ /**
+ * Logic that defines when the consumer should stop processing messages
+ */
+ public void stopProcessingMessages();
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java
new file mode 100644
index 0000000000..07ed8719b7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java
@@ -0,0 +1,40 @@
+package org.openecomp.mso.client.dmaap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import com.att.nsa.mr.client.MRClientFactory;
+import com.att.nsa.mr.client.MRConsumer;
+
+public class DmaapConsumer {
+
+ private final MRConsumer mrConsumer;
+ public DmaapConsumer() {
+ mrConsumer = null;
+ }
+ public DmaapConsumer (String filepath) throws FileNotFoundException, IOException {
+
+ mrConsumer = MRClientFactory.createConsumer(filepath);
+ }
+
+
+ public MRConsumer getMRConsumer() {
+ return mrConsumer;
+ }
+ public boolean consume(Consumer consumer) throws Exception {
+ boolean accepted = false;
+ while (consumer.continuePolling()) {
+ for (String message : this.getMRConsumer().fetch()) {
+ if (!accepted && consumer.isAccepted(message)) {
+ accepted = true;
+ }
+ if (accepted) {
+ consumer.processMessage(message);
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
new file mode 100644
index 0000000000..bce3e6c3d7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
@@ -0,0 +1,30 @@
+package org.openecomp.mso.client.dmaap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import com.att.nsa.mr.client.MRBatchingPublisher;
+import com.att.nsa.mr.client.MRClientFactory;
+
+public class DmaapPublisher {
+
+ private final long seconds;
+ private final MRBatchingPublisher publisher;
+
+ public DmaapPublisher(String filepath) throws FileNotFoundException, IOException {
+ this.seconds = 20;
+ this.publisher = MRClientFactory.createBatchingPublisher(filepath);
+ }
+
+ public DmaapPublisher(String filepath, long seconds) throws FileNotFoundException, IOException {
+ this.seconds = seconds;
+ this.publisher = MRClientFactory.createBatchingPublisher(filepath);
+ }
+
+ public void send(String json) throws IOException, InterruptedException {
+ publisher.send(json);
+ publisher.close(seconds, TimeUnit.SECONDS);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java
new file mode 100644
index 0000000000..b9e3c5d9ad
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java
@@ -0,0 +1,19 @@
+package org.openecomp.mso.client.exceptions;
+
+
+public class SDNOException extends Exception {
+
+ private static final long serialVersionUID = 6189163383568887383L;
+
+ public SDNOException() {
+ super();
+ }
+
+ public SDNOException(String string) {
+ super(string);
+ }
+
+ public SDNOException(Exception e) {
+ super(e);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java
new file mode 100644
index 0000000000..8e709f21b5
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java
@@ -0,0 +1,31 @@
+package org.openecomp.mso.client.policy;
+
+import javax.ws.rs.ext.ContextResolver;
+
+import javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+@Provider
+public class CommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
+
+ final ObjectMapper mapper;
+
+ public CommonObjectMapperProvider() {
+
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java
new file mode 100644
index 0000000000..2325955950
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java
@@ -0,0 +1,74 @@
+
+package org.openecomp.mso.client.policy;
+
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" })
+public class DecisionAttributes {
+
+ @JsonProperty("ServiceType")
+ private String serviceType;
+ @JsonProperty("VNFType")
+ private String vNFType;
+ @JsonProperty("BB_ID")
+ private String bbID;
+ @JsonProperty("WorkStep")
+ private String workStep;
+ @JsonProperty("ErrorCode")
+ private String errorCode;
+
+ @JsonProperty("ServiceType")
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ @JsonProperty("ServiceType")
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ @JsonProperty("VNFType")
+ public String getVNFType() {
+ return vNFType;
+ }
+
+ @JsonProperty("VNFType")
+ public void setVNFType(String vNFType) {
+ this.vNFType = vNFType;
+ }
+
+ @JsonProperty("BB_ID")
+ public String getBBID() {
+ return bbID;
+ }
+
+ @JsonProperty("BB_ID")
+ public void setBBID(String bBID) {
+ this.bbID = bBID;
+ }
+
+ @JsonProperty("WorkStep")
+ public String getWorkStep() {
+ return workStep;
+ }
+
+ @JsonProperty("WorkStep")
+ public void setWorkStep(String workStep) {
+ this.workStep = workStep;
+ }
+
+ @JsonProperty("ErrorCode")
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ @JsonProperty("ErrorCode")
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java
new file mode 100644
index 0000000000..9a7c21fba1
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java
@@ -0,0 +1,109 @@
+package org.openecomp.mso.client.policy;
+
+import java.io.BufferedInputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.logging.Logger;
+import javax.annotation.Priority;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+@Priority(Integer.MIN_VALUE)
+public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor {
+
+ private static final Logger logger = Logger.getLogger(LoggingFilter.class.getName());
+ private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream";
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+ private final int maxEntitySize = 1024 * 8;
+
+ private void log(StringBuilder sb) {
+ logger.info(sb.toString());
+ }
+
+ private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
+ throws IOException {
+ if (!stream.markSupported()) {
+ stream = new BufferedInputStream(stream);
+ }
+ stream.mark(maxEntitySize + 1);
+ final byte[] entity = new byte[maxEntitySize + 1];
+ final int entitySize = stream.read(entity);
+ b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
+ if (entitySize > maxEntitySize) {
+ b.append("...more...");
+ }
+ b.append('\n');
+ stream.reset();
+ return stream;
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext) throws IOException {
+ if (requestContext.hasEntity()) {
+ final OutputStream stream = new LoggingStream(requestContext.getEntityStream());
+ requestContext.setEntityStream(stream);
+ requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream);
+ }
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ final StringBuilder sb = new StringBuilder();
+ if (responseContext.hasEntity()) {
+ responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET));
+ log(sb);
+ }
+
+ }
+
+ @Override
+ public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
+ final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY);
+ context.proceed();
+ if (stream != null) {
+ log(stream.getStringBuilder(DEFAULT_CHARSET));
+ }
+ }
+
+ private class LoggingStream extends FilterOutputStream {
+
+ private final StringBuilder sb = new StringBuilder();
+ private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ LoggingStream(OutputStream out) {
+ super(out);
+ }
+
+ StringBuilder getStringBuilder(Charset charset) {
+ // write entity to the builder
+ final byte[] entity = baos.toByteArray();
+
+ sb.append(new String(entity, 0, entity.length, charset));
+ if (entity.length > maxEntitySize) {
+ sb.append("...more...");
+ }
+ sb.append('\n');
+
+ return sb;
+ }
+
+ @Override
+ public void write(final int i) throws IOException {
+ if (baos.size() <= maxEntitySize) {
+ baos.write(i);
+ }
+ out.write(i);
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java
new file mode 100644
index 0000000000..e0ad170504
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java
@@ -0,0 +1,38 @@
+
+package org.openecomp.mso.client.policy;
+
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({ "decision", "details" })
+public class PolicyDecision {
+
+ @JsonProperty("decision")
+ private String decision;
+ @JsonProperty("details")
+ private String details;
+
+ @JsonProperty("decision")
+ public String getDecision() {
+ return decision;
+ }
+
+ @JsonProperty("decision")
+ public void setDecision(String decision) {
+ this.decision = decision;
+ }
+
+ @JsonProperty("details")
+ public String getDetails() {
+ return details;
+ }
+
+ @JsonProperty("details")
+ public void setDetails(String details) {
+ this.details = details;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java
new file mode 100644
index 0000000000..2af91f6638
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java
@@ -0,0 +1,38 @@
+
+package org.openecomp.mso.client.policy;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({ "decisionAttributes", "ecompcomponentName" })
+public class PolicyDecisionRequest {
+
+ @JsonProperty("decisionAttributes")
+ private DecisionAttributes decisionAttributes;
+ @JsonProperty("ecompcomponentName")
+ private String ecompcomponentName;
+
+ @JsonProperty("decisionAttributes")
+ public DecisionAttributes getDecisionAttributes() {
+ return decisionAttributes;
+ }
+
+ @JsonProperty("decisionAttributes")
+ public void setDecisionAttributes(DecisionAttributes decisionAttributes) {
+ this.decisionAttributes = decisionAttributes;
+ }
+
+ @JsonProperty("ecompcomponentName")
+ public String getEcompcomponentName() {
+ return ecompcomponentName;
+ }
+
+ @JsonProperty("ecompcomponentName")
+ public void setEcompcomponentName(String ecompcomponentName) {
+ this.ecompcomponentName = ecompcomponentName;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java
new file mode 100644
index 0000000000..6af1c5dab7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.mso.client.policy;
+
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class PolicyRestClient extends RestClient {
+
+ private static final String ENDPOINT_KEY = "policy.endpoint";
+ private static final String X_ECOMP_REQUESTID = String.valueOf(UUID.randomUUID());
+
+ public PolicyRestClient() {
+ super(ENDPOINT_KEY);
+ }
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ headerMap.put("ClientAuth", properties.get("policy.client.auth"));
+ headerMap.put("Authorization", properties.get("policy.auth"));
+ headerMap.put("Environment", properties.get("policy.environment"));
+ headerMap.put("X-ECOMP-RequestID", X_ECOMP_REQUESTID);
+ }
+
+ public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep,
+ String errorCode) {
+ DecisionAttributes decisionAttributes = new DecisionAttributes();
+ decisionAttributes.setServiceType(serviceType);
+ decisionAttributes.setVNFType(vnfType);
+ decisionAttributes.setBBID(bbID);
+ decisionAttributes.setWorkStep(workStep);
+ decisionAttributes.setErrorCode(errorCode);
+
+ return this.getDecision(decisionAttributes);
+ }
+
+ private PolicyDecision getDecision(DecisionAttributes decisionAttributes) {
+ PolicyDecisionRequest decisionRequest = new PolicyDecisionRequest();
+ decisionRequest.setDecisionAttributes(decisionAttributes);
+ decisionRequest.setEcompcomponentName(ECOMP_COMPONENT_NAME);
+
+ return this.getBuilder().accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(decisionRequest, MediaType.APPLICATION_JSON)).readEntity(PolicyDecision.class);
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java
new file mode 100644
index 0000000000..f8e1ffd74f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.mso.client.policy;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Logger;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.logger.MsoLogger;
+import org.springframework.stereotype.Service;
+
+@Service
+public abstract class RestClient {
+ protected static final String ECOMP_COMPONENT_NAME = "MSO";
+
+ private WebTarget webTarget;
+
+ protected final Map<String, String> headerMap;
+ protected final MsoLogger msoLogger;
+ protected Map<String, String> properties;
+ protected String host;
+
+ protected RestClient(String endpointKey) {
+ Logger logger = Logger.getLogger(getClass().getName());
+ msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+
+ properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ headerMap = new HashMap<>();
+ initializeHeaderMap(headerMap);
+
+ host = this.getHost(endpointKey);
+
+ webTarget = ClientBuilder.newClient().register(logger).register(new LoggingFilter())
+ .register(new CommonObjectMapperProvider()).target(host);
+ }
+
+ private String getHost(String key) {
+ return properties.get(key);
+ }
+
+ protected Builder getBuilder() {
+ Builder builder = webTarget.request();
+
+ for (Entry<String, String> entry : headerMap.entrySet()) {
+ builder.header(entry.getKey(), entry.getValue());
+ }
+ return builder;
+ }
+
+ protected abstract void initializeHeaderMap(Map<String, String> headerMap);
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java
new file mode 100644
index 0000000000..d35d3906f2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java
@@ -0,0 +1,58 @@
+
+package org.openecomp.mso.client.sdno;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "input"
+})
+public class Body implements Serializable
+{
+
+ @JsonProperty("input")
+ private Input input;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private final static long serialVersionUID = 9101706044452851559L;
+
+ @JsonProperty("input")
+ public Input getInput() {
+ return input;
+ }
+
+ @JsonProperty("input")
+ public void setInput(Input input) {
+ this.input = input;
+ }
+
+ public Body withInput(Input input) {
+ this.input = input;
+ return this;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public Body withAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ return this;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java
new file mode 100644
index 0000000000..da28ac507a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java
@@ -0,0 +1,58 @@
+
+package org.openecomp.mso.client.sdno;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "request-healthdiagnostic"
+})
+public class Input implements Serializable
+{
+
+ @JsonProperty("request-healthdiagnostic")
+ private RequestHealthDiagnostic RequestHealthDiagnostic;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private final static long serialVersionUID = 7155546785389227528L;
+
+ @JsonProperty("request-healthdiagnostic")
+ public RequestHealthDiagnostic getRequestHealthDiagnostic() {
+ return RequestHealthDiagnostic;
+ }
+
+ @JsonProperty("request-healthdiagnostic")
+ public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) {
+ this.RequestHealthDiagnostic = RequestHealthDiagnostic;
+ }
+
+ public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) {
+ this.RequestHealthDiagnostic = RequestHealthDiagnostic;
+ return this;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public Input withAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ return this;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java
new file mode 100644
index 0000000000..a1109b2dfd
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java
@@ -0,0 +1,166 @@
+
+package org.openecomp.mso.client.sdno;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "request-client-name",
+ "request-node-name",
+ "request-node-ip",
+ "request-id",
+ "request-user-id",
+ "request-node-type",
+ "health-diagnostic-code"
+})
+public class RequestHealthDiagnostic implements Serializable
+{
+
+ @JsonProperty("request-client-name")
+ private String requestClientName;
+ @JsonProperty("request-node-name")
+ private String requestNodeName;
+ @JsonProperty("request-node-ip")
+ private String requestNodeIp;
+ @JsonProperty("request-id")
+ private String requestId;
+ @JsonProperty("request-user-id")
+ private String requestUserId;
+ @JsonProperty("request-node-type")
+ private String requestNodeType;
+ @JsonProperty("health-diagnostic-code")
+ private String healthDiagnosticCode;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private final static long serialVersionUID = 1166788526178388021L;
+
+ @JsonProperty("request-client-name")
+ public String getRequestClientName() {
+ return requestClientName;
+ }
+
+ @JsonProperty("request-client-name")
+ public void setRequestClientName(String requestClientName) {
+ this.requestClientName = requestClientName;
+ }
+
+ public RequestHealthDiagnostic withRequestClientName(String requestClientName) {
+ this.requestClientName = requestClientName;
+ return this;
+ }
+
+ @JsonProperty("request-node-name")
+ public String getRequestNodeName() {
+ return requestNodeName;
+ }
+
+ @JsonProperty("request-node-name")
+ public void setRequestNodeName(String requestNodeName) {
+ this.requestNodeName = requestNodeName;
+ }
+
+ public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) {
+ this.requestNodeName = requestNodeName;
+ return this;
+ }
+
+ @JsonProperty("request-node-ip")
+ public String getRequestNodeIp() {
+ return requestNodeIp;
+ }
+
+ @JsonProperty("request-node-ip")
+ public void setRequestNodeIp(String requestNodeIp) {
+ this.requestNodeIp = requestNodeIp;
+ }
+
+ public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) {
+ this.requestNodeIp = requestNodeIp;
+ return this;
+ }
+
+ @JsonProperty("request-id")
+ public String getRequestId() {
+ return requestId;
+ }
+
+ @JsonProperty("request-id")
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public RequestHealthDiagnostic withRequestId(String requestId) {
+ this.requestId = requestId;
+ return this;
+ }
+
+ @JsonProperty("request-user-id")
+ public String getRequestUserId() {
+ return requestUserId;
+ }
+
+ @JsonProperty("request-user-id")
+ public void setRequestUserId(String requestUserId) {
+ this.requestUserId = requestUserId;
+ }
+
+ public RequestHealthDiagnostic withRequestUserId(String requestUserId) {
+ this.requestUserId = requestUserId;
+ return this;
+ }
+
+ @JsonProperty("request-node-type")
+ public String getRequestNodeType() {
+ return requestNodeType;
+ }
+
+ @JsonProperty("request-node-type")
+ public void setRequestNodeType(String requestNodeType) {
+ this.requestNodeType = requestNodeType;
+ }
+
+ public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) {
+ this.requestNodeType = requestNodeType;
+ return this;
+ }
+
+ @JsonProperty("health-diagnostic-code")
+ public String getHealthDiagnosticCode() {
+ return healthDiagnosticCode;
+ }
+
+ @JsonProperty("health-diagnostic-code")
+ public void setHealthDiagnosticCode(String healthDiagnosticCode) {
+ this.healthDiagnosticCode = healthDiagnosticCode;
+ }
+
+ public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) {
+ this.healthDiagnosticCode = healthDiagnosticCode;
+ return this;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ return this;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java
new file mode 100644
index 0000000000..a5199acad7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java
@@ -0,0 +1,96 @@
+package org.openecomp.mso.client.sdno;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+"client-name",
+"code",
+"processing-host",
+"request-id",
+"status"
+})
+public class ResultInfo {
+
+@JsonProperty("client-name")
+private String clientName;
+@JsonProperty("code")
+private String code;
+@JsonProperty("processing-host")
+private String processingHost;
+@JsonProperty("request-id")
+private String requestId;
+@JsonProperty("status")
+private String status;
+@JsonIgnore
+private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+@JsonProperty("client-name")
+public String getClientName() {
+return clientName;
+}
+
+@JsonProperty("client-name")
+public void setClientName(String clientName) {
+this.clientName = clientName;
+}
+
+@JsonProperty("code")
+public String getCode() {
+return code;
+}
+
+@JsonProperty("code")
+public void setCode(String code) {
+this.code = code;
+}
+
+@JsonProperty("processing-host")
+public String getProcessingHost() {
+return processingHost;
+}
+
+@JsonProperty("processing-host")
+public void setProcessingHost(String processingHost) {
+this.processingHost = processingHost;
+}
+
+@JsonProperty("request-id")
+public String getRequestId() {
+return requestId;
+}
+
+@JsonProperty("request-id")
+public void setRequestId(String requestId) {
+this.requestId = requestId;
+}
+
+@JsonProperty("status")
+public String getStatus() {
+return status;
+}
+
+@JsonProperty("status")
+public void setStatus(String status) {
+this.status = status;
+}
+
+@JsonAnyGetter
+public Map<String, Object> getAdditionalProperties() {
+return this.additionalProperties;
+}
+
+@JsonAnySetter
+public void setAdditionalProperty(String name, Object value) {
+this.additionalProperties.put(name, value);
+}
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java
new file mode 100644
index 0000000000..c634164b59
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java
@@ -0,0 +1,94 @@
+
+package org.openecomp.mso.client.sdno;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "operation",
+ "nodeType",
+ "body"
+})
+public class SDNO implements Serializable
+{
+
+ @JsonProperty("operation")
+ private String operation;
+ @JsonProperty("nodeType")
+ private String nodeType;
+ @JsonProperty("body")
+ private Body body;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private final static long serialVersionUID = -5303297382564282650L;
+
+ @JsonProperty("operation")
+ public String getOperation() {
+ return operation;
+ }
+
+ @JsonProperty("operation")
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public SDNO withOperation(String operation) {
+ this.operation = operation;
+ return this;
+ }
+
+ @JsonProperty("nodeType")
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ @JsonProperty("nodeType")
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public SDNO withNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ return this;
+ }
+
+ @JsonProperty("body")
+ public Body getBody() {
+ return body;
+ }
+
+ @JsonProperty("body")
+ public void setBody(Body body) {
+ this.body = body;
+ }
+
+ public SDNO withBody(Body body) {
+ this.body = body;
+ return this;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public SDNO SDNO (String name, Object value) {
+ this.additionalProperties.put(name, value);
+ return this;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java
new file mode 100644
index 0000000000..be63feef05
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java
@@ -0,0 +1,9 @@
+package org.openecomp.mso.client.sdno;
+
+import java.io.IOException;
+
+public interface SDNOValidator {
+
+ void healthDiagnostic(String vnfName, String uuid) throws IOException, Exception;
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java
new file mode 100644
index 0000000000..d37e2bc70f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java
@@ -0,0 +1,133 @@
+package org.openecomp.mso.client.sdno;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Optional;
+
+import org.openecomp.mso.client.dmaap.Consumer;
+import org.openecomp.mso.client.dmaap.DmaapConsumer;
+import org.openecomp.mso.client.dmaap.DmaapPublisher;
+import org.openecomp.mso.client.exceptions.SDNOException;
+import org.openecomp.mso.jsonpath.JsonPathUtil;
+
+public class SDNOValidatorImpl implements SDNOValidator, Consumer {
+
+ private final static String aafUserName = "something";
+ private final static String clientName = "MSO";
+ private final static String healthDiagnosticPath = "body.output.response-healthdiagnostic";
+ private final static String producerFilePath = "";
+ private String uuid;
+ private boolean continuePolling = true;
+ @Override
+ public void healthDiagnostic(String vnfName, String uuid) {
+ //Query A&AI data
+ // setup SDNO Entity
+ //Call SDNO for Health Diagnostic
+ //create producer file for MRClient https://wiki.web.att.com/display/MessageRouter/DMaaP_MR_JavaReferenceClient
+ // final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher(producerFilePath);
+ // pub.send("Mypartitionkey",JSON.toString(object));
+ //create consumer file for MRClient https://wiki.web.att.com/display/MessageRouter/DMaaP_MR_JavaReferenceClient
+ //check for error in subscription feed filter via jsonpath
+ //block and continue to poll waiting for response
+ }
+
+ protected SDNO buildRequestDiagnostic(String vnfName, String uuid, String oamIp) {
+
+ Input input = new Input();
+ SDNO parentRequest = new SDNO();
+ Body body = new Body();
+ parentRequest.setBody(body);
+ parentRequest.setNodeType("vPE");
+ parentRequest.setOperation("health-diagnostic");
+
+ body.setInput(input);
+
+ RequestHealthDiagnostic request = new RequestHealthDiagnostic();
+ request.setRequestClientName(clientName);
+ request.setRequestNodeName(vnfName);
+ request.setRequestNodeIp(oamIp); //generic-vnf oam ip
+ request.setRequestUserId(aafUserName); //mech id?
+ request.setRequestId(uuid); //something to identify this request by for polling
+
+ input.setRequestHealthDiagnostic(request);
+
+ return parentRequest;
+ }
+ protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException {
+ DmaapPublisher publisher = new DmaapPublisher(this.producerFilePath);
+ publisher.send(json);
+ }
+ protected boolean pollForResponse(DmaapConsumer consumer, String uuid) throws Exception {
+ this.uuid = uuid;
+ return consumer.consume(this);
+ }
+
+ @Override
+ public boolean continuePolling() {
+ return continuePolling;
+ }
+
+ @Override
+ public void stopProcessingMessages() {
+ continuePolling = false;
+ }
+ @Override
+ public void processMessage(String message) throws Exception {
+ if (isHealthDiagnostic(message, this.getRequestId())) {
+ if (!healthDiagnosticSuccessful(message)) {
+ Optional<String> statusMessage = this.getStatusMessage(message);
+ if (statusMessage.isPresent()) {
+ throw new SDNOException(statusMessage.get());
+ } else {
+ throw new SDNOException();
+ }
+ } else {
+ stopProcessingMessages();
+ }
+ }
+ }
+
+ @Override
+ public boolean isAccepted(String message) {
+ if (isResultInfo(message)) {
+ Optional<String> code = isAccepted(message, this.getRequestId());
+ if (code.isPresent()) {
+ if ("202".equals(code.get())) {
+ return true;
+ } else {
+ //TODO check other statuses 400 and 500
+ }
+ } else {
+ //TODO throw error
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getRequestId() {
+ return uuid;
+ }
+
+ protected Optional<String> isAccepted(String json, String uuid) {
+ return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid));
+ }
+
+ protected boolean isResultInfo(String json) {
+ return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]");
+ }
+
+ protected boolean isHealthDiagnostic(String json, String uuid) {
+ return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath));
+ }
+
+ protected boolean healthDiagnosticSuccessful(String json) {
+ return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]");
+ }
+
+ protected Optional<String> getStatusMessage(String json) {
+ return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".response-details-json");
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java
new file mode 100644
index 0000000000..56ce2dfa19
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java
@@ -0,0 +1,39 @@
+package org.openecomp.mso.jsonpath;
+
+import java.util.Optional;
+
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.Option;
+
+import net.minidev.json.JSONArray;
+
+public class JsonPathUtil {
+
+
+ private final Configuration conf;
+
+ private JsonPathUtil() {
+ conf = Configuration.defaultConfiguration().addOptions(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS);
+ }
+
+ private static class Helper {
+ private static final JsonPathUtil INSTANCE = new JsonPathUtil();
+ }
+
+ public static JsonPathUtil getInstance() {
+ return Helper.INSTANCE;
+ }
+ public boolean pathExists(String json, String jsonPath) {
+ return !JsonPath.using(conf).parse(json).<JSONArray>read(jsonPath).isEmpty();
+ }
+
+ public <T> Optional<T> locateResult(String json, String jsonPath) {
+ final JSONArray result = JsonPath.using(conf).parse(json).read(jsonPath);
+ if (result.isEmpty()) {
+ return Optional.empty();
+ } else {
+ return Optional.of((T)result.get(0));
+ }
+ }
+}