diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 03:53:18 -0700 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 06:59:21 -0700 |
commit | 94ee92559b051f2f82ed681f841f4f13016842ed (patch) | |
tree | 9760a0ad7da03572ed4c9dc596c4b0f537e64112 /bpmn/MSOCommonBPMN/src/main/java | |
parent | 43bbca64032716730d2e7795b6569d5fdbda9d12 (diff) |
[MSO-8] Second step of the rebase for MSO
Second rebase containing additional features for MSO + total reworking
of the BPMN structure + Notification flow can now be added at the end of
some BPMN flows
Change-Id: I7e937c7a0ba1593ca85e164a093f79c7e38b6ce0
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java')
22 files changed, 3382 insertions, 3340 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java index 9931247885..9100974596 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java @@ -1,59 +1,59 @@ -package org.openecomp.mso.bpmn.common; -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - - -import java.util.List; - -import org.camunda.bpm.application.PostDeploy; -import org.camunda.bpm.application.PreUndeploy; -import org.camunda.bpm.application.ProcessApplication; -import org.camunda.bpm.application.ProcessApplicationInfo; -import org.camunda.bpm.application.impl.ServletProcessApplication; -import org.camunda.bpm.engine.ProcessEngine; - -import org.openecomp.mso.logger.MsoLogger; - -/** - * @since Version 1.0 - * - */ -@ProcessApplication("MSO Common Application") -public class MSOCommonApplication extends ServletProcessApplication { - - private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - @PostDeploy - public void postDeploy(ProcessEngine processEngineInstance) { - long startTime = System.currentTimeMillis(); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Post deployment complete..."); - } - - @PreUndeploy - public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, List<ProcessEngine> processEngines) { - long startTime = System.currentTimeMillis(); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Pre Undeploy complete..."); - - } - -} +package org.openecomp.mso.bpmn.common;
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+import java.util.List;
+
+import org.camunda.bpm.application.PostDeploy;
+import org.camunda.bpm.application.PreUndeploy;
+import org.camunda.bpm.application.ProcessApplication;
+import org.camunda.bpm.application.ProcessApplicationInfo;
+import org.camunda.bpm.application.impl.ServletProcessApplication;
+import org.camunda.bpm.engine.ProcessEngine;
+
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ * @since Version 1.0
+ *
+ */
+@ProcessApplication(name="MSO Common Application", deploymentDescriptors={"../processes.xml"})
+public class MSOCommonApplication extends ServletProcessApplication {
+
+ private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ @PostDeploy
+ public void postDeploy(ProcessEngine processEngineInstance) {
+ long startTime = System.currentTimeMillis();
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Post deployment complete...");
+ }
+
+ @PreUndeploy
+ public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, List<ProcessEngine> processEngines) {
+ long startTime = System.currentTimeMillis();
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Pre Undeploy complete...");
+
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java index 2e0ae1b930..3d6570166d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java @@ -1,91 +1,91 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.sdnc; - -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. - * - */ -@XmlRegistry -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 - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link RequestHeader } - * - */ - public RequestHeader createRequestHeader() { - return new RequestHeader(); - } - - /** - * Create an instance of {@link SDNCAdapterResponse } - * - */ - public SDNCAdapterResponse createSDNCAdapterResponse() { - return new SDNCAdapterResponse(); - } - - /** - * Create an instance of {@link SDNCAdapterCallbackRequest } - * - */ - public SDNCAdapterCallbackRequest createSDNCAdapterCallbackRequest() { - return new SDNCAdapterCallbackRequest(); - } - - /** - * Create an instance of {@link CallbackHeader } - * - */ - public CallbackHeader createCallbackHeader() { - return new CallbackHeader(); - } - - /** - * Create an instance of {@link SDNCAdapterRequest } - * - */ - public SDNCAdapterRequest createSDNCAdapterRequest() { - return new SDNCAdapterRequest(); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.sdnc;
+
+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.
+ *
+ */
+@XmlRegistry
+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
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link RequestHeader }
+ *
+ */
+ public RequestHeader createRequestHeader() {
+ return new RequestHeader();
+ }
+
+ /**
+ * Create an instance of {@link SDNCAdapterResponse }
+ *
+ */
+ public SDNCAdapterResponse createSDNCAdapterResponse() {
+ return new SDNCAdapterResponse();
+ }
+
+ /**
+ * Create an instance of {@link SDNCAdapterCallbackRequest }
+ *
+ */
+ public SDNCAdapterCallbackRequest createSDNCAdapterCallbackRequest() {
+ return new SDNCAdapterCallbackRequest();
+ }
+
+ /**
+ * Create an instance of {@link CallbackHeader }
+ *
+ */
+ public CallbackHeader createCallbackHeader() {
+ return new CallbackHeader();
+ }
+
+ /**
+ * Create an instance of {@link SDNCAdapterRequest }
+ *
+ */
+ public SDNCAdapterRequest createSDNCAdapterRequest() {
+ return new SDNCAdapterRequest();
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java index 27b1245856..f2e4de88d6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java @@ -1,223 +1,223 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.sdnc; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for anonymous complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="MsoAction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "svcInstanceId", - "svcAction", - "svcOperation", - "callbackUrl", - "msoAction" -}) -@XmlRootElement(name = "RequestHeader") -public class RequestHeader { - - @XmlElement(name = "RequestId", required = true) - protected String requestId; - @XmlElement(name = "SvcInstanceId") - protected String svcInstanceId; - @XmlElement(name = "SvcAction", required = true) - protected String svcAction; - @XmlElement(name = "SvcOperation", required = true) - protected String svcOperation; - @XmlElement(name = "CallbackUrl", required = true) - protected String callbackUrl; - @XmlElement(name = "MsoAction") - protected String msoAction; - - /** - * Gets the value of the requestId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRequestId() { - return requestId; - } - - /** - * Sets the value of the requestId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRequestId(String value) { - this.requestId = value; - } - - /** - * Gets the value of the svcInstanceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSvcInstanceId() { - return svcInstanceId; - } - - /** - * Sets the value of the svcInstanceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSvcInstanceId(String value) { - this.svcInstanceId = value; - } - - /** - * Gets the value of the svcAction property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSvcAction() { - return svcAction; - } - - /** - * Sets the value of the svcAction property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSvcAction(String value) { - this.svcAction = value; - } - - /** - * Gets the value of the svcOperation property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSvcOperation() { - return svcOperation; - } - - /** - * Sets the value of the svcOperation property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSvcOperation(String value) { - this.svcOperation = value; - } - - /** - * Gets the value of the callbackUrl property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCallbackUrl() { - return callbackUrl; - } - - /** - * Sets the value of the callbackUrl property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCallbackUrl(String value) { - this.callbackUrl = value; - } - - /** - * Gets the value of the msoAction property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMsoAction() { - return msoAction; - } - - /** - * Sets the value of the msoAction property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMsoAction(String value) { - this.msoAction = value; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.sdnc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="MsoAction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "requestId",
+ "svcInstanceId",
+ "svcAction",
+ "svcOperation",
+ "callbackUrl",
+ "msoAction"
+})
+@XmlRootElement(name = "RequestHeader")
+public class RequestHeader {
+
+ @XmlElement(name = "RequestId", required = true)
+ protected String requestId;
+ @XmlElement(name = "SvcInstanceId")
+ protected String svcInstanceId;
+ @XmlElement(name = "SvcAction", required = true)
+ protected String svcAction;
+ @XmlElement(name = "SvcOperation", required = true)
+ protected String svcOperation;
+ @XmlElement(name = "CallbackUrl", required = true)
+ protected String callbackUrl;
+ @XmlElement(name = "MsoAction")
+ protected String msoAction;
+
+ /**
+ * Gets the value of the requestId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * Sets the value of the requestId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequestId(String value) {
+ this.requestId = value;
+ }
+
+ /**
+ * Gets the value of the svcInstanceId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSvcInstanceId() {
+ return svcInstanceId;
+ }
+
+ /**
+ * Sets the value of the svcInstanceId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSvcInstanceId(String value) {
+ this.svcInstanceId = value;
+ }
+
+ /**
+ * Gets the value of the svcAction property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSvcAction() {
+ return svcAction;
+ }
+
+ /**
+ * Sets the value of the svcAction property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSvcAction(String value) {
+ this.svcAction = value;
+ }
+
+ /**
+ * Gets the value of the svcOperation property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSvcOperation() {
+ return svcOperation;
+ }
+
+ /**
+ * Sets the value of the svcOperation property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSvcOperation(String value) {
+ this.svcOperation = value;
+ }
+
+ /**
+ * Gets the value of the callbackUrl property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ /**
+ * Sets the value of the callbackUrl property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCallbackUrl(String value) {
+ this.callbackUrl = value;
+ }
+
+ /**
+ * Gets the value of the msoAction property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMsoAction() {
+ return msoAction;
+ }
+
+ /**
+ * Sets the value of the msoAction property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMsoAction(String value) {
+ this.msoAction = value;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java index 829af2c20b..2c38abe4ff 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java @@ -1,51 +1,51 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.sdnc; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for anonymous complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "SDNCAdapterResponse") -public class SDNCAdapterResponse { - - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.sdnc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "")
+@XmlRootElement(name = "SDNCAdapterResponse")
+public class SDNCAdapterResponse {
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java index b408184ae3..0cbb988e3b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java @@ -1,198 +1,198 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.vnf; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for deleteVnfNotification complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType name="deleteVnfNotification"> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> - * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> - * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "deleteVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage" -}) -public class DeleteVnfNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - - /** - * Gets the value of the messageId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return - * possible object is - * {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Overrides toString() method - * @return String type (deleteVnfNotification) - */ - - - public String toString() { - String deleteVnfNotification = ""; - if (exception==null) { - deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.openecomp.mso/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.openecomp.mso/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 ""; - } - } -*/ - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.vnf;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for deleteVnfNotification complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="deleteVnfNotification">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/>
+ * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "deleteVnfNotification1", propOrder = {
+ "messageId",
+ "completed",
+ "exception",
+ "errorMessage"
+})
+public class DeleteVnfNotification {
+
+ @XmlElement(required = true)
+ protected String messageId;
+ protected boolean completed;
+ protected MsoExceptionCategory exception;
+ protected String errorMessage;
+
+ /**
+ * Gets the value of the messageId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the value of the messageId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessageId(String value) {
+ this.messageId = value;
+ }
+
+ /**
+ * Gets the value of the completed property.
+ *
+ */
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ /**
+ * Sets the value of the completed property.
+ *
+ */
+ public void setCompleted(boolean value) {
+ this.completed = value;
+ }
+
+ /**
+ * Gets the value of the exception property.
+ *
+ * @return
+ * possible object is
+ * {@link MsoExceptionCategory }
+ *
+ */
+ public MsoExceptionCategory getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the value of the exception property.
+ *
+ * @param value
+ * allowed object is
+ * {@link MsoExceptionCategory }
+ *
+ */
+ public void setException(MsoExceptionCategory value) {
+ this.exception = value;
+ }
+
+ /**
+ * Gets the value of the errorMessage property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Sets the value of the errorMessage property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setErrorMessage(String value) {
+ this.errorMessage = value;
+ }
+
+ /**
+ * Overrides toString() method
+ * @return String type (deleteVnfNotification)
+ */
+
+
+ public String toString() {
+ String deleteVnfNotification = "";
+ if (exception==null) {
+ deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.openecomp.mso/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.openecomp.mso/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/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java index 80673a0fb6..444ef982fd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java @@ -1,61 +1,61 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.vnf; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for msoExceptionCategory. - * - * <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"> - * <enumeration value="OPENSTACK"/> - * <enumeration value="IO"/> - * <enumeration value="INTERNAL"/> - * <enumeration value="USERDATA"/> - * </restriction> - * </simpleType> - * </pre> - * - */ -@XmlType(name = "msoExceptionCategory") -@XmlEnum -public enum MsoExceptionCategory { - - OPENSTACK, - IO, - INTERNAL, - USERDATA; - - public String value() { - return name(); - } - - public static MsoExceptionCategory fromValue(String v) { - return valueOf(v); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.vnf;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for msoExceptionCategory.
+ *
+ * <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">
+ * <enumeration value="OPENSTACK"/>
+ * <enumeration value="IO"/>
+ * <enumeration value="INTERNAL"/>
+ * <enumeration value="USERDATA"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "msoExceptionCategory")
+@XmlEnum
+public enum MsoExceptionCategory {
+
+ OPENSTACK,
+ IO,
+ INTERNAL,
+ USERDATA;
+
+ public String value() {
+ return name();
+ }
+
+ public static MsoExceptionCategory fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java index f251a31ce8..01a6705898 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java @@ -1,114 +1,114 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.vnf; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for msoRequest complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType name="msoRequest"> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="requestId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="serviceInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "msoRequest", propOrder = { - "requestId", - "serviceInstanceId" -}) -public class MsoRequest { - - protected String requestId; - protected String serviceInstanceId; - - /** - * Gets the value of the requestId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRequestId() { - return requestId; - } - - /** - * Sets the value of the requestId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRequestId(String value) { - this.requestId = value; - } - - /** - * Gets the value of the serviceInstanceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * Sets the value of the serviceInstanceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceInstanceId(String value) { - this.serviceInstanceId = value; - } - - public String toString() { - String request = ""; - request = - "<requestId>"+requestId+"</requestId>" + '\n' + - "<serviceInstanceId>"+serviceInstanceId+"</serviceInstanceId>"; - return request; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.vnf;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for msoRequest complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="msoRequest">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="requestId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="serviceInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "msoRequest", propOrder = {
+ "requestId",
+ "serviceInstanceId"
+})
+public class MsoRequest {
+
+ protected String requestId;
+ protected String serviceInstanceId;
+
+ /**
+ * Gets the value of the requestId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * Sets the value of the requestId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequestId(String value) {
+ this.requestId = value;
+ }
+
+ /**
+ * Gets the value of the serviceInstanceId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ /**
+ * Sets the value of the serviceInstanceId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setServiceInstanceId(String value) {
+ this.serviceInstanceId = value;
+ }
+
+ public String toString() {
+ String request = "";
+ request =
+ "<requestId>"+requestId+"</requestId>" + '\n' +
+ "<serviceInstanceId>"+serviceInstanceId+"</serviceInstanceId>";
+ return request;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java index 47ae04577e..b7b93b7b5d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java @@ -1,488 +1,488 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.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; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for queryVnfNotification complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType name="queryVnfNotification"> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> - * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> - * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="vnfExists" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/> - * <element name="vnfId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="status" type="{http://org.openecomp.mso/vnfNotify}vnfStatus" minOccurs="0"/> - * <element name="outputs" minOccurs="0"> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="entry" maxOccurs="unbounded" minOccurs="0"> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </element> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </element> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "queryVnfNotification1", propOrder = { - "messageId", - "completed", - "exception", - "errorMessage", - "vnfExists", - "vnfId", - "status", - "outputs" -}) -public class QueryVnfNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - protected Boolean vnfExists; - protected String vnfId; - protected VnfStatus status; - protected QueryVnfNotification.Outputs outputs; - - /** - * Gets the value of the messageId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return - * possible object is - * {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value - * allowed object is - * {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Gets the value of the vnfExists property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isVnfExists() { - return vnfExists; - } - - /** - * Sets the value of the vnfExists property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setVnfExists(Boolean value) { - this.vnfExists = value; - } - - /** - * Gets the value of the vnfId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVnfId() { - return vnfId; - } - - /** - * Sets the value of the vnfId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVnfId(String value) { - this.vnfId = value; - } - - /** - * Gets the value of the status property. - * - * @return - * possible object is - * {@link VnfStatus } - * - */ - public VnfStatus getStatus() { - return status; - } - - /** - * Sets the value of the status property. - * - * @param value - * allowed object is - * {@link VnfStatus } - * - */ - public void setStatus(VnfStatus value) { - this.status = value; - } - - /** - * Gets the value of the outputs property. - * - * @return - * possible object is - * {@link QueryVnfNotification.Outputs } - * - */ - public QueryVnfNotification.Outputs getOutputs() { - return outputs; - } - - /** - * Sets the value of the outputs property. - * - * @param value - * allowed object is - * {@link QueryVnfNotification.Outputs } - * - */ - public void setOutputs(QueryVnfNotification.Outputs value) { - this.outputs = value; - } - - - /** - * <p>Java class for anonymous complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="entry" maxOccurs="unbounded" minOccurs="0"> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </element> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "entry" - }) - public static class Outputs { - - protected List<QueryVnfNotification.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. - * - * <p> - * For example, to add a new item, do as follows: - * <pre> - * getEntry().add(newItem); - * </pre> - * - * - * <p> - * Objects of the following type(s) are allowed in the list - * {@link QueryVnfNotification.Outputs.Entry } - * - * - */ - public List<QueryVnfNotification.Outputs.Entry> getEntry() { - if (entry == null) { - entry = new ArrayList<QueryVnfNotification.Outputs.Entry>(); - } - 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(); - } - - - /** - * <p>Java class for anonymous complex type. - * - * <p>The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = { - "key", - "value" - }) - public static class Entry { - - protected String key; - protected String value; - - /** - * Gets the value of the key property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getKey() { - return key; - } - - /** - * Sets the value of the key property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @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; - } - - } - - } - - // Not a generated method - public String toString() { - String queryVnfNotification = ""; - if (exception==null) { - queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.openecomp.mso/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.openecomp.mso/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; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.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;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for queryVnfNotification complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="queryVnfNotification">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/>
+ * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="vnfExists" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * <element name="vnfId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="status" type="{http://org.openecomp.mso/vnfNotify}vnfStatus" minOccurs="0"/>
+ * <element name="outputs" minOccurs="0">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="entry" maxOccurs="unbounded" minOccurs="0">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "queryVnfNotification1", propOrder = {
+ "messageId",
+ "completed",
+ "exception",
+ "errorMessage",
+ "vnfExists",
+ "vnfId",
+ "status",
+ "outputs"
+})
+public class QueryVnfNotification {
+
+ @XmlElement(required = true)
+ protected String messageId;
+ protected boolean completed;
+ protected MsoExceptionCategory exception;
+ protected String errorMessage;
+ protected Boolean vnfExists;
+ protected String vnfId;
+ protected VnfStatus status;
+ protected QueryVnfNotification.Outputs outputs;
+
+ /**
+ * Gets the value of the messageId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the value of the messageId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessageId(String value) {
+ this.messageId = value;
+ }
+
+ /**
+ * Gets the value of the completed property.
+ *
+ */
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ /**
+ * Sets the value of the completed property.
+ *
+ */
+ public void setCompleted(boolean value) {
+ this.completed = value;
+ }
+
+ /**
+ * Gets the value of the exception property.
+ *
+ * @return
+ * possible object is
+ * {@link MsoExceptionCategory }
+ *
+ */
+ public MsoExceptionCategory getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the value of the exception property.
+ *
+ * @param value
+ * allowed object is
+ * {@link MsoExceptionCategory }
+ *
+ */
+ public void setException(MsoExceptionCategory value) {
+ this.exception = value;
+ }
+
+ /**
+ * Gets the value of the errorMessage property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Sets the value of the errorMessage property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setErrorMessage(String value) {
+ this.errorMessage = value;
+ }
+
+ /**
+ * Gets the value of the vnfExists property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public Boolean isVnfExists() {
+ return vnfExists;
+ }
+
+ /**
+ * Sets the value of the vnfExists property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setVnfExists(Boolean value) {
+ this.vnfExists = value;
+ }
+
+ /**
+ * Gets the value of the vnfId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ /**
+ * Sets the value of the vnfId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVnfId(String value) {
+ this.vnfId = value;
+ }
+
+ /**
+ * Gets the value of the status property.
+ *
+ * @return
+ * possible object is
+ * {@link VnfStatus }
+ *
+ */
+ public VnfStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the value of the status property.
+ *
+ * @param value
+ * allowed object is
+ * {@link VnfStatus }
+ *
+ */
+ public void setStatus(VnfStatus value) {
+ this.status = value;
+ }
+
+ /**
+ * Gets the value of the outputs property.
+ *
+ * @return
+ * possible object is
+ * {@link QueryVnfNotification.Outputs }
+ *
+ */
+ public QueryVnfNotification.Outputs getOutputs() {
+ return outputs;
+ }
+
+ /**
+ * Sets the value of the outputs property.
+ *
+ * @param value
+ * allowed object is
+ * {@link QueryVnfNotification.Outputs }
+ *
+ */
+ public void setOutputs(QueryVnfNotification.Outputs value) {
+ this.outputs = value;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="entry" maxOccurs="unbounded" minOccurs="0">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "entry"
+ })
+ public static class Outputs {
+
+ protected List<QueryVnfNotification.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.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEntry().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueryVnfNotification.Outputs.Entry }
+ *
+ *
+ */
+ public List<QueryVnfNotification.Outputs.Entry> getEntry() {
+ if (entry == null) {
+ entry = new ArrayList<QueryVnfNotification.Outputs.Entry>();
+ }
+ 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();
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "key",
+ "value"
+ })
+ public static class Entry {
+
+ protected String key;
+ protected String value;
+
+ /**
+ * Gets the value of the key property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the value of the key property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setKey(String value) {
+ this.key = value;
+ }
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @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;
+ }
+
+ }
+
+ }
+
+ // Not a generated method
+ public String toString() {
+ String queryVnfNotification = "";
+ if (exception==null) {
+ queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.openecomp.mso/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.openecomp.mso/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/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java index a9b2ee2732..62026fb888 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java @@ -1,61 +1,61 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.adapter.vnf; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - * <p>Java class for vnfStatus. - * - * <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"> - * <enumeration value="ACTIVE"/> - * <enumeration value="FAILED"/> - * <enumeration value="NOTFOUND"/> - * <enumeration value="UNKNOWN"/> - * </restriction> - * </simpleType> - * </pre> - * - */ -@XmlType(name = "vnfStatus") -@XmlEnum -public enum VnfStatus { - - ACTIVE, - FAILED, - NOTFOUND, - UNKNOWN; - - public String value() { - return name(); - } - - public static VnfStatus fromValue(String v) { - return valueOf(v); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.adapter.vnf;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for vnfStatus.
+ *
+ * <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">
+ * <enumeration value="ACTIVE"/>
+ * <enumeration value="FAILED"/>
+ * <enumeration value="NOTFOUND"/>
+ * <enumeration value="UNKNOWN"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "vnfStatus")
+@XmlEnum
+public enum VnfStatus {
+
+ ACTIVE,
+ FAILED,
+ NOTFOUND,
+ UNKNOWN;
+
+ public String value() {
+ return name();
+ }
+
+ public static VnfStatus fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java index 1759b208b7..da1f177ea2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java @@ -1,57 +1,57 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.util; - -import java.security.GeneralSecurityException; - -public class CryptoHandler implements ICryptoHandler { - - private static String msoKey = "aa3871669d893c7fb8abbcda31b88b4f"; - //private static String msoAaiPwd = "mso0206"; - private static String msoAaiEncryptedPwd = "C1FC4A39E16419DD41DFC1212843F440"; - - public String getMsoAaiPassword() { - try { - return CryptoUtils.decrypt(msoAaiEncryptedPwd, msoKey); - } catch (GeneralSecurityException e) { - return null; - } - } - - - public String encryptMsoPassword(String plainMsoPwd) { - try { - return CryptoUtils.encrypt(plainMsoPwd, msoKey); - } catch (GeneralSecurityException e) { - return null; - } - } - - - public String decryptMsoPassword(String encryptedPwd) { - try { - return CryptoUtils.decrypt(encryptedPwd, msoKey); - } catch (GeneralSecurityException e) { - return null; - } - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.util;
+
+import java.security.GeneralSecurityException;
+
+public class CryptoHandler implements ICryptoHandler {
+
+ private static String msoKey = "aa3871669d893c7fb8abbcda31b88b4f";
+ //private static String msoAaiPwd = "mso0206";
+ private static String msoAaiEncryptedPwd = "C1FC4A39E16419DD41DFC1212843F440";
+
+ public String getMsoAaiPassword() {
+ try {
+ return CryptoUtils.decrypt(msoAaiEncryptedPwd, msoKey);
+ } catch (GeneralSecurityException e) {
+ return null;
+ }
+ }
+
+
+ public String encryptMsoPassword(String plainMsoPwd) {
+ try {
+ return CryptoUtils.encrypt(plainMsoPwd, msoKey);
+ } catch (GeneralSecurityException e) {
+ return null;
+ }
+ }
+
+
+ public String decryptMsoPassword(String encryptedPwd) {
+ try {
+ return CryptoUtils.decrypt(encryptedPwd, msoKey);
+ } catch (GeneralSecurityException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java index 70aeda01b0..6237735691 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java @@ -1,118 +1,118 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.util; - - -import java.security.GeneralSecurityException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - -//Need to add BPM error handler - -/** - * CryptoUtils adapted from RTTP client. - * - */ -public class CryptoUtils { - - public static final String AES = "AES"; - - /** - * encrypt a value and generate a keyfile - * if the keyfile is not found then a new one is created - * @throws GeneralSecurityException - * @throws IOException - */ - public static String encrypt(String value, String keyString) throws GeneralSecurityException - { - SecretKeySpec sks = getSecretKeySpec(keyString); - Cipher cipher = Cipher.getInstance(CryptoUtils.AES); - cipher.init(Cipher.ENCRYPT_MODE, sks, cipher.getParameters()); - byte[] encrypted = cipher.doFinal(value.getBytes()); - return byteArrayToHexString(encrypted); - } - - /** - * decrypt a value - * @throws GeneralSecurityException - * @throws IOException - */ - public static String decrypt(String message, String keyString) throws GeneralSecurityException - { - SecretKeySpec sks = getSecretKeySpec(keyString); - Cipher cipher = Cipher.getInstance(CryptoUtils.AES); - cipher.init(Cipher.DECRYPT_MODE, sks); - byte[] decrypted = cipher.doFinal(hexStringToByteArray(message)); - return new String(decrypted); - } - - private static SecretKeySpec getSecretKeySpec(String keyString) throws NoSuchAlgorithmException - { - byte [] key = hexStringToByteArray(keyString); - SecretKeySpec sks = new SecretKeySpec(key, CryptoUtils.AES); - return sks; - } - - - private static String byteArrayToHexString(byte[] b){ - StringBuffer sb = new StringBuffer(b.length * 2); - for (int i = 0; i < b.length; i++){ - int v = b[i] & 0xff; - if (v < 16) { - sb.append('0'); - } - sb.append(Integer.toHexString(v)); - } - return sb.toString().toUpperCase(); - } - - private static byte[] hexStringToByteArray(String s) { - byte[] b = new byte[s.length() / 2]; - for (int i = 0; i < b.length; i++){ - int index = i * 2; - int v = Integer.parseInt(s.substring(index, index + 2), 16); - b[i] = (byte)v; - } - return b; - } - - /** - * Not Used... - * - * Call Rttp utility jar to encrypt pwd - * @param clearPassword - * @return - * @throws GeneralSecurityException - * @throws Exception - * - public static String encryptRttpPwd(String clearPassword) throws GeneralSecurityException { - try { - return RttpBasicAuth.encrypt(clearPassword); - } catch (Exception e) { - // wrap generic exception - throw new GeneralSecurityException(e); - } - } - */ -} - +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.util;
+
+
+import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+
+//Need to add BPM error handler
+
+/**
+ * CryptoUtils adapted from RTTP client.
+ *
+ */
+public class CryptoUtils {
+
+ public static final String AES = "AES";
+
+ /**
+ * encrypt a value and generate a keyfile
+ * if the keyfile is not found then a new one is created
+ * @throws GeneralSecurityException
+ * @throws IOException
+ */
+ public static String encrypt(String value, String keyString) throws GeneralSecurityException
+ {
+ SecretKeySpec sks = getSecretKeySpec(keyString);
+ Cipher cipher = Cipher.getInstance(CryptoUtils.AES);
+ cipher.init(Cipher.ENCRYPT_MODE, sks, cipher.getParameters());
+ byte[] encrypted = cipher.doFinal(value.getBytes());
+ return byteArrayToHexString(encrypted);
+ }
+
+ /**
+ * decrypt a value
+ * @throws GeneralSecurityException
+ * @throws IOException
+ */
+ public static String decrypt(String message, String keyString) throws GeneralSecurityException
+ {
+ SecretKeySpec sks = getSecretKeySpec(keyString);
+ Cipher cipher = Cipher.getInstance(CryptoUtils.AES);
+ cipher.init(Cipher.DECRYPT_MODE, sks);
+ byte[] decrypted = cipher.doFinal(hexStringToByteArray(message));
+ return new String(decrypted);
+ }
+
+ private static SecretKeySpec getSecretKeySpec(String keyString) throws NoSuchAlgorithmException
+ {
+ byte [] key = hexStringToByteArray(keyString);
+ SecretKeySpec sks = new SecretKeySpec(key, CryptoUtils.AES);
+ return sks;
+ }
+
+
+ private static String byteArrayToHexString(byte[] b){
+ StringBuffer sb = new StringBuffer(b.length * 2);
+ for (int i = 0; i < b.length; i++){
+ int v = b[i] & 0xff;
+ if (v < 16) {
+ sb.append('0');
+ }
+ sb.append(Integer.toHexString(v));
+ }
+ return sb.toString().toUpperCase();
+ }
+
+ private static byte[] hexStringToByteArray(String s) {
+ byte[] b = new byte[s.length() / 2];
+ for (int i = 0; i < b.length; i++){
+ int index = i * 2;
+ int v = Integer.parseInt(s.substring(index, index + 2), 16);
+ b[i] = (byte)v;
+ }
+ return b;
+ }
+
+ /**
+ * Not Used...
+ *
+ * Call Rttp utility jar to encrypt pwd
+ * @param clearPassword
+ * @return
+ * @throws GeneralSecurityException
+ * @throws Exception
+ *
+ public static String encryptRttpPwd(String clearPassword) throws GeneralSecurityException {
+ try {
+ return RttpBasicAuth.encrypt(clearPassword);
+ } catch (Exception e) {
+ // wrap generic exception
+ throw new GeneralSecurityException(e);
+ }
+ }
+ */
+}
+
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java index 8d4f167596..bc74be05a7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java @@ -1,27 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.util; - -public interface ICryptoHandler { - public String getMsoAaiPassword(); - public String encryptMsoPassword(String plainPwd); - public String decryptMsoPassword(String encryptedPwd); -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.util;
+
+public interface ICryptoHandler {
+ public String getMsoAaiPassword();
+ public String encryptMsoPassword(String plainPwd);
+ public String decryptMsoPassword(String encryptedPwd);
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java index 02a471c971..4585d620ac 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java @@ -1,254 +1,280 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -import java.util.Map; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.ws.rs.core.Context; -import javax.xml.ws.WebServiceContext; - -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.MismatchingMessageCorrelationException; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; -import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; -import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; -import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType; -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -/** - * @version 1.0 - * - */ -@WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") -public class SDNCAdapterCallbackServiceImpl implements SDNCCallbackAdapterPortType { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private final int DEFAULT_RETRY_ATTEMPTS = 60; - private final int DEFAULT_SLEEP_TIME = 500; - - private final String logMarker = "[SDNC-CALLBACK]"; - - @Context WebServiceContext wsContext; - - private volatile ProcessEngineServices pes4junit = null; - - @WebMethod(operationName = "SDNCAdapterCallback") - @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") - public SDNCAdapterResponse sdncAdapterCallback( - @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") - SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { - - //Callback URL to use http://localhost:28080/mso/SDNCAdapterCallbackService - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - String receivedRequestId = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - MsoLogger.setServiceName("MSO." + "sdncAdapter"); - MsoLogger.setLogContext(receivedRequestId, "N/A"); - msoLogger.debug(logMarker + "Received callback response:" + sdncAdapterCallbackRequest.toString()); - SDNCAdapterResponse sdncAdapterResponse; - long startTime = System.currentTimeMillis(); - - /* Check to make sure the process instance is reay for correlation*/ - isReadyforCorrelation(runtimeService, receivedRequestId); - - msoLogger.debug(logMarker + "*** Received MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO sdncAdapterCallbackService"); - - msoLogger.debug(logMarker + "Callback response string:\n" + sdncAdapterCallbackRequest.toString()); - - String reqId = receivedRequestId; - Map<String,Object> variables = new HashMap<String,Object>(); - variables.put("SDNCA_requestId", reqId ); - variables.put("sdncAdapterCallbackRequest", sdncAdapterCallbackRequest.toString()); - - /*Correlating the response with the running instance*/ - - // NOTE: the following loop is a workaround for problems we've had - // with reliability of the runtime service. It seems that queries - // sometimes return results, and sometimes they don't. This might - // be a problem in mysql only. We aren't sure if it affects camunda - // on oracle or mariadb. The workaround is to repeat the request - // a number of times until it succeeds. If it doesn't succeed after - // 60 tries, then we give up. - - int maxAttempts = DEFAULT_RETRY_ATTEMPTS; - int attempt = 1; - int sleepTime = DEFAULT_SLEEP_TIME; - - Map<String,String> bpmnProperties = getMSOBPMNURNProperties(); - if (bpmnProperties != null) { - try { - maxAttempts = Integer.parseInt(bpmnProperties.get("mso.callbackRetryAttempts")); - msoLogger.debug(logMarker + "mso.callbackRetryAttempts=" + maxAttempts); - sleepTime = Integer.parseInt(bpmnProperties.get("mso.callbackRetrySleepTime")); - msoLogger.debug(logMarker + "mso.callbackRetrySleepTime:" + sleepTime); - } catch (Exception ex) { - - msoLogger.info (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", logMarker - + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" - + sleepTime + ":" - + maxAttempts); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker - + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" - + sleepTime + ":" - + maxAttempts); - - } - } - - while (true) { - try { - // sdncAdapterCallbackRequest is the message event name (defined in the bpmn process) - runtimeService.createMessageCorrelation("sdncAdapterCallbackRequest") - .setVariables(variables) - .processInstanceVariableEquals("SDNCA_requestId", reqId).correlate(); - sdncAdapterResponse = new SDNCAdapterResponse(); - msoLogger.debug(logMarker + "***** Completed processing of MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch (attempt " + attempt + "/" + maxAttempts + ")"); - if (attempt == maxAttempts) { - // Couldn't correlate requestId to any active flow - //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but that RequestId could not be correlated to any active process - ignoring the Request"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService." ); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e2) { - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but correlation was interrupted"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - } - - attempt++; - } - } - - - private Map<String,String> getMSOBPMNURNProperties() { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map<String,String> props = propertyConfiguration.getProperties("mso.bpmn.urn.properties"); - return props; - } - - private void isReadyforCorrelation(RuntimeService runtimeService, - String receivedRequestId) { - long waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName("sdncAdapterCallbackRequest") - .processVariableValueEquals("SDNCA_requestId", receivedRequestId).count(); - //Workaround for performance testing, explicit wait for a second for the transactions to be committed - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - } - - int retries = 50; - while (waitingInstances==0 && retries > 0) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker, e); - - } // you can still play with the numbers - waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName("sdncAdapterCallbackRequest") - .processVariableValueEquals("SDNCA_requestId", receivedRequestId).count(); - retries--; - } - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); - } else { - return pes4junit; - } - } - - @WebMethod(exclude=true) - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } - - public class SDNCAdapterExceptionResponse extends SDNCAdapterResponse { - private Exception ex; - - public SDNCAdapterExceptionResponse(Exception ex) { - super(); - this.ex = ex; - } - - public Exception getException() { - return ex; - } - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.ws.rs.core.Context;
+import javax.xml.ws.WebServiceContext;
+
+import org.camunda.bpm.BpmPlatform;
+import org.camunda.bpm.engine.MismatchingMessageCorrelationException;
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.runtime.ExecutionQuery;
+import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
+import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
+import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ * @version 1.0
+ *
+ */
+@WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1")
+public class SDNCAdapterCallbackServiceImpl implements SDNCCallbackAdapterPortType {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private final int DEFAULT_RETRY_ATTEMPTS = 60;
+ private final int DEFAULT_SLEEP_TIME = 500;
+
+ private final String logMarker = "[SDNC-CALLBACK]";
+
+ @Context WebServiceContext wsContext;
+
+ private volatile ProcessEngineServices pes4junit = null;
+
+ @WebMethod(operationName = "SDNCAdapterCallback")
+ @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse")
+ public SDNCAdapterResponse sdncAdapterCallback(
+ @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest")
+ SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) {
+
+ //Callback URL to use http://localhost:28080/mso/SDNCAdapterCallbackService
+ ProcessEngineServices pes = getProcessEngineServices();
+ RuntimeService runtimeService = pes.getRuntimeService();
+ String receivedRequestId = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId();
+ MsoLogger.setServiceName("MSO." + "sdncAdapter");
+ MsoLogger.setLogContext(receivedRequestId, "N/A");
+ msoLogger.debug(logMarker + "Received callback response:" + sdncAdapterCallbackRequest.toString());
+ SDNCAdapterResponse sdncAdapterResponse;
+ long startTime = System.currentTimeMillis();
+
+ /*Correlating the response with the running instance*/
+
+ // NOTE: the following loop is a workaround for problems we've had
+ // with reliability of the runtime service. It seems that queries
+ // sometimes return results, and sometimes they don't. This might
+ // be a problem in mysql only. We aren't sure if it affects camunda
+ // on oracle or mariadb. The workaround is to repeat the request
+ // a number of times until it succeeds. If it doesn't succeed after
+ // 60 tries, then we give up.
+
+ int maxAttempts = DEFAULT_RETRY_ATTEMPTS;
+ int attempt = 1;
+ int sleepTime = DEFAULT_SLEEP_TIME;
+
+ Map<String,String> bpmnProperties = getMSOBPMNURNProperties();
+ if (bpmnProperties != null) {
+ try {
+ maxAttempts = Integer.parseInt(bpmnProperties.get("mso.callbackRetryAttempts"));
+ msoLogger.debug(logMarker + "mso.callbackRetryAttempts=" + maxAttempts);
+ sleepTime = Integer.parseInt(bpmnProperties.get("mso.callbackRetrySleepTime"));
+ msoLogger.debug(logMarker + "mso.callbackRetrySleepTime:" + sleepTime);
+ } catch (Exception ex) {
+
+ msoLogger.debug (logMarker
+ + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:"
+ + sleepTime + ":"
+ + maxAttempts);
+
+ }
+ }
+
+ /* Check to make sure the process instance is reay for correlation*/
+ try{
+ isReadyforCorrelation(runtimeService, receivedRequestId, maxAttempts, sleepTime );
+ }catch(Exception e){
+ String msg =
+ "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '"
+ + receivedRequestId
+ + "' but that RequestId doesn't exist or has timed out waiting for the callback";
+ sdncAdapterResponse = new SDNCAdapterExceptionResponse(e);
+
+ msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + "Completed the execution of MSO SDNCAdapterCallbackService." );
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN",
+ MsoLogger.getServiceName(), "sdncAdapterCallback");
+
+ return sdncAdapterResponse;
+ }
+
+ msoLogger.debug(logMarker + "*** Received MSO sdncAdapterCallbackService ******");
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO sdncAdapterCallbackService");
+
+ msoLogger.debug(logMarker + "Callback response string:\n" + sdncAdapterCallbackRequest.toString());
+
+ String reqId = receivedRequestId;
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("SDNCA_requestId", reqId );
+ variables.put("sdncAdapterCallbackRequest", sdncAdapterCallbackRequest.toString());
+ while (true) {
+ try {
+ // sdncAdapterCallbackRequest is the message event name (defined in the bpmn process)
+ runtimeService.createMessageCorrelation("sdncAdapterCallbackRequest")
+ .setVariables(variables)
+ .processInstanceVariableEquals("SDNCA_requestId", reqId).correlate();
+ sdncAdapterResponse = new SDNCAdapterResponse();
+ msoLogger.debug(logMarker + "***** Completed processing of MSO sdncAdapterCallbackService ******");
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + "Completed the execution of MSO SDNCAdapterCallbackService.");
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN",
+ MsoLogger.getServiceName(), "sdncAdapterCallback");
+
+ return sdncAdapterResponse;
+ } catch(MismatchingMessageCorrelationException e) {
+ msoLogger.debug(logMarker + "[CORM]correlation id mismatch (attempt " + attempt + "/" + maxAttempts + ")");
+ if (attempt == maxAttempts) {
+ // Couldn't correlate requestId to any active flow
+ //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService");
+ String msg =
+ "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '"
+ + receivedRequestId
+ + "' but that RequestId could not be correlated to any active process - ignoring the Request";
+ sdncAdapterResponse = new SDNCAdapterExceptionResponse(e);
+
+ msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + "Completed the execution of MSO SDNCAdapterCallbackService." );
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN",
+ MsoLogger.getServiceName(), "sdncAdapterCallback");
+
+ return sdncAdapterResponse;
+ }
+
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e2) {
+ String msg =
+ "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '"
+ + receivedRequestId
+ + "' but correlation was interrupted";
+ sdncAdapterResponse = new SDNCAdapterExceptionResponse(e);
+
+ msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + "Completed the execution of MSO SDNCAdapterCallbackService.");
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN",
+ MsoLogger.getServiceName(), "sdncAdapterCallback");
+
+ return sdncAdapterResponse;
+ }
+ }
+
+ attempt++;
+ }
+ }
+
+
+ private Map<String,String> getMSOBPMNURNProperties() {
+ PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
+ Map<String,String> props = propertyConfiguration.getProperties("mso.bpmn.urn.properties");
+ return props;
+ }
+
+ private void isReadyforCorrelation(RuntimeService runtimeService,
+ String receivedRequestId, int retries, int sleepTime){
+ ExecutionQuery waitingInstances = null;
+ long waitingInstancesCount = 0;
+
+ //Workaround for performance testing, explicit wait for a second for the transactions to be committed
+ //Also check to make sure the process didn't timeout before trying to correlate
+
+ do{
+ waitingInstances = runtimeService.createExecutionQuery() //
+ .messageEventSubscriptionName("sdncAdapterCallbackRequest")
+ .processVariableValueEquals("SDNCA_requestId", receivedRequestId);
+ waitingInstancesCount = waitingInstances.count();
+ retries--;
+ msoLogger.debug(logMarker + "waitingInstancesCount: " + waitingInstancesCount);
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+
+ msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, logMarker, e);
+
+ }
+ }while (waitingInstancesCount==0 && retries > 0);
+ if(waitingInstancesCount > 0){
+ msoLogger.debug(logMarker + "waitingInstancesCount before timeout check: " + waitingInstancesCount);
+ waitingInstancesCount = waitingInstances.processVariableValueEquals("asynchronousResponseTimeout", false).count();
+ msoLogger.debug(logMarker + "waitingInstancesCount after timeout check: " + waitingInstancesCount);
+ if(waitingInstancesCount<=0){
+ msoLogger.debug(logMarker + "detected timeout on flow to correlate");
+ throw new IllegalStateException("process timed out");
+ }
+ }else{
+ //flow may have already ended, so can't check timeout variable. Throw exception?
+ msoLogger.debug(logMarker + "no flow to correlate to");
+ throw new IllegalStateException("no flow to correlate to");
+ }
+ }
+
+ private ProcessEngineServices getProcessEngineServices() {
+ if (pes4junit == null) {
+ return BpmPlatform.getDefaultProcessEngine();
+ } else {
+ return pes4junit;
+ }
+ }
+
+ @WebMethod(exclude=true)
+ public void setProcessEngineServices4junit(ProcessEngineServices pes) {
+ pes4junit = pes;
+ }
+
+ public class SDNCAdapterExceptionResponse extends SDNCAdapterResponse {
+ private Exception ex;
+
+ public SDNCAdapterExceptionResponse(Exception ex) {
+ super();
+ this.ex = ex;
+ }
+
+ public Exception getException() {
+ return ex;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java index 5abd4e91da..c0ea0cf874 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java @@ -1,36 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.ProcessEngines; - - -public class WorkflowAsyncCommonResource extends WorkflowAsyncResource { - - protected ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return ProcessEngines.getProcessEngine("common"); - } else { - return pes4junit; - } - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.ProcessEngines;
+
+
+public class WorkflowAsyncCommonResource extends WorkflowAsyncResource {
+
+ protected ProcessEngineServices getProcessEngineServices() {
+ if (pes4junit == null) {
+ return ProcessEngines.getProcessEngine("common");
+ } else {
+ return pes4junit;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java index 28541930ab..b13ac46784 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -1,293 +1,293 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; - -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.ProcessEngines; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.jboss.resteasy.annotations.Suspend; -import org.jboss.resteasy.spi.AsynchronousResponse; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.slf4j.MDC; - -/** - * - * @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 - */ -@Path("/async") +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.ProcessEngines;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
+import org.jboss.resteasy.annotations.Suspend;
+import org.jboss.resteasy.spi.AsynchronousResponse;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.slf4j.MDC;
+
+/**
+ *
+ * @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
+ */
+@Path("/async")
public abstract class WorkflowAsyncResource { - - private WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - protected ProcessEngineServices pes4junit = null; - - private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private static final String logMarker = "[WRKFLOW-RESOURCE]"; - private static final int DEFAULT_WAIT_TIME = 30000; //default wait time - - /** - * Asynchronous JAX-RS method that starts a process instance. - * @param asyncResponse an object that will receive the asynchronous response - * @param processKey the process key - * @param variableMap input variables to the process - */ - @POST - @Path("/services/{processKey}") - @Produces("application/json") - @Consumes("application/json") - public void startProcessInstanceByKey(final @Suspend(180000) AsynchronousResponse asyncResponse, - @PathParam("processKey") String processKey, VariableMapImpl variableMap) { - - WorkflowResponse response = new WorkflowResponse(); - long startTime = System.currentTimeMillis(); - Map<String, Object> inputVariables = null; - WorkflowContext workflowContext = null; - - try { - inputVariables = getInputVariables(variableMap); - setLogContext(processKey, inputVariables); - - // This variable indicates that the flow was invoked asynchronously - inputVariables.put("isAsyncProcess", "true"); - - workflowContext = new WorkflowContext(processKey, getRequestId(inputVariables), - asyncResponse, getWaitTime(inputVariables)); - - msoLogger.debug("Adding the workflow context into holder: " - + workflowContext.getProcessKey() + ":" - + workflowContext.getRequestId() + ":" - + workflowContext.getTimeout()); - - contextHolder.put(workflowContext); - - ProcessThread processThread = new ProcessThread(processKey, inputVariables); - processThread.start(); - } catch (Exception e) { - setLogContext(processKey, inputVariables); - - if (workflowContext != null) { - contextHolder.remove(workflowContext); - } - - msoLogger.debug(logMarker + "Exception in startProcessInstance by key"); - response.setMessage("Fail" ); - response.setResponse("Error occurred while executing the process: " + e); - response.setMessageCode(500); - recordEvents(processKey, response, startTime); - - msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker - + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); - - Response errorResponse = Response.serverError().entity(response).build(); - asyncResponse.setResponse(errorResponse); - } - } - - /** - * - * @version 1.0 - * - */ - class ProcessThread extends Thread { - private final String processKey; - private final Map<String,Object> inputVariables; - - public ProcessThread(String processKey, Map<String, Object> inputVariables) { - this.processKey = processKey; - this.inputVariables = inputVariables; - } - - public void run() { - - String processInstanceId = null; - long startTime = System.currentTimeMillis(); - - try { - setLogContext(processKey, inputVariables); - - // Note: this creates a random businessKey if it wasn't specified. - String businessKey = getBusinessKey(inputVariables); - - msoLogger.debug(logMarker + "***Received MSO startProcessInstanceByKey with processKey: " - + processKey + " and variables: " + inputVariables); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with processKey:" - + processKey + " and variables: " + inputVariables); - - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( - processKey, businessKey, inputVariables); - processInstanceId = processInstance.getId(); - - msoLogger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + - (processInstance.isEnded() ? "ENDED" : "RUNNING")); - } catch (Exception e) { - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, - logMarker + "Error in starting the process: "+ e.getMessage()); - - WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); - callbackResponse.setStatusCode(500); - callbackResponse.setMessage("Fail"); - callbackResponse.setResponse("Error occurred while executing the process: " + e); - - // TODO: is the processInstanceId used by the API handler? I don't think so. - // It may be null here. - WorkflowContextHolder.getInstance().processCallback( - processKey, processInstanceId, - getRequestId(inputVariables), - callbackResponse); - } - } - } - - - /** - * Callback resource which is invoked from BPMN to process to send the workflow response - * - * @param processKey - * @param processInstanceId - * @param requestId - * @param callbackResponse - * @return - */ - @POST - @Path("/services/callback/{processKey}/{processInstanceId}/{requestId}") - @Produces("application/json") - @Consumes("application/json") - public Response processWorkflowCallback( - @PathParam("processKey") String processKey, - @PathParam("processInstanceId") String processInstanceId, - @PathParam("requestId")String requestId, - WorkflowCallbackResponse callbackResponse) { - - msoLogger.debug(logMarker + "Process instance ID:" + processInstanceId + ":" + requestId + ":" + processKey + ":" + isProcessEnded(processInstanceId)); - msoLogger.debug(logMarker + "About to process the callback request:" + callbackResponse.getResponse() + ":" + callbackResponse.getMessage() + ":" + callbackResponse.getStatusCode()); - return contextHolder.processCallback(processKey, processInstanceId, requestId, callbackResponse); - } - - // Note: the business key is used to identify the process in unit tests - private String getBusinessKey(Map<String, Object> inputVariables) { - Object businessKey = inputVariables.get("mso-business-key"); - if (businessKey == null ) { - businessKey = UUID.randomUUID().toString(); - inputVariables.put("mso-business-key", businessKey); - } - return businessKey.toString(); - } - - private String getRequestId(Map<String, Object> inputVariables) { - Object requestId = inputVariables.get("mso-request-id"); - if (requestId == null ) { - requestId = UUID.randomUUID().toString(); - inputVariables.put("mso-request-id", requestId); - } - return requestId.toString(); - } - - private long getWaitTime(Map<String, Object> inputVariables) - { - String timeout = inputVariables.get("mso-service-request-timeout") == null - ? null : inputVariables.get("mso-service-request-timeout").toString(); - - if (timeout != null) { - try { - return Long.parseLong(timeout)*1000; - } catch (NumberFormatException nex) { - msoLogger.debug("Invalid input for mso-service-request-timeout"); - } - } - - return DEFAULT_WAIT_TIME; - } - - private void recordEvents(String processKey, WorkflowResponse response, - long startTime) { - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + response.getMessage() + "for processKey: " + processKey + " with response: " + response.getResponse()); - - } - - private void setLogContext(String processKey, - Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id")); - } - } - - private String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { - if (inputVariables == null) return ""; - Object requestId = inputVariables.get(key); - if (requestId != null) return requestId.toString(); - return "N/A"; - } - - private boolean isProcessEnded(String processInstanceId) { - ProcessEngineServices pes = getProcessEngineServices(); - return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; - } - - +
+ private WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
+ protected ProcessEngineServices pes4junit = null;
+
+ private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private static final String logMarker = "[WRKFLOW-RESOURCE]";
+ private static final int DEFAULT_WAIT_TIME = 30000; //default wait time
+
+ /**
+ * Asynchronous JAX-RS method that starts a process instance.
+ * @param asyncResponse an object that will receive the asynchronous response
+ * @param processKey the process key
+ * @param variableMap input variables to the process
+ */
+ @POST
+ @Path("/services/{processKey}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ public void startProcessInstanceByKey(final @Suspend(180000) AsynchronousResponse asyncResponse,
+ @PathParam("processKey") String processKey, VariableMapImpl variableMap) {
+
+ WorkflowResponse response = new WorkflowResponse();
+ long startTime = System.currentTimeMillis();
+ Map<String, Object> inputVariables = null;
+ WorkflowContext workflowContext = null;
+
+ try {
+ inputVariables = getInputVariables(variableMap);
+ setLogContext(processKey, inputVariables);
+
+ // This variable indicates that the flow was invoked asynchronously
+ inputVariables.put("isAsyncProcess", "true");
+
+ workflowContext = new WorkflowContext(processKey, getRequestId(inputVariables),
+ asyncResponse, getWaitTime(inputVariables));
+
+ msoLogger.debug("Adding the workflow context into holder: "
+ + workflowContext.getProcessKey() + ":"
+ + workflowContext.getRequestId() + ":"
+ + workflowContext.getTimeout());
+
+ contextHolder.put(workflowContext);
+
+ ProcessThread processThread = new ProcessThread(processKey, inputVariables);
+ processThread.start();
+ } catch (Exception e) {
+ setLogContext(processKey, inputVariables);
+
+ if (workflowContext != null) {
+ contextHolder.remove(workflowContext);
+ }
+
+ msoLogger.debug(logMarker + "Exception in startProcessInstance by key");
+ response.setMessage("Fail" );
+ response.setResponse("Error occurred while executing the process: " + e);
+ response.setMessageCode(500);
+ recordEvents(processKey, response, startTime);
+
+ msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker
+ + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse());
+
+ Response errorResponse = Response.serverError().entity(response).build();
+ asyncResponse.setResponse(errorResponse);
+ }
+ }
+
+ /**
+ *
+ * @version 1.0
+ *
+ */
+ class ProcessThread extends Thread {
+ private final String processKey;
+ private final Map<String,Object> inputVariables;
+
+ public ProcessThread(String processKey, Map<String, Object> inputVariables) {
+ this.processKey = processKey;
+ this.inputVariables = inputVariables;
+ }
+
+ public void run() {
+
+ String processInstanceId = null;
+ long startTime = System.currentTimeMillis();
+
+ try {
+ setLogContext(processKey, inputVariables);
+
+ // Note: this creates a random businessKey if it wasn't specified.
+ String businessKey = getBusinessKey(inputVariables);
+
+ msoLogger.debug(logMarker + "***Received MSO startProcessInstanceByKey with processKey: "
+ + processKey + " and variables: " + inputVariables);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with processKey:"
+ + processKey + " and variables: " + inputVariables);
+
+ RuntimeService runtimeService = getProcessEngineServices().getRuntimeService();
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
+ processKey, businessKey, inputVariables);
+ processInstanceId = processInstance.getId();
+
+ msoLogger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " +
+ (processInstance.isEnded() ? "ENDED" : "RUNNING"));
+ } catch (Exception e) {
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ logMarker + "Error in starting the process: "+ e.getMessage());
+
+ WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
+ callbackResponse.setStatusCode(500);
+ callbackResponse.setMessage("Fail");
+ callbackResponse.setResponse("Error occurred while executing the process: " + e);
+
+ // TODO: is the processInstanceId used by the API handler? I don't think so.
+ // It may be null here.
+ WorkflowContextHolder.getInstance().processCallback(
+ processKey, processInstanceId,
+ getRequestId(inputVariables),
+ callbackResponse);
+ }
+ }
+ }
+
+
+ /**
+ * Callback resource which is invoked from BPMN to process to send the workflow response
+ *
+ * @param processKey
+ * @param processInstanceId
+ * @param requestId
+ * @param callbackResponse
+ * @return
+ */
+ @POST
+ @Path("/services/callback/{processKey}/{processInstanceId}/{requestId}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ public Response processWorkflowCallback(
+ @PathParam("processKey") String processKey,
+ @PathParam("processInstanceId") String processInstanceId,
+ @PathParam("requestId")String requestId,
+ WorkflowCallbackResponse callbackResponse) {
+
+ msoLogger.debug(logMarker + "Process instance ID:" + processInstanceId + ":" + requestId + ":" + processKey + ":" + isProcessEnded(processInstanceId));
+ msoLogger.debug(logMarker + "About to process the callback request:" + callbackResponse.getResponse() + ":" + callbackResponse.getMessage() + ":" + callbackResponse.getStatusCode());
+ return contextHolder.processCallback(processKey, processInstanceId, requestId, callbackResponse);
+ }
+
+ // Note: the business key is used to identify the process in unit tests
+ private String getBusinessKey(Map<String, Object> inputVariables) {
+ Object businessKey = inputVariables.get("mso-business-key");
+ if (businessKey == null ) {
+ businessKey = UUID.randomUUID().toString();
+ inputVariables.put("mso-business-key", businessKey);
+ }
+ return businessKey.toString();
+ }
+
+ private String getRequestId(Map<String, Object> inputVariables) {
+ Object requestId = inputVariables.get("mso-request-id");
+ if (requestId == null ) {
+ requestId = UUID.randomUUID().toString();
+ inputVariables.put("mso-request-id", requestId);
+ }
+ return requestId.toString();
+ }
+
+ private long getWaitTime(Map<String, Object> inputVariables)
+ {
+ String timeout = inputVariables.get("mso-service-request-timeout") == null
+ ? null : inputVariables.get("mso-service-request-timeout").toString();
+
+ if (timeout != null) {
+ try {
+ return Long.parseLong(timeout)*1000;
+ } catch (NumberFormatException nex) {
+ msoLogger.debug("Invalid input for mso-service-request-timeout");
+ }
+ }
+
+ return DEFAULT_WAIT_TIME;
+ }
+
+ private void recordEvents(String processKey, WorkflowResponse response,
+ long startTime) {
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + response.getMessage() + "for processKey: " + processKey + " with response: " + response.getResponse());
+
+ }
+
+ private void setLogContext(String processKey,
+ Map<String, Object> inputVariables) {
+ MsoLogger.setServiceName("MSO." + processKey);
+ if (inputVariables != null) {
+ MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id"));
+ }
+ }
+
+ private String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
+ if (inputVariables == null) return "";
+ Object requestId = inputVariables.get(key);
+ if (requestId != null) return requestId.toString();
+ return "N/A";
+ }
+
+ private boolean isProcessEnded(String processInstanceId) {
+ ProcessEngineServices pes = getProcessEngineServices();
+ return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
+ }
+
+
protected abstract ProcessEngineServices getProcessEngineServices(); - - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } - - private Map<String, Object> getInputVariables(VariableMapImpl variableMap) { - Map<String, Object> inputVariables = new HashMap<String,Object>(); - @SuppressWarnings("unchecked") - Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); - for (String vName : vMap.keySet()) { - @SuppressWarnings("unchecked") - Map<String, Object> valueMap = (Map<String,Object>)vMap.get(vName); // value, type - inputVariables.put(vName, valueMap.get("value")); - } - return inputVariables; - } -} +
+ public void setProcessEngineServices4junit(ProcessEngineServices pes) {
+ pes4junit = pes;
+ }
+
+ private Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
+ Map<String, Object> inputVariables = new HashMap<String,Object>();
+ @SuppressWarnings("unchecked")
+ Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
+ for (String vName : vMap.keySet()) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> valueMap = (Map<String,Object>)vMap.get(vName); // value, type
+ inputVariables.put(vName, valueMap.get("value"));
+ }
+ return inputVariables;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java index b3e5ad1c58..945d64d81a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java @@ -1,52 +1,52 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -/** - * @version 1.0 - * Workflow Response bean to generate workflow response in JSON format - */ -public class WorkflowCallbackResponse { - - private String response; - private int statusCode; - private String message; - - public String getResponse() { - return response; - } - public void setResponse(String response) { - this.response = response; - } - public int getStatusCode() { - return statusCode; - } - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+/**
+ * @version 1.0
+ * Workflow Response bean to generate workflow response in JSON format
+ */
+public class WorkflowCallbackResponse {
+
+ private String response;
+ private int statusCode;
+ private String message;
+
+ public String getResponse() {
+ return response;
+ }
+ public void setResponse(String response) {
+ this.response = response;
+ }
+ public int getStatusCode() {
+ return statusCode;
+ }
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java index 867226c02a..3d7e333fdf 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java @@ -1,96 +1,96 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.concurrent.Delayed; -import java.util.concurrent.TimeUnit; - -import org.jboss.resteasy.spi.AsynchronousResponse; - -/** - * @version 1.0 - * Workflow context object used to send timeout response, if workflow instance does not write the response in time - */ -public class WorkflowContext implements Delayed { - private final String processKey; - private final String requestId; - private final AsynchronousResponse asynchronousResponse; - private final long startTime; - private final long timeout; - - public WorkflowContext(String processKey, String requestId, - AsynchronousResponse asynchronousResponse, long timeout) { - this.processKey = processKey; - this.requestId = requestId; - this.asynchronousResponse = asynchronousResponse; - this.timeout = timeout; - this.startTime = System.currentTimeMillis(); - } - - public String getRequestId() { - return requestId; - } - - public String getProcessKey() { - return processKey; - } - - public AsynchronousResponse getAsynchronousResponse() { - return asynchronousResponse; - } - - public long getTimeout() { - return timeout; - } - - public long getStartTime() { - return startTime; - } - - /** - * Required implementation by Delay queue - * Returns the elapsed time for this context - */ - @Override - public long getDelay(TimeUnit unit) { - // 0 or negative means this object is considered to be expired - return unit.convert(startTime + timeout - System.currentTimeMillis(), unit); - } - - /** - * Required implementation by Delay queue - * Compares the object to determine whether the object can be marked as expired - */ - @Override - public int compareTo(Delayed object) { - WorkflowContext that = (WorkflowContext) object; - long thisEndTime = startTime + timeout; - long thatEndTime = that.startTime + that.timeout; - - if (thisEndTime < thatEndTime) { - return -1; - } else if (thisEndTime > thatEndTime) { - return 1; - } else { - return 0; - } - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.concurrent.Delayed;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.resteasy.spi.AsynchronousResponse;
+
+/**
+ * @version 1.0
+ * Workflow context object used to send timeout response, if workflow instance does not write the response in time
+ */
+public class WorkflowContext implements Delayed {
+ private final String processKey;
+ private final String requestId;
+ private final AsynchronousResponse asynchronousResponse;
+ private final long startTime;
+ private final long timeout;
+
+ public WorkflowContext(String processKey, String requestId,
+ AsynchronousResponse asynchronousResponse, long timeout) {
+ this.processKey = processKey;
+ this.requestId = requestId;
+ this.asynchronousResponse = asynchronousResponse;
+ this.timeout = timeout;
+ this.startTime = System.currentTimeMillis();
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public String getProcessKey() {
+ return processKey;
+ }
+
+ public AsynchronousResponse getAsynchronousResponse() {
+ return asynchronousResponse;
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * Required implementation by Delay queue
+ * Returns the elapsed time for this context
+ */
+ @Override
+ public long getDelay(TimeUnit unit) {
+ // 0 or negative means this object is considered to be expired
+ return unit.convert(startTime + timeout - System.currentTimeMillis(), unit);
+ }
+
+ /**
+ * Required implementation by Delay queue
+ * Compares the object to determine whether the object can be marked as expired
+ */
+ @Override
+ public int compareTo(Delayed object) {
+ WorkflowContext that = (WorkflowContext) object;
+ long thisEndTime = startTime + timeout;
+ long thatEndTime = that.startTime + that.timeout;
+
+ if (thisEndTime < thatEndTime) {
+ return -1;
+ } else if (thisEndTime > thatEndTime) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java index 1c48e7173a..ca3b1f1390 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java @@ -1,188 +1,188 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.concurrent.DelayQueue; -import java.util.concurrent.TimeUnit; - -import javax.ws.rs.core.Response; - -import org.jboss.resteasy.spi.AsynchronousResponse; -import org.slf4j.MDC; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java - * @version 1.0 - * - */ -public class WorkflowContextHolder { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]"; - private static WorkflowContextHolder instance = null; - - /** - * Delay Queue which holds workflow context holder objects - */ - private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<WorkflowContext>(); - private final TimeoutThread timeoutThread = new TimeoutThread(); - - private WorkflowContextHolder() { - timeoutThread.start(); - } - - /** - * Singleton holder which eliminates hot lock - * Since the JVM synchronizes static method there is no synchronization needed for this method - * @return - */ - public static synchronized WorkflowContextHolder getInstance() { - if (instance == null) { - instance = new WorkflowContextHolder(); - } - return instance; - } - - public void put(WorkflowContext context) { - msoLogger.debug(logMarker + " Adding context to the queue: " - + context.getRequestId()); - responseQueue.put(context); - } - - public void remove(WorkflowContext context) { - msoLogger.debug(logMarker + " Removing context from the queue: " - + context.getRequestId()); - responseQueue.remove(context); - } - - public WorkflowContext getWorkflowContext(String requestId) { - // Note: DelayQueue interator is threadsafe - for (WorkflowContext context : responseQueue) { - if (requestId.equals(context.getRequestId())) { - msoLogger.debug("Found context for request id: " + requestId); - return context; - } - } - - msoLogger.debug("Unable to find context for request id: " + requestId); - return null; - } - - /** - * Builds the callback response object to respond to client - * @param processKey - * @param processInstanceId - * @param requestId - * @param callbackResponse - * @return - */ - public Response processCallback(String processKey, String processInstanceId, - String requestId, WorkflowCallbackResponse callbackResponse) { - WorkflowResponse workflowResponse = new WorkflowResponse(); - WorkflowContext workflowContext = getWorkflowContext(requestId); - - if (workflowContext == null) { - msoLogger.debug("Unable to correlate workflow context for request id: " + requestId - + ":processInstance Id:" + processInstanceId - + ":process key:" + processKey); - workflowResponse.setMessage("Fail"); - workflowResponse.setMessageCode(400); - workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId); - return Response.serverError().entity(workflowResponse).build(); - } - - responseQueue.remove(workflowContext); - - msoLogger.debug("Using callback response for request id: " + requestId); - workflowResponse.setResponse(callbackResponse.getResponse()); - workflowResponse.setProcessInstanceID(processInstanceId); - workflowResponse.setMessageCode(callbackResponse.getStatusCode()); - workflowResponse.setMessage(callbackResponse.getMessage()); - sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse); - return Response.ok().entity(workflowResponse).build(); - } - - /** - * Send the response to client asynchronously when invoked by the BPMN process - * @param processKey - * @param workflowContext - * @param workflowResponse - */ - private void sendWorkflowResponseToClient(String processKey, WorkflowContext workflowContext, - WorkflowResponse workflowResponse) { - msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId()); - recordEvents(processKey, workflowResponse, workflowContext.getStartTime()); - Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build(); - AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse(); - asyncResp.setResponse(response); - } - - /** - * Timeout thread which monitors the delay queue for expired context and send timeout response - * to client - * - * */ - private class TimeoutThread extends Thread { - public void run() { - while (!isInterrupted()) { - try { - WorkflowContext requestObject = responseQueue.take(); - msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS)); - msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId()); - WorkflowResponse response = new WorkflowResponse(); - response.setMessage("Fail"); - response.setResponse("Request timedout, request id:" + requestObject.getRequestId()); - //response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId()); - recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime()); - response.setMessageCode(500); - Response result = Response.status(500).entity(response).build(); - requestObject.getAsynchronousResponse().setResponse(result); - msoLogger.debug("Sending timeout response for request id:" + requestObject.getRequestId() + ":response:" + response); - } catch (InterruptedException e) { - break; - } catch (Exception e) { - msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread"); - - } - } - - msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting"); - } - } - - private static void recordEvents(String processKey, WorkflowResponse response, - long startTime) { - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); - - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.concurrent.DelayQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.spi.AsynchronousResponse;
+import org.slf4j.MDC;
+
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java
+ * @version 1.0
+ *
+ */
+public class WorkflowContextHolder {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]";
+ private static WorkflowContextHolder instance = null;
+
+ /**
+ * Delay Queue which holds workflow context holder objects
+ */
+ private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<WorkflowContext>();
+ private final TimeoutThread timeoutThread = new TimeoutThread();
+
+ private WorkflowContextHolder() {
+ timeoutThread.start();
+ }
+
+ /**
+ * Singleton holder which eliminates hot lock
+ * Since the JVM synchronizes static method there is no synchronization needed for this method
+ * @return
+ */
+ public static synchronized WorkflowContextHolder getInstance() {
+ if (instance == null) {
+ instance = new WorkflowContextHolder();
+ }
+ return instance;
+ }
+
+ public void put(WorkflowContext context) {
+ msoLogger.debug(logMarker + " Adding context to the queue: "
+ + context.getRequestId());
+ responseQueue.put(context);
+ }
+
+ public void remove(WorkflowContext context) {
+ msoLogger.debug(logMarker + " Removing context from the queue: "
+ + context.getRequestId());
+ responseQueue.remove(context);
+ }
+
+ public WorkflowContext getWorkflowContext(String requestId) {
+ // Note: DelayQueue interator is threadsafe
+ for (WorkflowContext context : responseQueue) {
+ if (requestId.equals(context.getRequestId())) {
+ msoLogger.debug("Found context for request id: " + requestId);
+ return context;
+ }
+ }
+
+ msoLogger.debug("Unable to find context for request id: " + requestId);
+ return null;
+ }
+
+ /**
+ * Builds the callback response object to respond to client
+ * @param processKey
+ * @param processInstanceId
+ * @param requestId
+ * @param callbackResponse
+ * @return
+ */
+ public Response processCallback(String processKey, String processInstanceId,
+ String requestId, WorkflowCallbackResponse callbackResponse) {
+ WorkflowResponse workflowResponse = new WorkflowResponse();
+ WorkflowContext workflowContext = getWorkflowContext(requestId);
+
+ if (workflowContext == null) {
+ msoLogger.debug("Unable to correlate workflow context for request id: " + requestId
+ + ":processInstance Id:" + processInstanceId
+ + ":process key:" + processKey);
+ workflowResponse.setMessage("Fail");
+ workflowResponse.setMessageCode(400);
+ workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId);
+ return Response.serverError().entity(workflowResponse).build();
+ }
+
+ responseQueue.remove(workflowContext);
+
+ msoLogger.debug("Using callback response for request id: " + requestId);
+ workflowResponse.setResponse(callbackResponse.getResponse());
+ workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setMessageCode(callbackResponse.getStatusCode());
+ workflowResponse.setMessage(callbackResponse.getMessage());
+ sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse);
+ return Response.ok().entity(workflowResponse).build();
+ }
+
+ /**
+ * Send the response to client asynchronously when invoked by the BPMN process
+ * @param processKey
+ * @param workflowContext
+ * @param workflowResponse
+ */
+ private void sendWorkflowResponseToClient(String processKey, WorkflowContext workflowContext,
+ WorkflowResponse workflowResponse) {
+ msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId());
+ recordEvents(processKey, workflowResponse, workflowContext.getStartTime());
+ Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build();
+ AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse();
+ asyncResp.setResponse(response);
+ }
+
+ /**
+ * Timeout thread which monitors the delay queue for expired context and send timeout response
+ * to client
+ *
+ * */
+ private class TimeoutThread extends Thread {
+ public void run() {
+ while (!isInterrupted()) {
+ try {
+ WorkflowContext requestObject = responseQueue.take();
+ msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS));
+ msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId());
+ WorkflowResponse response = new WorkflowResponse();
+ response.setMessage("Fail");
+ response.setResponse("Request timedout, request id:" + requestObject.getRequestId());
+ //response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId());
+ recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime());
+ response.setMessageCode(500);
+ Response result = Response.status(500).entity(response).build();
+ requestObject.getAsynchronousResponse().setResponse(result);
+ msoLogger.debug("Sending timeout response for request id:" + requestObject.getRequestId() + ":response:" + response);
+ } catch (InterruptedException e) {
+ break;
+ } catch (Exception e) {
+ msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread");
+
+ }
+ }
+
+ msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting");
+ }
+ }
+
+ private static void recordEvents(String processKey, WorkflowResponse response,
+ long startTime) {
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ logMarker + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse());
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java index da9376ddc0..5afbded982 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -1,141 +1,141 @@ -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * 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 - * </pre> - */ -@Path("/") -public class WorkflowMessageResource { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; - - private ProcessEngineServices pes4junit = null; - - @POST - @Path("/WorkflowMessage/{messageType}/{correlator}") - @Consumes("*/*") - @Produces(MediaType.TEXT_PLAIN) - public Response deliver(@PathParam("messageType") String messageType, - @PathParam("correlator") String correlator, String message) { - - LOGGER.debug(LOGMARKER + " Received workflow message" - + " type='" + messageType + "'" - + " correlator='" + correlator + "'" - + System.lineSeparator() + message); - - MsoLogger.setServiceName("MSO." + "WorkflowMessage"); - - if (messageType == null || messageType.isEmpty()) { - String msg = "Missing message type"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.DataError, 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, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg); - return Response.status(400).entity(msg).build(); - } - - String correlatorVariable = messageType + "_CORRELATOR"; - String messageVariable = messageType + "_MESSAGE"; - - long startTime = System.currentTimeMillis(); - - try { - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - - if (!isReadyforCorrelation(runtimeService, correlatorVariable, correlator)) { - String msg = "No process is waiting to receive '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg); - return Response.status(500).entity(msg).build(); - } - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put(correlatorVariable, correlator); - variables.put(messageVariable, message); - - runtimeService.createMessageCorrelation("WorkflowMessage").setVariables(variables) - .processInstanceVariableEquals(correlatorVariable, correlator).correlate(); - - String msg = "Completed delivery of '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); - return Response.status(204).build(); - } catch (Exception e) { - // For example: MismatchingMessageCorrelationException - String msg = "Caught " + e.getClass().getSimpleName() + " processing '" + messageType + "' WorkflowMessage with " + correlatorVariable + "='" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg, e); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg); - return Response.status(500).entity(msg).build(); - } - } - - private boolean isReadyforCorrelation(RuntimeService runtimeService, - String correlationVariable, String correlationValue) - throws InterruptedException { - - long waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - int retries = 50; - while (waitingInstances == 0 && retries > 0) { - Thread.sleep(100); - - waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - retries--; - } - - return waitingInstances != 0; - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); - } else { - return pes4junit; - } - } - - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } +package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.camunda.bpm.BpmPlatform;
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RuntimeService;
+
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ * 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
+ * </pre>
+ */
+@Path("/")
+public class WorkflowMessageResource {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private static final String LOGMARKER = "[WORKFLOW-MESSAGE]";
+
+ private ProcessEngineServices pes4junit = null;
+
+ @POST
+ @Path("/WorkflowMessage/{messageType}/{correlator}")
+ @Consumes("*/*")
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response deliver(@PathParam("messageType") String messageType,
+ @PathParam("correlator") String correlator, String message) {
+
+ LOGGER.debug(LOGMARKER + " Received workflow message"
+ + " type='" + messageType + "'"
+ + " correlator='" + correlator + "'"
+ + System.lineSeparator() + message);
+
+ MsoLogger.setServiceName("MSO." + "WorkflowMessage");
+
+ if (messageType == null || messageType.isEmpty()) {
+ String msg = "Missing message type";
+ LOGGER.debug(LOGMARKER + " " + msg);
+ LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.DataError, 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, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg);
+ return Response.status(400).entity(msg).build();
+ }
+
+ String correlatorVariable = messageType + "_CORRELATOR";
+ String messageVariable = messageType + "_MESSAGE";
+
+ long startTime = System.currentTimeMillis();
+
+ try {
+ RuntimeService runtimeService = getProcessEngineServices().getRuntimeService();
+
+ if (!isReadyforCorrelation(runtimeService, correlatorVariable, correlator)) {
+ String msg = "No process is waiting to receive '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'";
+ LOGGER.debug(LOGMARKER + " " + msg);
+ LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg, "BPMN", MsoLogger.getServiceName(), messageType);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg);
+ return Response.status(500).entity(msg).build();
+ }
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put(correlatorVariable, correlator);
+ variables.put(messageVariable, message);
+
+ runtimeService.createMessageCorrelation("WorkflowMessage").setVariables(variables)
+ .processInstanceVariableEquals(correlatorVariable, correlator).correlate();
+
+ String msg = "Completed delivery of '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'";
+ LOGGER.debug(LOGMARKER + msg);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg, "BPMN", MsoLogger.getServiceName(), messageType);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg);
+ return Response.status(204).build();
+ } catch (Exception e) {
+ // For example: MismatchingMessageCorrelationException
+ String msg = "Caught " + e.getClass().getSimpleName() + " processing '" + messageType + "' WorkflowMessage with " + correlatorVariable + "='" + correlator + "'";
+ LOGGER.debug(LOGMARKER + " " + msg);
+ LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg, e);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg, "BPMN", MsoLogger.getServiceName(), messageType);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg);
+ return Response.status(500).entity(msg).build();
+ }
+ }
+
+ private boolean isReadyforCorrelation(RuntimeService runtimeService,
+ String correlationVariable, String correlationValue)
+ throws InterruptedException {
+
+ long waitingInstances = runtimeService.createExecutionQuery()
+ .messageEventSubscriptionName("WorkflowMessage")
+ .processVariableValueEquals(correlationVariable, correlationValue)
+ .count();
+
+ int retries = 50;
+ while (waitingInstances == 0 && retries > 0) {
+ Thread.sleep(100);
+
+ waitingInstances = runtimeService.createExecutionQuery()
+ .messageEventSubscriptionName("WorkflowMessage")
+ .processVariableValueEquals(correlationVariable, correlationValue)
+ .count();
+
+ retries--;
+ }
+
+ return waitingInstances != 0;
+ }
+
+ private ProcessEngineServices getProcessEngineServices() {
+ if (pes4junit == null) {
+ return BpmPlatform.getDefaultProcessEngine();
+ } else {
+ return pes4junit;
+ }
+ }
+
+ public void setProcessEngineServices4junit(ProcessEngineServices pes) {
+ pes4junit = pes;
+ }
}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java index d15bc31625..a9a9f4b12d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java @@ -1,609 +1,625 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -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; -import javax.ws.rs.PathParam; -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; -import org.camunda.bpm.engine.ProcessEngines; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.history.HistoricVariableInstance; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.variable.VariableMap; -import org.camunda.bpm.engine.variable.Variables; -import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats; -import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.slf4j.MDC; - -@Path("/workflow") -public class WorkflowResource { - - private ProcessEngineServices pes4junit = null; - - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - 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}") - @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,msoLogger); - 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) { - msoLogger.debug(LOGMARKER + processKey + " process has not been created yet"); - continue; - } - - String processInstanceId = processInstance.getId(); - workflowResponse.setProcessInstanceID(processInstanceId); - - responseMap = getResponseMap(processInstance, processKey, timeProcessEnded); - - if (responseMap == null) { - msoLogger.debug(LOGMARKER + processKey + " has not produced a response yet"); - - 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) { - msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key"); - ex.printStackTrace(); - workflowResponse.setMessage("Fail" ); - workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); - if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), - MsoLogger.ErrorCode.UnknownError, 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) { - msoLogger.debug("Invalid input for mso-service-request-timeout"); - } - } - return DEFAULT_WAIT_TIME; - } - - private void recordEvents(String processKey, WorkflowResponse response, long startTime) { - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); - } - - private void setLogContext(String processKey, Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getValueFromInputVariables(inputVariables, "mso-request-id"), - getValueFromInputVariables(inputVariables, "mso-service-instance-id")); - } - } - - 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(); - return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; - } - - 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) { - msoLogger.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 { - msoLogger.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 MsoLogger msoLogger; - private final String businessKey; - private ProcessInstance processInstance = null; - private Exception exception = null; - - public ProcessThread(Map<String, Object> inputVariables, String processKey, MsoLogger msoLogger) { - this.inputVariables = inputVariables; - this.processKey = processKey; - this.msoLogger = msoLogger; - 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 { - msoLogger.debug(LOGMARKER + "***Received MSO startProcessInstanceByKey with processKey:" - + processKey + " and variables: " + inputVariables); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER - + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with" - + " processKey:" + processKey - + " businessKey:" + businessKey - + " variables: " + inputVariables); - - 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) { - msoLogger.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) { - msoLogger.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); - msoLogger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); - - if (workflowResponse != null) { - Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<String, Object>(); - 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<String, Object>(); - 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<String, Object>(); - responseMap.put("WorkflowException", workflowExceptionText); - responseMap.put("ResponseCode", responseCode); - responseMap.put("Status", "Fail"); - return responseMap; - } - - } - msoLogger.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); - msoLogger.debug(LOGMARKER + processKey + "Response: " + response); - - if (response != null) { - object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<String, Object>(); - 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); - msoLogger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); - - if (errorResponse != null) { - object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); - String responseCode = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); - responseMap = new HashMap<String, Object>(); - 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 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) { - msoLogger.debug("Error retrieving process " + processInstanceId - + " variable " + variableName + " from history: " + e); - return null; - } - } - - @POST - @Path("/services/{processKey}/{processInstanceId}") - @Produces("application/json") - @Consumes("application/json") - 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<String,String>(); - for (HistoricVariableInstance variableInstance: variables) { - variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString()); - } - - msoLogger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + variablesMap.toString()); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER - + "Call to MSO workflow/services in Camunda. 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); - - msoLogger.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); - - msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), MsoLogger.ErrorCode.UnknownError, LOGMARKER - + response.getMessage() - + " for processKey: " - + processKey - + " with response: " - + response.getResponse()); - - } - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); - - return response; - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return ProcessEngines.getDefaultProcessEngine(); - } else { - return pes4junit; - } - } - - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.HashMap;
+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;
+import javax.ws.rs.PathParam;
+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;
+import org.camunda.bpm.engine.ProcessEngines;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.history.HistoricVariableInstance;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.camunda.bpm.engine.variable.VariableMap;
+import org.camunda.bpm.engine.variable.Variables;
+import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats;
+import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
+import org.openecomp.mso.bpmn.core.WorkflowException;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.slf4j.MDC;
+
+@Path("/workflow")
+public class WorkflowResource {
+
+ private ProcessEngineServices pes4junit = null;
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ 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}")
+ @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,msoLogger);
+ 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) {
+ msoLogger.debug(LOGMARKER + processKey + " process has not been created yet");
+ continue;
+ }
+
+ String processInstanceId = processInstance.getId();
+ workflowResponse.setProcessInstanceID(processInstanceId);
+
+ responseMap = getResponseMap(processInstance, processKey, timeProcessEnded);
+
+ if (responseMap == null) {
+ msoLogger.debug(LOGMARKER + processKey + " has not produced a response yet");
+
+ 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) {
+ msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key");
+ ex.printStackTrace();
+ workflowResponse.setMessage("Fail" );
+ workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage());
+ if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId());
+
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey),
+ MsoLogger.ErrorCode.UnknownError, 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) {
+ msoLogger.debug("Invalid input for mso-service-request-timeout");
+ }
+ }
+ return DEFAULT_WAIT_TIME;
+ }
+
+ private void recordEvents(String processKey, WorkflowResponse response, long startTime) {
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ LOGMARKER + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ LOGMARKER + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse());
+ }
+
+ private void setLogContext(String processKey, Map<String, Object> inputVariables) {
+ MsoLogger.setServiceName("MSO." + processKey);
+ if (inputVariables != null) {
+ MsoLogger.setLogContext(getValueFromInputVariables(inputVariables, "mso-request-id"),
+ getValueFromInputVariables(inputVariables, "mso-service-instance-id"));
+ }
+ }
+
+ 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();
+ return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
+ }
+
+ 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) {
+ msoLogger.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 {
+ msoLogger.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 MsoLogger msoLogger;
+ private final String businessKey;
+ private ProcessInstance processInstance = null;
+ private Exception exception = null;
+
+ public ProcessThread(Map<String, Object> inputVariables, String processKey, MsoLogger msoLogger) {
+ this.inputVariables = inputVariables;
+ this.processKey = processKey;
+ this.msoLogger = msoLogger;
+ 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 {
+ msoLogger.debug(LOGMARKER + "***Received MSO startProcessInstanceByKey with processKey:"
+ + processKey + " and variables: " + inputVariables);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER
+ + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with"
+ + " processKey:" + processKey
+ + " businessKey:" + businessKey
+ + " variables: " + inputVariables);
+
+ 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) {
+ msoLogger.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) {
+ msoLogger.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);
+ msoLogger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse);
+
+ if (workflowResponse != null) {
+ Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
+ String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject);
+ msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
+ responseMap = new HashMap<String, Object>();
+ 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<String, Object>();
+ 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<String, Object>();
+ responseMap.put("WorkflowException", workflowExceptionText);
+ responseMap.put("ResponseCode", responseCode);
+ responseMap.put("Status", "Fail");
+ return responseMap;
+ }
+
+ }
+ msoLogger.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);
+ msoLogger.debug(LOGMARKER + processKey + "Response: " + response);
+
+ if (response != null) {
+ object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
+ String responseCode = object == null ? null : String.valueOf(object);
+ msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
+ responseMap = new HashMap<String, Object>();
+ 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);
+ msoLogger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse);
+
+ if (errorResponse != null) {
+ object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
+ String responseCode = object == null ? null : String.valueOf(object);
+ msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
+ responseMap = new HashMap<String, Object>();
+ 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.
+ msoLogger.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) {
+ msoLogger.debug("Error retrieving process " + processInstanceId
+ + " variable " + variableName + " from history: " + e);
+ return null;
+ }
+ }
+
+ @POST
+ @Path("/services/{processKey}/{processInstanceId}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ 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<String,String>();
+ for (HistoricVariableInstance variableInstance: variables) {
+ variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString());
+ }
+
+ msoLogger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + variablesMap.toString());
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER
+ + "Call to MSO workflow/services in Camunda. 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);
+
+ msoLogger.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);
+
+ msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), MsoLogger.ErrorCode.UnknownError, LOGMARKER
+ + response.getMessage()
+ + " for processKey: "
+ + processKey
+ + " with response: "
+ + response.getResponse());
+
+ }
+
+ msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ LOGMARKER + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ LOGMARKER + response.getMessage() + " for processKey: "
+ + processKey + " with response: " + response.getResponse());
+
+ return response;
+ }
+
+ private ProcessEngineServices getProcessEngineServices() {
+ if (pes4junit == null) {
+ return ProcessEngines.getDefaultProcessEngine();
+ } else {
+ return pes4junit;
+ }
+ }
+
+ public void setProcessEngineServices4junit(ProcessEngineServices pes) {
+ pes4junit = pes;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java index afc7bdb128..d6c9b51cd6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java @@ -1,57 +1,57 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; - -/** - * @version 1.0 - * RESTeasy workflow application which wires synchronous and asynchronous response - * - */ -@ApplicationPath("/") -public class WorkflowResourceApplication extends Application { - private Set<Object> singletons = new HashSet<Object>(); - private Set<Class<?>> classes = new HashSet<Class<?>>(); - - public WorkflowResourceApplication() { - singletons.add(new WorkflowResource()); - singletons.add(new WorkflowAsyncCommonResource()); - singletons.add(new WorkflowMessageResource()); - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } - - @Override - public Set<Object> getSingletons() { - return singletons; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
+
+/**
+ * @version 1.0
+ * RESTeasy workflow application which wires synchronous and asynchronous response
+ *
+ */
+@ApplicationPath("/")
+public class WorkflowResourceApplication extends Application {
+ private Set<Object> singletons = new HashSet<Object>();
+ private Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public WorkflowResourceApplication() {
+ singletons.add(new WorkflowResource());
+ singletons.add(new WorkflowAsyncCommonResource());
+ singletons.add(new WorkflowMessageResource());
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java index 5da7c8fef4..79e29e6770 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java @@ -1,69 +1,69 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.Map; - -/** - * @version 1.0 - * Synchronous workflow response bean - * - */ -public class WorkflowResponse { - - private String response; - private String message; - private String processInstanceID; - private Map<String,String> variables; - private int messageCode; - - public String getResponse() { - return response; - } - public void setResponse(String response) { - this.response = response; - } - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - public String getProcessInstanceID() { - return processInstanceID; - } - public void setProcessInstanceID(String pID) { - this.processInstanceID = pID; - } - public Map<String, String> getVariables() { - return variables; - } - public void setVariables(Map<String, String> variables) { - this.variables = variables; - } - public void setMessageCode(int messageCode) { - this.messageCode = messageCode; - } - - public int getMessageCode() { - return messageCode; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.Map;
+
+/**
+ * @version 1.0
+ * Synchronous workflow response bean
+ *
+ */
+public class WorkflowResponse {
+
+ private String response;
+ private String message;
+ private String processInstanceID;
+ private Map<String,String> variables;
+ private int messageCode;
+
+ public String getResponse() {
+ return response;
+ }
+ public void setResponse(String response) {
+ this.response = response;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ public String getProcessInstanceID() {
+ return processInstanceID;
+ }
+ public void setProcessInstanceID(String pID) {
+ this.processInstanceID = pID;
+ }
+ public Map<String, String> getVariables() {
+ return variables;
+ }
+ public void setVariables(Map<String, String> variables) {
+ this.variables = variables;
+ }
+ public void setMessageCode(int messageCode) {
+ this.messageCode = messageCode;
+ }
+
+ public int getMessageCode() {
+ return messageCode;
+ }
+}
|