aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-03-14 02:07:32 -0400
committerRob Daugherty <rd472p@att.com>2018-03-14 04:08:41 -0400
commit38f720752af4d4aad8c4e467a288d9048659f688 (patch)
treee81066a8b5c77272e30fb57a64999573c4db4d86 /bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc
parentaee3d223f92a6f250f43e17558a2dfd576ff7294 (diff)
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java95
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java46
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java43
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java46
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java98
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java154
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java77
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java219
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java222
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java136
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java57
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java108
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java128
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java53
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java126
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java39
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java73
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java317
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java195
21 files changed, 2325 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java
new file mode 100644
index 0000000000..cd04fc5ef0
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.mso.client.sdnc.beans;
+
+public class SDNCRequest {
+ private String requestId;
+ private String svcInstanceId;
+ private SDNCSvcAction svcAction;
+ private SDNCSvcOperation svcOperation;
+ private String callbackUrl;
+ private String msoAction;
+ private String requestData;
+
+ public SDNCRequest(String requestId, String svcInstanceId, SDNCSvcAction svcAction, SDNCSvcOperation svcOperation,
+ String callbackUrl, String msoAction, String requestData) {
+ this.requestId = requestId;
+ this.svcInstanceId = svcInstanceId;
+ this.svcAction = svcAction;
+ this.svcOperation = svcOperation;
+ this.callbackUrl = callbackUrl;
+ this.msoAction = msoAction;
+ this.requestData = requestData;
+ }
+ public SDNCRequest(){
+
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+ public String getSvcInstanceId() {
+ return svcInstanceId;
+ }
+ public void setSvcInstanceId(String svcInstanceId) {
+ this.svcInstanceId = svcInstanceId;
+ }
+ public SDNCSvcAction getSvcAction() {
+ return svcAction;
+ }
+ public void setSvcAction(SDNCSvcAction svcAction) {
+ this.svcAction = svcAction;
+ }
+ public SDNCSvcOperation getSvcOperation() {
+ return svcOperation;
+ }
+ public void setSvcOperation(SDNCSvcOperation svcOperation) {
+ this.svcOperation = svcOperation;
+ }
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+ public String getMsoAction() {
+ return msoAction;
+ }
+ public void setMsoAction(String msoAction) {
+ this.msoAction = msoAction;
+ }
+
+ public String getRequestData() {
+ return requestData;
+ }
+ public void setRequestData(String requestData) {
+ this.requestData = requestData;
+ }
+ @Override
+ public String toString() {
+ return "SDNCRequest [requestId=" + requestId + ", svcInstanceId=" + svcInstanceId + ", svcAction=" + svcAction
+ + ", svcOperation=" + svcOperation + ", callbackUrl=" + callbackUrl + ", msoAction=" + msoAction
+ + ", requestData=" + requestData + "]";
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java
new file mode 100644
index 0000000000..91e3a59276
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.beans;
+
+public enum SDNCSvcAction {
+ ACTIVATE("activate"),
+ DELETE("delete"),
+ ASSIGN("assign"),
+ ROLLBACK("rollback"),
+ UNASSIGN("unassign"),
+ DEACTIVATE("deactivate"),
+ CHANGE_DELETE("changedelete"),
+ CHANGE_ASSIGN("changeassign"),
+ CREATE("create"),
+ ENABLE("enable"),
+ DISABLE("disable");
+
+ private final String name;
+
+ private SDNCSvcAction(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java
new file mode 100644
index 0000000000..8cf1052064
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.beans;
+
+public enum SDNCSvcOperation {
+
+ VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"),
+ NETWORK_TOPOLOGY_OPERATION("network-topology-operation"),
+ VNF_TOPOLOGY_OPERATION("vnf-topology-operation"),
+ CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"),
+ SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"),
+ PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"),
+ SERVICE_TOPOLOGY_OPERATION("service-topology-operation");
+
+ private final String name;
+
+ private SDNCSvcOperation(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java
new file mode 100644
index 0000000000..3e714e901d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.mapper;
+
+import java.util.Optional;
+
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
+import org.openecomp.mso.client.sdnc.beans.SDNCRequest;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation;
+
+public abstract class SDNCRequestMapper {
+
+ protected final Optional<String> msoAction;
+ protected final SDNCSvcOperation svcOperation;
+ protected final SDNCSvcAction svcAction;
+ protected final String requestAction;
+
+ public SDNCRequestMapper (Optional<String> msoAction, SDNCSvcOperation svcOperation,
+ SDNCSvcAction svcAction, String requestAction) {
+ this.msoAction = msoAction;
+ this.svcOperation = svcOperation;
+ this.svcAction = svcAction;
+ this.requestAction = requestAction;
+ }
+
+ public abstract SDNCRequest reqMapper (ServiceDecomposition serviceDecomp);
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java
new file mode 100644
index 0000000000..b87ed00650
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.mapper;
+
+import java.io.StringWriter;
+import java.util.Optional;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
+import org.openecomp.mso.client.sdnc.beans.SDNCRequest;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation;
+
+import openecomp.org.mso.workflow.schema.v1.EcompModelInformation;
+import openecomp.org.mso.workflow.schema.v1.RequestInformation;
+import openecomp.org.mso.workflow.schema.v1.SDNCServiceInstanceRequestData;
+import openecomp.org.mso.workflow.schema.v1.ServiceInformation;
+import openecomp.org.mso.workflow.schema.v1.ServiceRequestInput;
+
+public class ServiceTopologyOperationRequestMapper extends SDNCRequestMapper{
+
+ public ServiceTopologyOperationRequestMapper(Optional<String> msoAction, SDNCSvcOperation svcOperation,
+ SDNCSvcAction svcAction, String requestAction) {
+ super(msoAction, svcOperation, svcAction, requestAction);
+ }
+
+ @Override
+ public SDNCRequest reqMapper (ServiceDecomposition serviceDecomp) {
+ SDNCRequest req = new SDNCRequest();
+ req.setCallbackUrl(serviceDecomp.getCallbackURN());
+ if(msoAction.isPresent()){
+ req.setMsoAction(msoAction.get());
+ }
+ req.setRequestId(serviceDecomp.getRequest().getSdncRequestId());
+ req.setSvcInstanceId(serviceDecomp.getServiceInstance().getInstanceId());
+ req.setSvcAction(svcAction);
+ req.setSvcOperation(svcOperation);
+ String reqData ="";
+
+ RequestInformation reqInfo = new RequestInformation();
+ reqInfo.setRequestAction(requestAction);
+ reqInfo.setSource("MSO");
+ reqInfo.setRequestId(serviceDecomp.getRequest().getRequestId());
+ ServiceInformation servInfo = new ServiceInformation();
+ EcompModelInformation emi = new EcompModelInformation();
+ emi.setModelInvariantUuid(serviceDecomp.getRequest().getModelInfo().getModelInvariantUuid());
+ emi.setModelName(serviceDecomp.getRequest().getModelInfo().getModelName());
+ emi.setModelVersion(serviceDecomp.getRequest().getModelInfo().getModelVersion() );
+ servInfo.setEcompModelInformation(emi);
+ servInfo.setServiceId(serviceDecomp.getServiceInstance().getServiceId());
+ servInfo.setSubscriptionServiceType(serviceDecomp.getCustomer().getSubscriptionServiceType());
+ servInfo.setServiceInstanceId(serviceDecomp.getServiceInstance().getInstanceName());
+ servInfo.setGlobalCustomerId(serviceDecomp.getCustomer().getGlobalSubscriberId());
+ ServiceRequestInput servReqInput = new ServiceRequestInput();
+ servReqInput.setServiceInstanceName(serviceDecomp.getServiceInstance().getInstanceName());
+ SDNCServiceInstanceRequestData sdncSIRD = new SDNCServiceInstanceRequestData();
+ sdncSIRD.setRequestInformation(reqInfo);
+ sdncSIRD.setServiceInformation(servInfo);
+ sdncSIRD.setServiceRequestInput(servReqInput);
+
+ try {
+ JAXBContext context = JAXBContext.newInstance(SDNCServiceInstanceRequestData.class);
+
+ Marshaller jaxbMarshaller = context.createMarshaller();
+ jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ StringWriter sw = new StringWriter();
+ jaxbMarshaller.marshal(sdncSIRD, sw);
+ reqData = sw.toString();
+ req.setRequestData(reqData);
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+
+ return req;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java
new file mode 100644
index 0000000000..2ddafc1c17
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="ResponseCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="ResponseMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+//SDNCAdapter to BPEL Async response header
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "requestId",
+ "responseCode",
+ "responseMessage"
+})
+@XmlRootElement(name = "CallbackHeader")
+public class CallbackHeader {
+
+ @XmlElement(name = "RequestId", required = true)
+ protected String requestId;
+ @XmlElement(name = "ResponseCode", required = true)
+ protected String responseCode;
+ @XmlElement(name = "ResponseMessage", required = true)
+ protected String responseMessage;
+
+ public CallbackHeader() {
+ }
+
+ public CallbackHeader(String reqId, String respCode, String respMsg) {
+ this.requestId = reqId;
+ this.responseCode = respCode;
+ this.responseMessage = respMsg;
+ }
+
+ /**
+ * 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 responseCode property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResponseCode() {
+ return responseCode;
+ }
+
+ /**
+ * Sets the value of the responseCode property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResponseCode(String value) {
+ this.responseCode = value;
+ }
+
+ /**
+ * Gets the value of the responseMessage property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResponseMessage() {
+ return responseMessage;
+ }
+
+ /**
+ * Sets the value of the responseMessage property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResponseMessage(String value) {
+ this.responseMessage = value;
+ }
+
+ @Override
+ public String toString() {
+ return "CallbackHeader [requestId=" + requestId + ", responseCode="
+ + responseCode + ", responseMessage=" + responseMessage + "]";
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java
new file mode 100644
index 0000000000..331fefa677
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+public interface Constants {
+
+ public static final String BPEL_REST_URL_PROP = "org.openecomp.mso.adapters.sdnc.rest.bpelurl";
+ public static final String BPEL_URL_PROP = "org.openecomp.mso.adapters.sdnc.bpelurl";
+ public static final String DEFAULT_BPEL_URL = "http://localhost:8080//active-bpel/services/SDNCAdapterCallbackV1";
+
+ public static final String MY_URL_PROP = "org.openecomp.mso.adapters.sdnc.myurl";
+ public static final String DEFAULT_MY_URL = "https://localhost:8443/adapters/rest/SDNCNotify";
+
+ public static final String SDNC_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.sdncauth";
+ public static final String DEFAULT_SDNC_AUTH = "406B2AE613211B6FB52466DE6E1769AC";
+
+ public static final String DEFAULT_BPEL_AUTH = "05FDA034C27D1CA51AAB8FAE512EDE45241E16FC8C137D292AA3A964431C82DB";
+ public static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.bpelauth";
+
+
+ public static final String SDNC_SVCCFGRESP_ROOT = "input";
+ public static final String SDNC_REQ_ID = "/svc-request-id";
+ public static final String SDNC_RESP_CODE = "/response-code";
+ public static final String SDNC_RESP_MSG = "/response-message";
+ public static final String SDNC_CONNECTTIME_PROP = "org.openecomp.mso.adapters.sdnc.sdncconnecttime";
+ public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
+
+ public static final String REQUEST_TUNABLES = "org.openecomp.mso.adapters.sdnc";
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java
new file mode 100644
index 0000000000..3ddfdb2925
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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.mso.adapters.sdnc 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.mso.adapters.sdnc
+ *
+ */
+ 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 SDNCAdapterRequest }
+ *
+ */
+ public SDNCAdapterRequest createSDNCAdapterRequest() {
+ return new SDNCAdapterRequest();
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java
new file mode 100644
index 0000000000..dee79898fa
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java
@@ -0,0 +1,219 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+//BPEL to SDNCAdapter request header
+@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;
+ }
+
+ public String getSvcInstanceId() {
+ return svcInstanceId;
+ }
+
+ public void setSvcInstanceId(String svcInstanceId) {
+ this.svcInstanceId = svcInstanceId;
+ }
+
+ /**
+ * 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 callbackUrl property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMsoAction() {
+ return msoAction;
+ }
+
+ /**
+ * Sets the value of the callbackUrl property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMsoAction(String value) {
+ this.msoAction = value;
+ }
+
+
+ @Override
+ public String toString() {
+ return "RequestHeader [requestId=" + requestId +
+ ", svcInstanceId=" + svcInstanceId +
+ ", svcAction=" + svcAction +
+ ", svcOperation=" + svcOperation +
+ ", callbackUrl=" + callbackUrl +
+ ", msoAction=" + msoAction + "]";
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java
new file mode 100644
index 0000000000..55d42df6e1
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+import org.openecomp.mso.logger.MessageEnum;
+public class RequestTunables {
+
+ private MsoPropertiesFactory msoPropertiesFactory;
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER";
+
+ //criteria
+ private String reqId = "";
+ private String msoAction = "";
+ private String operation = "";
+ private String action = "";
+
+ //tunables
+ private String reqMethod = "POST";
+ private String sdncUrl = null;
+ private String timeout = "60000";
+ private String headerName = "sdnc-request-header";
+ private String namespace = "";
+ private String asyncInd = "N"; //future use
+
+ private String sdncaNotificationUrl = null;
+
+ public RequestTunables(String reqId, String msoAction, String operation, String action, MsoPropertiesFactory msoPropFactory) {
+ super();
+ msoPropertiesFactory = msoPropFactory;
+ if (reqId != null) {
+ this.reqId = reqId;
+ }
+ if (msoAction != null) {
+ this.msoAction = msoAction;
+ }
+ if (operation != null) {
+ this.operation = operation;
+ }
+ if (action != null) {
+ this.action = action;
+ }
+ }
+
+ public String getReqId() {
+ return reqId;
+ }
+ public void setReqId(String reqId) {
+ this.reqId = reqId;
+ }
+ public String getReqMethod() {
+ return reqMethod;
+ }
+ public void setReqMethod(String reqMethod) {
+ this.reqMethod = reqMethod;
+ }
+ public String getMsoAction() {
+ return msoAction;
+ }
+ public void setMsoAction(String msoAction) {
+ this.msoAction = msoAction;
+ }
+ public String getAction() {
+ return action;
+ }
+ public void setAction(String action) {
+ this.action = action;
+ }
+ public String getOperation() {
+ return operation;
+ }
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+ public String getSdncUrl() {
+ return sdncUrl;
+ }
+ public void setSdncUrl(String sdncUrl) {
+ this.sdncUrl = sdncUrl;
+ }
+ public String getTimeout() {
+ return timeout;
+ }
+ public void setTimeout(String timeout) {
+ this.timeout = timeout;
+ }
+ public String getAsyncInd() {
+ return asyncInd;
+ }
+ public void setAsyncInd(String asyncInd) {
+ this.asyncInd = asyncInd;
+ }
+ public String getHeaderName() {
+ return headerName;
+ }
+ public void setHeaderName(String headerName) {
+ this.headerName = headerName;
+ }
+
+
+ public String getSdncaNotificationUrl() {
+ return sdncaNotificationUrl;
+ }
+
+ public void setSdncaNotificationUrl(String sdncaNotificationUrl) {
+ this.sdncaNotificationUrl = sdncaNotificationUrl;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ @Override
+ public String toString() {
+ return "RequestTunables [reqId=" + reqId + ", msoAction=" + msoAction
+ + ", operation=" + operation + ", action=" + action
+ + ", reqMethod=" + reqMethod + ", sdncUrl=" + sdncUrl
+ + ", timeout=" + timeout + ", headerName=" + headerName
+ + ", sdncaNotificationUrl=" + sdncaNotificationUrl
+ + ", namespace=" + namespace + "]";
+ }
+
+ public void setTunables()
+ {
+ String error = null;
+ String key = null;
+ if ("query".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + ".." + action;
+ msoLogger.debug("Generated key: " + key);
+ }
+ else if ("put".equals(action) || "restdelete".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
+ key = Constants.REQUEST_TUNABLES + "..." + action;
+ msoLogger.debug("Generated key: " + key);
+ } else {
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + "." + operation +"." + action;
+ msoLogger.debug("Generated key: " + key);
+ }
+
+ String value;
+ try {
+ value = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, "");
+ } catch (MsoPropertiesException e) {
+ msoLogger.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e);
+ value="";
+ }
+
+ if (value != null && value.length() > 0) {
+
+ String[] parts = value.split("\\|"); //escape pipe
+ if (parts.length < 3) {
+ msoLogger.warn(MessageEnum.RA_SDNC_INVALID_CONFIG, key, value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config");
+ }
+
+ for (int i = 0; i < parts.length; i++) {
+ if (i == 0) {
+ reqMethod = parts[i];
+ msoLogger.debug("Request Method is set to: " + reqMethod);
+ } else if (i == 1) {
+ timeout = parts[i];
+ msoLogger.debug("Timeout is set to: " + timeout);
+ } else if (i == 2) {
+ sdncUrl = SDNCAdapterPortTypeImpl.getProperty(Constants.REQUEST_TUNABLES + "." + parts[i], "",msoPropertiesFactory);
+ if (operation != null && sdncUrl != null) {
+ sdncUrl = sdncUrl + operation;
+ }
+ msoLogger.debug("SDNC Url is set to: " + sdncUrl);
+ } else if (i == 3) {
+ headerName = parts[i];
+ msoLogger.debug("HeaderName is set to: " + headerName);
+ } else if (i == 4) {
+ namespace = parts[i];
+ msoLogger.debug("NameSpace is set to: " + namespace);
+ } else if (i == 5) {
+ asyncInd = parts[i];
+ msoLogger.debug("AsyncInd is set to: " + asyncInd);
+ }
+ }
+ if (sdncUrl == null) {
+ error = "Invalid configuration, sdncUrl required for:" + key + " value:" + value;
+ }
+ } else {
+ error = "Missing configuration for:" + key;
+ }
+ if (error != null) {
+ msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, key, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param");
+ alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
+ }
+ msoLogger.debug ("RequestTunables Key:" + key + " Value:" + value + " Tunables:" + this.toString());
+ return;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java
new file mode 100644
index 0000000000..6e9d6757ad
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import java.io.StringWriter;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.logger.MessageEnum;
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}CallbackHeader"/>
+ * &lt;element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+//SDNCAdapter to BPEL Async response
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "callbackHeader",
+ "requestData"
+})
+@XmlRootElement(name = "SDNCAdapterCallbackRequest")
+public class SDNCAdapterCallbackRequest {
+
+ @XmlElement(name = "CallbackHeader", required = true)
+ protected CallbackHeader callbackHeader;
+ @XmlElement(name = "RequestData")
+ protected Object requestData;
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ /**
+ * Gets the value of the callbackHeader property.
+ *
+ * @return
+ * possible object is
+ * {@link CallbackHeader }
+ *
+ */
+ public CallbackHeader getCallbackHeader() {
+ return callbackHeader;
+ }
+
+ /**
+ * Sets the value of the callbackHeader property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CallbackHeader }
+ *
+ */
+ public void setCallbackHeader(CallbackHeader value) {
+ this.callbackHeader = value;
+ }
+
+ /**
+ * Gets the value of the requestData property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ *
+ */
+ public Object getRequestData() {
+ return requestData;
+ }
+
+ /**
+ * Sets the value of the requestData property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ *
+ */
+ public void setRequestData(Object value) {
+ this.requestData = value;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ JAXBContext ctx = JAXBContext.newInstance("org.openecomp.mso.adapters.sdnc.client");
+ Marshaller m = ctx.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ StringWriter w = new StringWriter();
+ m.marshal(this, w);
+ return (w.toString());
+ }
+ catch (Exception e)
+ {
+ msoLogger.error(MessageEnum.RA_MARSHING_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception - MARSHING_ERROR", e);
+ }
+ return("");
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java
new file mode 100644
index 0000000000..8b56932769
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+import org.openecomp.mso.client.sdnc.beans.SDNCRequest;
+
+
+/**
+ * This class was generated by Apache CXF 2.7.11.redhat-3
+ * 2015-01-27T18:25:50.914-05:00
+ * Generated source version: 2.7.11.redhat-3
+ *
+ */
+//BPEL SDNCAdapter SOAP WebService - impl class in impl pkg
+@WebService(targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/wsdl/v1", name = "SDNCAdapterPortType")
+@XmlSeeAlso({ObjectFactory.class})
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface SDNCAdapterPortType {
+
+ @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterResponse")
+ @WebMethod(operationName = "SDNCAdapter")
+ public SDNCAdapterResponse sdncAdapter(
+ @WebParam(partName = "SDNCAdapterRequest", name = "SDNCAdapterRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1")
+ SDNCAdapterRequest sdncAdapterRequest
+ );
+
+ @WebMethod
+ public void healthCheck();
+
+ SDNCAdapterResponse sdncAdapter(SDNCRequest bpelRequest);
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java
new file mode 100644
index 0000000000..3d9aab666a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+import javax.annotation.PostConstruct;
+import javax.jws.WebService;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openecomp.mso.client.sdnc.beans.SDNCRequest;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+//BPEL SDNCAdapter SOAP Web Service implementation
+@WebService(serviceName = "SDNCAdapterService", endpointInterface = "org.openecomp.mso.client.sdnc.sync.SDNCAdapterPortType", targetNamespace = "http://org.openecomp/workflow/sdnc/ad")
+public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType {
+
+ private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ private static final String LOG_SERVICE_NAME = "MSO-BPMN:MSO-SDNCAdapter.";
+ private static final String LOG_REPLY_NAME = "MSO-SDNCAdapter:MSO-BPMN.";
+ public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER";
+
+ @PostConstruct
+ public void init () {
+ msoLogger.info(MessageEnum.RA_INIT_SDNC_ADAPTER, "SDNC", "SDNCAdapterPortType");
+ }
+
+ /**
+ * Health Check web method. Does nothing but return to show the adapter is deployed.
+ */
+ @Override
+ public void healthCheck ()
+ {
+ msoLogger.debug("Health check call in SDNC Adapter");
+ }
+
+ public static String getProperty(String key, String defaultValue, MsoPropertiesFactory msoPropertiesFactoryp) {
+ String value;
+ try {
+ value = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, defaultValue);
+ } catch (MsoPropertiesException e) {
+ msoLogger.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e);
+ return null;
+ }
+ msoLogger.debug("Config read for " + MSO_PROP_SDNC_ADAPTER + " - key:" + key + " value:" + value);
+ return value;
+ }
+
+ @Override
+ public SDNCAdapterResponse sdncAdapter(SDNCRequest bpelRequest) {
+ String bpelReqId = bpelRequest.getRequestId();
+ String callbackUrl = bpelRequest.getCallbackUrl();
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getSvcInstanceId());
+ MsoLogger.setServiceName (bpelRequest.getSvcAction().toString());
+ msoLogger.info(MessageEnum.RA_RECEIVE_BPEL_REQUEST, bpelReqId, callbackUrl, "SDNC", "");
+
+ SDNCSyncRpcClient sdncClient = new SDNCSyncRpcClient(bpelRequest,msoPropertiesFactory);
+ long subStartTime = System.currentTimeMillis ();
+ try {
+ Thread sdncClientThread = new Thread(sdncClient);
+ sdncClientThread.start();
+ }
+ catch (Exception e){
+ String respMsg = "Error sending request to SDNC. Failed to start SDNC Client thread " + e.getMessage();
+ msoLogger.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception sending request to SDNC. Failed to start SDNC Client thread", e);
+ alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg);
+ SDNCResponse sdncResp = new SDNCResponse(bpelReqId);
+ sdncResp.setRespCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ sdncResp.setRespMsg(respMsg);
+ }
+
+ msoLogger.debug("Sending synchronous response to BPEL");
+ SDNCAdapterResponse wsResp = new SDNCAdapterResponse();
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return (wsResp);
+ }
+
+ @Override
+ public org.openecomp.mso.client.sdnc.sync.SDNCAdapterResponse sdncAdapter(
+ org.openecomp.mso.client.sdnc.sync.SDNCAdapterRequest sdncAdapterRequest) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java
new file mode 100644
index 0000000000..5beedb12be
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}RequestHeader"/>
+ * &lt;element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+//BPEL to SDNCAdapter request
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "requestHeader",
+ "requestData"
+})
+@XmlRootElement(name = "SDNCAdapterRequest")
+public class SDNCAdapterRequest {
+
+ @XmlElement(name = "RequestHeader", required = true)
+ protected RequestHeader requestHeader;
+ @XmlElement(name = "RequestData", required = true)
+ protected Object requestData;
+
+ /**
+ * Gets the value of the requestHeader property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestHeader }
+ *
+ */
+ public RequestHeader getRequestHeader() {
+ return requestHeader;
+ }
+
+ /**
+ * Sets the value of the requestHeader property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestHeader }
+ *
+ */
+ public void setRequestHeader(RequestHeader value) {
+ this.requestHeader = value;
+ }
+
+ /**
+ * Gets the value of the requestData property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ *
+ */
+ public Object getRequestData() {
+ return requestData;
+ }
+
+ /**
+ * Sets the value of the requestData property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ *
+ */
+ public void setRequestData(Object value) {
+ this.requestData = value;
+ }
+
+ @Override
+ public String toString() {
+
+ String rd = "";
+ if (requestData != null)
+ {
+ Node node = (Node) requestData;
+ Document doc = node.getOwnerDocument();
+ rd = Utils.domToStr(doc);
+ }
+ return "SDNCAdapterRequest [requestHeader=" + requestHeader.toString()
+ + ", requestData=" + rd + "]";
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java
new file mode 100644
index 0000000000..4625bfb74f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+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>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+//SDNCAdapter to BPEL Sync Response(ACK) - async response(s) follow
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "")
+@XmlRootElement(name = "SDNCAdapterResponse")
+public class SDNCAdapterResponse {
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java
new file mode 100644
index 0000000000..08d3bdbad7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+
+
+//SDNCAdapter to BPEL Async response WEB Service
+@WebService(targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", name = "SDNCCallbackAdapterPortType")
+@XmlSeeAlso({ObjectFactory.class})
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface SDNCCallbackAdapterPortType {
+
+ @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse")
+ @WebMethod(operationName = "SDNCAdapterCallback")
+ public SDNCAdapterResponse sdncAdapterCallback(
+ @WebParam(partName = "SDNCAdapterCallbackRequest", name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1")
+ SDNCAdapterCallbackRequest sdncAdapterCallbackRequest
+ );
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java
new file mode 100644
index 0000000000..0e65a3080f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceFeature;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ * This class was generated by Apache CXF 2.7.11.redhat-3
+ * 2015-01-28T11:07:02.074-05:00
+ * Generated source version: 2.7.11.redhat-3
+ *
+ */
+//SDNCAdapter to BPEL Async response WEB Service
+@WebServiceClient(name = "SDNCCallbackAdapterService",
+ wsdlLocation = "main/resources/SDNCCallbackAdapter.wsdl",
+ targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1")
+public class SDNCCallbackAdapterService extends Service {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ public final static URL WSDL_LOCATION;
+ public final static QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService");
+ public final static QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort");
+ static {
+ URL wsdlUrl = null;
+ try {
+ wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl");
+ //wsdlUrl = SDNCCallbackAdapterService.class.getClassLoader().getResource("SDNCCallbackAdapter.wsdl");
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e);
+ }
+ if(wsdlUrl == null) {
+ msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found");
+ } else {
+ try {
+ msoLogger.info(MessageEnum.RA_PRINT_URL, "SDNCCallbackAdapter.wsdl", wsdlUrl.toURI().toString(), "SDNC", "");
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e);
+ }
+ }
+ WSDL_LOCATION = wsdlUrl;
+ }
+
+ public SDNCCallbackAdapterService(URL wsdlLocation) {
+ super(wsdlLocation, SERVICE);
+ }
+
+ public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public SDNCCallbackAdapterService() {
+ super(WSDL_LOCATION, SERVICE);
+ }
+
+ //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
+ //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
+ //compliant code instead.
+ public SDNCCallbackAdapterService(WebServiceFeature ... features) {
+ super(WSDL_LOCATION, SERVICE, features);
+ }
+
+ //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
+ //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
+ //compliant code instead.
+ public SDNCCallbackAdapterService(URL wsdlLocation, WebServiceFeature ... features) {
+ super(wsdlLocation, SERVICE, features);
+ }
+
+ //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
+ //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
+ //compliant code instead.
+ public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
+ super(wsdlLocation, serviceName, features);
+ }
+
+ /**
+ *
+ * @return
+ * returns SDNCCallbackAdapterPortType
+ */
+ @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort")
+ public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort() {
+ return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class);
+ }
+
+ /**
+ *
+ * @param features
+ * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
+ * @return
+ * returns SDNCCallbackAdapterPortType
+ */
+ @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort")
+ public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort(WebServiceFeature... features) {
+ return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class, features);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java
new file mode 100644
index 0000000000..d905748591
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+public class SDNCRequestIdUtil {
+ // Add private constructor to prevent instance creation.
+ private SDNCRequestIdUtil () {}
+
+ public static String getSDNCOriginalRequestId (String newRequestId) {
+
+ // Camunda scripts will add postfix, such as -1, -2, on the original requestID, to make sure requestID is unique while sending request to SDNC
+ // In order to use the unique requestID in logging, need to remove the postfix added by the Camunda scripts
+ // Verify whether the requestId is a valid UUID with postfix (-1, -2). If yes, it should contain 5 times char '-', since valid UUID contains 4 times '-'
+ // If the requestId is not a valid UUID with postfix, we do nothing
+ if (newRequestId.split("-").length == 6) {
+ return newRequestId.substring(0, newRequestId.lastIndexOf('-'));
+ }
+ return newRequestId;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java
new file mode 100644
index 0000000000..850f5b4734
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import java.io.Serializable;
+
+public class SDNCResponse implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String reqId = null;
+ private int respCode = 0;
+ private String respMsg = null;
+ private String sdncResp = null;
+
+ public SDNCResponse(String reqId) {
+ this.reqId = reqId;
+ }
+ public SDNCResponse(String reqId, int respCode, String respMsg) {
+ this.reqId = reqId;
+ this.respCode = respCode;
+ this.respMsg = respMsg;
+ }
+
+ public String getReqId() {
+ return reqId;
+ }
+ public void setReqId(String reqId) {
+ this.reqId = reqId;
+ }
+ public int getRespCode() {
+ return respCode;
+ }
+ public void setRespCode(int respCode) {
+ this.respCode = respCode;
+ }
+ public String getRespMsg() {
+ return respMsg;
+ }
+ public void setRespMsg(String respMsg) {
+ this.respMsg = respMsg;
+ }
+ public String getSdncResp() {
+ return sdncResp;
+ }
+ public void setSdncResp(String sdncResp) {
+ this.sdncResp = sdncResp;
+ }
+
+ @Override
+ public String toString() {
+ return "SDNCResponse [reqId=" + reqId + ", respCode=" + respCode
+ + ", respMsg=" + respMsg + ", sdncResp=" + sdncResp + "]";
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java
new file mode 100644
index 0000000000..ce9b706760
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java
@@ -0,0 +1,317 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.DatatypeConverter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.openecomp.mso.client.sdnc.beans.SDNCRequest;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction;
+import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+//SDNCAdapter to SDNC Rest Client
+public class SDNCSyncRpcClient implements Runnable {
+
+ private MsoPropertiesFactory msoPropertiesFactory;
+
+ private SDNCRequest bpelRequest;
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER";
+
+
+ public SDNCSyncRpcClient(SDNCRequest bpelRequest,MsoPropertiesFactory msoPropFactory) {
+ this.bpelRequest = bpelRequest;
+ msoPropertiesFactory = msoPropFactory;
+ }
+
+ @Override
+ public void run()
+ {
+ String action = bpelRequest.getSvcAction().toString();
+ String operation = bpelRequest.getSvcOperation().toString();
+ String bpelReqId = bpelRequest.getRequestId();
+ String msoAction = bpelRequest.getMsoAction();
+ MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getSvcInstanceId());
+ MsoLogger.setServiceName("SDNCRestClient");
+ String sdncReqBody = "";
+
+ msoLogger.debug("BPEL Request:" + bpelRequest.toString());
+ RequestTunables rt = new RequestTunables(bpelReqId, msoAction, operation, action, msoPropertiesFactory);
+ rt.setTunables();
+ rt.setSdncaNotificationUrl(SDNCAdapterPortTypeImpl.getProperty(Constants.MY_URL_PROP, Constants.DEFAULT_MY_URL,msoPropertiesFactory));
+
+ if ("POST".equals(rt.getReqMethod())) {
+ try {
+ DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ InputSource is = new InputSource();
+ is.setCharacterStream(new StringReader(bpelRequest.getRequestData()));
+ Document reqDoc = db.parse(is);
+ sdncReqBody = Utils.genSdncReq(reqDoc, rt);
+ }catch(Exception ex) {
+ throw new IllegalStateException();
+ }
+ } else if("PUT".equals(rt.getReqMethod())) {
+ try {
+ DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ InputSource is = new InputSource();
+ is.setCharacterStream(new StringReader(bpelRequest.getRequestData()));
+ Document reqDoc = db.parse(is);
+ sdncReqBody = Utils.genSdncPutReq(reqDoc, rt);
+ }catch(Exception ex) {
+ throw new IllegalStateException();
+ }
+ }
+ long sdncStartTime = System.currentTimeMillis();
+ SDNCResponse sdncResp = getSdncResp(sdncReqBody, rt, msoPropertiesFactory);
+ msoLogger.recordMetricEvent (sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from SDNC", "SDNC", action + "." + operation, null);
+ msoLogger.debug ("Got the SDNC Code : " + sdncResp.getRespCode());
+ msoLogger.debug ("Got the SDNC Response Message:" + sdncResp.getRespMsg());
+ validateSDNCResponse(sdncResp.getSdncResp());
+ return;
+ }
+
+ public static SDNCResponse getSdncResp(String sdncReqBody, RequestTunables rt, MsoPropertiesFactory msoPropertiesFactoryp) {
+ URL url;
+ HttpURLConnection con = null;
+ DataOutputStream out = null;
+ BufferedReader in = null;
+ SDNCResponse sdncResp = new SDNCResponse(rt.getReqId());
+ StringBuffer response = new StringBuffer();
+
+ msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", "");
+ msoLogger.debug("SDNC Request Body:\n" + sdncReqBody);
+
+ try {
+ msoLogger.debug("url is: " + rt.getSdncUrl());
+ url = new URL(rt.getSdncUrl());
+ con = (HttpURLConnection) url.openConnection();
+ con.setConnectTimeout(Integer.parseInt(SDNCAdapterPortTypeImpl.getProperty(Constants.SDNC_CONNECTTIME_PROP, "2000",msoPropertiesFactoryp)));
+ con.setReadTimeout(Integer.parseInt(rt.getTimeout()));
+ con.setRequestProperty("Accept", "application/json");
+ String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.SDNC_AUTH_PROP, Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY);
+
+ String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes());
+ con.setRequestProperty ("Authorization", basicAuth);
+ con.setRequestMethod(rt.getReqMethod());
+
+ if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) {
+ con.setRequestProperty("Content-type", "application/json");
+ con.setRequestProperty("Content-length",String.valueOf(sdncReqBody.length()));
+ con.setDoOutput(true);
+ out = new DataOutputStream(con.getOutputStream());
+ out.writeBytes(sdncReqBody);
+ out.flush();
+ out.close();
+ }
+
+ //Get response
+ sdncResp.setRespCode(con.getResponseCode());
+ sdncResp.setRespMsg(con.getResponseMessage());
+
+ if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) {
+ in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+ String inputLine;
+ //Not parsing the response -it contains a responseHdr section and data section
+ while ((inputLine = in.readLine()) != null) {
+ response.append(inputLine);
+ }
+ in.close();
+ }
+
+ sdncResp.setSdncResp(response.toString());
+ msoLogger.info(MessageEnum.RA_RESPONSE_FROM_SDNC, sdncResp.toString(), "SDNC", "");
+ return(sdncResp);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception processing request to SDNC", e);
+ //default
+ sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
+ String respMsg = "Error processing request to SDNC. ";
+ String sdncErrMsg = null;
+
+ if (e instanceof java.net.SocketTimeoutException ) {
+ sdncResp.setRespCode(HttpURLConnection.HTTP_CLIENT_TIMEOUT);
+ respMsg = "Request to SDNC timed out. ";
+ }
+ if (con != null) {
+ try { //e1
+ if (con.getResponseCode() != HttpURLConnection.HTTP_OK) //seen in SocketException connection reset
+ sdncResp.setRespCode(con.getResponseCode());
+ respMsg = respMsg + con.getResponseMessage() + ". ";
+ InputStream is = con.getErrorStream();
+ if (is != null) {
+ XPathFactory xpathFactory = XPathFactory.newInstance();
+ XPath xpath = xpathFactory.newXPath();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ DocumentBuilder db;
+ Document doc = null;
+ try { //e2
+ db = dbf.newDocumentBuilder();
+ doc = db.parse(is);
+ NodeList errors = (NodeList)xpath.evaluate("errors/error", doc, XPathConstants.NODESET);
+ for (int i = 0; i < errors.getLength(); i++) {
+ Element error = (Element) errors.item(i);
+ String eType = null;
+ try {
+ eType = xpath.evaluate("error-type", error);
+ sdncErrMsg = ". SDNC Returned-[error-type:" + eType;
+ } catch (Exception e3) {
+ msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
+ }
+
+ String eTag = null;
+ try {
+ eTag = xpath.evaluate( "error-tag", error);
+ sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag;
+ } catch (Exception e3) {
+ msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
+ }
+
+ String eMsg = null;
+ try {
+ eMsg = xpath.evaluate("error-message", error);
+ sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]";
+ } catch (Exception e3) {
+ msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
+ }
+ }
+ } catch (Exception e2) {
+ msoLogger.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while analyse error", e2);
+ }
+ } //is != null
+ } catch (Exception e1) {
+ msoLogger.error (MessageEnum.RA_ERROR_GET_RESPONSE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while get SDNC response", e1);
+ }
+ } //con != null
+
+ if (e.getMessage() != null) {
+ respMsg = respMsg + e.getMessage();
+ }
+ if (sdncErrMsg != null) {
+ respMsg = respMsg + sdncErrMsg;
+ }
+
+ sdncResp.setRespMsg(respMsg);
+
+ msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e);
+ alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg);
+ return(sdncResp);
+ }
+ finally {
+ if (con != null) {
+ con.disconnect();
+ }
+ }
+ }
+ public void validateSDNCResponse (String sdncResponse){
+ String msg;
+ msoLogger.debug ("Starting validate sdnc response");
+ String responseMessage = "";
+ String responseCode = "";
+ if (sdncResponse != null || !sdncResponse.equals("")){
+ try{
+ msoLogger.debug ("Got the SDNC Response: " + sdncResponse);
+ JSONObject jsonObj = new JSONObject(sdncResponse);
+ msoLogger.debug ("jsonObj has been created");
+
+ JSONObject requestData = jsonObj.getJSONObject("v1:RequestData");
+ JSONObject output = requestData.getJSONObject("output");
+ try{
+ responseMessage = output.getString("response-message");
+ responseCode = output.getString("response-code");
+ } catch (Exception ex) {
+ msoLogger.debug("Response not in lower hyphen");
+ }
+ if(responseMessage.equals("")&&responseCode.equals("")){
+ try{
+ responseMessage = output.getString("ResponseMessage");
+ responseCode = output.getString("ResponseCode");
+ } catch (Exception ex) {
+ msoLogger.debug("Response does not exist");
+ }
+ }
+ msoLogger.debug("ResponseMessage is: " + responseMessage);
+ msoLogger.debug("Response Code is: " + responseCode);
+ if(responseMessage.equals("")){
+ msg = "Error from SDNC: Response Message is empty.";
+ msoLogger.debug(msg);
+ throw new IllegalStateException(msg);
+ }
+
+ if(responseCode.equals("")){
+ responseCode = "0";
+ }
+
+ int code = Integer.parseInt(responseCode);
+ if(code >=200 && code <=299 || code ==0){
+ msoLogger.debug ("Successful Response from SDNC");
+
+ } else {
+ msg = "Error from SDNC: Code is not 200-299 or 0.";
+ msoLogger.debug(msg);
+ throw new IllegalStateException(msg);
+ }
+ } catch (Exception ex) {
+ msg = "Validate SDNC Response has failed.";
+ msoLogger.debug(msg);
+ throw new IllegalStateException(msg);
+ }
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java
new file mode 100644
index 0000000000..7457b59390
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java
@@ -0,0 +1,195 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdnc.sync;
+
+
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.logger.MessageEnum;
+public class Utils {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ public static String genSdncReq(Document reqDoc, RequestTunables rt) {
+ try {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ //NewDoc for output
+ //Root
+ Document newdoc = db.newDocument();
+ Element root = newdoc.createElementNS(rt.getNamespace(), "input");
+ newdoc.appendChild(root);
+
+ //Header
+ Element hdr = newdoc.createElement(rt.getHeaderName());
+ root.appendChild(hdr);
+
+ String elemData = rt.getReqId();
+ Element hdrChild;
+ if (elemData != null && elemData.length() > 0)
+ {
+ hdrChild = newdoc.createElement("svc-request-id");
+ hdrChild.appendChild(newdoc.createTextNode(elemData));
+ hdr.appendChild(hdrChild);
+ }
+
+ elemData = rt.getAction();
+ if (elemData != null && elemData.length() > 0)
+ {
+ hdrChild = newdoc.createElement("svc-action");
+ hdrChild.appendChild(newdoc.createTextNode(elemData));
+ hdr.appendChild(hdrChild);
+ }
+
+ elemData = rt.getSdncaNotificationUrl();
+ if (elemData != null && elemData.length() > 0)
+ {
+ hdrChild = newdoc.createElement("svc-notification-url");
+ hdrChild.appendChild(newdoc.createTextNode(elemData));
+ hdr.appendChild(hdrChild);
+ }
+
+ //RequestData
+ NodeList nodes = reqDoc.getDocumentElement().getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ Node newNode = newdoc.importNode(n, true);
+ root.appendChild(newNode);
+ }
+
+ String s = domToStr(newdoc);
+ msoLogger.debug("Formatted SdncReq:\n" + s);
+ return (s);
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e);
+ }
+ return(null);
+ }
+
+ public static String genSdncPutReq(Document reqDoc, RequestTunables rt) {
+ try {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ //NewDoc for output
+ //Root
+ Document newdoc = db.newDocument();
+
+ //RequestData
+ NodeList nodes = reqDoc.getDocumentElement().getChildNodes();
+
+
+ Element root = newdoc.createElement(nodes.item(0).getNodeName());
+ newdoc.appendChild(root);
+
+ NodeList childNodes = nodes.item(0).getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node n = childNodes.item(i);
+ Node newNode = newdoc.importNode(n, true);
+ root.appendChild(newNode);
+ }
+
+ String s = domToStr(newdoc);
+ msoLogger.debug("Formatted SdncPutReq:\n" + s);
+ return (s);
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genSdncPutReq", e);
+ }
+ return(null);
+ }
+
+ public static String genMsoFailResp(SDNCResponse resp) {
+ try {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ //NewDoc for output
+ //Root
+ Document newdoc = db.newDocument();
+ Element root = newdoc.createElement("output");
+ newdoc.appendChild(root);
+
+ Element elem1 = newdoc.createElement("svc-request-id");
+ elem1.appendChild(newdoc.createTextNode(resp.getReqId()));
+ root.appendChild(elem1);
+
+ Element elem2 = newdoc.createElement("response-code");
+ elem2.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespCode())));
+ root.appendChild(elem2);
+
+ Element elem3 = newdoc.createElement("response-message");
+ elem3.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespMsg())));
+ root.appendChild(elem3);
+
+ String s = domToStr(newdoc);
+ msoLogger.debug("Formatted SdncReq:" + s);
+ return (s);
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_RESPONSE, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genMsoFailResp", e);
+ }
+ return(null);
+ }
+
+
+ public static String domToStr(Document doc)
+ {
+ if (doc != null)
+ {
+ try {
+ DOMSource ds = new DOMSource(doc);
+ StringWriter sw = new StringWriter();
+ StreamResult sr = new StreamResult(sw);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t = tf.newTransformer();
+ //t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");//<?xml version="1.0" encoding="UTF-8"?>
+ t.transform(ds, sr);
+ String s = sw.toString();
+
+ // This is an awful fix for now but we don't want that xmlns="" to be generated
+ s = s.replaceAll("xmlns=\"\"", "");
+ return(s);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", MsoLogger.ErrorCode.DataError, "Exception - domToStr", e);
+ }
+ }
+ return(null);
+ }
+}