diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/main/java')
34 files changed, 2301 insertions, 2714 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/CallbackHeader.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/CallbackHeader.java index bf4c59ca09..1172d77c13 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/CallbackHeader.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/CallbackHeader.java @@ -28,9 +28,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -49,28 +51,24 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "responseCode", - "responseMessage" -}, namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") +@XmlType(name = "", propOrder = {"requestId", "responseCode", "responseMessage"}, + namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") @XmlRootElement(name = "CallbackHeader") public class CallbackHeader { - @XmlElement(name = "RequestId", required = true, namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") + @XmlElement(name = "RequestId", required = true, namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") protected String requestId; - @XmlElement(name = "ResponseCode", required = true,namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") + @XmlElement(name = "ResponseCode", required = true, namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") protected String responseCode; - @XmlElement(name = "ResponseMessage", required = true,namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") + @XmlElement(name = "ResponseMessage", required = true, + namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") protected String responseMessage; /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getRequestId() { return requestId; @@ -79,10 +77,8 @@ public class CallbackHeader { /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setRequestId(String value) { this.requestId = value; @@ -91,10 +87,8 @@ public class CallbackHeader { /** * Gets the value of the responseCode property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getResponseCode() { return responseCode; @@ -103,10 +97,8 @@ public class CallbackHeader { /** * Sets the value of the responseCode property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setResponseCode(String value) { this.responseCode = value; @@ -115,10 +107,8 @@ public class CallbackHeader { /** * Gets the value of the responseMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getResponseMessage() { return responseMessage; @@ -127,10 +117,8 @@ public class CallbackHeader { /** * Sets the value of the responseMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setResponseMessage(String value) { this.responseMessage = value; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactory.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactory.java index a72e23e57f..721bc1d4f3 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactory.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactory.java @@ -24,17 +24,13 @@ import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 package. - * <p>An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. + * This object contains factory methods for each Java content interface and Java element interface generated in the + * org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 package. + * <p> + * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. + * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in + * this class. * */ @XmlRegistry @@ -42,11 +38,11 @@ public class ObjectFactory { /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: + * org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 * */ - public ObjectFactory() { - } + public ObjectFactory() {} /** * Create an instance of {@link RequestHeader } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/RequestHeader.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/RequestHeader.java index 2c56a110db..58f5c468f5 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/RequestHeader.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/RequestHeader.java @@ -28,9 +28,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -52,14 +54,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "svcInstanceId", - "svcAction", - "svcOperation", - "callbackUrl", - "msoAction" -}) +@XmlType(name = "", propOrder = {"requestId", "svcInstanceId", "svcAction", "svcOperation", "callbackUrl", "msoAction"}) @XmlRootElement(name = "RequestHeader") public class RequestHeader { @@ -79,10 +74,8 @@ public class RequestHeader { /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getRequestId() { return requestId; @@ -91,10 +84,8 @@ public class RequestHeader { /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setRequestId(String value) { this.requestId = value; @@ -103,10 +94,8 @@ public class RequestHeader { /** * Gets the value of the svcInstanceId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getSvcInstanceId() { return svcInstanceId; @@ -115,10 +104,8 @@ public class RequestHeader { /** * Sets the value of the svcInstanceId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setSvcInstanceId(String value) { this.svcInstanceId = value; @@ -127,10 +114,8 @@ public class RequestHeader { /** * Gets the value of the svcAction property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getSvcAction() { return svcAction; @@ -139,10 +124,8 @@ public class RequestHeader { /** * Sets the value of the svcAction property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setSvcAction(String value) { this.svcAction = value; @@ -151,10 +134,8 @@ public class RequestHeader { /** * Gets the value of the svcOperation property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getSvcOperation() { return svcOperation; @@ -163,10 +144,8 @@ public class RequestHeader { /** * Sets the value of the svcOperation property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setSvcOperation(String value) { this.svcOperation = value; @@ -175,10 +154,8 @@ public class RequestHeader { /** * Gets the value of the callbackUrl property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getCallbackUrl() { return callbackUrl; @@ -187,10 +164,8 @@ public class RequestHeader { /** * Sets the value of the callbackUrl property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setCallbackUrl(String value) { this.callbackUrl = value; @@ -199,10 +174,8 @@ public class RequestHeader { /** * Gets the value of the msoAction property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getMsoAction() { return msoAction; @@ -211,10 +184,8 @@ public class RequestHeader { /** * Sets the value of the msoAction property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setMsoAction(String value) { this.msoAction = value; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java index e77232510a..2b4b8cb90f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.common.adapter.sdnc; import java.io.StringWriter; - import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -33,9 +32,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -53,25 +54,21 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", namespace="http://org.onap/workflow/sdnc/adapter/schema/v1", propOrder = { - "callbackHeader", - "requestData" -}) -@XmlRootElement(name = "SDNCAdapterCallbackRequest", namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") +@XmlType(name = "", namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + propOrder = {"callbackHeader", "requestData"}) +@XmlRootElement(name = "SDNCAdapterCallbackRequest", namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") public class SDNCAdapterCallbackRequest { - @XmlElement(name = "CallbackHeader", required = true, namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") + @XmlElement(name = "CallbackHeader", required = true, namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") protected CallbackHeader callbackHeader; - @XmlElement(name = "RequestData", required=false, namespace="http://org.onap/workflow/sdnc/adapter/schema/v1") + @XmlElement(name = "RequestData", required = false, namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") protected Object requestData; /** * Gets the value of the callbackHeader property. * - * @return - * possible object is - * {@link CallbackHeader } - * + * @return possible object is {@link CallbackHeader } + * */ public CallbackHeader getCallbackHeader() { return callbackHeader; @@ -80,10 +77,8 @@ public class SDNCAdapterCallbackRequest { /** * Sets the value of the callbackHeader property. * - * @param value - * allowed object is - * {@link CallbackHeader } - * + * @param value allowed object is {@link CallbackHeader } + * */ public void setCallbackHeader(CallbackHeader value) { this.callbackHeader = value; @@ -92,10 +87,8 @@ public class SDNCAdapterCallbackRequest { /** * Gets the value of the requestData property. * - * @return - * possible object is - * {@link Object } - * + * @return possible object is {@link Object } + * */ public Object getRequestData() { return requestData; @@ -104,27 +97,24 @@ public class SDNCAdapterCallbackRequest { /** * Sets the value of the requestData property. * - * @param value - * allowed object is - * {@link Object } - * + * @param value allowed object is {@link Object } + * */ public void setRequestData(Object value) { this.requestData = value; } @Override - public String toString() { - StringWriter writer = new StringWriter(); - try { - JAXBContext context = JAXBContext - .newInstance(SDNCAdapterCallbackRequest.class); - Marshaller m = context.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - m.marshal(this, writer); - return writer.getBuffer().toString(); - } catch (JAXBException e) { - return ""; - } - } + public String toString() { + StringWriter writer = new StringWriter(); + try { + JAXBContext context = JAXBContext.newInstance(SDNCAdapterCallbackRequest.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.marshal(this, writer); + return writer.getBuffer().toString(); + } catch (JAXBException e) { + return ""; + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java index 179776d95d..0ae5f7a614 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java @@ -28,9 +28,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -48,10 +50,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestHeader", - "requestData" -}) +@XmlType(name = "", propOrder = {"requestHeader", "requestData"}) @XmlRootElement(name = "SDNCAdapterRequest") public class SDNCAdapterRequest { @@ -63,10 +62,8 @@ public class SDNCAdapterRequest { /** * Gets the value of the requestHeader property. * - * @return - * possible object is - * {@link RequestHeader } - * + * @return possible object is {@link RequestHeader } + * */ public RequestHeader getRequestHeader() { return requestHeader; @@ -75,10 +72,8 @@ public class SDNCAdapterRequest { /** * Sets the value of the requestHeader property. * - * @param value - * allowed object is - * {@link RequestHeader } - * + * @param value allowed object is {@link RequestHeader } + * */ public void setRequestHeader(RequestHeader value) { this.requestHeader = value; @@ -87,10 +82,8 @@ public class SDNCAdapterRequest { /** * Gets the value of the requestData property. * - * @return - * possible object is - * {@link Object } - * + * @return possible object is {@link Object } + * */ public Object getRequestData() { return requestData; @@ -99,10 +92,8 @@ public class SDNCAdapterRequest { /** * Sets the value of the requestData property. * - * @param value - * allowed object is - * {@link Object } - * + * @param value allowed object is {@link Object } + * */ public void setRequestData(Object value) { this.requestData = value; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java index 3666cb56a6..332b3ebbbd 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java @@ -27,9 +27,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java index eff70f5b12..887b1994d5 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java @@ -28,12 +28,11 @@ import javax.jws.soap.SOAPBinding; /** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.4-b01 - * Generated source version: 2.2 + * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.4-b01 Generated source version: 2.2 * */ -@WebService(name = "SDNCCallbackAdapterPortType", targetNamespace = "http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1") +@WebService(name = "SDNCCallbackAdapterPortType", + targetNamespace = "http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) public interface SDNCCallbackAdapterPortType { @@ -41,13 +40,13 @@ public interface SDNCCallbackAdapterPortType { /** * * @param sdncAdapterCallbackRequest - * @return - * returns org.openecomp.domain2.workflow.sdnc.adapter.schema.v1.SDNCAdapterResponse + * @return returns org.openecomp.domain2.workflow.sdnc.adapter.schema.v1.SDNCAdapterResponse */ @WebMethod(operationName = "SDNCAdapterCallback") - @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") - public SDNCAdapterResponse sdncAdapterCallback( - @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") - SDNCAdapterCallbackRequest sdncAdapterCallbackRequest); + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + partName = "SDNCAdapterCallbackResponse") + public SDNCAdapterResponse sdncAdapterCallback(@WebParam(name = "SDNCAdapterCallbackRequest", + targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + partName = "SDNCAdapterCallbackRequest") SDNCAdapterCallbackRequest sdncAdapterCallbackRequest); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/package-info.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/package-info.java index ec341d82b5..88be09ee85 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/package-info.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/sdnc/package-info.java @@ -18,5 +18,6 @@ * ============LICENSE_END========================================================= */ -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.onap.so.bpmn.common.adapter.sdnc; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/CreateVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/CreateVnfNotification.java index aa348c7765..e1cb6fd38e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/CreateVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/CreateVnfNotification.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.adapter.vnf; 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; @@ -30,9 +29,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for createVnfNotification complex type. + * <p> + * Java class for createVnfNotification complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="createVnfNotification"> @@ -76,15 +77,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "createVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage", - "vnfId", - "outputs", - "rollback" -}) +@XmlType(name = "createVnfNotification1", + propOrder = {"messageId", "completed", "exception", "errorMessage", "vnfId", "outputs", "rollback"}) public class CreateVnfNotification { @XmlElement(required = true) @@ -99,10 +93,8 @@ public class CreateVnfNotification { /** * Gets the value of the messageId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getMessageId() { return messageId; @@ -111,10 +103,8 @@ public class CreateVnfNotification { /** * Sets the value of the messageId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setMessageId(String value) { this.messageId = value; @@ -139,10 +129,8 @@ public class CreateVnfNotification { /** * Gets the value of the exception property. * - * @return - * possible object is - * {@link MsoExceptionCategory } - * + * @return possible object is {@link MsoExceptionCategory } + * */ public MsoExceptionCategory getException() { return exception; @@ -151,10 +139,8 @@ public class CreateVnfNotification { /** * Sets the value of the exception property. * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * + * @param value allowed object is {@link MsoExceptionCategory } + * */ public void setException(MsoExceptionCategory value) { this.exception = value; @@ -163,10 +149,8 @@ public class CreateVnfNotification { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorMessage() { return errorMessage; @@ -175,10 +159,8 @@ public class CreateVnfNotification { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorMessage(String value) { this.errorMessage = value; @@ -187,10 +169,8 @@ public class CreateVnfNotification { /** * Gets the value of the vnfId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfId() { return vnfId; @@ -199,10 +179,8 @@ public class CreateVnfNotification { /** * Sets the value of the vnfId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfId(String value) { this.vnfId = value; @@ -211,10 +189,8 @@ public class CreateVnfNotification { /** * Gets the value of the outputs property. * - * @return - * possible object is - * {@link CreateVnfNotification.Outputs } - * + * @return possible object is {@link CreateVnfNotification.Outputs } + * */ public CreateVnfNotification.Outputs getOutputs() { return outputs; @@ -223,10 +199,8 @@ public class CreateVnfNotification { /** * Sets the value of the outputs property. * - * @param value - * allowed object is - * {@link CreateVnfNotification.Outputs } - * + * @param value allowed object is {@link CreateVnfNotification.Outputs } + * */ public void setOutputs(CreateVnfNotification.Outputs value) { this.outputs = value; @@ -235,10 +209,8 @@ public class CreateVnfNotification { /** * Gets the value of the rollback property. * - * @return - * possible object is - * {@link VnfRollback } - * + * @return possible object is {@link VnfRollback } + * */ public VnfRollback getRollback() { return rollback; @@ -247,10 +219,8 @@ public class CreateVnfNotification { /** * Sets the value of the rollback property. * - * @param value - * allowed object is - * {@link VnfRollback } - * + * @param value allowed object is {@link VnfRollback } + * */ public void setRollback(VnfRollback value) { this.rollback = value; @@ -258,9 +228,11 @@ public class CreateVnfNotification { /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -288,32 +260,29 @@ public class CreateVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "entry" - }) + @XmlType(name = "", propOrder = {"entry"}) public static class Outputs { protected List<CreateVnfNotification.Outputs.Entry> entry; - + /** * Gets the value of the entry property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the entry property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you + * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> + * method for the entry property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getEntry().add(newItem); + * getEntry().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link CreateVnfNotification.Outputs.Entry } + * Objects of the following type(s) are allowed in the list {@link CreateVnfNotification.Outputs.Entry } * * */ @@ -325,24 +294,26 @@ public class CreateVnfNotification { } // Not a generated method - @Override + @Override public String toString() { - StringBuilder out = new StringBuilder(); - out.append("<outputs>\n"); - if (entry != null) { - for (Entry e : entry) { - out.append(e.toString()); - out.append('\n'); - } - } - out.append("</outputs>"); - return out.toString(); + StringBuilder out = new StringBuilder(); + out.append("<outputs>\n"); + if (entry != null) { + for (Entry e : entry) { + out.append(e.toString()); + out.append('\n'); + } + } + out.append("</outputs>"); + return out.toString(); } /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -360,10 +331,7 @@ public class CreateVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "key", - "value" - }) + @XmlType(name = "", propOrder = {"key", "value"}) public static class Entry { protected String key; @@ -372,10 +340,8 @@ public class CreateVnfNotification { /** * Gets the value of the key property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getKey() { return key; @@ -384,10 +350,8 @@ public class CreateVnfNotification { /** * Sets the value of the key property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setKey(String value) { this.key = value; @@ -396,10 +360,8 @@ public class CreateVnfNotification { /** * Gets the value of the value property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getValue() { return value; @@ -408,55 +370,45 @@ public class CreateVnfNotification { /** * Sets the value of the value property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; - + } - + // Not a generated method @Override public String toString() { - String entrystr; - entrystr = - "<entry>"+ '\n' + - " <key>"+key+"</key>" + '\n' + - " <value>"+value+"</value>" + '\n' + - "</entry>"; - return entrystr; + String entrystr; + entrystr = "<entry>" + '\n' + " <key>" + key + "</key>" + '\n' + " <value>" + value + "</value>" + + '\n' + "</entry>"; + return entrystr; } } } - // Not a generated method - @Override - public String toString() { - String createVnfNotification; - if (exception==null) { - createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <vnfId>"+vnfId+"</vnfId>" + '\n' + - (outputs == null ? "" : outputs.toString() + '\n') + - " <rollback>"+rollback+"</rollback>" + '\n' + - "</ns2:createVnfNotification>"; - } else { - createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - (outputs == null ? "" : outputs.toString() + '\n') + - " <exception>"+exception+"</exception>" + '\n' + - " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + - "</ns2:createVnfNotification>"; - } - return createVnfNotification; - } + // Not a generated method + @Override + public String toString() { + String createVnfNotification; + if (exception == null) { + createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <vnfId>" + vnfId + "</vnfId>" + '\n' + (outputs == null ? "" : outputs.toString() + '\n') + + " <rollback>" + rollback + "</rollback>" + '\n' + "</ns2:createVnfNotification>"; + } else { + createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + " <exception>" + exception + "</exception>" + + '\n' + " <errorMessage>" + errorMessage + "</errorMessage>" + '\n' + + "</ns2:createVnfNotification>"; + } + return createVnfNotification; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java index 3ad217306d..cd4257ec60 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java @@ -27,9 +27,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for deleteVnfNotification complex type. + * <p> + * Java class for deleteVnfNotification complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="deleteVnfNotification"> @@ -49,12 +51,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "deleteVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage" -}) +@XmlType(name = "deleteVnfNotification1", propOrder = {"messageId", "completed", "exception", "errorMessage"}) public class DeleteVnfNotification { @XmlElement(required = true) @@ -66,10 +63,8 @@ public class DeleteVnfNotification { /** * Gets the value of the messageId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getMessageId() { return messageId; @@ -78,10 +73,8 @@ public class DeleteVnfNotification { /** * Sets the value of the messageId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setMessageId(String value) { this.messageId = value; @@ -106,10 +99,8 @@ public class DeleteVnfNotification { /** * Gets the value of the exception property. * - * @return - * possible object is - * {@link MsoExceptionCategory } - * + * @return possible object is {@link MsoExceptionCategory } + * */ public MsoExceptionCategory getException() { return exception; @@ -118,10 +109,8 @@ public class DeleteVnfNotification { /** * Sets the value of the exception property. * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * + * @param value allowed object is {@link MsoExceptionCategory } + * */ public void setException(MsoExceptionCategory value) { this.exception = value; @@ -130,10 +119,8 @@ public class DeleteVnfNotification { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorMessage() { return errorMessage; @@ -142,57 +129,43 @@ public class DeleteVnfNotification { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorMessage(String value) { this.errorMessage = value; } /** - * Overrides toString() method + * Overrides toString() method + * * @return String type (deleteVnfNotification) */ - + @Override - public String toString() { - String deleteVnfNotification; - if (exception == null) { - deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - "</ns2:deleteVnfNotification>"; - } else { - deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <exception>"+exception+"</exception>" + '\n' + - " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + - "</ns2:deleteVnfNotification>"; - } - return deleteVnfNotification; - } - -/* - public String toString() { - StringWriter writer = new StringWriter(); - try { - JAXBContext context = JAXBContext - .newInstance(DeleteVnfNotification.class); - Marshaller m = context.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - m.marshal(this, writer); - //System.out.println("toString() - " + writer.getBuffer().toString()); - return writer.getBuffer().toString(); - } catch (JAXBException e) { - //System.out.println("JAXBException - " + e.getStackTrace()); - return ""; - } - } -*/ - + public String toString() { + String deleteVnfNotification; + if (exception == null) { + deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + "</ns2:deleteVnfNotification>"; + } else { + deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <exception>" + exception + "</exception>" + '\n' + " <errorMessage>" + errorMessage + + "</errorMessage>" + '\n' + "</ns2:deleteVnfNotification>"; + } + return deleteVnfNotification; + } + + /* + * public String toString() { StringWriter writer = new StringWriter(); try { JAXBContext context = JAXBContext + * .newInstance(DeleteVnfNotification.class); Marshaller m = context.createMarshaller(); + * m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(this, writer); + * //System.out.println("toString() - " + writer.getBuffer().toString()); return writer.getBuffer().toString(); } + * catch (JAXBException e) { //System.out.println("JAXBException - " + e.getStackTrace()); return ""; } } + */ + } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoExceptionCategory.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoExceptionCategory.java index e4c95e82cd..aae624dde1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoExceptionCategory.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoExceptionCategory.java @@ -25,10 +25,13 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for msoExceptionCategory. + * <p> + * Java class for msoExceptionCategory. * - * <p>The following schema fragment specifies the expected content contained within this class. * <p> + * The following schema fragment specifies the expected content contained within this class. + * <p> + * * <pre> * <simpleType name="msoExceptionCategory"> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> @@ -45,10 +48,7 @@ import javax.xml.bind.annotation.XmlType; @XmlEnum public enum MsoExceptionCategory { - OPENSTACK, - IO, - INTERNAL, - USERDATA; + OPENSTACK, IO, INTERNAL, USERDATA; public String value() { return name(); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoRequest.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoRequest.java index 6830109097..3db5ca159a 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoRequest.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/MsoRequest.java @@ -26,9 +26,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for msoRequest complex type. + * <p> + * Java class for msoRequest complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="msoRequest"> @@ -46,10 +48,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "msoRequest", propOrder = { - "requestId", - "serviceInstanceId" -}) +@XmlType(name = "msoRequest", propOrder = {"requestId", "serviceInstanceId"}) public class MsoRequest { protected String requestId; @@ -58,10 +57,8 @@ public class MsoRequest { /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getRequestId() { return requestId; @@ -70,10 +67,8 @@ public class MsoRequest { /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setRequestId(String value) { this.requestId = value; @@ -82,10 +77,8 @@ public class MsoRequest { /** * Gets the value of the serviceInstanceId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getServiceInstanceId() { return serviceInstanceId; @@ -94,10 +87,8 @@ public class MsoRequest { /** * Sets the value of the serviceInstanceId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setServiceInstanceId(String value) { this.serviceInstanceId = value; @@ -106,7 +97,7 @@ public class MsoRequest { @Override public String toString() { return "<requestId>" + requestId + "</requestId>" + '\n' + "<serviceInstanceId>" + serviceInstanceId - + "</serviceInstanceId>"; + + "</serviceInstanceId>"; } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/ObjectFactory.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/ObjectFactory.java index 21bd08fae7..c84a9356b8 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/ObjectFactory.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/ObjectFactory.java @@ -27,22 +27,18 @@ import javax.xml.namespace.QName; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.onap.so.adapters.vnf.async.client package. - * <p>An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. + * This object contains factory methods for each Java content interface and Java element interface generated in the + * org.onap.so.adapters.vnf.async.client package. + * <p> + * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. + * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in + * this class. * */ @XmlRegistry public class ObjectFactory { - private static final String VNF_NOTIFY = "http://org.onap.so/vnfNotify"; + private static final String VNF_NOTIFY = "http://org.onap.so/vnfNotify"; private static final QName _RollbackVnfNotification_QNAME = new QName(VNF_NOTIFY, "rollbackVnfNotification"); private static final QName _DeleteVnfNotification_QNAME = new QName(VNF_NOTIFY, "deleteVnfNotification"); private static final QName _CreateVnfNotification_QNAME = new QName(VNF_NOTIFY, "createVnfNotification"); @@ -50,11 +46,11 @@ public class ObjectFactory { private static final QName _QueryVnfNotification_QNAME = new QName(VNF_NOTIFY, "queryVnfNotification"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.onap.so.adapters.vnf.async.client + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: + * org.onap.so.adapters.vnf.async.client * */ - public ObjectFactory() { - } + public ObjectFactory() {} /** * Create an instance of {@link UpdateVnfNotification } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/QueryVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/QueryVnfNotification.java index e7496b8028..d3ac2439c1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/QueryVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/QueryVnfNotification.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.adapter.vnf; 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; @@ -30,9 +29,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for queryVnfNotification complex type. + * <p> + * Java class for queryVnfNotification complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="queryVnfNotification"> @@ -77,16 +78,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "queryVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage", - "vnfExists", - "vnfId", - "status", - "outputs" -}) +@XmlType(name = "queryVnfNotification1", + propOrder = {"messageId", "completed", "exception", "errorMessage", "vnfExists", "vnfId", "status", "outputs"}) public class QueryVnfNotification { @XmlElement(required = true) @@ -102,10 +95,8 @@ public class QueryVnfNotification { /** * Gets the value of the messageId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getMessageId() { return messageId; @@ -114,10 +105,8 @@ public class QueryVnfNotification { /** * Sets the value of the messageId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setMessageId(String value) { this.messageId = value; @@ -142,10 +131,8 @@ public class QueryVnfNotification { /** * Gets the value of the exception property. * - * @return - * possible object is - * {@link MsoExceptionCategory } - * + * @return possible object is {@link MsoExceptionCategory } + * */ public MsoExceptionCategory getException() { return exception; @@ -154,10 +141,8 @@ public class QueryVnfNotification { /** * Sets the value of the exception property. * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * + * @param value allowed object is {@link MsoExceptionCategory } + * */ public void setException(MsoExceptionCategory value) { this.exception = value; @@ -166,10 +151,8 @@ public class QueryVnfNotification { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorMessage() { return errorMessage; @@ -178,10 +161,8 @@ public class QueryVnfNotification { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorMessage(String value) { this.errorMessage = value; @@ -190,10 +171,8 @@ public class QueryVnfNotification { /** * Gets the value of the vnfExists property. * - * @return - * possible object is - * {@link Boolean } - * + * @return possible object is {@link Boolean } + * */ public Boolean isVnfExists() { return vnfExists; @@ -202,10 +181,8 @@ public class QueryVnfNotification { /** * Sets the value of the vnfExists property. * - * @param value - * allowed object is - * {@link Boolean } - * + * @param value allowed object is {@link Boolean } + * */ public void setVnfExists(Boolean value) { this.vnfExists = value; @@ -214,10 +191,8 @@ public class QueryVnfNotification { /** * Gets the value of the vnfId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfId() { return vnfId; @@ -226,10 +201,8 @@ public class QueryVnfNotification { /** * Sets the value of the vnfId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfId(String value) { this.vnfId = value; @@ -238,10 +211,8 @@ public class QueryVnfNotification { /** * Gets the value of the status property. * - * @return - * possible object is - * {@link VnfStatus } - * + * @return possible object is {@link VnfStatus } + * */ public VnfStatus getStatus() { return status; @@ -250,10 +221,8 @@ public class QueryVnfNotification { /** * Sets the value of the status property. * - * @param value - * allowed object is - * {@link VnfStatus } - * + * @param value allowed object is {@link VnfStatus } + * */ public void setStatus(VnfStatus value) { this.status = value; @@ -262,10 +231,8 @@ public class QueryVnfNotification { /** * Gets the value of the outputs property. * - * @return - * possible object is - * {@link QueryVnfNotification.Outputs } - * + * @return possible object is {@link QueryVnfNotification.Outputs } + * */ public QueryVnfNotification.Outputs getOutputs() { return outputs; @@ -274,10 +241,8 @@ public class QueryVnfNotification { /** * Sets the value of the outputs property. * - * @param value - * allowed object is - * {@link QueryVnfNotification.Outputs } - * + * @param value allowed object is {@link QueryVnfNotification.Outputs } + * */ public void setOutputs(QueryVnfNotification.Outputs value) { this.outputs = value; @@ -285,9 +250,11 @@ public class QueryVnfNotification { /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -315,9 +282,7 @@ public class QueryVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "entry" - }) + @XmlType(name = "", propOrder = {"entry"}) public static class Outputs { protected List<QueryVnfNotification.Outputs.Entry> entry; @@ -326,21 +291,20 @@ public class QueryVnfNotification { * Gets the value of the entry property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the entry property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you + * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> + * method for the entry property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getEntry().add(newItem); + * getEntry().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link QueryVnfNotification.Outputs.Entry } + * Objects of the following type(s) are allowed in the list {@link QueryVnfNotification.Outputs.Entry } * * */ @@ -350,26 +314,28 @@ public class QueryVnfNotification { } return this.entry; } - + // Not a generated method public String toString() { - StringBuilder out = new StringBuilder(); - out.append("<outputs>\n"); - if (entry != null) { - for (Entry e : entry) { - out.append(e.toString()); - out.append('\n'); - } - } - out.append("</outputs>"); - return out.toString(); + StringBuilder out = new StringBuilder(); + out.append("<outputs>\n"); + if (entry != null) { + for (Entry e : entry) { + out.append(e.toString()); + out.append('\n'); + } + } + out.append("</outputs>"); + return out.toString(); } /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -387,10 +353,7 @@ public class QueryVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "key", - "value" - }) + @XmlType(name = "", propOrder = {"key", "value"}) public static class Entry { protected String key; @@ -399,10 +362,8 @@ public class QueryVnfNotification { /** * Gets the value of the key property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getKey() { return key; @@ -411,10 +372,8 @@ public class QueryVnfNotification { /** * Sets the value of the key property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setKey(String value) { this.key = value; @@ -423,10 +382,8 @@ public class QueryVnfNotification { /** * Gets the value of the value property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getValue() { return value; @@ -435,54 +392,44 @@ public class QueryVnfNotification { /** * Sets the value of the value property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; } - + // Not a generated method public String toString() { - String entry = ""; - entry = - "<entry>"+ '\n' + - " <key>"+key+"</key>" + '\n' + - " <value>"+value+"</value>" + '\n' + - "</entry>"; - return entry; + String entry = ""; + entry = "<entry>" + '\n' + " <key>" + key + "</key>" + '\n' + " <value>" + value + "</value>" + '\n' + + "</entry>"; + return entry; } } } - - // Not a generated method - public String toString() { - String queryVnfNotification = ""; - if (exception==null) { - queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <vnfExists>"+vnfExists+"</vnfExists>" + '\n' + - " <vnfId>"+vnfId+"</vnfId>" + '\n' + - " <status>"+status+"</status>" + '\n' + - (outputs == null ? "" : outputs.toString() + '\n') + - "</ns2:queryVnfNotification>"; - } else { - queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - (outputs == null ? "" : outputs.toString() + '\n') + - " <exception>"+exception+"</exception>" + '\n' + - " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + - "</ns2:queryVnfNotification>"; - } - return queryVnfNotification; - } + + // Not a generated method + public String toString() { + String queryVnfNotification = ""; + if (exception == null) { + queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <vnfExists>" + vnfExists + "</vnfExists>" + '\n' + " <vnfId>" + vnfId + "</vnfId>" + '\n' + + " <status>" + status + "</status>" + '\n' + (outputs == null ? "" : outputs.toString() + '\n') + + "</ns2:queryVnfNotification>"; + } else { + queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + " <exception>" + exception + "</exception>" + + '\n' + " <errorMessage>" + errorMessage + "</errorMessage>" + '\n' + + "</ns2:queryVnfNotification>"; + } + return queryVnfNotification; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/RollbackVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/RollbackVnfNotification.java index 6b143a2494..70e8199e95 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/RollbackVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/RollbackVnfNotification.java @@ -27,9 +27,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for rollbackVnfNotification complex type. + * <p> + * Java class for rollbackVnfNotification complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="rollbackVnfNotification"> @@ -49,12 +51,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "rollbackVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage" -}) +@XmlType(name = "rollbackVnfNotification1", propOrder = {"messageId", "completed", "exception", "errorMessage"}) public class RollbackVnfNotification { @XmlElement(required = true) @@ -66,10 +63,8 @@ public class RollbackVnfNotification { /** * Gets the value of the messageId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getMessageId() { return messageId; @@ -78,10 +73,8 @@ public class RollbackVnfNotification { /** * Sets the value of the messageId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setMessageId(String value) { this.messageId = value; @@ -106,10 +99,8 @@ public class RollbackVnfNotification { /** * Gets the value of the exception property. * - * @return - * possible object is - * {@link MsoExceptionCategory } - * + * @return possible object is {@link MsoExceptionCategory } + * */ public MsoExceptionCategory getException() { return exception; @@ -118,10 +109,8 @@ public class RollbackVnfNotification { /** * Sets the value of the exception property. * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * + * @param value allowed object is {@link MsoExceptionCategory } + * */ public void setException(MsoExceptionCategory value) { this.exception = value; @@ -130,10 +119,8 @@ public class RollbackVnfNotification { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorMessage() { return errorMessage; @@ -142,34 +129,29 @@ public class RollbackVnfNotification { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorMessage(String value) { this.errorMessage = value; } - + public String toString() { - String rollbackVnfNotification = ""; - if (exception==null) { - rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - "</ns2:rollbackVnfNotification>"; - } else { - rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <exception>"+exception+"</exception>" + '\n' + - " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + - "</ns2:rollbackVnfNotification>"; - } - return rollbackVnfNotification; + String rollbackVnfNotification = ""; + if (exception == null) { + rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + "</ns2:rollbackVnfNotification>"; + } else { + rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <exception>" + exception + "</exception>" + '\n' + " <errorMessage>" + errorMessage + + "</errorMessage>" + '\n' + "</ns2:rollbackVnfNotification>"; + } + return rollbackVnfNotification; } - - } + +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/UpdateVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/UpdateVnfNotification.java index b89135b865..dd86f340a2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/UpdateVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/UpdateVnfNotification.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.adapter.vnf; 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; @@ -30,9 +29,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for updateVnfNotification complex type. + * <p> + * Java class for updateVnfNotification complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="updateVnfNotification"> @@ -75,14 +76,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "updateVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage", - "outputs", - "rollback" -}) +@XmlType(name = "updateVnfNotification1", + propOrder = {"messageId", "completed", "exception", "errorMessage", "outputs", "rollback"}) public class UpdateVnfNotification { @XmlElement(required = true) @@ -96,9 +91,7 @@ public class UpdateVnfNotification { /** * Gets the value of the messageId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getMessageId() { @@ -108,9 +101,7 @@ public class UpdateVnfNotification { /** * Sets the value of the messageId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setMessageId(String value) { @@ -136,9 +127,7 @@ public class UpdateVnfNotification { /** * Gets the value of the exception property. * - * @return - * possible object is - * {@link MsoExceptionCategory } + * @return possible object is {@link MsoExceptionCategory } * */ public MsoExceptionCategory getException() { @@ -148,9 +137,7 @@ public class UpdateVnfNotification { /** * Sets the value of the exception property. * - * @param value - * allowed object is - * {@link MsoExceptionCategory } + * @param value allowed object is {@link MsoExceptionCategory } * */ public void setException(MsoExceptionCategory value) { @@ -160,9 +147,7 @@ public class UpdateVnfNotification { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getErrorMessage() { @@ -172,9 +157,7 @@ public class UpdateVnfNotification { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setErrorMessage(String value) { @@ -184,9 +167,7 @@ public class UpdateVnfNotification { /** * Gets the value of the outputs property. * - * @return - * possible object is - * {@link UpdateVnfNotification.Outputs } + * @return possible object is {@link UpdateVnfNotification.Outputs } * */ public UpdateVnfNotification.Outputs getOutputs() { @@ -196,9 +177,7 @@ public class UpdateVnfNotification { /** * Sets the value of the outputs property. * - * @param value - * allowed object is - * {@link UpdateVnfNotification.Outputs } + * @param value allowed object is {@link UpdateVnfNotification.Outputs } * */ public void setOutputs(UpdateVnfNotification.Outputs value) { @@ -208,9 +187,7 @@ public class UpdateVnfNotification { /** * Gets the value of the rollback property. * - * @return - * possible object is - * {@link VnfRollback } + * @return possible object is {@link VnfRollback } * */ public VnfRollback getRollback() { @@ -220,9 +197,7 @@ public class UpdateVnfNotification { /** * Sets the value of the rollback property. * - * @param value - * allowed object is - * {@link VnfRollback } + * @param value allowed object is {@link VnfRollback } * */ public void setRollback(VnfRollback value) { @@ -231,9 +206,11 @@ public class UpdateVnfNotification { /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -261,9 +238,7 @@ public class UpdateVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "entry" - }) + @XmlType(name = "", propOrder = {"entry"}) public static class Outputs { protected List<UpdateVnfNotification.Outputs.Entry> entry; @@ -272,21 +247,20 @@ public class UpdateVnfNotification { * Gets the value of the entry property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the entry property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you + * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> + * method for the entry property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getEntry().add(newItem); + * getEntry().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link UpdateVnfNotification.Outputs.Entry } + * Objects of the following type(s) are allowed in the list {@link UpdateVnfNotification.Outputs.Entry } * * */ @@ -299,9 +273,11 @@ public class UpdateVnfNotification { /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -319,10 +295,7 @@ public class UpdateVnfNotification { * */ @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "key", - "value" - }) + @XmlType(name = "", propOrder = {"key", "value"}) public static class Entry { protected String key; @@ -331,9 +304,7 @@ public class UpdateVnfNotification { /** * Gets the value of the key property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getKey() { @@ -343,9 +314,7 @@ public class UpdateVnfNotification { /** * Sets the value of the key property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setKey(String value) { @@ -355,9 +324,7 @@ public class UpdateVnfNotification { /** * Gets the value of the value property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getValue() { @@ -367,9 +334,7 @@ public class UpdateVnfNotification { /** * Sets the value of the value property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setValue(String value) { @@ -377,36 +342,30 @@ public class UpdateVnfNotification { } public String toString() { - String entry = ""; - entry = - " <key>"+key+"</key>" + '\n' + - " <value>"+value+"</value>"; - return entry; + String entry = ""; + entry = " <key>" + key + "</key>" + '\n' + " <value>" + value + "</value>"; + return entry; } } } - public String toString(){ - String updateVnfNotification = ""; - if (exception==null) { - updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <rollback>"+rollback+"</rollback>" + '\n' + - "</ns2:updateVnfNotification>"; - } else { - updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + - " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + - " <messageId>"+messageId+"</messageId>" + '\n' + - " <completed>"+completed+"</completed>" + '\n' + - " <exception>"+exception+"</exception>" + '\n' + - " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + - "</ns2:updateVnfNotification>"; - } - - return updateVnfNotification; + public String toString() { + String updateVnfNotification = ""; + if (exception == null) { + updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <rollback>" + rollback + "</rollback>" + '\n' + "</ns2:updateVnfNotification>"; + } else { + updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.onap.so/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + " <messageId>" + + messageId + "</messageId>" + '\n' + " <completed>" + completed + "</completed>" + '\n' + + " <exception>" + exception + "</exception>" + '\n' + " <errorMessage>" + errorMessage + + "</errorMessage>" + '\n' + "</ns2:updateVnfNotification>"; + } + + return updateVnfNotification; } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify.java index adedca9ac5..1390b82c50 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify.java @@ -30,15 +30,11 @@ import javax.xml.ws.RequestWrapper; /** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.8 - * Generated source version: 2.2 + * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.8 Generated source version: 2.2 * */ @WebService(name = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify") -@XmlSeeAlso({ - ObjectFactory.class -}) +@XmlSeeAlso({ObjectFactory.class}) public interface VnfAdapterNotify { @@ -51,17 +47,13 @@ public interface VnfAdapterNotify { */ @WebMethod @Oneway - @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification") + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackVnfNotificationRequest") - public void rollbackVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage); + public void rollbackVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage); /** * @@ -76,25 +68,17 @@ public interface VnfAdapterNotify { */ @WebMethod @Oneway - @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification") + @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/queryVnfNotificationRequest") - public void queryVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfExists", targetNamespace = "") - Boolean vnfExists, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "status", targetNamespace = "") - VnfStatus status, - @WebParam(name = "outputs", targetNamespace = "") - org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs); + public void queryVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") String vnfId, + @WebParam(name = "status", targetNamespace = "") VnfStatus status, @WebParam(name = "outputs", + targetNamespace = "") org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs); /** * @@ -108,23 +92,17 @@ public interface VnfAdapterNotify { */ @WebMethod @Oneway - @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification") + @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest") - public void createVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "outputs", targetNamespace = "") - org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback); + public void createVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") String vnfId, + @WebParam(name = "outputs", + targetNamespace = "") org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback); /** * @@ -137,21 +115,16 @@ public interface VnfAdapterNotify { */ @WebMethod @Oneway - @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification") + @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest") - public void updateVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "outputs", targetNamespace = "") - org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback); + public void updateVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "outputs", + targetNamespace = "") org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback); /** * @@ -162,16 +135,12 @@ public interface VnfAdapterNotify { */ @WebMethod @Oneway - @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification") + @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest") - public void deleteVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage); + public void deleteVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java index 667545d855..531b6d572e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java @@ -30,24 +30,24 @@ import javax.xml.ws.WebServiceFeature; /** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.8 - * Generated source version: 2.2 + * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.8 Generated source version: 2.2 * */ -@WebServiceClient(name = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify", wsdlLocation = "/VnfAdapterNotify.wsdl") -public class VnfAdapterNotify_Service extends Service -{ +@WebServiceClient(name = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify", + wsdlLocation = "/VnfAdapterNotify.wsdl") +public class VnfAdapterNotify_Service extends Service { private final static URL VNFADAPTERNOTIFY_WSDL_LOCATION; private final static WebServiceException VNFADAPTERNOTIFY_EXCEPTION; private final static QName VNFADAPTERNOTIFY_QNAME = new QName("http://org.onap.so/vnfNotify", "vnfAdapterNotify"); static { - VNFADAPTERNOTIFY_WSDL_LOCATION = org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify_Service.class.getResource("/VnfAdapterNotify.wsdl"); + VNFADAPTERNOTIFY_WSDL_LOCATION = org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify_Service.class + .getResource("/VnfAdapterNotify.wsdl"); WebServiceException e = null; if (VNFADAPTERNOTIFY_WSDL_LOCATION == null) { - e = new WebServiceException("Cannot find '/VnfAdapterNotify.wsdl' wsdl. Place the resource correctly in the classpath."); + e = new WebServiceException( + "Cannot find '/VnfAdapterNotify.wsdl' wsdl. Place the resource correctly in the classpath."); } VNFADAPTERNOTIFY_EXCEPTION = e; } @@ -78,28 +78,28 @@ public class VnfAdapterNotify_Service extends Service /** * - * @return - * returns VnfAdapterNotify + * @return returns VnfAdapterNotify */ @WebEndpoint(name = "MsoVnfAdapterAsyncImplPort") public VnfAdapterNotify getMsoVnfAdapterAsyncImplPort() { - return super.getPort(new QName("http://org.onap.so/vnfNotify", "MsoVnfAdapterAsyncImplPort"), VnfAdapterNotify.class); + return super.getPort(new QName("http://org.onap.so/vnfNotify", "MsoVnfAdapterAsyncImplPort"), + VnfAdapterNotify.class); } /** * - * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. - * @return - * returns VnfAdapterNotify + * @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features + * not in the <code>features</code> parameter will have their default values. + * @return returns VnfAdapterNotify */ @WebEndpoint(name = "MsoVnfAdapterAsyncImplPort") public VnfAdapterNotify getMsoVnfAdapterAsyncImplPort(WebServiceFeature... features) { - return super.getPort(new QName("http://org.onap.so/vnfNotify", "MsoVnfAdapterAsyncImplPort"), VnfAdapterNotify.class, features); + return super.getPort(new QName("http://org.onap.so/vnfNotify", "MsoVnfAdapterAsyncImplPort"), + VnfAdapterNotify.class, features); } private static URL __getWsdlLocation() { - if (VNFADAPTERNOTIFY_EXCEPTION!= null) { + if (VNFADAPTERNOTIFY_EXCEPTION != null) { throw VNFADAPTERNOTIFY_EXCEPTION; } return VNFADAPTERNOTIFY_WSDL_LOCATION; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfRollback.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfRollback.java index 9fd3bc596f..1e02c0d07c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfRollback.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfRollback.java @@ -26,9 +26,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for vnfRollback complex type. + * <p> + * Java class for vnfRollback complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="vnfRollback"> @@ -51,15 +53,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "vnfRollback", propOrder = { - "cloudSiteId", - "cloudOwner", - "msoRequest", - "tenantCreated", - "tenantId", - "vnfCreated", - "vnfId" -}) +@XmlType(name = "vnfRollback", + propOrder = {"cloudSiteId", "cloudOwner", "msoRequest", "tenantCreated", "tenantId", "vnfCreated", "vnfId"}) public class VnfRollback { protected String cloudSiteId; @@ -73,10 +68,8 @@ public class VnfRollback { /** * Gets the value of the cloudSiteId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getCloudSiteId() { return cloudSiteId; @@ -85,10 +78,8 @@ public class VnfRollback { /** * Sets the value of the cloudSiteId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setCloudSiteId(String value) { this.cloudSiteId = value; @@ -97,10 +88,8 @@ public class VnfRollback { /** * Gets the value of the cloudOwner property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getCloudOwner() { return cloudOwner; @@ -109,10 +98,8 @@ public class VnfRollback { /** * Sets the value of the cloudOwner property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setCloudOwner(String value) { this.cloudOwner = value; @@ -121,10 +108,8 @@ public class VnfRollback { /** * Gets the value of the msoRequest property. * - * @return - * possible object is - * {@link MsoRequest } - * + * @return possible object is {@link MsoRequest } + * */ public MsoRequest getMsoRequest() { return msoRequest; @@ -133,10 +118,8 @@ public class VnfRollback { /** * Sets the value of the msoRequest property. * - * @param value - * allowed object is - * {@link MsoRequest } - * + * @param value allowed object is {@link MsoRequest } + * */ public void setMsoRequest(MsoRequest value) { this.msoRequest = value; @@ -161,10 +144,8 @@ public class VnfRollback { /** * Gets the value of the tenantId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getTenantId() { return tenantId; @@ -173,10 +154,8 @@ public class VnfRollback { /** * Sets the value of the tenantId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setTenantId(String value) { this.tenantId = value; @@ -201,10 +180,8 @@ public class VnfRollback { /** * Gets the value of the vnfId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfId() { return vnfId; @@ -213,26 +190,19 @@ public class VnfRollback { /** * Sets the value of the vnfId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfId(String value) { this.vnfId = value; } - + public String toString() { - String msoRequestElement = msoRequest == null ? "" - : "<msoRequest>"+msoRequest+"</msoRequest>" + '\n'; - - return - "<cloudSiteId>"+cloudSiteId+"</cloudSiteId>" + '\n' + - "<cloudOwner>"+cloudOwner+"</cloudOwner>" + '\n' + - msoRequestElement + - "<tenantCreated>"+tenantCreated+"</tenantCreated>" + '\n' + - "<tenantId>"+tenantId+"</tenantId>" + '\n' + - "<vnfCreated>"+vnfCreated+"</vnfCreated>" + '\n' + - "<vnfId>"+vnfId+"</vnfId>"; + String msoRequestElement = msoRequest == null ? "" : "<msoRequest>" + msoRequest + "</msoRequest>" + '\n'; + + return "<cloudSiteId>" + cloudSiteId + "</cloudSiteId>" + '\n' + "<cloudOwner>" + cloudOwner + "</cloudOwner>" + + '\n' + msoRequestElement + "<tenantCreated>" + tenantCreated + "</tenantCreated>" + '\n' + + "<tenantId>" + tenantId + "</tenantId>" + '\n' + "<vnfCreated>" + vnfCreated + "</vnfCreated>" + '\n' + + "<vnfId>" + vnfId + "</vnfId>"; } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfStatus.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfStatus.java index d093f79e03..007b5ab487 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfStatus.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/VnfStatus.java @@ -25,10 +25,13 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for vnfStatus. + * <p> + * Java class for vnfStatus. * - * <p>The following schema fragment specifies the expected content contained within this class. * <p> + * The following schema fragment specifies the expected content contained within this class. + * <p> + * * <pre> * <simpleType name="vnfStatus"> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> @@ -45,10 +48,7 @@ import javax.xml.bind.annotation.XmlType; @XmlEnum public enum VnfStatus { - ACTIVE, - FAILED, - NOTFOUND, - UNKNOWN; + ACTIVE, FAILED, NOTFOUND, UNKNOWN; public String value() { return name(); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index 46a6fa3ef3..7c0c2f20b3 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.camunda.bpm.engine.MismatchingMessageCorrelationException; import org.camunda.bpm.engine.OptimisticLockingException; import org.camunda.bpm.engine.RuntimeService; @@ -46,372 +45,354 @@ import org.springframework.stereotype.Service; */ @Service public class CallbackHandlerService { - public static final long DEFAULT_TIMEOUT_SECONDS = 60; - public static final long FAST_POLL_DUR_SECONDS = 5; - public static final long FAST_POLL_INT_MS = 100; - public static final long SLOW_POLL_INT_MS = 1000; - - private static final Logger logger = LoggerFactory.getLogger(CallbackHandlerService.class); - - private RuntimeService runtimeService; - - @Autowired - public CallbackHandlerService(RuntimeService runtimeService) { - this.runtimeService = runtimeService; - } - - /** - * Parameterized callback handler. - */ - @Async - protected CallbackResult handleCallback(String method, Object message, - String messageEventName, String messageVariable, - String correlationVariable, String correlationValue, - String logMarker) { - - return handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker, null); - } - - /** - * Parameterized callback handler. - */ - protected CallbackResult handleCallback(String method, Object message, - String messageEventName, String messageVariable, - String correlationVariable, String correlationValue, - String logMarker, Map<String, Object> injectedVariables) { - - long startTime = System.currentTimeMillis(); - - logger.debug(logMarker + " " + method + " received message: " - + (message == null ? "" : System.lineSeparator()) + message); - - try { - Map<String, Object> variables = new HashMap<>(); - - if (injectedVariables != null) { - variables.putAll(injectedVariables); - } - - variables.put(correlationVariable, correlationValue); - variables.put(messageVariable, message == null ? null : message.toString()); - - boolean ok = correlate(messageEventName, correlationVariable, - correlationValue, variables, logMarker); - - if (!ok) { - String msg = "No process is waiting for " + messageEventName - + " with " + correlationVariable + " = '" + correlationValue + "'"; - logCallbackError(method, startTime, msg); - return new CallbackError(msg); - } - - logCallbackSuccess(method, startTime); - return new CallbackSuccess(); - } catch (Exception e) { - logger.debug("Exception :",e); - String msg = "Caught " + e.getClass().getSimpleName() - + " processing " + messageEventName + " with " + correlationVariable - + " = '" + correlationValue + "'"; - logCallbackError(method, startTime, msg); - return new CallbackError(msg); - } - } - - /** - * Performs message correlation. Waits a limited amount of time for - * a process to become ready for correlation. The return value indicates - * whether or not a process was found to receive the message. Due to the - * synchronous nature of message injection in Camunda, by the time this - * method returns, one of 3 things will have happened: (1) the process - * received the message and ended, (2) the process received the message - * and reached an activity that suspended, or (3) an exception occurred - * during correlation or while the process was executing. Correlation - * exceptions are handled differently from process execution exceptions. - * Correlation exceptions are thrown so the client knows something went - * wrong with the delivery of the message. Process execution exceptions - * are logged but not thrown. - * @param messageEventName the message event name - * @param correlationVariable the process variable used as the correlator - * @param correlationValue the correlation value - * @param variables variables to inject into the process - * @param logMarker a marker for debug logging - * @return true if a process could be found, false if not - */ - protected boolean correlate(String messageEventName, String correlationVariable, - String correlationValue, Map<String, Object> variables, String logMarker) { - try{ - logger.debug(logMarker + " Attempting to find process waiting" - + " for " + messageEventName + " with " + correlationVariable - + " = '" + correlationValue + "'"); - - - - long timeout = DEFAULT_TIMEOUT_SECONDS; - - // The code is here in case we ever need to change the default. - String correlationTimemout = UrnPropertiesReader.getVariable("mso.correlation.timeout"); - if (correlationTimemout != null) { - try { - timeout = Long.parseLong(correlationTimemout); - } catch (NumberFormatException e) { - // Ignore - } - } - - long now = System.currentTimeMillis(); - long fastPollEndTime = now + (FAST_POLL_DUR_SECONDS * 1000); - long endTime = now + (timeout * 1000); - long sleep = FAST_POLL_INT_MS; - - List<Execution> waitingProcesses = null; - Exception queryException = null; - int queryCount = 0; - int queryFailCount = 0; - - while (true) { - try { - ++queryCount; - waitingProcesses = runtimeService.createExecutionQuery() - .messageEventSubscriptionName(messageEventName) - .processVariableValueEquals(correlationVariable, correlationValue) - .list(); - } catch (Exception e) { - ++queryFailCount; - queryException = e; - } - - if (waitingProcesses != null && waitingProcesses.size() > 0) { - break; - } - - if (now > endTime - sleep) { - break; - } - - Thread.sleep(sleep); - now = System.currentTimeMillis(); - - if (now > fastPollEndTime) { - sleep = SLOW_POLL_INT_MS; - } - } - - if (waitingProcesses == null) { - waitingProcesses = new ArrayList<Execution>(0); - } - - int count = waitingProcesses.size(); - - List<ExecInfo> execInfoList = new ArrayList<>(count); - for (Execution execution : waitingProcesses) { - execInfoList.add(new ExecInfo(execution)); - } - - logger.debug(logMarker + " Found " + count + " process(es) waiting" - + " for " + messageEventName + " with " + correlationVariable - + " = '" + correlationValue + "': " + execInfoList); - - if (count == 0) { - if (queryFailCount > 0) { - String msg = queryFailCount + "/" + queryCount - + " execution queries failed attempting to correlate " - + messageEventName + " with " + correlationVariable - + " = '" + correlationValue + "'; last exception was:" - + queryException; - logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), msg, queryException); - } - - return false; - } - - if (count > 1) { - // Only one process should be waiting. Throw an exception back to the client. - throw new MismatchingMessageCorrelationException(messageEventName, - "more than 1 process is waiting with " + correlationVariable - + " = '" + correlationValue + "'"); - } - - // We prototyped an asynchronous solution, i.e. resuming the process - // flow in a separate thread, but this affected too many existing tests, - // and we went back to the synchronous solution. The synchronous solution - // has some troublesome characteristics though. For example, the - // resumed flow may send request #2 to a remote system before MSO has - // acknowledged the notification associated with request #1. - - try { - logger.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " - + messageEventName + " with " + correlationVariable + " = '" - + correlationValue + "'"); - - @SuppressWarnings("unused") - MessageCorrelationResult result = runtimeService - .createMessageCorrelation(messageEventName) - .setVariables(variables) - .processInstanceVariableEquals(correlationVariable, correlationValue) - .correlateWithResult(); - - } catch (MismatchingMessageCorrelationException e) { - // A correlation exception occurred even after we identified - // one waiting process. Throw it back to the client. - throw e; - } catch (OptimisticLockingException ole) { - - String msg = "Caught " + ole.getClass().getSimpleName() + " after receiving " + messageEventName - + " with " + correlationVariable + " = '" + correlationValue - + "': " + ole; - logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", - ErrorCode.UnknownError.getValue(), msg, ole); - - //Retry for OptimisticLocking Exceptions - int retryCount = 0; - String retryStr = UrnPropertiesReader.getVariable("mso.bpmn.optimisticlockingexception.retrycount"); - if (retryStr != null) { - try { - retryCount = Integer.parseInt(retryStr); - } catch (NumberFormatException e) { - // Ignore - } - } - - logger.debug("Retry correlate for OptimisticLockingException, retryCount:{}", retryCount); - - for (; retryCount >0 ; retryCount--) { - - try{ - Thread.sleep(SLOW_POLL_INT_MS); - - @SuppressWarnings("unused") - MessageCorrelationResult result = runtimeService - .createMessageCorrelation(messageEventName) - .setVariables(variables) - .processInstanceVariableEquals(correlationVariable, correlationValue) - .correlateWithResult(); - retryCount = 0; - logger.debug("OptimisticLockingException retry was successful, seting retryCount: {}", retryCount); - } catch (OptimisticLockingException olex) { - //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; - String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + olex; - logger.debug(strMsg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), strMsg, olex); - } catch (Exception excep) { - retryCount = 0; - //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; - String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + excep; - logger.debug(strMsg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), strMsg, excep); - } - - } - - }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() + " running " - + execInfoList.get(0) + " after receiving " + messageEventName - + " with " + correlationVariable + " = '" + correlationValue - + "': " + e; - logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), 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.toString(), "BPMN CORRELATION ERROR -", - ErrorCode.UnknownError.getValue(), msg, e); - } - - return true; - } - - /** - * Records audit and metric events in the log for a callback success. - * @param method the method name - * @param startTime the request start time - */ - protected void logCallbackSuccess(String method, long startTime) { - } - - /** - * Records error, audit and metric events in the log for a callback - * internal error. - * @param method the method name - * @param startTime the request start time - * @param msg the error message - */ - protected void logCallbackError(String method, long startTime, String msg) { - logCallbackError(method, startTime, msg, null); - } - - /** - * Records error, audit and metric events in the log for a callback - * internal error. - * @param method the method name - * @param startTime the request start time - * @param msg the error message - * @param e the exception - */ - protected void logCallbackError(String method, long startTime, String msg, Exception e) { - if (e == null) { - logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), msg); - } else { - logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", - ErrorCode.UnknownError.getValue(), msg, e); - } - } - - /** - * Abstract callback result object. - */ - protected abstract class CallbackResult { - } - - /** - * Indicates that callback handling was successful. - */ - protected class CallbackSuccess extends CallbackResult { - } - - /** - * Indicates that callback handling failed. - */ - protected class CallbackError extends CallbackResult { - private final String errorMessage; - - public CallbackError(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * Gets the error message. - */ - public String getErrorMessage() { - return errorMessage; - } - } - - private static class ExecInfo { - private final Execution execution; - - public ExecInfo(Execution execution) { - this.execution = execution; - } - - @Override - public String toString() { - return "Process[" + execution.getProcessInstanceId() - + ":" + execution.getId() + "]"; - } - } + public static final long DEFAULT_TIMEOUT_SECONDS = 60; + public static final long FAST_POLL_DUR_SECONDS = 5; + public static final long FAST_POLL_INT_MS = 100; + public static final long SLOW_POLL_INT_MS = 1000; + + private static final Logger logger = LoggerFactory.getLogger(CallbackHandlerService.class); + + private RuntimeService runtimeService; + + @Autowired + public CallbackHandlerService(RuntimeService runtimeService) { + this.runtimeService = runtimeService; + } + + /** + * Parameterized callback handler. + */ + @Async + protected CallbackResult handleCallback(String method, Object message, String messageEventName, + String messageVariable, String correlationVariable, String correlationValue, String logMarker) { + + return handleCallback(method, message, messageEventName, messageVariable, correlationVariable, correlationValue, + logMarker, null); + } + + /** + * Parameterized callback handler. + */ + protected CallbackResult handleCallback(String method, Object message, String messageEventName, + String messageVariable, String correlationVariable, String correlationValue, String logMarker, + Map<String, Object> injectedVariables) { + + long startTime = System.currentTimeMillis(); + + logger.debug(logMarker + " " + method + " received message: " + (message == null ? "" : System.lineSeparator()) + + message); + + try { + Map<String, Object> variables = new HashMap<>(); + + if (injectedVariables != null) { + variables.putAll(injectedVariables); + } + + variables.put(correlationVariable, correlationValue); + variables.put(messageVariable, message == null ? null : message.toString()); + + boolean ok = correlate(messageEventName, correlationVariable, correlationValue, variables, logMarker); + + if (!ok) { + String msg = "No process is waiting for " + messageEventName + " with " + correlationVariable + " = '" + + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + + logCallbackSuccess(method, startTime); + return new CallbackSuccess(); + } catch (Exception e) { + logger.debug("Exception :", e); + String msg = "Caught " + e.getClass().getSimpleName() + " processing " + messageEventName + " with " + + correlationVariable + " = '" + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + } + + /** + * Performs message correlation. Waits a limited amount of time for a process to become ready for correlation. The + * return value indicates whether or not a process was found to receive the message. Due to the synchronous nature + * of message injection in Camunda, by the time this method returns, one of 3 things will have happened: (1) the + * process received the message and ended, (2) the process received the message and reached an activity that + * suspended, or (3) an exception occurred during correlation or while the process was executing. Correlation + * exceptions are handled differently from process execution exceptions. Correlation exceptions are thrown so the + * client knows something went wrong with the delivery of the message. Process execution exceptions are logged but + * not thrown. + * + * @param messageEventName the message event name + * @param correlationVariable the process variable used as the correlator + * @param correlationValue the correlation value + * @param variables variables to inject into the process + * @param logMarker a marker for debug logging + * @return true if a process could be found, false if not + */ + protected boolean correlate(String messageEventName, String correlationVariable, String correlationValue, + Map<String, Object> variables, String logMarker) { + try { + logger.debug(logMarker + " Attempting to find process waiting" + " for " + messageEventName + " with " + + correlationVariable + " = '" + correlationValue + "'"); + + + + long timeout = DEFAULT_TIMEOUT_SECONDS; + + // The code is here in case we ever need to change the default. + String correlationTimemout = UrnPropertiesReader.getVariable("mso.correlation.timeout"); + if (correlationTimemout != null) { + try { + timeout = Long.parseLong(correlationTimemout); + } catch (NumberFormatException e) { + // Ignore + } + } + + long now = System.currentTimeMillis(); + long fastPollEndTime = now + (FAST_POLL_DUR_SECONDS * 1000); + long endTime = now + (timeout * 1000); + long sleep = FAST_POLL_INT_MS; + + List<Execution> waitingProcesses = null; + Exception queryException = null; + int queryCount = 0; + int queryFailCount = 0; + + while (true) { + try { + ++queryCount; + waitingProcesses = + runtimeService.createExecutionQuery().messageEventSubscriptionName(messageEventName) + .processVariableValueEquals(correlationVariable, correlationValue).list(); + } catch (Exception e) { + ++queryFailCount; + queryException = e; + } + + if (waitingProcesses != null && waitingProcesses.size() > 0) { + break; + } + + if (now > endTime - sleep) { + break; + } + + Thread.sleep(sleep); + now = System.currentTimeMillis(); + + if (now > fastPollEndTime) { + sleep = SLOW_POLL_INT_MS; + } + } + + if (waitingProcesses == null) { + waitingProcesses = new ArrayList<Execution>(0); + } + + int count = waitingProcesses.size(); + + List<ExecInfo> execInfoList = new ArrayList<>(count); + for (Execution execution : waitingProcesses) { + execInfoList.add(new ExecInfo(execution)); + } + + logger.debug(logMarker + " Found " + count + " process(es) waiting" + " for " + messageEventName + " with " + + correlationVariable + " = '" + correlationValue + "': " + execInfoList); + + if (count == 0) { + if (queryFailCount > 0) { + String msg = + queryFailCount + "/" + queryCount + " execution queries failed attempting to correlate " + + messageEventName + " with " + correlationVariable + " = '" + correlationValue + + "'; last exception was:" + queryException; + logger.debug(msg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), msg, queryException); + } + + return false; + } + + if (count > 1) { + // Only one process should be waiting. Throw an exception back to the client. + throw new MismatchingMessageCorrelationException(messageEventName, + "more than 1 process is waiting with " + correlationVariable + " = '" + correlationValue + "'"); + } + + // We prototyped an asynchronous solution, i.e. resuming the process + // flow in a separate thread, but this affected too many existing tests, + // and we went back to the synchronous solution. The synchronous solution + // has some troublesome characteristics though. For example, the + // resumed flow may send request #2 to a remote system before MSO has + // acknowledged the notification associated with request #1. + + try { + logger.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + "'"); + + @SuppressWarnings("unused") + MessageCorrelationResult result = runtimeService.createMessageCorrelation(messageEventName) + .setVariables(variables).processInstanceVariableEquals(correlationVariable, correlationValue) + .correlateWithResult(); + + } catch (MismatchingMessageCorrelationException e) { + // A correlation exception occurred even after we identified + // one waiting process. Throw it back to the client. + throw e; + } catch (OptimisticLockingException ole) { + + String msg = "Caught " + ole.getClass().getSimpleName() + " after receiving " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + "': " + ole; + logger.debug(msg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", + ErrorCode.UnknownError.getValue(), msg, ole); + + // Retry for OptimisticLocking Exceptions + int retryCount = 0; + String retryStr = UrnPropertiesReader.getVariable("mso.bpmn.optimisticlockingexception.retrycount"); + if (retryStr != null) { + try { + retryCount = Integer.parseInt(retryStr); + } catch (NumberFormatException e) { + // Ignore + } + } + + logger.debug("Retry correlate for OptimisticLockingException, retryCount:{}", retryCount); + + for (; retryCount > 0; retryCount--) { + + try { + Thread.sleep(SLOW_POLL_INT_MS); + + @SuppressWarnings("unused") + MessageCorrelationResult result = + runtimeService.createMessageCorrelation(messageEventName).setVariables(variables) + .processInstanceVariableEquals(correlationVariable, correlationValue) + .correlateWithResult(); + retryCount = 0; + logger.debug("OptimisticLockingException retry was successful, seting retryCount: {}", + retryCount); + } catch (OptimisticLockingException olex) { + // oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; + String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + + retryCount + " | exception returned: " + olex; + logger.debug(strMsg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), strMsg, olex); + } catch (Exception excep) { + retryCount = 0; + // oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; + String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + + retryCount + " | exception returned: " + excep; + logger.debug(strMsg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), strMsg, excep); + } + + } + + } 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() + " running " + execInfoList.get(0) + + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + + correlationValue + "': " + e; + logger.debug(msg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), 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.toString(), "BPMN CORRELATION ERROR -", + ErrorCode.UnknownError.getValue(), msg, e); + } + + return true; + } + + /** + * Records audit and metric events in the log for a callback success. + * + * @param method the method name + * @param startTime the request start time + */ + protected void logCallbackSuccess(String method, long startTime) {} + + /** + * Records error, audit and metric events in the log for a callback internal error. + * + * @param method the method name + * @param startTime the request start time + * @param msg the error message + */ + protected void logCallbackError(String method, long startTime, String msg) { + logCallbackError(method, startTime, msg, null); + } + + /** + * Records error, audit and metric events in the log for a callback internal error. + * + * @param method the method name + * @param startTime the request start time + * @param msg the error message + * @param e the exception + */ + protected void logCallbackError(String method, long startTime, String msg, Exception e) { + if (e == null) { + logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), msg); + } else { + logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", + ErrorCode.UnknownError.getValue(), msg, e); + } + } + + /** + * Abstract callback result object. + */ + protected abstract class CallbackResult { + } + + /** + * Indicates that callback handling was successful. + */ + protected class CallbackSuccess extends CallbackResult { + } + + /** + * Indicates that callback handling failed. + */ + protected class CallbackError extends CallbackResult { + private final String errorMessage; + + public CallbackError(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets the error message. + */ + public String getErrorMessage() { + return errorMessage; + } + } + + private static class ExecInfo { + private final Execution execution; + + public ExecInfo(Execution execution) { + this.execution = execution; + } + + @Override + public String toString() { + return "Process[" + execution.getProcessInstanceId() + ":" + execution.getId() + "]"; + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java index 8ceb1c1277..1134bc052b 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java @@ -22,45 +22,45 @@ package org.onap.so.bpmn.common.workflow.service; import java.util.Optional; - import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.ProcessEngines; import org.springframework.stereotype.Service; /** - * Base class for services that must be process-engine aware. The only - * process engine currently supported is the "default" process engine. + * Base class for services that must be process-engine aware. The only process engine currently supported is the + * "default" process engine. */ @Service public class ProcessEngineAwareService { - - private final String processEngineName = "default"; - private volatile Optional<ProcessEngineServices> pes4junit = Optional.empty(); - - /** - * Gets the process engine name. - * @return the process engine name - */ - public String getProcessEngineName() { - return processEngineName; - } - /** - * Gets process engine services. - * @return process engine services - */ - public ProcessEngineServices getProcessEngineServices() { - return pes4junit.orElse(ProcessEngines.getProcessEngine( - getProcessEngineName())); - } + private final String processEngineName = "default"; + private volatile Optional<ProcessEngineServices> pes4junit = Optional.empty(); + + /** + * Gets the process engine name. + * + * @return the process engine name + */ + public String getProcessEngineName() { + return processEngineName; + } + + /** + * Gets process engine services. + * + * @return process engine services + */ + public ProcessEngineServices getProcessEngineServices() { + return pes4junit.orElse(ProcessEngines.getProcessEngine(getProcessEngineName())); + } - /** - * Allows a particular process engine to be specified, overriding the - * usual process engine lookup by name. Intended primarily for the - * unit test environment. - * @param pes process engine services - */ - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = Optional.ofNullable(pes); - } + /** + * Allows a particular process engine to be specified, overriding the usual process engine lookup by name. Intended + * primarily for the unit test environment. + * + * @param pes process engine services + */ + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = Optional.ofNullable(pes); + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java index a74bdfc649..b81506ead9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java @@ -28,7 +28,6 @@ import javax.jws.WebResult; import javax.jws.WebService; import javax.ws.rs.core.Context; import javax.xml.ws.WebServiceContext; - import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterResponse; import org.onap.so.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType; @@ -40,50 +39,53 @@ import org.springframework.stereotype.Service; /** * Implementation of SDNCAdapterCallbackService. */ -@WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.onap/workflow/sdnc/adapter/schema/v1") +@WebService(serviceName = "SDNCAdapterCallbackService", + targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1") @Service public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService implements SDNCCallbackAdapterPortType { - private final static String logMarker = "[SDNC-CALLBACK]"; + private final static String logMarker = "[SDNC-CALLBACK]"; + + @Context + WebServiceContext wsContext; - @Context WebServiceContext wsContext; - - @Autowired - CallbackHandlerService callback; + @Autowired + CallbackHandlerService callback; - @WebMethod(operationName = "SDNCAdapterCallback") - @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") - public SDNCAdapterResponse sdncAdapterCallback( - @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") - SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { + @WebMethod(operationName = "SDNCAdapterCallback") + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + partName = "SDNCAdapterCallbackResponse") + public SDNCAdapterResponse sdncAdapterCallback(@WebParam(name = "SDNCAdapterCallbackRequest", + targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", + partName = "SDNCAdapterCallbackRequest") SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { - String method = "sdncAdapterCallback"; - Object message = sdncAdapterCallbackRequest; - String messageEventName = "sdncAdapterCallbackRequest"; - String messageVariable = "sdncAdapterCallbackRequest"; - String correlationVariable = "SDNCA_requestId"; - String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); + String method = "sdncAdapterCallback"; + Object message = sdncAdapterCallbackRequest; + String messageEventName = "sdncAdapterCallbackRequest"; + String messageVariable = "sdncAdapterCallbackRequest"; + String correlationVariable = "SDNCA_requestId"; + String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - CallbackResult result = callback.handleCallback(method, message, messageEventName, - messageVariable, correlationVariable, correlationValue, logMarker); + CallbackResult result = callback.handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); - if (result instanceof CallbackError) { - return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage()); - } else { - return new SDNCAdapterResponse(); - } - } + if (result instanceof CallbackError) { + return new SDNCAdapterErrorResponse(((CallbackError) result).getErrorMessage()); + } else { + return new SDNCAdapterResponse(); + } + } - // This subclass allows unit tests to extract the error - public class SDNCAdapterErrorResponse extends SDNCAdapterResponse { - private String error; + // This subclass allows unit tests to extract the error + public class SDNCAdapterErrorResponse extends SDNCAdapterResponse { + private String error; - public SDNCAdapterErrorResponse(String error) { - this.error = error; - } + public SDNCAdapterErrorResponse(String error) { + this.error = error; + } - public String getError() { - return error; - } - } + public String getError() { + return error; + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index ed524c115e..5f70ab5924 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -30,7 +30,6 @@ import javax.ws.rs.core.Context; import javax.xml.ws.Action; import javax.xml.ws.RequestWrapper; import javax.xml.ws.WebServiceContext; - import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification; import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification; import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory; @@ -48,195 +47,167 @@ import org.springframework.stereotype.Service; */ @WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify") @Service -public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService implements VnfAdapterNotify{ +public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService implements VnfAdapterNotify { + + private final String logMarker = "[VNF-NOTIFY]"; - private final String logMarker = "[VNF-NOTIFY]"; - - @Autowired - CallbackHandlerService callback; + @Autowired + CallbackHandlerService callback; - @Context WebServiceContext wsContext; + @Context + WebServiceContext wsContext; @WebMethod(operationName = "rollbackVnfNotification") @Oneway - @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification") + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackVnfNotificationRequest") - public void rollbackVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); - - rollbackVnfNotification.setMessageId(messageId); - rollbackVnfNotification.setCompleted(completed); - rollbackVnfNotification.setException(exception); - rollbackVnfNotification.setErrorMessage(errorMessage); - - String method = "rollbackVnfNotification"; - Object message = rollbackVnfNotification; - String messageEventName = "rollbackVnfNotificationCallback"; - String messageVariable = "rollbackVnfNotificationCallback"; - String correlationVariable = "VNFRB_messageId"; - String correlationValue = messageId; - - callback.handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker); + public void rollbackVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage) { + + RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); + + rollbackVnfNotification.setMessageId(messageId); + rollbackVnfNotification.setCompleted(completed); + rollbackVnfNotification.setException(exception); + rollbackVnfNotification.setErrorMessage(errorMessage); + + String method = "rollbackVnfNotification"; + Object message = rollbackVnfNotification; + String messageEventName = "rollbackVnfNotificationCallback"; + String messageVariable = "rollbackVnfNotificationCallback"; + String correlationVariable = "VNFRB_messageId"; + String correlationValue = messageId; + + callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, + correlationValue, logMarker); } @WebMethod(operationName = "queryVnfNotification") @Oneway - @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification") + @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/queryVnfNotificationRequest") - public void queryVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfExists", targetNamespace = "") - Boolean vnfExists, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "status", targetNamespace = "") - VnfStatus status, - @WebParam(name = "outputs", targetNamespace = "") - QueryVnfNotification.Outputs outputs){ - - String method = "queryVnfNotification"; - String messageEventName = "queryVnfNotificationCallback"; - String messageVariable = "queryVnfNotificationCallback"; - String correlationVariable = "VNFQ_messageId"; - String correlationValue = messageId; - - QueryVnfNotification message = new QueryVnfNotification(); - - message.setMessageId(messageId); - message.setCompleted(completed); - message.setException(exception); - message.setErrorMessage(errorMessage); - message.setVnfExists(vnfExists); - message.setVnfId(vnfId); - message.setStatus(status); - message.setOutputs(outputs); - - callback.handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker); + public void queryVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") String vnfId, + @WebParam(name = "status", targetNamespace = "") VnfStatus status, + @WebParam(name = "outputs", targetNamespace = "") QueryVnfNotification.Outputs outputs) { + + String method = "queryVnfNotification"; + String messageEventName = "queryVnfNotificationCallback"; + String messageVariable = "queryVnfNotificationCallback"; + String correlationVariable = "VNFQ_messageId"; + String correlationValue = messageId; + + QueryVnfNotification message = new QueryVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfExists(vnfExists); + message.setVnfId(vnfId); + message.setStatus(status); + message.setOutputs(outputs); + + callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, + correlationValue, logMarker); } - @WebMethod(operationName = "createVnfNotification") + @WebMethod(operationName = "createVnfNotification") @Oneway - @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification") + @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest") - public void createVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "outputs", targetNamespace = "") - CreateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - String method = "createVnfNotification"; - String messageEventName = "createVnfNotificationCallback"; - String messageVariable = "createVnfNotificationCallback"; - String correlationVariable = "VNFC_messageId"; - String correlationValue = messageId; - - CreateVnfNotification message = new CreateVnfNotification(); - - message.setMessageId(messageId); - message.setCompleted(completed); - message.setException(exception); - message.setErrorMessage(errorMessage); - message.setVnfId(vnfId); - message.setOutputs(outputs); - message.setRollback(rollback); - - callback.handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker); - } - - @WebMethod(operationName = "updateVnfNotification") + public void createVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") String vnfId, + @WebParam(name = "outputs", targetNamespace = "") CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback) { + + String method = "createVnfNotification"; + String messageEventName = "createVnfNotificationCallback"; + String messageVariable = "createVnfNotificationCallback"; + String correlationVariable = "VNFC_messageId"; + String correlationValue = messageId; + + CreateVnfNotification message = new CreateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfId(vnfId); + message.setOutputs(outputs); + message.setRollback(rollback); + + callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, + correlationValue, logMarker); + } + + @WebMethod(operationName = "updateVnfNotification") @Oneway - @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification") + @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest") - public void updateVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "outputs", targetNamespace = "") - UpdateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - String method = "updateVnfNotification"; - String messageEventName = "updateVnfNotificationCallback"; - String messageVariable = "updateVnfNotificationCallback"; - String correlationVariable = "VNFU_messageId"; - String correlationValue = messageId; - - UpdateVnfNotification message = new UpdateVnfNotification(); - - message.setMessageId(messageId); - message.setCompleted(completed); - message.setException(exception); - message.setErrorMessage(errorMessage); - message.setOutputs(outputs); - message.setRollback(rollback); - - callback.handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker); - } + public void updateVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, + @WebParam(name = "outputs", targetNamespace = "") UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback) { + + String method = "updateVnfNotification"; + String messageEventName = "updateVnfNotificationCallback"; + String messageVariable = "updateVnfNotificationCallback"; + String correlationVariable = "VNFU_messageId"; + String correlationValue = messageId; + + UpdateVnfNotification message = new UpdateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setOutputs(outputs); + message.setRollback(rollback); + + callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, + correlationValue, logMarker); + } @WebMethod(operationName = "deleteVnfNotification") @Oneway - @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification") + @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", + className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification") @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest") - public void deleteVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - String method = "deleteVnfNotification"; - String messageEventName = "deleteVnfACallback"; - String messageVariable = "deleteVnfACallback"; - String correlationVariable = "VNFDEL_uuid"; - String correlationValue = messageId; - - DeleteVnfNotification message = new DeleteVnfNotification(); - - message.setMessageId(messageId); - message.setCompleted(completed); - message.setException(exception); - message.setErrorMessage(errorMessage); - - callback.handleCallback(method, message, messageEventName, messageVariable, - correlationVariable, correlationValue, logMarker); - } + public void deleteVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, + @WebParam(name = "completed", targetNamespace = "") boolean completed, + @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage) { + + String method = "deleteVnfNotification"; + String messageEventName = "deleteVnfACallback"; + String messageVariable = "deleteVnfACallback"; + String correlationVariable = "VNFDEL_uuid"; + String correlationValue = messageId; + + DeleteVnfNotification message = new DeleteVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + + callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, + correlationValue, logMarker); + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java index a9a3a63f2f..a534e57b3a 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java @@ -26,8 +26,8 @@ import org.camunda.bpm.engine.ProcessEngines; public class WorkflowAsyncCommonResource extends WorkflowAsyncResource { - @Override + @Override public String getProcessEngineName() { - return "default"; - } + return "default"; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index f9f06447a7..e8e4b85cae 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.UUID; - import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -34,7 +33,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import javax.ws.rs.ext.Provider; - import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.logging.ref.slf4j.ONAPLogConstants; @@ -47,20 +45,19 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** * - * @version 1.0 - * Asynchronous Workflow processing using JAX RS RESTeasy implementation - * Both Synchronous and Asynchronous BPMN process can benefit from this implementation since the workflow gets executed in the background - * and the server thread is freed up, server scales better to process more incoming requests + * @version 1.0 Asynchronous Workflow processing using JAX RS RESTeasy implementation Both Synchronous and Asynchronous + * BPMN process can benefit from this implementation since the workflow gets executed in the background and the + * server thread is freed up, server scales better to process more incoming requests * - * Usage: For synchronous process, when you are ready to send the response invoke the callback to write the response - * For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process + * Usage: For synchronous process, when you are ready to send the response invoke the callback to write the + * response For asynchronous process - the activity may send a acknowledgement response and then proceed + * further on executing the process */ @Path("/async") @Api(value = "/async", description = "Provides asynchronous starting of a bpmn process") @@ -68,81 +65,79 @@ import io.swagger.annotations.ApiOperation; @Component public class WorkflowAsyncResource extends ProcessEngineAwareService { - private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - - long workflowPollInterval=1000; - - @Autowired - private WorkflowProcessor processor; - - @Autowired - private WorkflowContextHolder workflowContext; - - public void setProcessor(WorkflowProcessor processor) { - this.processor = processor; - } - - protected static final Logger logger = LoggerFactory.getLogger(WorkflowAsyncResource.class); - protected static final long DEFAULT_WAIT_TIME = 60000; //default wait time - - /** - * Asynchronous JAX-RS method that starts a process instance. - * @param processKey the process key - * @param variableMap input variables to the process - * @return - */ - - @POST - @Path("/services/{processKey}") - @ApiOperation( - value = "Starts a new process with the appropriate process Key", - notes = "Aysnc fall outs are only logged" - ) - @Produces("application/json") - @Consumes("application/json") - public Response startProcessInstanceByKey ( - @PathParam("processKey") String processKey, VariableMapImpl variableMap){ - Map<String, Object> inputVariables = getInputVariables(variableMap); - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); - processor.startProcess(processKey, variableMap); - WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); - return Response.status(202).entity(response).build(); - } catch (WorkflowProcessorException e) { - WorkflowResponse response = e.getWorkflowResponse(); - return Response.status(500).entity(response).build(); - }catch (Exception e) { - WorkflowResponse response = buildUnkownError(getRequestId(inputVariables),e.getMessage()); - return Response.status(500).entity(response).build(); - } - } - - private WorkflowResponse waitForResponse(String requestId) throws Exception { - long currentWaitTime = 0; - while (DEFAULT_WAIT_TIME > currentWaitTime ) { - Thread.sleep(workflowPollInterval); - currentWaitTime = currentWaitTime + workflowPollInterval; - WorkflowContext foundContext = contextHolder.getWorkflowContext(requestId); - if(foundContext!=null){ - contextHolder.remove(foundContext); - return buildResponse(foundContext); - } - } - throw new Exception("TimeOutOccured"); - } - - private WorkflowResponse buildUnkownError(String requestId,String error) { - WorkflowResponse response = new WorkflowResponse(); - response.setMessage(error); - response.setResponse("UnknownError, request id:" + requestId); - response.setMessageCode(500); - return response; - } - - private WorkflowResponse buildResponse(WorkflowContext foundContext) { - return foundContext.getWorkflowResponse(); - } - + private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); + + long workflowPollInterval = 1000; + + @Autowired + private WorkflowProcessor processor; + + @Autowired + private WorkflowContextHolder workflowContext; + + public void setProcessor(WorkflowProcessor processor) { + this.processor = processor; + } + + protected static final Logger logger = LoggerFactory.getLogger(WorkflowAsyncResource.class); + protected static final long DEFAULT_WAIT_TIME = 60000; // default wait time + + /** + * Asynchronous JAX-RS method that starts a process instance. + * + * @param processKey the process key + * @param variableMap input variables to the process + * @return + */ + + @POST + @Path("/services/{processKey}") + @ApiOperation(value = "Starts a new process with the appropriate process Key", + notes = "Aysnc fall outs are only logged") + @Produces("application/json") + @Consumes("application/json") + public Response startProcessInstanceByKey(@PathParam("processKey") String processKey, VariableMapImpl variableMap) { + Map<String, Object> inputVariables = getInputVariables(variableMap); + try { + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); + processor.startProcess(processKey, variableMap); + WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); + return Response.status(202).entity(response).build(); + } catch (WorkflowProcessorException e) { + WorkflowResponse response = e.getWorkflowResponse(); + return Response.status(500).entity(response).build(); + } catch (Exception e) { + WorkflowResponse response = buildUnkownError(getRequestId(inputVariables), e.getMessage()); + return Response.status(500).entity(response).build(); + } + } + + private WorkflowResponse waitForResponse(String requestId) throws Exception { + long currentWaitTime = 0; + while (DEFAULT_WAIT_TIME > currentWaitTime) { + Thread.sleep(workflowPollInterval); + currentWaitTime = currentWaitTime + workflowPollInterval; + WorkflowContext foundContext = contextHolder.getWorkflowContext(requestId); + if (foundContext != null) { + contextHolder.remove(foundContext); + return buildResponse(foundContext); + } + } + throw new Exception("TimeOutOccured"); + } + + private WorkflowResponse buildUnkownError(String requestId, String error) { + WorkflowResponse response = new WorkflowResponse(); + response.setMessage(error); + response.setResponse("UnknownError, request id:" + requestId); + response.setMessageCode(500); + return response; + } + + private WorkflowResponse buildResponse(WorkflowContext foundContext) { + return foundContext.getWorkflowResponse(); + } + protected static String getOrCreate(Map<String, Object> inputVariables, String key) { String value = Objects.toString(inputVariables.get(key), null); if (value == null) { @@ -152,27 +147,28 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { return value; } - protected static String getRequestId(Map<String, Object> inputVariables) { + protected static String getRequestId(Map<String, Object> inputVariables) { return getOrCreate(inputVariables, "mso-request-id"); - } - - protected boolean isProcessEnded(String processInstanceId) { - ProcessEngineServices pes = getProcessEngineServices(); - return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null; - } - - protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) { - Map<String, Object> inputVariables = new HashMap<>(); - @SuppressWarnings("unchecked") - Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); - 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>)value; // value, type - inputVariables.put(vName, valueMap.get("value")); - } - return inputVariables; - } + } + + protected boolean isProcessEnded(String processInstanceId) { + ProcessEngineServices pes = getProcessEngineServices(); + return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId) + .singleResult() == null; + } + + protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) { + Map<String, Object> inputVariables = new HashMap<>(); + @SuppressWarnings("unchecked") + Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); + 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>) value; // value, type + inputVariables.put(vName, valueMap.get("value")); + } + return inputVariables; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java index 075102331c..1e9ebdf0b2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -24,7 +24,6 @@ package org.onap.so.bpmn.common.workflow.service; import java.util.HashMap; import java.util.Map; - import javax.ws.rs.Consumes; import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; @@ -33,7 +32,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; import org.onap.so.logger.ErrorCode; @@ -42,13 +40,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** - * Generalized REST interface that injects a message event into a waiting BPMN process. - * Examples: + * Generalized REST interface that injects a message event into a waiting BPMN process. Examples: + * * <pre> * /WorkflowMessage/SDNCAResponse/6d10d075-100c-42d0-9d84-a52432681cae-1478486185286 * /WorkflowMessage/SDNCAEvent/USOSTCDALTX0101UJZZ01 @@ -57,70 +54,62 @@ import io.swagger.annotations.ApiOperation; @Path("/") @Api(description = "Provides a generic service to inject messages into a waiting BPMN Proccess") @Component -public class WorkflowMessageResource{ - private static final Logger logger = LoggerFactory.getLogger(WorkflowMessageResource.class); - private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; - - @Autowired - CallbackHandlerService callback; - - @POST - @Path("/WorkflowMessage/{messageType}/{correlator}") - @ApiOperation( - value = "Workflow message correlator", - notes = "" - ) - @Consumes("*/*") - @Produces(MediaType.TEXT_PLAIN) - public Response deliver( - @HeaderParam("Content-Type") String contentType, - @PathParam("messageType") String messageType, - @PathParam("correlator") String correlator, - String message) { +public class WorkflowMessageResource { + private static final Logger logger = LoggerFactory.getLogger(WorkflowMessageResource.class); + private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; + + @Autowired + CallbackHandlerService callback; + + @POST + @Path("/WorkflowMessage/{messageType}/{correlator}") + @ApiOperation(value = "Workflow message correlator", notes = "") + @Consumes("*/*") + @Produces(MediaType.TEXT_PLAIN) + public Response deliver(@HeaderParam("Content-Type") String contentType, + @PathParam("messageType") String messageType, @PathParam("correlator") String correlator, String message) { - String method = "receiveWorkflowMessage"; + String method = "receiveWorkflowMessage"; - logger.debug(LOGMARKER + " Received workflow message" - + " type='" + messageType + "'" - + " correlator='" + correlator + "'" - + (contentType == null ? "" : " contentType='" + contentType + "'") - + " message=" + System.lineSeparator() + message); + logger.debug(LOGMARKER + " Received workflow message" + " type='" + messageType + "'" + " correlator='" + + correlator + "'" + (contentType == null ? "" : " contentType='" + contentType + "'") + " message=" + + System.lineSeparator() + message); - if (messageType == null || messageType.isEmpty()) { - String msg = "Missing message type"; - logger.debug(LOGMARKER + " " + msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); - return Response.status(400).entity(msg).build(); - } + if (messageType == null || messageType.isEmpty()) { + String msg = "Missing message type"; + logger.debug(LOGMARKER + " " + msg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); + return Response.status(400).entity(msg).build(); + } - if (correlator == null || correlator.isEmpty()) { - String msg = "Missing correlator"; - logger.debug(LOGMARKER + " " + msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); - return Response.status(400).entity(msg).build(); - } + if (correlator == null || correlator.isEmpty()) { + String msg = "Missing correlator"; + logger.debug(LOGMARKER + " " + msg); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); + return Response.status(400).entity(msg).build(); + } - String messageEventName = "WorkflowMessage"; - String messageVariable = messageType + "_MESSAGE"; - String correlationVariable = messageType + "_CORRELATOR"; - String correlationValue = correlator; - String contentTypeVariable = messageType + "_CONTENT_TYPE"; + String messageEventName = "WorkflowMessage"; + String messageVariable = messageType + "_MESSAGE"; + String correlationVariable = messageType + "_CORRELATOR"; + String correlationValue = correlator; + String contentTypeVariable = messageType + "_CONTENT_TYPE"; - Map<String, Object> variables = new HashMap<>(); + Map<String, Object> variables = new HashMap<>(); - if (contentType != null) { - variables.put(contentTypeVariable, contentType); - } + if (contentType != null) { + variables.put(contentTypeVariable, contentType); + } - CallbackResult result = callback.handleCallback(method, message, messageEventName, - messageVariable, correlationVariable, correlationValue, LOGMARKER, variables); + CallbackResult result = callback.handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, LOGMARKER, variables); - if (result instanceof CallbackError) { - return Response.status(500).entity(((CallbackError)result).getErrorMessage()).build(); - } else { - return Response.status(204).build(); - } - } + if (result instanceof CallbackError) { + return Response.status(500).entity(((CallbackError) result).getErrorMessage()).build(); + } else { + return Response.status(204).build(); + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index b1062962a6..4e9e9fdf0e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.UUID; - import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; @@ -39,65 +38,64 @@ import org.springframework.stereotype.Service; @Service public class WorkflowProcessor extends ProcessEngineAwareService { - - private static final Logger logger = LoggerFactory.getLogger(WorkflowProcessor.class); - protected static final String logMarker = "[WRKFLOW-RESOURCE]"; - - @Async - public void startProcess( String processKey, VariableMapImpl variableMap) - { - - long startTime = System.currentTimeMillis(); - Map<String, Object> inputVariables = null; - String processInstanceId = null; - try { - inputVariables = getInputVariables(variableMap); - // This variable indicates that the flow was invoked asynchronously - inputVariables.put("isAsyncProcess", "true"); - // Note: this creates a random businessKey if it wasn't specified. - String businessKey = getBusinessKey(inputVariables); + private static final Logger logger = LoggerFactory.getLogger(WorkflowProcessor.class); + protected static final String logMarker = "[WRKFLOW-RESOURCE]"; + + @Async + public void startProcess(String processKey, VariableMapImpl variableMap) { + + long startTime = System.currentTimeMillis(); + Map<String, Object> inputVariables = null; + String processInstanceId = null; + try { + inputVariables = getInputVariables(variableMap); + // This variable indicates that the flow was invoked asynchronously + inputVariables.put("isAsyncProcess", "true"); - logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey, - inputVariables); + // Note: this creates a random businessKey if it wasn't specified. + String businessKey = getBusinessKey(inputVariables); - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey, - inputVariables); - processInstanceId = processInstance.getId(); + logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey, + inputVariables); - logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " - + (processInstance.isEnded() ? "ENDED" : "RUNNING")); - } catch (Exception e) { - WorkflowResponse workflowResponse = new WorkflowResponse(); - workflowResponse.setResponse("Error occurred while executing the process: " + e); - workflowResponse.setProcessInstanceID(processInstanceId); - workflowResponse.setMessageCode(500); - workflowResponse.setMessage("Fail"); - throw new WorkflowProcessorException(workflowResponse); - } - } + RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + ProcessInstance processInstance = + runtimeService.startProcessInstanceByKey(processKey, businessKey, inputVariables); + processInstanceId = processInstance.getId(); + + logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + + (processInstance.isEnded() ? "ENDED" : "RUNNING")); + } catch (Exception e) { + WorkflowResponse workflowResponse = new WorkflowResponse(); + workflowResponse.setResponse("Error occurred while executing the process: " + e); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(500); + workflowResponse.setMessage("Fail"); + throw new WorkflowProcessorException(workflowResponse); + } + } - // Note: the business key is used to identify the process in unit tests - protected static String getBusinessKey(Map<String, Object> inputVariables) { + // Note: the business key is used to identify the process in unit tests + protected static String getBusinessKey(Map<String, Object> inputVariables) { return getOrCreate(inputVariables, "mso-business-key"); - } + } + + + protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) { + Map<String, Object> inputVariables = new HashMap<>(); + @SuppressWarnings("unchecked") + Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); + 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>) value; // value, type + inputVariables.put(vName, valueMap.get("value")); + } + return inputVariables; + } - - protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) { - Map<String, Object> inputVariables = new HashMap<>(); - @SuppressWarnings("unchecked") - Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); - 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>)value; // value, type - inputVariables.put(vName, valueMap.get("value")); - } - return inputVariables; - } - protected static String getOrCreate(Map<String, Object> inputVariables, String key) { String value = Objects.toString(inputVariables.get(key), null); if (value == null) { diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index a5d479ae41..9d63e8eaf1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; - import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -37,7 +36,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import org.camunda.bpm.engine.HistoryService; import org.camunda.bpm.engine.ProcessEngineException; import org.camunda.bpm.engine.ProcessEngineServices; @@ -56,7 +54,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.stereotype.Component; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -64,534 +61,531 @@ import io.swagger.annotations.ApiOperation; @Api(value = "/workflow", description = "Root of workflow services") @Component public class WorkflowResource extends ProcessEngineAwareService { - - private static final Logger logger = LoggerFactory.getLogger(WorkflowResource.class); - private static final String LOGMARKER = "[WRKFLOW-RESOURCE]"; - - private static final int DEFAULT_WAIT_TIME = 30000; - - @Context - private UriInfo uriInfo = null; - - /** - * Starts the process instance and responds to client synchronously - * If the request does not contain mso-service-request-timeout then it waits for the value specified in DEFAULT_WAIT_TIME - * Note: value specified in mso-service-request-timeout is in seconds - * During polling time, if there is an exception encountered in the process execution then polling is stopped and the error response is - * returned to the client - * @param processKey - * @param variableMap - * @return - */ - @POST - @Path("/services/{processKey}") - @ApiOperation( - value = "Starts a new process with the appropriate process synchronously", - notes = "d" - ) - @Produces("application/json") - @Consumes("application/json") - public Response startProcessInstanceByKey(@PathParam("processKey") String processKey, - VariableMapImpl variableMap) { - - Map<String, Object> inputVariables = getInputVariables(variableMap); - setLogContext(processKey, inputVariables); - - WorkflowResponse workflowResponse = new WorkflowResponse(); - long startTime = System.currentTimeMillis(); - ProcessInstance processInstance = null; - - try { - //Kickoff the process - ProcessThread thread = new ProcessThread(inputVariables,processKey); - thread.start(); - - Map<String, Object> responseMap = null; - - //wait for process to be completed - long waitTime = getWaitTime(inputVariables); - long now = System.currentTimeMillis(); - long start = now; - long endTime = start + waitTime; - long pollingInterval = 500; - - // TEMPORARY LOGIC FOR UNIT TEST REFACTORING - // If this is a unit test (method is invoked directly), wait a max - // of 5 seconds after process ended for a result. In production, - // wait up to 60 seconds. - long timeToWaitAfterProcessEnded = uriInfo == null ? 5000 : 60000; - AtomicLong timeProcessEnded = new AtomicLong(0); - boolean endedWithNoResponse = false; - - while (now <= endTime) { - Thread.sleep(pollingInterval); - - now = System.currentTimeMillis(); - - // Increase the polling interval over time - - long elapsed = now - start; - - if (elapsed > 60000) { - pollingInterval = 5000; - } else if (elapsed > 10000) { - pollingInterval = 1000; - } - Exception exception = thread.getException(); - if (exception != null) { - throw new Exception(exception); - } - - processInstance = thread.getProcessInstance(); - - if (processInstance == null) { - logger.debug("{} process has not been created yet", LOGMARKER + processKey ); - continue; - } - - String processInstanceId = processInstance.getId(); - workflowResponse.setProcessInstanceID(processInstanceId); - - responseMap = getResponseMap(processInstance, processKey, timeProcessEnded); - - if (responseMap == null) { - logger.debug("{} has not produced a response yet", LOGMARKER + processKey); - - if (timeProcessEnded.longValue() != 0) { - long elapsedSinceEnded = System.currentTimeMillis() - timeProcessEnded.longValue(); - - if (elapsedSinceEnded > timeToWaitAfterProcessEnded) { - endedWithNoResponse = true; - break; - } - } - } else { - processResponseMap(workflowResponse, responseMap); - recordEvents(processKey, workflowResponse, startTime); - return Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build(); - } - } - - //if we dont get response after waiting then send timeout response - - String state; - String processInstanceId; - - if (processInstance == null) { - processInstanceId = "N/A"; - state = "NOT STARTED"; - } else { - processInstanceId = processInstance.getProcessInstanceId(); - state = isProcessEnded(processInstanceId) ? "ENDED" : "NOT ENDED"; - } - - workflowResponse.setMessage("Fail"); - if (endedWithNoResponse) { - workflowResponse.setResponse("Process ended without producing a response"); - } else { - workflowResponse.setResponse("Request timed out, process state: " + state); - } - workflowResponse.setProcessInstanceID(processInstanceId); - recordEvents(processKey, workflowResponse, startTime); - workflowResponse.setMessageCode(500); - return Response.status(500).entity(workflowResponse).build(); - } catch (Exception ex) { - logger.debug(LOGMARKER + "Exception in startProcessInstance by key",ex); - workflowResponse.setMessage("Fail" ); - workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); - if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); - - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), - ErrorCode.UnknownError.getValue(), - LOGMARKER + workflowResponse.getMessage() + " for processKey: " + processKey + " with response: " - + workflowResponse.getResponse()); - - workflowResponse.setMessageCode(500); - recordEvents(processKey, workflowResponse, startTime); - return Response.status(500).entity(workflowResponse).build(); - } - } - - /** - * Returns the wait time, this is used by the resource on how long it should wait to send a response - * If none specified DEFAULT_WAIT_TIME is used - * @param inputVariables - * @return - */ - private int getWaitTime(Map<String, Object> inputVariables) - { - String timeout = inputVariables.get("mso-service-request-timeout") == null - ? null : inputVariables.get("mso-service-request-timeout").toString(); - - if (timeout != null) { - try { - return Integer.parseInt(timeout)*1000; - } catch (NumberFormatException nex) { - logger.debug("Invalid input for mso-service-request-timeout"); - } - } - return DEFAULT_WAIT_TIME; - } - - private void recordEvents(String processKey, WorkflowResponse response, long startTime) { - } - - private void setLogContext(String processKey, Map<String, Object> inputVariables) { - } - - private String getValueFromInputVariables(Map<String,Object> inputVariables, String key) { - Object value = inputVariables.get(key); - if (value == null) { - return "N/A"; - } else { - return value.toString(); - } - } - - /** - * Checks to see if the specified process is ended. - * @param processInstanceId the process instance ID - * @return true if the process is ended - */ - private boolean isProcessEnded(String processInstanceId) { - ProcessEngineServices pes = getProcessEngineServices(); - try { - return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; - } catch (Exception e) { - logger.debug("Exception :",e); - return true; - } - } - - private void processResponseMap(WorkflowResponse workflowResponse, Map<String, Object> responseMap) { - Object object = responseMap.get("Response"); - String response = object == null ? null : String.valueOf(object); - if(response == null){ - object = responseMap.get("WorkflowResponse"); - response = object == null ? null : String.valueOf(object); - } - - workflowResponse.setResponse(response); - - object = responseMap.get("ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - - try { - workflowResponse.setMessageCode(Integer.parseInt(responseCode)); - } catch(NumberFormatException nex) { - logger.debug(LOGMARKER + "Failed to parse ResponseCode: " + responseCode); - workflowResponse.setMessageCode(-1); - } - - Object status = responseMap.get("Status"); - - if ("Success".equalsIgnoreCase(String.valueOf(status))) { - workflowResponse.setMessage("Success"); - } else if ("Fail".equalsIgnoreCase(String.valueOf(status))) { - workflowResponse.setMessage("Fail"); - } else { - logger.debug(LOGMARKER + "Unrecognized Status: " + responseCode); - workflowResponse.setMessage("Fail"); - } - } - - /** - * @version 1.0 - * Triggers the workflow in a separate thread - */ - private class ProcessThread extends Thread { - private final Map<String,Object> inputVariables; - private final String processKey; - private final String businessKey; - private ProcessInstance processInstance = null; - private Exception exception = null; - - public ProcessThread(Map<String, Object> inputVariables, String processKey) { - this.inputVariables = inputVariables; - this.processKey = processKey; - this.businessKey = UUID.randomUUID().toString(); - } - - /** - * If an exception occurs when starting the process instance, it may - * be obtained by calling this method. Note that exceptions are only - * recorded while the process is executing in its original thread. - * Once a process is suspended, exception recording stops. - * @return the exception, or null if none has occurred - */ - public Exception getException() { - return exception; - } - - - public ProcessInstance getProcessInstance() { - return this.processInstance; - } - - /** - * Sets the process instance exception. - * @param exception the exception - */ - private void setException(Exception exception) { - this.exception = exception; - } - - public void run() { - setLogContext(processKey, inputVariables); - - long startTime = System.currentTimeMillis(); - - try { - - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - - // Note that this method doesn't return until the process suspends - // itself or finishes. We provide a business key so we can identify - // the process instance immediately. - processInstance = runtimeService.startProcessInstanceByKey( - processKey, inputVariables); - - } catch (Exception e) { - logger.debug(LOGMARKER + "ProcessThread caught an exception executing " - + processKey + ": " + e); - setException(e); - } - } - - } - - private Map<String, Object> getInputVariables(VariableMapImpl variableMap) { - VariableMap inputVariables = Variables.createVariables(); - @SuppressWarnings("unchecked") - Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); - for (String key : vMap.keySet()) { //variabe name vn - @SuppressWarnings("unchecked") - Map<String, Object> valueMap = (Map<String,Object>)vMap.get(key); //value, type - inputVariables.putValueTyped(key, Variables - .objectValue(valueMap.get("value")) - .serializationDataFormat(SerializationDataFormats.JAVA) // tells the engine to use java serialization for persisting the value - .create()); - } - return inputVariables; - } - - /** - * Attempts to get a response map from the specified process instance. - * @return the response map, or null if it is unavailable - */ - private Map<String, Object> getResponseMap(ProcessInstance processInstance, - String processKey, AtomicLong timeProcessEnded) { - - String responseMapVariable = processKey + "ResponseMap"; - String processInstanceId = processInstance.getId(); - - // Query the runtime service to see if a response map is ready. - -/* RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - List<Execution> executions = runtimeService.createExecutionQuery() - .processInstanceId(processInstanceId).list(); - - for (Execution execution : executions) { - @SuppressWarnings("unchecked") - Map<String, Object> responseMap = (Map<String, Object>) - getVariableFromExecution(runtimeService, execution.getId(), - responseMapVariable); - - if (responseMap != null) { - msoLogger.debug(LOGMARKER + "Obtained " + responseMapVariable - + " from process " + processInstanceId + " execution " - + execution.getId()); - return responseMap; - } - } -*/ - //Querying history seem to return consistent results compared to querying the runtime service - - boolean alreadyEnded = timeProcessEnded.longValue() != 0; - - if (alreadyEnded || isProcessEnded(processInstance.getId())) { - if (!alreadyEnded) { - timeProcessEnded.set(System.currentTimeMillis()); - } - - // Query the history service to see if a response map exists. - - HistoryService historyService = getProcessEngineServices().getHistoryService(); - @SuppressWarnings("unchecked") - Map<String, Object> responseMap = (Map<String, Object>) - getVariableFromHistory(historyService, processInstance.getId(), - responseMapVariable); - - if (responseMap != null) { - logger.debug(LOGMARKER + "Obtained " + responseMapVariable - + " from process " + processInstanceId + " history"); - return responseMap; - } - - // Query the history service for old-style response variables. - - String prefix = (String) getVariableFromHistory(historyService, processInstanceId, "prefix"); - - if (prefix != null) { - - // Check for 'WorkflowResponse' variable - Object workflowResponseObject = getVariableFromHistory(historyService, processInstanceId, "WorkflowResponse"); - String workflowResponse = workflowResponseObject == null ? null : String.valueOf(workflowResponseObject); - logger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); - - if (workflowResponse != null) { - Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject); - logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<>(); - responseMap.put("WorkflowResponse", workflowResponse); - responseMap.put("ResponseCode", responseCode); - responseMap.put("Status", "Success"); - return responseMap; - } - - - // Check for 'WorkflowException' variable - WorkflowException workflowException = null; - String workflowExceptionText = null; - - Object workflowExceptionObject = getVariableFromHistory(historyService, processInstanceId, "WorkflowException"); - if(workflowExceptionObject != null) { - if(workflowExceptionObject instanceof WorkflowException) { - workflowException = (WorkflowException) workflowExceptionObject; - workflowExceptionText = workflowException.toString(); - responseMap = new HashMap<>(); - responseMap.put("WorkflowException", workflowExceptionText); - responseMap.put("ResponseCode", workflowException.getErrorCode()); - responseMap.put("Status", "Fail"); - return responseMap; - } - else if (workflowExceptionObject instanceof String) { - Object object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - workflowExceptionText = (String) workflowExceptionObject; - responseMap = new HashMap<>(); - responseMap.put("WorkflowException", workflowExceptionText); - responseMap.put("ResponseCode", responseCode); - responseMap.put("Status", "Fail"); - return responseMap; - } - - } - logger.debug(LOGMARKER + "WorkflowException: " + workflowExceptionText); - - // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE - Object object = getVariableFromHistory(historyService, processInstanceId, processKey + "Response"); - String response = object == null ? null : String.valueOf(object); - logger.debug(LOGMARKER + processKey + "Response: " + response); - - if (response != null) { - object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<>(); - responseMap.put("Response", response); - responseMap.put("ResponseCode", responseCode); - responseMap.put("Status", "Success"); - return responseMap; - } - - object = getVariableFromHistory(historyService, processInstanceId, prefix + "ErrorResponse"); - String errorResponse = object == null ? null : String.valueOf(object); - logger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); - - if (errorResponse != null) { - object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<>(); - responseMap.put("Response", errorResponse); - responseMap.put("ResponseCode", responseCode); - responseMap.put("Status", "Fail"); - return responseMap; - } - // END LEGACY SUPPORT. TODO: REMOVE THIS CODE - } - } - return null; - } - - /** - * Gets a variable value from the specified execution. - * @return the variable value, or null if the variable could not be - * obtained - */ - private Object getVariableFromExecution(RuntimeService runtimeService, - String executionId, String variableName) { - try { - return runtimeService.getVariable(executionId, variableName); - } catch (ProcessEngineException e) { - // Most likely cause is that the execution no longer exists. - logger.debug("Error retrieving execution " + executionId - + " variable " + variableName + ": " + e); - return null; - } - } - /** - * Gets a variable value from specified historical process instance. - * @return the variable value, or null if the variable could not be - * obtained - */ - private Object getVariableFromHistory(HistoryService historyService, - String processInstanceId, String variableName) { - try { - HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery() - .processInstanceId(processInstanceId).variableName(variableName).singleResult(); - return v == null ? null : v.getValue(); - } catch (Exception e) { - logger.debug("Error retrieving process {} variable {} from history: ", processInstanceId, - variableName, e); - return null; - } - } - - @POST - @Path("/services/{processKey}/{processInstanceId}") - @Produces("application/json") - @Consumes("application/json") - @ApiOperation( - value = "Allows for retrieval of the variables for a given process", - notes = "" - ) - public WorkflowResponse getProcessVariables(@PathParam("processKey") String processKey, @PathParam("processInstanceId") String processInstanceId) { - //TODO filter only set of variables - WorkflowResponse response = new WorkflowResponse(); - - long startTime = System.currentTimeMillis(); - try { - ProcessEngineServices engine = getProcessEngineServices(); - List<HistoricVariableInstance> variables = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list(); - Map<String,String> variablesMap = new HashMap<>(); - for (HistoricVariableInstance variableInstance: variables) { - variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString()); - } - - logger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + - variablesMap.toString()); - - response.setVariables(variablesMap); - response.setMessage("Success"); - response.setResponse("Successfully retrieved the variables"); - response.setProcessInstanceID(processInstanceId); - - logger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response - .getResponse()); - } catch (Exception ex) { - response.setMessage("Fail"); - response.setResponse("Failed to retrieve the variables," + ex.getMessage()); - response.setProcessInstanceID(processInstanceId); - - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), - ErrorCode.UnknownError.getValue(), - LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response - .getResponse()); - logger.debug("Exception :",ex); - } - return response; - } + + private static final Logger logger = LoggerFactory.getLogger(WorkflowResource.class); + private static final String LOGMARKER = "[WRKFLOW-RESOURCE]"; + + private static final int DEFAULT_WAIT_TIME = 30000; + + @Context + private UriInfo uriInfo = null; + + /** + * Starts the process instance and responds to client synchronously If the request does not contain + * mso-service-request-timeout then it waits for the value specified in DEFAULT_WAIT_TIME Note: value specified in + * mso-service-request-timeout is in seconds During polling time, if there is an exception encountered in the + * process execution then polling is stopped and the error response is returned to the client + * + * @param processKey + * @param variableMap + * @return + */ + @POST + @Path("/services/{processKey}") + @ApiOperation(value = "Starts a new process with the appropriate process synchronously", notes = "d") + @Produces("application/json") + @Consumes("application/json") + public Response startProcessInstanceByKey(@PathParam("processKey") String processKey, VariableMapImpl variableMap) { + + Map<String, Object> inputVariables = getInputVariables(variableMap); + setLogContext(processKey, inputVariables); + + WorkflowResponse workflowResponse = new WorkflowResponse(); + long startTime = System.currentTimeMillis(); + ProcessInstance processInstance = null; + + try { + // Kickoff the process + ProcessThread thread = new ProcessThread(inputVariables, processKey); + thread.start(); + + Map<String, Object> responseMap = null; + + // wait for process to be completed + long waitTime = getWaitTime(inputVariables); + long now = System.currentTimeMillis(); + long start = now; + long endTime = start + waitTime; + long pollingInterval = 500; + + // TEMPORARY LOGIC FOR UNIT TEST REFACTORING + // If this is a unit test (method is invoked directly), wait a max + // of 5 seconds after process ended for a result. In production, + // wait up to 60 seconds. + long timeToWaitAfterProcessEnded = uriInfo == null ? 5000 : 60000; + AtomicLong timeProcessEnded = new AtomicLong(0); + boolean endedWithNoResponse = false; + + while (now <= endTime) { + Thread.sleep(pollingInterval); + + now = System.currentTimeMillis(); + + // Increase the polling interval over time + + long elapsed = now - start; + + if (elapsed > 60000) { + pollingInterval = 5000; + } else if (elapsed > 10000) { + pollingInterval = 1000; + } + Exception exception = thread.getException(); + if (exception != null) { + throw new Exception(exception); + } + + processInstance = thread.getProcessInstance(); + + if (processInstance == null) { + logger.debug("{} process has not been created yet", LOGMARKER + processKey); + continue; + } + + String processInstanceId = processInstance.getId(); + workflowResponse.setProcessInstanceID(processInstanceId); + + responseMap = getResponseMap(processInstance, processKey, timeProcessEnded); + + if (responseMap == null) { + logger.debug("{} has not produced a response yet", LOGMARKER + processKey); + + if (timeProcessEnded.longValue() != 0) { + long elapsedSinceEnded = System.currentTimeMillis() - timeProcessEnded.longValue(); + + if (elapsedSinceEnded > timeToWaitAfterProcessEnded) { + endedWithNoResponse = true; + break; + } + } + } else { + processResponseMap(workflowResponse, responseMap); + recordEvents(processKey, workflowResponse, startTime); + return Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build(); + } + } + + // if we dont get response after waiting then send timeout response + + String state; + String processInstanceId; + + if (processInstance == null) { + processInstanceId = "N/A"; + state = "NOT STARTED"; + } else { + processInstanceId = processInstance.getProcessInstanceId(); + state = isProcessEnded(processInstanceId) ? "ENDED" : "NOT ENDED"; + } + + workflowResponse.setMessage("Fail"); + if (endedWithNoResponse) { + workflowResponse.setResponse("Process ended without producing a response"); + } else { + workflowResponse.setResponse("Request timed out, process state: " + state); + } + workflowResponse.setProcessInstanceID(processInstanceId); + recordEvents(processKey, workflowResponse, startTime); + workflowResponse.setMessageCode(500); + return Response.status(500).entity(workflowResponse).build(); + } catch (Exception ex) { + logger.debug(LOGMARKER + "Exception in startProcessInstance by key", ex); + workflowResponse.setMessage("Fail"); + workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); + if (processInstance != null) + workflowResponse.setProcessInstanceID(processInstance.getId()); + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", + MDC.get(processKey), ErrorCode.UnknownError.getValue(), LOGMARKER + workflowResponse.getMessage() + + " for processKey: " + processKey + " with response: " + workflowResponse.getResponse()); + + workflowResponse.setMessageCode(500); + recordEvents(processKey, workflowResponse, startTime); + return Response.status(500).entity(workflowResponse).build(); + } + } + + /** + * Returns the wait time, this is used by the resource on how long it should wait to send a response If none + * specified DEFAULT_WAIT_TIME is used + * + * @param inputVariables + * @return + */ + private int getWaitTime(Map<String, Object> inputVariables) { + String timeout = inputVariables.get("mso-service-request-timeout") == null ? null + : inputVariables.get("mso-service-request-timeout").toString(); + + if (timeout != null) { + try { + return Integer.parseInt(timeout) * 1000; + } catch (NumberFormatException nex) { + logger.debug("Invalid input for mso-service-request-timeout"); + } + } + return DEFAULT_WAIT_TIME; + } + + private void recordEvents(String processKey, WorkflowResponse response, long startTime) {} + + private void setLogContext(String processKey, Map<String, Object> inputVariables) {} + + private String getValueFromInputVariables(Map<String, Object> inputVariables, String key) { + Object value = inputVariables.get(key); + if (value == null) { + return "N/A"; + } else { + return value.toString(); + } + } + + /** + * Checks to see if the specified process is ended. + * + * @param processInstanceId the process instance ID + * @return true if the process is ended + */ + private boolean isProcessEnded(String processInstanceId) { + ProcessEngineServices pes = getProcessEngineServices(); + try { + return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId) + .singleResult() == null ? true : false; + } catch (Exception e) { + logger.debug("Exception :", e); + return true; + } + } + + private void processResponseMap(WorkflowResponse workflowResponse, Map<String, Object> responseMap) { + Object object = responseMap.get("Response"); + String response = object == null ? null : String.valueOf(object); + if (response == null) { + object = responseMap.get("WorkflowResponse"); + response = object == null ? null : String.valueOf(object); + } + + workflowResponse.setResponse(response); + + object = responseMap.get("ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + + try { + workflowResponse.setMessageCode(Integer.parseInt(responseCode)); + } catch (NumberFormatException nex) { + logger.debug(LOGMARKER + "Failed to parse ResponseCode: " + responseCode); + workflowResponse.setMessageCode(-1); + } + + Object status = responseMap.get("Status"); + + if ("Success".equalsIgnoreCase(String.valueOf(status))) { + workflowResponse.setMessage("Success"); + } else if ("Fail".equalsIgnoreCase(String.valueOf(status))) { + workflowResponse.setMessage("Fail"); + } else { + logger.debug(LOGMARKER + "Unrecognized Status: " + responseCode); + workflowResponse.setMessage("Fail"); + } + } + + /** + * @version 1.0 Triggers the workflow in a separate thread + */ + private class ProcessThread extends Thread { + private final Map<String, Object> inputVariables; + private final String processKey; + private final String businessKey; + private ProcessInstance processInstance = null; + private Exception exception = null; + + public ProcessThread(Map<String, Object> inputVariables, String processKey) { + this.inputVariables = inputVariables; + this.processKey = processKey; + this.businessKey = UUID.randomUUID().toString(); + } + + /** + * If an exception occurs when starting the process instance, it may be obtained by calling this method. Note + * that exceptions are only recorded while the process is executing in its original thread. Once a process is + * suspended, exception recording stops. + * + * @return the exception, or null if none has occurred + */ + public Exception getException() { + return exception; + } + + + public ProcessInstance getProcessInstance() { + return this.processInstance; + } + + /** + * Sets the process instance exception. + * + * @param exception the exception + */ + private void setException(Exception exception) { + this.exception = exception; + } + + public void run() { + setLogContext(processKey, inputVariables); + + long startTime = System.currentTimeMillis(); + + try { + + RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + + // Note that this method doesn't return until the process suspends + // itself or finishes. We provide a business key so we can identify + // the process instance immediately. + processInstance = runtimeService.startProcessInstanceByKey(processKey, inputVariables); + + } catch (Exception e) { + logger.debug(LOGMARKER + "ProcessThread caught an exception executing " + processKey + ": " + e); + setException(e); + } + } + + } + + private Map<String, Object> getInputVariables(VariableMapImpl variableMap) { + VariableMap inputVariables = Variables.createVariables(); + @SuppressWarnings("unchecked") + Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); + for (String key : vMap.keySet()) { // variabe name vn + @SuppressWarnings("unchecked") + Map<String, Object> valueMap = (Map<String, Object>) vMap.get(key); // value, type + inputVariables.putValueTyped(key, + Variables.objectValue(valueMap.get("value")).serializationDataFormat(SerializationDataFormats.JAVA) // tells + // the + // engine + // to + // use + // java + // serialization + // for + // persisting + // the + // value + .create()); + } + return inputVariables; + } + + /** + * Attempts to get a response map from the specified process instance. + * + * @return the response map, or null if it is unavailable + */ + private Map<String, Object> getResponseMap(ProcessInstance processInstance, String processKey, + AtomicLong timeProcessEnded) { + + String responseMapVariable = processKey + "ResponseMap"; + String processInstanceId = processInstance.getId(); + + // Query the runtime service to see if a response map is ready. + + /* + * RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); List<Execution> executions = + * runtimeService.createExecutionQuery() .processInstanceId(processInstanceId).list(); + * + * for (Execution execution : executions) { + * + * @SuppressWarnings("unchecked") Map<String, Object> responseMap = (Map<String, Object>) + * getVariableFromExecution(runtimeService, execution.getId(), responseMapVariable); + * + * if (responseMap != null) { msoLogger.debug(LOGMARKER + "Obtained " + responseMapVariable + " from process " + + * processInstanceId + " execution " + execution.getId()); return responseMap; } } + */ + // Querying history seem to return consistent results compared to querying the runtime service + + boolean alreadyEnded = timeProcessEnded.longValue() != 0; + + if (alreadyEnded || isProcessEnded(processInstance.getId())) { + if (!alreadyEnded) { + timeProcessEnded.set(System.currentTimeMillis()); + } + + // Query the history service to see if a response map exists. + + HistoryService historyService = getProcessEngineServices().getHistoryService(); + @SuppressWarnings("unchecked") + Map<String, Object> responseMap = (Map<String, Object>) getVariableFromHistory(historyService, + processInstance.getId(), responseMapVariable); + + if (responseMap != null) { + logger.debug(LOGMARKER + "Obtained " + responseMapVariable + " from process " + processInstanceId + + " history"); + return responseMap; + } + + // Query the history service for old-style response variables. + + String prefix = (String) getVariableFromHistory(historyService, processInstanceId, "prefix"); + + if (prefix != null) { + + // Check for 'WorkflowResponse' variable + Object workflowResponseObject = + getVariableFromHistory(historyService, processInstanceId, "WorkflowResponse"); + String workflowResponse = + workflowResponseObject == null ? null : String.valueOf(workflowResponseObject); + logger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); + + if (workflowResponse != null) { + Object responseCodeObject = + getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<>(); + responseMap.put("WorkflowResponse", workflowResponse); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Success"); + return responseMap; + } + + + // Check for 'WorkflowException' variable + WorkflowException workflowException = null; + String workflowExceptionText = null; + + Object workflowExceptionObject = + getVariableFromHistory(historyService, processInstanceId, "WorkflowException"); + if (workflowExceptionObject != null) { + if (workflowExceptionObject instanceof WorkflowException) { + workflowException = (WorkflowException) workflowExceptionObject; + workflowExceptionText = workflowException.toString(); + responseMap = new HashMap<>(); + responseMap.put("WorkflowException", workflowExceptionText); + responseMap.put("ResponseCode", workflowException.getErrorCode()); + responseMap.put("Status", "Fail"); + return responseMap; + } else if (workflowExceptionObject instanceof String) { + Object object = + getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + workflowExceptionText = (String) workflowExceptionObject; + responseMap = new HashMap<>(); + responseMap.put("WorkflowException", workflowExceptionText); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Fail"); + return responseMap; + } + + } + logger.debug(LOGMARKER + "WorkflowException: " + workflowExceptionText); + + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + Object object = getVariableFromHistory(historyService, processInstanceId, processKey + "Response"); + String response = object == null ? null : String.valueOf(object); + logger.debug(LOGMARKER + processKey + "Response: " + response); + + if (response != null) { + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<>(); + responseMap.put("Response", response); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Success"); + return responseMap; + } + + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ErrorResponse"); + String errorResponse = object == null ? null : String.valueOf(object); + logger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); + + if (errorResponse != null) { + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<>(); + responseMap.put("Response", errorResponse); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Fail"); + return responseMap; + } + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + } + } + return null; + } + + /** + * Gets a variable value from the specified execution. + * + * @return the variable value, or null if the variable could not be obtained + */ + private Object getVariableFromExecution(RuntimeService runtimeService, String executionId, String variableName) { + try { + return runtimeService.getVariable(executionId, variableName); + } catch (ProcessEngineException e) { + // Most likely cause is that the execution no longer exists. + logger.debug("Error retrieving execution " + executionId + " variable " + variableName + ": " + e); + return null; + } + } + + /** + * Gets a variable value from specified historical process instance. + * + * @return the variable value, or null if the variable could not be obtained + */ + private Object getVariableFromHistory(HistoryService historyService, String processInstanceId, + String variableName) { + try { + HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + logger.debug("Error retrieving process {} variable {} from history: ", processInstanceId, variableName, e); + return null; + } + } + + @POST + @Path("/services/{processKey}/{processInstanceId}") + @Produces("application/json") + @Consumes("application/json") + @ApiOperation(value = "Allows for retrieval of the variables for a given process", notes = "") + public WorkflowResponse getProcessVariables(@PathParam("processKey") String processKey, + @PathParam("processInstanceId") String processInstanceId) { + // TODO filter only set of variables + WorkflowResponse response = new WorkflowResponse(); + + long startTime = System.currentTimeMillis(); + try { + ProcessEngineServices engine = getProcessEngineServices(); + List<HistoricVariableInstance> variables = engine.getHistoryService().createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).list(); + Map<String, String> variablesMap = new HashMap<>(); + for (HistoricVariableInstance variableInstance : variables) { + variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString()); + } + + logger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + + " and variables: " + variablesMap.toString()); + + response.setVariables(variablesMap); + response.setMessage("Success"); + response.setResponse("Successfully retrieved the variables"); + response.setProcessInstanceID(processInstanceId); + + logger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + + response.getResponse()); + } catch (Exception ex) { + response.setMessage("Fail"); + response.setResponse("Failed to retrieve the variables," + ex.getMessage()); + response.setProcessInstanceID(processInstanceId); + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", + MDC.get(processKey), ErrorCode.UnknownError.getValue(), LOGMARKER + response.getMessage() + + " for processKey: " + processKey + " with response: " + response.getResponse()); + logger.debug("Exception :", ex); + } + return response; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 3eed14bc30..296ab64df3 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; - import org.camunda.bpm.engine.RepositoryService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.ExecutionListener; @@ -53,8 +52,6 @@ import org.camunda.bpm.model.bpmn.impl.instance.FlowNodeImpl; import org.camunda.bpm.model.bpmn.instance.EndEvent; import org.camunda.bpm.model.bpmn.instance.FlowNode; import org.camunda.bpm.model.bpmn.instance.StartEvent; - - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -72,256 +69,259 @@ import org.springframework.stereotype.Component; @Component public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { - @Autowired - private LoggingParseListener loggingParseListener; - - @Override - public void preInit( - ProcessEngineConfigurationImpl processEngineConfiguration) { - List<BpmnParseListener> preParseListeners = processEngineConfiguration - .getCustomPreBPMNParseListeners(); - if (preParseListeners == null) { - preParseListeners = new ArrayList<>(); - processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); - } - preParseListeners.add(loggingParseListener); - } - - /** - * Called when a process flow is parsed so we can inject listeners. - */ - @Component - public class LoggingParseListener extends AbstractBpmnParseListener { - - - private void injectLogExecutionListener(ActivityImpl activity) { - activity.addListener( - ExecutionListener.EVENTNAME_END, - new LoggingExecutionListener("END")); - - activity.addListener( - ExecutionListener.EVENTNAME_START, - new LoggingExecutionListener("START")); - - activity.addListener( - ExecutionListener.EVENTNAME_TAKE, - new LoggingExecutionListener("TAKE")); - } - - @Override - public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { - } - - @Override - public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { - // Inject these listeners only on the main start event for the flow, not on any embedded subflow start events - - injectLogExecutionListener(startEventActivity); - } - - @Override - public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) { - injectLogExecutionListener(timerActivity); - } - - @Override - public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { - //injectLogExecutionListener(activity); - } - - @Override - public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) { - injectLogExecutionListener(timerActivity); - } - - @Override - public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { - - } - - @Override - public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, ActivityImpl signalActivity) { - injectLogExecutionListener(signalActivity); - } - - @Override - public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) { - injectLogExecutionListener(signalActivity); - } - - @Override - public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) { - injectLogExecutionListener(compensationActivity); - } - - @Override - public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) { - injectLogExecutionListener(nestedActivity); - } - - @Override - public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, ActivityImpl nestedActivity) { - injectLogExecutionListener(nestedActivity); - } - - @Override - public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, ActivityImpl messageActivity) { - injectLogExecutionListener(messageActivity); - } - } - - /** - * Logs details about the current activity. - */ - public class LoggingExecutionListener implements ExecutionListener { - private final Logger logger = LoggerFactory.getLogger(LoggingExecutionListener.class); - - private String event; - - public LoggingExecutionListener() { - this.event = ""; - } - - public LoggingExecutionListener(String event) { - this.event = event; - } - - public String getEvent() { - return event; - } - - @Override - public void notify(DelegateExecution execution) throws Exception { - //required for legacy groovy processing in camunda - execution.setVariable("isDebugLogEnabled", "true"); - if (!isBlank(execution.getCurrentActivityName())) { - try { - - String id = execution.getId(); - if (id != null ) { - RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); - String processName = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(execution.getProcessDefinitionId()) - .singleResult() - .getName(); - - - String requestId = (String) execution.getVariable("mso-request-id"); - String svcid = (String) execution.getVariable("mso-service-instance-id"); - } - } catch(Exception e) { - logger.error("Exception occurred", e); - } - } - } - - private boolean isBlank(Object object) { - return object == null || "".equals(object.toString().trim()); - } - } + @Autowired + private LoggingParseListener loggingParseListener; + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(loggingParseListener); + } + + /** + * Called when a process flow is parsed so we can inject listeners. + */ + @Component + public class LoggingParseListener extends AbstractBpmnParseListener { + + + private void injectLogExecutionListener(ActivityImpl activity) { + activity.addListener(ExecutionListener.EVENTNAME_END, new LoggingExecutionListener("END")); + + activity.addListener(ExecutionListener.EVENTNAME_START, new LoggingExecutionListener("START")); + + activity.addListener(ExecutionListener.EVENTNAME_TAKE, new LoggingExecutionListener("TAKE")); + } + + @Override + public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {} + + @Override + public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { + // Inject these listeners only on the main start event for the flow, not on any embedded subflow start + // events + + injectLogExecutionListener(startEventActivity); + } + + @Override + public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, + ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + @Override + public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, + ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { + // injectLogExecutionListener(activity); + } + + @Override + public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseMultiInstanceLoopCharacteristics(Element activityElement, + Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + @Override + public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { + + } + + @Override + public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, + ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + @Override + public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, + ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + @Override + public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseCompensateEventDefinition(Element compensateEventDefinition, + ActivityImpl compensationActivity) { + injectLogExecutionListener(compensationActivity); + } + + @Override + public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, + ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + @Override + public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, + ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + @Override + public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, + ActivityImpl messageActivity) { + injectLogExecutionListener(messageActivity); + } + } + + /** + * Logs details about the current activity. + */ + public class LoggingExecutionListener implements ExecutionListener { + private final Logger logger = LoggerFactory.getLogger(LoggingExecutionListener.class); + + private String event; + + public LoggingExecutionListener() { + this.event = ""; + } + + public LoggingExecutionListener(String event) { + this.event = event; + } + + public String getEvent() { + return event; + } + + @Override + public void notify(DelegateExecution execution) throws Exception { + // required for legacy groovy processing in camunda + execution.setVariable("isDebugLogEnabled", "true"); + if (!isBlank(execution.getCurrentActivityName())) { + try { + + String id = execution.getId(); + if (id != null) { + RepositoryService repositoryService = + execution.getProcessEngineServices().getRepositoryService(); + String processName = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(execution.getProcessDefinitionId()).singleResult().getName(); + + + String requestId = (String) execution.getVariable("mso-request-id"); + String svcid = (String) execution.getVariable("mso-service-instance-id"); + } + } catch (Exception e) { + logger.error("Exception occurred", e); + } + } + } + + private boolean isBlank(Object object) { + return object == null || "".equals(object.toString().trim()); + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java index 8bc0055343..ab21c0807e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java @@ -25,7 +25,6 @@ package org.onap.so.bpmn.core.plugins; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.ExecutionListener; @@ -41,7 +40,6 @@ import org.camunda.bpm.engine.impl.pvm.PvmTransition; import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl; import org.camunda.bpm.engine.impl.util.xml.Element; - import org.onap.so.bpmn.core.WorkflowException; import org.springframework.stereotype.Component; import org.slf4j.Logger; @@ -50,125 +48,115 @@ import org.slf4j.LoggerFactory; /** * This plugin does the following: * <ol> - * <li> - * Adds logic at the start of every Call Activity to remove any existing - * WorkflowException object from the execution (saving a copy of it in a - * different variable). - * </li> - * <li> - * Adds logic at the end of every Call Activity to generate a MSOWorkflowException - * event if there is a WorkflowException object in the execution. - * </li> + * <li>Adds logic at the start of every Call Activity to remove any existing WorkflowException object from the execution + * (saving a copy of it in a different variable).</li> + * <li>Adds logic at the end of every Call Activity to generate a MSOWorkflowException event if there is a + * WorkflowException object in the execution.</li> * </ol> */ @Component public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { - private static final Logger logger = LoggerFactory.getLogger(WorkflowExceptionPlugin.class); - - @Override - public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { - List<BpmnParseListener> preParseListeners = - processEngineConfiguration.getCustomPreBPMNParseListeners(); - - if (preParseListeners == null) { - preParseListeners = new ArrayList<>(); - processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); - } - - preParseListeners.add(new WorkflowExceptionParseListener()); - } - - public static class WorkflowExceptionParseListener extends AbstractBpmnParseListener { - @Override - public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { - AtomicInteger triggerTaskIndex = new AtomicInteger(1); - List<ActivityImpl> activities = new ArrayList<>(processDefinition.getActivities()); - recurse(activities, triggerTaskIndex); - } - - /** - * Helper method that recurses (into subprocesses) over all the listed activities. - * @param activities a list of workflow activities - * @param triggerTaskIndex the index of the next trigger task (mutable) - */ - private void recurse(List<ActivityImpl> activities, AtomicInteger triggerTaskIndex) { - for (ActivityImpl activity : activities) { - String type = (String) activity.getProperty("type"); - - if ("callActivity".equals(type)) { - // Add a WorkflowExceptionResetListener to clear the WorkflowException - // variable when each Call Activity starts. - - activity.addListener( - ExecutionListener.EVENTNAME_START, - new WorkflowExceptionResetListener()); - - // Add a WorkflowExceptionTriggerTask after the call activity. - // It must be a task because a listener cannot be used to generate - // an event. Throwing BpmnError from an execution listener will - // cause the process to die. - - List<PvmTransition> outTransitions = - new ArrayList<>(activity.getOutgoingTransitions()); - - for (PvmTransition transition : outTransitions) { - String triggerTaskId = "WorkflowExceptionTriggerTask_" + triggerTaskIndex; - - ActivityImpl triggerTask = activity.getFlowScope().createActivity(triggerTaskId); - - ClassDelegateActivityBehavior behavior = new ClassDelegateActivityBehavior( - WorkflowExceptionTriggerTask.class.getName(), - new ArrayList<>(0)); - - triggerTask.setActivityBehavior(behavior); - triggerTask.setName("Workflow Exception Trigger Task " + triggerTaskIndex); - triggerTaskIndex.getAndIncrement(); - - TransitionImpl transitionImpl = (TransitionImpl) transition; - TransitionImpl triggerTaskOutTransition = triggerTask.createOutgoingTransition(); - triggerTaskOutTransition.setDestination((ActivityImpl)transitionImpl.getDestination()); - transitionImpl.setDestination(triggerTask); - } - } else if ("subProcess".equals(type)) { - recurse(new ArrayList<>(activity.getActivities()), triggerTaskIndex); - } - } - } - } + private static final Logger logger = LoggerFactory.getLogger(WorkflowExceptionPlugin.class); + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + + preParseListeners.add(new WorkflowExceptionParseListener()); + } + + public static class WorkflowExceptionParseListener extends AbstractBpmnParseListener { + @Override + public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { + AtomicInteger triggerTaskIndex = new AtomicInteger(1); + List<ActivityImpl> activities = new ArrayList<>(processDefinition.getActivities()); + recurse(activities, triggerTaskIndex); + } + + /** + * Helper method that recurses (into subprocesses) over all the listed activities. + * + * @param activities a list of workflow activities + * @param triggerTaskIndex the index of the next trigger task (mutable) + */ + private void recurse(List<ActivityImpl> activities, AtomicInteger triggerTaskIndex) { + for (ActivityImpl activity : activities) { + String type = (String) activity.getProperty("type"); + + if ("callActivity".equals(type)) { + // Add a WorkflowExceptionResetListener to clear the WorkflowException + // variable when each Call Activity starts. + + activity.addListener(ExecutionListener.EVENTNAME_START, new WorkflowExceptionResetListener()); + + // Add a WorkflowExceptionTriggerTask after the call activity. + // It must be a task because a listener cannot be used to generate + // an event. Throwing BpmnError from an execution listener will + // cause the process to die. + + List<PvmTransition> outTransitions = new ArrayList<>(activity.getOutgoingTransitions()); + + for (PvmTransition transition : outTransitions) { + String triggerTaskId = "WorkflowExceptionTriggerTask_" + triggerTaskIndex; + + ActivityImpl triggerTask = activity.getFlowScope().createActivity(triggerTaskId); + + ClassDelegateActivityBehavior behavior = new ClassDelegateActivityBehavior( + WorkflowExceptionTriggerTask.class.getName(), new ArrayList<>(0)); + + triggerTask.setActivityBehavior(behavior); + triggerTask.setName("Workflow Exception Trigger Task " + triggerTaskIndex); + triggerTaskIndex.getAndIncrement(); + + TransitionImpl transitionImpl = (TransitionImpl) transition; + TransitionImpl triggerTaskOutTransition = triggerTask.createOutgoingTransition(); + triggerTaskOutTransition.setDestination((ActivityImpl) transitionImpl.getDestination()); + transitionImpl.setDestination(triggerTask); + } + } else if ("subProcess".equals(type)) { + recurse(new ArrayList<>(activity.getActivities()), triggerTaskIndex); + } + } + } + } /** - * If there is a WorkflowException object in the execution, this method - * removes it (saving a copy of it in a different variable). + * If there is a WorkflowException object in the execution, this method removes it (saving a copy of it in a + * different variable). */ - public static class WorkflowExceptionResetListener implements ExecutionListener { - public void notify(DelegateExecution execution) throws Exception { - Object workflowException = execution.getVariable("WorkflowException"); + public static class WorkflowExceptionResetListener implements ExecutionListener { + public void notify(DelegateExecution execution) throws Exception { + Object workflowException = execution.getVariable("WorkflowException"); - if (workflowException instanceof WorkflowException) { - int index = 1; - String saveName = "SavedWorkflowException" + index; - while (execution.getVariable(saveName) != null) { - saveName = "SavedWorkflowException" + (++index); - } + if (workflowException instanceof WorkflowException) { + int index = 1; + String saveName = "SavedWorkflowException" + index; + while (execution.getVariable(saveName) != null) { + saveName = "SavedWorkflowException" + (++index); + } - logger.debug("WorkflowExceptionResetTask is moving WorkflowException to " + saveName); + logger.debug("WorkflowExceptionResetTask is moving WorkflowException to " + saveName); - execution.setVariable(saveName, workflowException); - execution.setVariable("WorkflowException", null); - } - } - } + execution.setVariable(saveName, workflowException); + execution.setVariable("WorkflowException", null); + } + } + } /** - * Generates an MSOWorkflowException event if there is a WorkflowException - * object in the execution. + * Generates an MSOWorkflowException event if there is a WorkflowException object in the execution. */ - public static class WorkflowExceptionTriggerTask implements JavaDelegate { - public void execute(DelegateExecution execution) throws Exception { - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - logger.debug("WorkflowExceptionTriggerTask is generating a MSOWorkflowException event"); - throw new BpmnError("MSOWorkflowException"); - } - } - } + public static class WorkflowExceptionTriggerTask implements JavaDelegate { + public void execute(DelegateExecution execution) throws Exception { + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + logger.debug("WorkflowExceptionTriggerTask is generating a MSOWorkflowException event"); + throw new BpmnError("MSOWorkflowException"); + } + } + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java index cb20ded8de..6572beaba9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java @@ -23,9 +23,7 @@ package org.onap.so.bpmn.infrastructure; import java.util.Arrays; - import javax.xml.ws.Endpoint; - import org.apache.cxf.Bus; import org.apache.cxf.endpoint.Server; import org.apache.cxf.feature.LoggingFeature; @@ -47,45 +45,44 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; - import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @Configuration public class CXFConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(CXFConfiguration.class); - + + private static final Logger logger = LoggerFactory.getLogger(CXFConfiguration.class); + + @Autowired + private Bus bus; + + @Autowired + private WorkflowMessageResource wmr; + + @Autowired + private WorkflowResource workflowResource; + + @Autowired + private WorkflowAsyncResource workflowAsyncResource; + @Autowired - private Bus bus; - - @Autowired - private WorkflowMessageResource wmr; - - @Autowired - private WorkflowResource workflowResource; - - @Autowired - private WorkflowAsyncResource workflowAsyncResource; - - @Autowired - private JaxRsFilterLogging jaxRsFilterLogging; - - @Autowired - private ObjectMapper mapper; - - @Autowired - private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl; - - @Autowired - private VnfAdapterNotify vnfAdapterNotifyServiceImpl; - - @Bean + private JaxRsFilterLogging jaxRsFilterLogging; + + @Autowired + private ObjectMapper mapper; + + @Autowired + private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl; + + @Autowired + private VnfAdapterNotify vnfAdapterNotifyServiceImpl; + + @Bean public ServletRegistrationBean cxfServlet() { return new ServletRegistrationBean(new CXFServlet(), "/mso/*"); } - + @Bean public Endpoint vnfAdapterCallback() { EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl); @@ -95,7 +92,7 @@ public class CXFConfiguration { endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor()); return endpoint; } - + @Bean public Endpoint sndcAdapterCallback() { EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl); @@ -105,22 +102,22 @@ public class CXFConfiguration { endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor()); return endpoint; } - + @Bean public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(bus); endpoint.setServiceBeans(Arrays.<Object>asList(wmr, workflowResource, workflowAsyncResource)); - endpoint.setAddress("/"); + endpoint.setAddress("/"); endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature())); - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper),jaxRsFilterLogging)); - + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), jaxRsFilterLogging)); + return endpoint.create(); } @Bean public Swagger2Feature createSwaggerFeature() { - Swagger2Feature swagger2Feature= new Swagger2Feature(); + Swagger2Feature swagger2Feature = new Swagger2Feature(); swagger2Feature.setPrettyPrint(true); swagger2Feature.setTitle("SO Orchestration Application"); swagger2Feature.setContact("The ONAP SO team"); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index af9ab2899e..bd430fd679 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -24,7 +24,6 @@ package org.onap.so.bpmn.infrastructure; import java.util.List; import java.util.concurrent.Executor; - import org.camunda.bpm.application.PostDeploy; import org.camunda.bpm.application.PreUndeploy; import org.camunda.bpm.application.ProcessApplicationInfo; @@ -51,55 +50,53 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @SpringBootApplication @EnableAsync -@ComponentScan(basePackages = { "org.onap" }, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = { - @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) }) +@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) public class MSOInfrastructureApplication { - private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class); + private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class); - @Value("${mso.async.core-pool-size}") - private int corePoolSize; + @Value("${mso.async.core-pool-size}") + private int corePoolSize; - @Value("${mso.async.max-pool-size}") - private int maxPoolSize; + @Value("${mso.async.max-pool-size}") + private int maxPoolSize; - @Value("${mso.async.queue-capacity}") - private int queueCapacity; + @Value("${mso.async.queue-capacity}") + private int queueCapacity; - private static final String LOGS_DIR = "logs_dir"; + private static final String LOGS_DIR = "logs_dir"; - private static void setLogsDir() { - if (System.getProperty(LOGS_DIR) == null) { - System.getProperties().setProperty(LOGS_DIR, "./logs/bpmn/"); - } - } + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/bpmn/"); + } + } - public static void main(String... args) { - SpringApplication.run(MSOInfrastructureApplication.class, args); - System.getProperties().setProperty("mso.config.path", "."); - setLogsDir(); - } + public static void main(String... args) { + SpringApplication.run(MSOInfrastructureApplication.class, args); + System.getProperties().setProperty("mso.config.path", "."); + setLogsDir(); + } - @PostDeploy - public void postDeploy(ProcessEngine processEngineInstance) { - } + @PostDeploy + public void postDeploy(ProcessEngine processEngineInstance) {} - @PreUndeploy - public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, - List<ProcessEngine> processEngines) { - } + @PreUndeploy + public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, + List<ProcessEngine> processEngines) {} - @Bean - @Primary - public Executor asyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setTaskDecorator(new MDCTaskDecorator()); - executor.setCorePoolSize(corePoolSize); - executor.setMaxPoolSize(maxPoolSize); - executor.setQueueCapacity(queueCapacity); - executor.setThreadNamePrefix("Camunda-"); - executor.initialize(); - return executor; - } + @Bean + @Primary + public Executor asyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setTaskDecorator(new MDCTaskDecorator()); + executor.setCorePoolSize(corePoolSize); + executor.setMaxPoolSize(maxPoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setThreadNamePrefix("Camunda-"); + executor.initialize(); + return executor; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java index ad9e210452..c2af155d51 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java @@ -31,22 +31,19 @@ import org.springframework.util.StringUtils; @EnableWebSecurity public class WebSecurityConfigImpl extends WebSecurityConfig { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable() - .authorizeRequests() - .antMatchers("/manage/health","/manage/info").permitAll() - .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) - .and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", + "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") + .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",").toString()).and().httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } } |