aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter
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/adapter
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/adapter')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java97
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java56
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java35
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java300
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java62
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java69
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java33
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java40
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java138
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java89
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java29
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java106
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java56
16 files changed, 1251 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java
new file mode 100644
index 0000000000..5e3aca5613
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.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.adapter.network;
+
+import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
+
+public interface NetworkAdapterClient {
+
+ CreateNetworkResponse createNetwork(CreateNetworkRequest req);
+
+ DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req);
+
+ RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req);
+
+ QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId);
+
+ UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req);
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java
new file mode 100644
index 0000000000..6a1c862a66
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java
@@ -0,0 +1,97 @@
+/*-
+ * ============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.adapter.network;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
+import org.openecomp.mso.client.adapter.vnf.AdapterRestClient;
+
+public class NetworkAdapterClientImpl implements NetworkAdapterClient {
+
+ private final NetworkAdapterRestProperties props;
+ public NetworkAdapterClientImpl() {
+ this.props = new NetworkAdapterRestProperties();
+ }
+ @Override
+ public CreateNetworkResponse createNetwork(CreateNetworkRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("").build()).post(req,
+ CreateNetworkResponse.class);
+ }
+
+ @Override
+ public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
+ DeleteNetworkResponse.class);
+ }
+
+ @Override
+ public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
+ RollbackNetworkResponse.class);
+ }
+
+ @Override
+ public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId,
+ String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId) {
+ UriBuilder builder = this.getUri("/" + aaiNetworkId);
+ if (cloudSiteId != null) {
+ builder.queryParam("cloudSiteId", cloudSiteId);
+ }
+ if (tenantId != null) {
+ builder.queryParam("tenantId", tenantId);
+ }
+ if (networkStackId != null) {
+ builder.queryParam("networkStackId", networkStackId);
+ }
+
+ builder.queryParam("skipAAI", skipAAI);
+
+ if (requestId != null) {
+ builder.queryParam("msoRequest.requestId", requestId);
+ }
+ if (serviceInstanceId != null) {
+ builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ }
+ return new AdapterRestClient(this.props, builder.build(), MediaType.TEXT_XML, MediaType.TEXT_XML)
+ .get(QueryNetworkResponse.class);
+ }
+
+ @Override
+ public UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req,
+ UpdateNetworkResponse.class);
+ }
+
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java
new file mode 100644
index 0000000000..62d78d423c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.adapter.network;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.client.adapter.vnf.AdapterRestProperties;
+
+public class NetworkAdapterRestProperties implements AdapterRestProperties {
+
+ private final Map<String, String> props;
+
+ public NetworkAdapterRestProperties() {
+ this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ }
+
+ @Override
+ public String getAuth() {
+ return props.get("mso.adapters.po.auth");
+ }
+ @Override
+ public String getKey() {
+ return props.get("mso.msoKey");
+ }
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(props.get("mso.adapters.network.rest.endpoint"));
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java
new file mode 100644
index 0000000000..c3ba8e16ea
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.adapter.requests.db;
+
+import org.openecomp.mso.client.adapter.requests.db.entities.MsoRequestsDbException;
+import org.openecomp.mso.client.adapter.requests.db.entities.UpdateInfraRequest;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+
+public interface MsoRequestsDbAdapter {
+
+ public void updateInfraRequest(UpdateInfraRequest request) throws MsoRequestsDbException;
+
+ public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException;
+
+ public boolean getSiteStatus(String siteName);
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java
new file mode 100644
index 0000000000..109da17ea2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java
@@ -0,0 +1,300 @@
+/*-
+ * ============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.adapter.requests.db;
+
+import java.sql.Timestamp;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openecomp.mso.client.adapter.requests.db.entities.MsoRequestsDbException;
+import org.openecomp.mso.client.adapter.requests.db.entities.RequestStatusType;
+import org.openecomp.mso.client.adapter.requests.db.entities.UpdateInfraRequest;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
+import org.openecomp.mso.requestsdb.SiteStatus;
+import org.openecomp.mso.utils.UUIDChecker;
+
+public class MsoRequestsDbAdapterClient implements MsoRequestsDbAdapter {
+
+ protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ @Override
+ public void updateInfraRequest(UpdateInfraRequest request) throws MsoRequestsDbException {
+ Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
+ int result = 0;
+ long startTime = System.currentTimeMillis();
+ if (request.getRequestId() != null && request.getLastModifiedBy() != null) {
+ MsoLogger.setLogContext(request.getRequestId(), null);
+ try {
+ session.beginTransaction();
+ String queryString = "update InfraActiveRequests set ";
+ String statusMessage = null;
+ String responseBody = null;
+ RequestStatusType requestStatus = null;
+ String progress = null;
+ String vnfOutputs = null;
+ String serviceInstanceId = null;
+ String networkId = null;
+ String vnfId = null;
+ String vfModuleId = null;
+ String volumeGroupId = null;
+ String serviceInstanceName = null;
+ String vfModuleName = null;
+ String configurationId = null;
+ String configurationName = null;
+ if (request.getStatusMessage() != null) {
+ queryString += "statusMessage = :statusMessage, ";
+ statusMessage = request.getStatusMessage();
+ }
+ if (request.getResponseBody() != null) {
+ queryString += "responseBody = :responseBody, ";
+ responseBody = request.getResponseBody();
+ }
+ if (request.getRequestStatus() != null) {
+ queryString += "requestStatus = :requestStatus, ";
+ requestStatus = request.getRequestStatus();
+ }
+ if (request.getProgress() != null) {
+ queryString += "progress = :progress, ";
+ progress = request.getProgress();
+ }
+ if (request.getVnfOutputs() != null) {
+ queryString += "vnfOutputs = :vnfOutputs, ";
+ vnfOutputs = request.getVnfOutputs();
+ }
+ if (request.getServiceInstanceId() != null) {
+ queryString += "serviceInstanceId = :serviceInstanceId, ";
+ serviceInstanceId = request.getServiceInstanceId();
+ }
+ if (request.getNetworkId() != null) {
+ queryString += "networkId = :networkId, ";
+ networkId = request.getNetworkId();
+ }
+ if (request.getVnfId() != null) {
+ queryString += "vnfId = :vnfId, ";
+ vnfId = request.getVnfId();
+ }
+ if (request.getVfModuleId() != null) {
+ queryString += "vfModuleId = :vfModuleId, ";
+ vfModuleId = request.getVfModuleId();
+ }
+ if (request.getVolumeGroupId() != null) {
+ queryString += "volumeGroupId = :volumeGroupId, ";
+ volumeGroupId = request.getVolumeGroupId();
+ }
+ if (request.getServiceInstanceName() != null) {
+ queryString += "serviceInstanceName = :serviceInstanceName, ";
+ serviceInstanceName = request.getServiceInstanceName();
+ }
+ if (request.getVfModuleName() != null) {
+ queryString += "vfModuleName = :vfModuleName, ";
+ vfModuleName = request.getVfModuleName();
+ }
+ if (request.getConfigurationId() != null) {
+ queryString += "configurationId = :configurationId, ";
+ configurationId = request.getConfigurationId();
+ }
+ if (request.getConfigurationName() != null) {
+ queryString += "configurationName = :configurationName, ";
+ configurationName = request.getConfigurationName();
+ }
+ if (request.getRequestStatus() == RequestStatusType.COMPLETE
+ || request.getRequestStatus() == RequestStatusType.FAILED) {
+ queryString += "endTime = :endTime, ";
+ } else {
+ queryString += "modifyTime = :modifyTime, ";
+ }
+ queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId";
+
+ LOGGER.debug("Executing update: " + queryString);
+
+ Query query = session.createQuery(queryString);
+ query.setParameter("requestId", request.getRequestId());
+ if (statusMessage != null) {
+ query.setParameter("statusMessage", statusMessage);
+ LOGGER.debug("StatusMessage in updateInfraRequest is set to: " + statusMessage);
+ }
+ if (responseBody != null) {
+ query.setParameter("responseBody", responseBody);
+ LOGGER.debug("ResponseBody in updateInfraRequest is set to: " + responseBody);
+ }
+ if (requestStatus != null) {
+ query.setParameter("requestStatus", requestStatus.toString());
+ LOGGER.debug("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString());
+ }
+
+ if (progress != null) {
+ query.setParameter("progress", Long.parseLong(progress));
+ LOGGER.debug("Progress in updateInfraRequest is set to: " + progress);
+ }
+ if (vnfOutputs != null) {
+ query.setParameter("vnfOutputs", vnfOutputs);
+ LOGGER.debug("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs);
+ }
+ if (serviceInstanceId != null) {
+ query.setParameter("serviceInstanceId", serviceInstanceId);
+ LOGGER.debug("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId);
+ }
+ if (networkId != null) {
+ query.setParameter("networkId", networkId);
+ LOGGER.debug("NetworkId in updateInfraRequest is set to: " + networkId);
+ }
+ if (vnfId != null) {
+ query.setParameter("vnfId", vnfId);
+ LOGGER.debug("VnfId in updateInfraRequest is set to: " + vnfId);
+ }
+ if (vfModuleId != null) {
+ query.setParameter("vfModuleId", vfModuleId);
+ LOGGER.debug("vfModuleId in updateInfraRequest is set to: " + vfModuleId);
+ }
+ if (volumeGroupId != null) {
+ query.setParameter("volumeGroupId", volumeGroupId);
+ LOGGER.debug("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId);
+ }
+ if (serviceInstanceName != null) {
+ query.setParameter("serviceInstanceName", serviceInstanceName);
+ LOGGER.debug("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName);
+ }
+ if (configurationId != null) {
+ query.setParameter("configurationId", configurationId);
+ LOGGER.debug("configurationId in updateInfraRequest is set to: " + configurationId);
+ }
+ if (configurationName != null) {
+ query.setParameter("configurationName", configurationName);
+ LOGGER.debug("configurationName in updateInfraRequest is set to: " + configurationName);
+ }
+ if (vfModuleName != null) {
+ query.setParameter("vfModuleName", vfModuleName);
+ LOGGER.debug("vfModuleName in updateInfraRequest is set to: " + vfModuleName);
+ }
+ Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis());
+ if (request.getRequestStatus() == RequestStatusType.COMPLETE
+ || request.getRequestStatus() == RequestStatusType.FAILED) {
+ query.setParameter("endTime", nowTimeStamp);
+ LOGGER.debug("EndTime in updateInfraRequest is set to: " + nowTimeStamp);
+ } else {
+ query.setParameter("modifyTime", nowTimeStamp);
+ LOGGER.debug("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp);
+ }
+ query.setParameter("lastModifiedBy", request.getLastModifiedBy());
+ LOGGER.debug("LastModifiedBy in updateInfraRequest is set to: " + request.getLastModifiedBy());
+ result = query.executeUpdate();
+ checkIfExists(result, request.getRequestId(), startTime);
+ session.getTransaction().commit();
+ } catch (HibernateException e) {
+ String error = "Unable to update MSO Requests DB: " + e.getMessage();
+ LOGGER.error(MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", request.getRequestId(), "",
+ "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ error);
+ throw new MsoRequestsDbException(error, e);
+ } finally {
+ if (session != null && session.isOpen()) {
+ session.close();
+ }
+ }
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ } else {
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ "Required fields: requestId and lastModifiedBy");
+ }
+ }
+
+ private void checkIfExists(int result, String requestId, long startTime) throws MsoRequestsDbException {
+ if (result == 0) {
+ String error = "Request ID does not exist in MSO Requests DB: " + requestId;
+ LOGGER.error(MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error);
+ throw new MsoRequestsDbException(error);
+ }
+ }
+
+ @Override
+ public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException {
+ long startTime = System.currentTimeMillis();
+ MsoLogger.setLogContext(requestId, null);
+ Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
+
+ LOGGER.debug("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId);
+
+ InfraActiveRequests request = null;
+ try {
+ session.beginTransaction();
+ Query query = session.createQuery(
+ "FROM InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId");
+ query.setParameter("requestId", requestId);
+ request = (InfraActiveRequests) query.uniqueResult();
+ } catch (HibernateException e) {
+ String error = "Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
+ LOGGER.error(MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error);
+ throw new MsoRequestsDbException(error, e);
+ } finally {
+ if (session != null && session.isOpen()) {
+ session.close();
+ }
+ }
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return request;
+ }
+
+ /**
+ * Get SiteStatus by SiteName.
+ *
+ * @param siteName
+ * The unique name of the site
+ * @return Status of that site
+ */
+ public boolean getSiteStatus(String siteName) {
+ UUIDChecker.generateUUID(LOGGER);
+ Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
+
+ long startTime = System.currentTimeMillis();
+ SiteStatus siteStatus = null;
+ LOGGER.debug("Request database - get Site Status with Site name:" + siteName);
+ try {
+ String hql = "FROM SiteStatus WHERE siteName = :site_name";
+ Query query = session.createQuery(hql);
+ query.setParameter("site_name", siteName);
+
+ siteStatus = (SiteStatus) query.uniqueResult();
+ } finally {
+ if (session != null && session.isOpen()) {
+ session.close();
+ }
+ }
+ if (siteStatus == null) {
+ // if not exist in DB, it means the site is not disabled, thus
+ // return true
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return true;
+ } else {
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return siteStatus.getStatus();
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java
new file mode 100644
index 0000000000..a495d0eac1
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.adapter.requests.db.entities;
+
+
+
+import javax.xml.ws.WebFault;
+
+/**
+ * This class simply extends Exception (without addition additional functionality)
+ * to provide an identifier for RequestsDB related exceptions on create, delete, query.
+ *
+ *
+ */
+@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.openecomp.mso/requestsdb")
+public class MsoRequestsDbException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private MsoRequestsDbExceptionBean faultInfo;
+
+ public MsoRequestsDbException (String msg) {
+ super(msg);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbException (Throwable e) {
+ super(e);
+ faultInfo = new MsoRequestsDbExceptionBean (e.getMessage());
+ }
+
+ public MsoRequestsDbException (String msg, Throwable e) {
+ super (msg, e);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbExceptionBean getFaultInfo() {
+ return faultInfo;
+ }
+
+ public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) {
+ this.faultInfo = faultInfo;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java
new file mode 100644
index 0000000000..f566418ade
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.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.adapter.requests.db.entities;
+
+
+import java.io.Serializable;
+
+/**
+ * Jax-WS Fault Bean for MsoRequestsDB Exception
+ */
+public class MsoRequestsDbExceptionBean implements Serializable {
+
+ private static final long serialVersionUID = 1360000062602372639L;
+
+ private String message;
+
+ public MsoRequestsDbExceptionBean () {}
+
+ public MsoRequestsDbExceptionBean (String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java
new file mode 100644
index 0000000000..2fa6f2b6a2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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=========================================================
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.07.24 at 11:49:17 AM EDT
+//
+
+
+package org.openecomp.mso.client.adapter.requests.db.entities;
+
+
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for request-status-type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * &lt;simpleType name="request-status-type">
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ * &lt;enumeration value="COMPLETE"/>
+ * &lt;enumeration value="FAILED"/>
+ * &lt;enumeration value="IN_PROGRESS"/>
+ * &lt;/restriction>
+ * &lt;/simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "request-status-type")
+@XmlEnum
+public enum RequestStatusType {
+
+ COMPLETE,
+ FAILED,
+ IN_PROGRESS;
+
+ public String value() {
+ return name();
+ }
+
+ public static RequestStatusType fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java
new file mode 100644
index 0000000000..cc00fd1ff2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.adapter.requests.db.entities;
+
+
+
+/*
+ * Enum for Status values returned by API Handler to Tail-F
+*/
+public enum ResponseStatus {
+ SENDING_FINAL_NOTIFY,
+ SUCCESS,
+ FAILED,
+ TIMEOUT
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java
new file mode 100644
index 0000000000..e9750a2b3b
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.adapter.requests.db.entities;
+
+
+/*
+ * Enum for Status values returned by API Handler to Tail-F
+*/
+public enum Status {
+ PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT;
+
+ public boolean isFinished () {
+ switch (this) {
+ case COMPLETED:
+ case FAILED:
+ case TIMEOUT:
+ return true;
+ default:
+ return false;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java
new file mode 100644
index 0000000000..15c57253f3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java
@@ -0,0 +1,138 @@
+/*-
+ * ============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.adapter.requests.db.entities;
+
+public class UpdateInfraRequest {
+
+ private String requestId;
+ private String lastModifiedBy;
+ private String statusMessage;
+ private String responseBody;
+ private RequestStatusType requestStatus;
+ private String progress;
+ private String vnfOutputs;
+ private String serviceInstanceId;
+ private String networkId;
+ private String vnfId;
+ private String vfModuleId;
+ private String volumeGroupId;
+ private String serviceInstanceName;
+ private String configurationId;
+ private String configurationName;
+ private String vfModuleName;
+
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+ public String getLastModifiedBy() {
+ return lastModifiedBy;
+ }
+ public void setLastModifiedBy(String lastModifiedBy) {
+ this.lastModifiedBy = lastModifiedBy;
+ }
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+ public String getResponseBody() {
+ return responseBody;
+ }
+ public void setResponseBody(String responseBody) {
+ this.responseBody = responseBody;
+ }
+ public RequestStatusType getRequestStatus() {
+ return requestStatus;
+ }
+ public void setRequestStatus(RequestStatusType requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+ public String getProgress() {
+ return progress;
+ }
+ public void setProgress(String progress) {
+ this.progress = progress;
+ }
+ public String getVnfOutputs() {
+ return vnfOutputs;
+ }
+ public void setVnfOutputs(String vnfOutputs) {
+ this.vnfOutputs = vnfOutputs;
+ }
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+ public String getNetworkId() {
+ return networkId;
+ }
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+ public String getVnfId() {
+ return vnfId;
+ }
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+ public String getVfModuleId() {
+ return vfModuleId;
+ }
+ public void setVfModuleId(String vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+ public String getVolumeGroupId() {
+ return volumeGroupId;
+ }
+ public void setVolumeGroupId(String volumeGroupId) {
+ this.volumeGroupId = volumeGroupId;
+ }
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+ public String getConfigurationId() {
+ return configurationId;
+ }
+ public void setConfigurationId(String configurationId) {
+ this.configurationId = configurationId;
+ }
+ public String getConfigurationName() {
+ return configurationName;
+ }
+ public void setConfigurationName(String configurationName) {
+ this.configurationName = configurationName;
+ }
+ public String getVfModuleName() {
+ return vfModuleName;
+ }
+ public void setVfModuleName(String vfModuleName) {
+ this.vfModuleName = vfModuleName;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java
new file mode 100644
index 0000000000..3e315a5f04
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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.adapter.vnf;
+
+import java.net.URI;
+import java.security.GeneralSecurityException;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.ext.ContextResolver;
+
+import org.apache.commons.codec.binary.Base64;
+import org.openecomp.mso.bpmn.common.util.CryptoUtils;
+import org.openecomp.mso.client.ResponseExceptionMapperImpl;
+import org.openecomp.mso.client.policy.JettisonStyleMapperProvider;
+import org.openecomp.mso.client.policy.RestClient;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AdapterRestClient extends RestClient {
+
+ private final AdapterRestProperties props;
+ public AdapterRestClient(AdapterRestProperties props, URI uri) {
+ super(props, UUID.randomUUID(), Optional.of(uri));
+ this.props = props;
+ }
+
+ public AdapterRestClient(AdapterRestProperties props, URI uri, String accept, String contentType) {
+ super(props, UUID.randomUUID(), Optional.of(uri), accept, contentType);
+ this.props = props;
+ }
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ headerMap.put("Authorization",
+ this.getBasicAuth(props.getAuth(), props.getKey()));
+ }
+
+ @Override
+ protected Optional<ClientResponseFilter> addResponseFilter() {
+ return Optional.of(new ResponseExceptionMapperImpl());
+ }
+
+ @Override
+ public RestClient addRequestId(UUID requestId) {
+ return null;
+ }
+
+ @Override
+ protected ContextResolver<ObjectMapper> getMapper() {
+ return new JettisonStyleMapperProvider();
+ }
+
+ private String getBasicAuth(String encryptedAuth, String msoKey) {
+ if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty())) {
+ return null;
+ }
+ try {
+ String auth = CryptoUtils.decrypt(encryptedAuth, msoKey);
+ byte[] encoded = Base64.encodeBase64(auth.getBytes());
+ String encodedString = new String(encoded);
+ encodedString = "Basic " + encodedString;
+ return encodedString;
+ } catch (GeneralSecurityException e) {
+ this.logger.warn(e.getMessage(), e);
+ return null;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java
new file mode 100644
index 0000000000..af429db1f2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java
@@ -0,0 +1,29 @@
+/*-
+ * ============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.adapter.vnf;
+
+import org.openecomp.mso.client.RestProperties;
+
+public interface AdapterRestProperties extends RestProperties {
+
+ public String getAuth();
+ public String getKey();
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java
new file mode 100644
index 0000000000..5ee38fe0fb
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.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.adapter.vnf;
+
+import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse;
+
+public interface VnfAdapterClient {
+
+ CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req);
+
+ RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req);
+
+ DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req);
+
+ UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req);
+
+ QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, String tenantId,
+ String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId);
+
+ String healthCheck();
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java
new file mode 100644
index 0000000000..2b391d302d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.adapter.vnf;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse;
+import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse;
+
+public class VnfAdapterClientImpl implements VnfAdapterClient {
+
+ private static final String VF_MODULES = "/vf-modules/";
+
+ private final VnfAdapterRestProperties props;
+ public VnfAdapterClientImpl() {
+ this.props = new VnfAdapterRestProperties();
+ }
+
+ @Override
+ public CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req,
+ CreateVfModuleResponse.class);
+ }
+
+ @Override
+ public RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId,
+ RollbackVfModuleRequest req) {
+ return new AdapterRestClient(this.props,
+ this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req,
+ RollbackVfModuleResponse.class);
+ }
+
+ @Override
+ public DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
+ .delete(req, DeleteVfModuleResponse.class);
+ }
+
+ @Override
+ public UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req) {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
+ .put(req, UpdateVfModuleResponse.class);
+ }
+
+ @Override
+ public QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId,
+ String tenantId, String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId) {
+ UriBuilder builder = this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId);
+ if (cloudSiteId != null) {
+ builder.queryParam("cloudSiteId", cloudSiteId);
+ }
+ if (tenantId != null) {
+ builder.queryParam("tenantId", tenantId);
+ }
+ if (vfModuleName != null) {
+ builder.queryParam("vfModuleName", vfModuleName);
+ }
+
+ builder.queryParam("skipAAI", skipAAI);
+
+ if (requestId != null) {
+ builder.queryParam("msoRequest.requestId", requestId);
+ }
+ if (serviceInstanceId != null) {
+ builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ }
+ return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON)
+ .get(QueryVfModuleResponse.class);
+ }
+
+ @Override
+ public String healthCheck() {
+ return new AdapterRestClient(this.props, this.getUri("/healthcheck").build()).get(String.class);
+ }
+
+ public UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java
new file mode 100644
index 0000000000..e342aeedac
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.adapter.vnf;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.client.adapter.vnf.AdapterRestProperties;
+
+public class VnfAdapterRestProperties implements AdapterRestProperties {
+
+ private final Map<String, String> props;
+
+ public VnfAdapterRestProperties() {
+ this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ }
+
+ @Override
+ public String getAuth() {
+ return props.get("mso.adapters.po.auth");
+ }
+ @Override
+ public String getKey() {
+ return props.get("mso.msoKey");
+ }
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(props.get("mso.adapters.vnf.rest.endpoint"));
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+
+}