summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java10
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java15
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java9
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java1
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java2
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java1
-rwxr-xr-xbpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy18
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java376
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java2
14 files changed, 262 insertions, 218 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
index 0777c60278..052f09ab85 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java
@@ -22,17 +22,15 @@ package org.openecomp.mso.cloud;
import java.io.IOException;
import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> {
@Override
public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException, JsonProcessingException {
+ throws IOException {
jsonGenerator.writeObject(tmpObj.toString());
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
index ff1cd43b05..b8a7a5571c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java
@@ -61,6 +61,6 @@ public abstract class MsoException extends Exception
if (this.context == null)
return getMessage();
else
- return ("[" + context + "] " + getMessage());
+ return "[" + context + "] " + getMessage();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
index a62339d0f4..8aa8d3f5e8 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
@@ -71,7 +71,13 @@ public class MsoOpenstackException extends MsoException
@Override
public String toString () {
- String error = "" + statusCode + " " + statusMessage + ": " + errorDetail;
- return error;
+ StringBuilder error = new StringBuilder();
+ error.append("");
+ error.append(statusCode);
+ error.append(" ");
+ error.append(statusMessage);
+ error.append(": ");
+ error.append(errorDetail);
+ return error.toString();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
index 31e2fca4c1..a2e605f897 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
@@ -56,10 +56,18 @@ public class MsoHeatEnvironmentResource {
public void setValue(String value) {
this.value = value;
}
+
+ @Override
public String toString() {
- return "\"" + this.name + "\": " + this.value;
+ StringBuilder str = new StringBuilder();
+ str.append("\"");
+ str.append(this.name);
+ str.append("\": ");
+ str.append(this.value);
+ return str.toString();
}
-
+
+ @Override
public boolean equals(Object o) {
if (!(o instanceof MsoHeatEnvironmentResource)) {
return false;
@@ -74,7 +82,8 @@ public class MsoHeatEnvironmentResource {
}
return false;
}
-
+
+ @Override
public int hashCode() {
int result = 0;
try {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
index bd649e867f..c227d72f0c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
@@ -32,7 +32,6 @@ import java.util.Set;
import java.util.Map.Entry;
import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
import org.codehaus.jackson.map.ObjectMapper;
-import java.util.LinkedHashMap;
import org.yaml.snakeyaml.Yaml;
@@ -63,7 +62,7 @@ public class MsoYamlEditorWithEnvt {
public synchronized Set <MsoHeatEnvironmentParameter> getParameterListFromEnvt() {
// In an environment entry, the parameters section can only contain the name:value -
// not other attributes.
- Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<MsoHeatEnvironmentParameter>();
+ Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<>();
Map<String, Object> resourceMap = null;
try {
resourceMap = (Map<String,Object>) yml.get("parameters");
@@ -79,13 +78,9 @@ public class MsoYamlEditorWithEnvt {
while (it.hasNext()) {
MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter();
Map.Entry <String, Object> pair = it.next();
- //Map<String, String> resourceEntry = (Map <String, String>) pair.getValue();
- //String value = null;
- String value = null;
+ String value;
Object obj = pair.getValue();
if (obj instanceof java.lang.String) {
- //value = (String) pair.getValue();
- // handle block scalar - literals and folded:
value = yaml.dump(obj);
// but this adds an extra '\n' at the end - which won't hurt - but we don't need it
value = value.substring(0, value.length() - 1);
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
index f3f252d96e..2395495a36 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
@@ -30,7 +30,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.map.ObjectMapper;
import org.jboss.resteasy.annotations.providers.NoJackson;
-import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.openstack.beans.VnfStatus;
@XmlRootElement(name = "queryVfModuleResponse")
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index 87be2e1ccb..5140b6c4cb 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -21,8 +21,6 @@
package org.openecomp.mso.adapters.requestsdb;
import java.sql.Timestamp;
-
-import javax.jws.WebMethod;
import javax.jws.WebService;
import org.hibernate.HibernateException;
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java
index d41291420e..a4d9f278ba 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java
@@ -41,7 +41,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
-import javax.ejb.EJB;
import org.openecomp.mso.utils.UUIDChecker;
import org.w3c.dom.Document;
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy
index dcbb73c7db..0abab94597 100755
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy
@@ -1,5 +1,21 @@
/*
- * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.scripts
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 4f621128f2..99909b68a0 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
@@ -53,7 +53,7 @@ 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 abstract class WorkflowAsyncResource {
private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
protected Optional<ProcessEngineServices> pes4junit = Optional.empty();
@@ -261,7 +261,10 @@ public abstract class WorkflowAsyncResource {
}
private static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
- if (inputVariables == null) return "";
+ if (inputVariables == null) {
+ return "";
+ }
+
return Objects.toString(inputVariables.get(key), "N/A");
}
@@ -271,19 +274,21 @@ public abstract class WorkflowAsyncResource {
}
- protected abstract ProcessEngineServices getProcessEngineServices();
+ protected abstract ProcessEngineServices getProcessEngineServices();
public void setProcessEngineServices4junit(ProcessEngineServices pes) {
pes4junit = Optional.ofNullable(pes);
}
private static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
- Map<String, Object> inputVariables = new HashMap<String,Object>();
+ Map<String, Object> inputVariables = new HashMap<>();
@SuppressWarnings("unchecked")
Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
- for (String vName : vMap.keySet()) {
+ for (Map.Entry<String, Object> entry : vMap.entrySet()) {
+ String vName = entry.getKey();
+ Object value = entry.getValue();
@SuppressWarnings("unchecked")
- Map<String, Object> valueMap = (Map<String,Object>)vMap.get(vName); // value, type
+ Map<String, Object> valueMap = (Map<String,Object>)value; // value, type
inputVariables.put(vName, valueMap.get("value"));
}
return inputVariables;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
index 05c0688b21..731b18db36 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
@@ -1,188 +1,188 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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 java.util.concurrent.DelayQueue;
-import java.util.concurrent.TimeUnit;
-
-import javax.ws.rs.core.Response;
-
-import org.jboss.resteasy.spi.AsynchronousResponse;
-import org.slf4j.MDC;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java
- * @version 1.0
- *
- */
-public class WorkflowContextHolder {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]";
- private static WorkflowContextHolder instance = null;
-
- /**
- * Delay Queue which holds workflow context holder objects
- */
- private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<WorkflowContext>();
- private final TimeoutThread timeoutThread = new TimeoutThread();
-
- private WorkflowContextHolder() {
- timeoutThread.start();
- }
-
- /**
- * Singleton holder which eliminates hot lock
- * Since the JVM synchronizes static method there is no synchronization needed for this method
- * @return
- */
- public static synchronized WorkflowContextHolder getInstance() {
- if (instance == null) {
- instance = new WorkflowContextHolder();
- }
- return instance;
- }
-
- public void put(WorkflowContext context) {
- msoLogger.debug(logMarker + " Adding context to the queue: "
- + context.getRequestId());
- responseQueue.put(context);
- }
-
- public void remove(WorkflowContext context) {
- msoLogger.debug(logMarker + " Removing context from the queue: "
- + context.getRequestId());
- responseQueue.remove(context);
- }
-
- public WorkflowContext getWorkflowContext(String requestId) {
- // Note: DelayQueue interator is threadsafe
- for (WorkflowContext context : responseQueue) {
- if (requestId.equals(context.getRequestId())) {
- msoLogger.debug("Found context for request id: " + requestId);
- return context;
- }
- }
-
- msoLogger.debug("Unable to find context for request id: " + requestId);
- return null;
- }
-
- /**
- * Builds the callback response object to respond to client
- * @param processKey
- * @param processInstanceId
- * @param requestId
- * @param callbackResponse
- * @return
- */
- public Response processCallback(String processKey, String processInstanceId,
- String requestId, WorkflowCallbackResponse callbackResponse) {
- WorkflowResponse workflowResponse = new WorkflowResponse();
- WorkflowContext workflowContext = getWorkflowContext(requestId);
-
- if (workflowContext == null) {
- msoLogger.debug("Unable to correlate workflow context for request id: " + requestId
- + ":processInstance Id:" + processInstanceId
- + ":process key:" + processKey);
- workflowResponse.setMessage("Fail");
- workflowResponse.setMessageCode(400);
- workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId);
- return Response.serverError().entity(workflowResponse).build();
- }
-
- responseQueue.remove(workflowContext);
-
- msoLogger.debug("Using callback response for request id: " + requestId);
- workflowResponse.setResponse(callbackResponse.getResponse());
- workflowResponse.setProcessInstanceID(processInstanceId);
- workflowResponse.setMessageCode(callbackResponse.getStatusCode());
- workflowResponse.setMessage(callbackResponse.getMessage());
- sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse);
- return Response.ok().entity(workflowResponse).build();
- }
-
- /**
- * Send the response to client asynchronously when invoked by the BPMN process
- * @param processKey
- * @param workflowContext
- * @param workflowResponse
- */
- private void sendWorkflowResponseToClient(String processKey, WorkflowContext workflowContext,
- WorkflowResponse workflowResponse) {
- msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId());
- recordEvents(processKey, workflowResponse, workflowContext.getStartTime());
- Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build();
- AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse();
- asyncResp.setResponse(response);
- }
-
- /**
- * Timeout thread which monitors the delay queue for expired context and send timeout response
- * to client
- *
- * */
- private class TimeoutThread extends Thread {
- public void run() {
- while (!isInterrupted()) {
- try {
- WorkflowContext requestObject = responseQueue.take();
- msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS));
- msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId());
- WorkflowResponse response = new WorkflowResponse();
- response.setMessage("Fail");
- response.setResponse("Request timedout, request id:" + requestObject.getRequestId());
- //response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId());
- recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime());
- response.setMessageCode(500);
- Response result = Response.status(500).entity(response).build();
- requestObject.getAsynchronousResponse().setResponse(result);
- msoLogger.debug("Sending timeout response for request id:" + requestObject.getRequestId() + ":response:" + response);
- } catch (InterruptedException e) {
- break;
- } catch (Exception e) {
- msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e);
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
- MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread");
-
- }
- }
-
- msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting");
- }
- }
-
- private static void recordEvents(String processKey, WorkflowResponse response,
- long startTime) {
-
- msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- logMarker + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
- + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse());
-
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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 java.util.concurrent.DelayQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.spi.AsynchronousResponse;
+import org.slf4j.MDC;
+
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java
+ * @version 1.0
+ *
+ */
+public class WorkflowContextHolder {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]";
+ private static WorkflowContextHolder instance = null;
+
+ /**
+ * Delay Queue which holds workflow context holder objects
+ */
+ private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<>();
+ private final TimeoutThread timeoutThread = new TimeoutThread();
+
+ private WorkflowContextHolder() {
+ timeoutThread.start();
+ }
+
+ /**
+ * Singleton holder which eliminates hot lock
+ * Since the JVM synchronizes static method there is no synchronization needed for this method
+ * @return
+ */
+ public static synchronized WorkflowContextHolder getInstance() {
+ if (instance == null) {
+ instance = new WorkflowContextHolder();
+ }
+ return instance;
+ }
+
+ public void put(WorkflowContext context) {
+ msoLogger.debug(logMarker + " Adding context to the queue: "
+ + context.getRequestId());
+ responseQueue.put(context);
+ }
+
+ public void remove(WorkflowContext context) {
+ msoLogger.debug(logMarker + " Removing context from the queue: "
+ + context.getRequestId());
+ responseQueue.remove(context);
+ }
+
+ public WorkflowContext getWorkflowContext(String requestId) {
+ // Note: DelayQueue interator is threadsafe
+ for (WorkflowContext context : responseQueue) {
+ if (requestId.equals(context.getRequestId())) {
+ msoLogger.debug("Found context for request id: " + requestId);
+ return context;
+ }
+ }
+
+ msoLogger.debug("Unable to find context for request id: " + requestId);
+ return null;
+ }
+
+ /**
+ * Builds the callback response object to respond to client
+ * @param processKey
+ * @param processInstanceId
+ * @param requestId
+ * @param callbackResponse
+ * @return
+ */
+ public Response processCallback(String processKey, String processInstanceId,
+ String requestId, WorkflowCallbackResponse callbackResponse) {
+ WorkflowResponse workflowResponse = new WorkflowResponse();
+ WorkflowContext workflowContext = getWorkflowContext(requestId);
+
+ if (workflowContext == null) {
+ msoLogger.debug("Unable to correlate workflow context for request id: " + requestId
+ + ":processInstance Id:" + processInstanceId
+ + ":process key:" + processKey);
+ workflowResponse.setMessage("Fail");
+ workflowResponse.setMessageCode(400);
+ workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId);
+ return Response.serverError().entity(workflowResponse).build();
+ }
+
+ responseQueue.remove(workflowContext);
+
+ msoLogger.debug("Using callback response for request id: " + requestId);
+ workflowResponse.setResponse(callbackResponse.getResponse());
+ workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setMessageCode(callbackResponse.getStatusCode());
+ workflowResponse.setMessage(callbackResponse.getMessage());
+ sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse);
+ return Response.ok().entity(workflowResponse).build();
+ }
+
+ /**
+ * Send the response to client asynchronously when invoked by the BPMN process
+ * @param processKey
+ * @param workflowContext
+ * @param workflowResponse
+ */
+ private void sendWorkflowResponseToClient(String processKey, WorkflowContext workflowContext,
+ WorkflowResponse workflowResponse) {
+ msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId());
+ recordEvents(processKey, workflowResponse, workflowContext.getStartTime());
+ Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build();
+ AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse();
+ asyncResp.setResponse(response);
+ }
+
+ /**
+ * Timeout thread which monitors the delay queue for expired context and send timeout response
+ * to client
+ *git review -R
+ * */
+ private class TimeoutThread extends Thread {
+ public void run() {
+ while (!isInterrupted()) {
+ try {
+ WorkflowContext requestObject = responseQueue.take();
+ msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS));
+ msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId());
+ WorkflowResponse response = new WorkflowResponse();
+ response.setMessage("Fail");
+ response.setResponse("Request timedout, request id:" + requestObject.getRequestId());
+ //response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId());
+ recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime());
+ response.setMessageCode(500);
+ Response result = Response.status(500).entity(response).build();
+ requestObject.getAsynchronousResponse().setResponse(result);
+ msoLogger.debug("Sending timeout response for request id:" + requestObject.getRequestId() + ":response:" + response);
+ } catch (InterruptedException e) {
+ break;
+ } catch (Exception e) {
+ msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread");
+
+ }
+ }
+
+ msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting");
+ }
+ }
+
+ private static void recordEvents(String processKey, WorkflowResponse response,
+ long startTime) {
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse());
+
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
index 46b6dd8366..0cbcfabddd 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
@@ -1,5 +1,21 @@
/*
- * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.infrastructure.scripts;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java
index 3e29a8221a..328ef816e9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java
@@ -23,6 +23,9 @@ package org.openecomp.mso.apihandlerinfra;
public class Constants {
+ private Constants() {
+ }
+
public static final String VNF_TYPES_PATH = "/{version: v1|v2|v3}/vnf-types";
public static final String NETWORK_TYPES_PATH = "/{version: v1|v2|v3}/network-types";
public static final String VF_MODULE_MODEL_NAMES_PATH = "/{version: v2|v3}/vf-module-model-names";
@@ -47,4 +50,4 @@ public class Constants {
public static final String VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$";
public static final String A_LA_CARTE = "aLaCarte";
-} \ No newline at end of file
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java
index 91bf2df48c..746493c194 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java
@@ -28,7 +28,7 @@ import org.openecomp.mso.apihandler.common.ErrorNumbers;
public class Messages {
- public static final Map<String,String> errors = new HashMap<>();
+ protected static final Map<String,String> errors = new HashMap<>();
static {
errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_service", "Service request FAILED schema validation. %s");
errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_feature", "Feature request FAILED schema validation. %s");