From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- .../adapter/network/NetworkAdapterClient.java | 45 --- .../adapter/network/NetworkAdapterClientImpl.java | 97 ------- .../network/NetworkAdapterRestProperties.java | 56 ---- .../adapter/requests/db/MsoRequestsDbAdapter.java | 35 --- .../requests/db/MsoRequestsDbAdapterClient.java | 300 ------------------- .../db/entities/MsoRequestsDbException.java | 62 ---- .../db/entities/MsoRequestsDbExceptionBean.java | 48 ---- .../requests/db/entities/RequestStatusType.java | 69 ----- .../requests/db/entities/ResponseStatus.java | 33 --- .../adapter/requests/db/entities/Status.java | 40 --- .../requests/db/entities/UpdateInfraRequest.java | 138 --------- .../mso/client/adapter/vnf/AdapterRestClient.java | 69 ----- .../client/adapter/vnf/AdapterRestProperties.java | 29 -- .../mso/client/adapter/vnf/VnfAdapterClient.java | 48 ---- .../client/adapter/vnf/VnfAdapterClientImpl.java | 106 ------- .../adapter/vnf/VnfAdapterRestProperties.java | 56 ---- .../client/appc/ApplicationControllerAction.java | 178 ------------ .../client/appc/ApplicationControllerCallback.java | 40 --- .../client/appc/ApplicationControllerClient.java | 212 -------------- .../appc/ApplicationControllerOrchestrator.java | 50 ---- ...ApplicationControllerOrchestratorException.java | 36 --- .../client/appc/ApplicationControllerSupport.java | 215 -------------- .../dmaaproperties/DefaultDmaapPropertiesImpl.java | 39 --- .../mso/client/orchestration/AAIOrchestrator.java | 114 -------- .../mso/client/orchestration/SDNCOrchestrator.java | 61 ---- .../client/restproperties/AAIPropertiesImpl.java | 64 ----- .../restproperties/PolicyRestPropertiesImpl.java | 64 ----- .../mso/client/sdnc/beans/SDNCRequest.java | 95 ------ .../mso/client/sdnc/beans/SDNCSvcAction.java | 46 --- .../mso/client/sdnc/beans/SDNCSvcOperation.java | 43 --- .../mso/client/sdnc/mapper/SDNCRequestMapper.java | 46 --- .../ServiceTopologyOperationRequestMapper.java | 98 ------- .../mso/client/sdnc/sync/CallbackHeader.java | 154 ---------- .../openecomp/mso/client/sdnc/sync/Constants.java | 48 ---- .../mso/client/sdnc/sync/ObjectFactory.java | 77 ----- .../mso/client/sdnc/sync/RequestHeader.java | 219 -------------- .../mso/client/sdnc/sync/RequestTunables.java | 222 --------------- .../sdnc/sync/SDNCAdapterCallbackRequest.java | 136 --------- .../mso/client/sdnc/sync/SDNCAdapterPortType.java | 57 ---- .../client/sdnc/sync/SDNCAdapterPortTypeImpl.java | 108 ------- .../mso/client/sdnc/sync/SDNCAdapterRequest.java | 128 --------- .../mso/client/sdnc/sync/SDNCAdapterResponse.java | 53 ---- .../sdnc/sync/SDNCCallbackAdapterPortType.java | 45 --- .../sdnc/sync/SDNCCallbackAdapterService.java | 126 -------- .../mso/client/sdnc/sync/SDNCRequestIdUtil.java | 39 --- .../mso/client/sdnc/sync/SDNCResponse.java | 73 ----- .../mso/client/sdnc/sync/SDNCSyncRpcClient.java | 317 --------------------- .../org/openecomp/mso/client/sdnc/sync/Utils.java | 195 ------------- 48 files changed, 4629 deletions(-) delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client') 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 deleted file mode 100644 index 5e3aca5613..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 6a1c862a66..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 62d78d423c..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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 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 deleted file mode 100644 index c3ba8e16ea..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 2443169151..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java +++ /dev/null @@ -1,300 +0,0 @@ -/*- - * ============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(); - StringBuilder queryString = new StringBuilder("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.append("statusMessage = :statusMessage, "); - statusMessage = request.getStatusMessage(); - } - if (request.getResponseBody() != null) { - queryString.append("responseBody = :responseBody, "); - responseBody = request.getResponseBody(); - } - if (request.getRequestStatus() != null) { - queryString.append("requestStatus = :requestStatus, "); - requestStatus = request.getRequestStatus(); - } - if (request.getProgress() != null) { - queryString.append("progress = :progress, "); - progress = request.getProgress(); - } - if (request.getVnfOutputs() != null) { - queryString.append("vnfOutputs = :vnfOutputs, "); - vnfOutputs = request.getVnfOutputs(); - } - if (request.getServiceInstanceId() != null) { - queryString.append("serviceInstanceId = :serviceInstanceId, "); - serviceInstanceId = request.getServiceInstanceId(); - } - if (request.getNetworkId() != null) { - queryString.append("networkId = :networkId, "); - networkId = request.getNetworkId(); - } - if (request.getVnfId() != null) { - queryString.append("vnfId = :vnfId, "); - vnfId = request.getVnfId(); - } - if (request.getVfModuleId() != null) { - queryString.append("vfModuleId = :vfModuleId, "); - vfModuleId = request.getVfModuleId(); - } - if (request.getVolumeGroupId() != null) { - queryString.append("volumeGroupId = :volumeGroupId, "); - volumeGroupId = request.getVolumeGroupId(); - } - if (request.getServiceInstanceName() != null) { - queryString.append("serviceInstanceName = :serviceInstanceName, "); - serviceInstanceName = request.getServiceInstanceName(); - } - if (request.getVfModuleName() != null) { - queryString.append("vfModuleName = :vfModuleName, "); - vfModuleName = request.getVfModuleName(); - } - if (request.getConfigurationId() != null) { - queryString.append("configurationId = :configurationId, "); - configurationId = request.getConfigurationId(); - } - if (request.getConfigurationName() != null) { - queryString.append("configurationName = :configurationName, "); - configurationName = request.getConfigurationName(); - } - if (request.getRequestStatus() == RequestStatusType.COMPLETE - || request.getRequestStatus() == RequestStatusType.FAILED) { - queryString.append("endTime = :endTime, "); - } else { - queryString.append("modifyTime = :modifyTime, "); - } - queryString.append("lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId"); - - LOGGER.debug("Executing update: " + queryString.toString()); - - Query query = session.createQuery(queryString.toString()); - 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 deleted file mode 100644 index a495d0eac1..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index f566418ade..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 2fa6f2b6a2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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 http://java.sun.com/xml/jaxb -// 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; - - -/** - *

Java class for request-status-type. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="request-status-type">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="COMPLETE"/>
- *     <enumeration value="FAILED"/>
- *     <enumeration value="IN_PROGRESS"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@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 deleted file mode 100644 index cc00fd1ff2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index e9750a2b3b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 15c57253f3..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 16fd351b43..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.ext.ContextResolver; - -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 headerMap) { - addBasicAuthHeader(props.getAuth(), props.getKey()); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(UUID requestId) { - return null; - } - - @Override - protected ContextResolver getMapper() { - return new JettisonStyleMapperProvider(); - } -} 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 deleted file mode 100644 index af429db1f2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 5ee38fe0fb..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 2b391d302d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index e342aeedac..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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 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"; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java deleted file mode 100644 index 3c00627bff..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============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.appc; - -import java.util.HashMap; -import java.util.List; - -import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; -import org.openecomp.mso.bpmn.appc.payload.PayloadClient; -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.client.appc.ApplicationControllerOrchestrator; -import java.util.Optional; -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.Status; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.att.eelf.configuration.EELFLogger.Level; -import java.lang.NoSuchMethodError; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class ApplicationControllerAction { - protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); - private String errorCode = "1002"; - private String errorMessage = "Unable to reach App C Servers"; - protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional payload, HashMap payloadInfo, String controllerType){ Status appCStatus = null; - try{ - String vnfName = payloadInfo.getOrDefault("vnfName", ""); - String aicIdentity = payloadInfo.getOrDefault("vnfName",""); - String vnfHostIpAddress = payloadInfo.getOrDefault("vnfHostIpAddress",""); - String vmIdList = payloadInfo.getOrDefault("vmIdList", ""); - String identityUrl = payloadInfo.getOrDefault("identityUrl", ""); - switch(action){ - case ResumeTraffic: - appCStatus = resumeTrafficAction(msoRequestId, vnfId, vnfName, controllerType); - break; - case Start: - case Stop: - appCStatus = startStopAction(action, msoRequestId, vnfId, aicIdentity, controllerType); - break; - case Unlock: - case Lock: - appCStatus = client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), controllerType); - break; - case QuiesceTraffic: - appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); - break; - case HealthCheck: - appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress, controllerType); - break; - case Snapshot: - String vmIds = JsonUtils.getJsonValue(vmIdList, "vmIds"); - String vmId = ""; - ObjectMapper mapper = new ObjectMapper(); - List vmIdJsonList = mapper.readValue(vmIds, new TypeReference>(){}); - int i = 0; - while(i < vmIdJsonList.size()){ - vmId = vmIdJsonList.get(i); - appCStatus = snapshotAction(msoRequestId, vnfId, vmId, identityUrl, controllerType); - i++; - } - break; - case ConfigModify: - case ConfigScaleOut: - appCStatus = payloadAction(action, msoRequestId, vnfId, payload, controllerType); - break; - case UpgradePreCheck: - case UpgradePostCheck: - case UpgradeSoftware: - case UpgradeBackup: - appCStatus = upgradeAction(action,msoRequestId, vnfId, payload, vnfName, controllerType); - break; - default: - errorMessage = "Unable to idenify Action request for AppCClient"; - break; - } - if(appCStatus != null){ - errorCode = Integer.toString(appCStatus.getCode()); - errorMessage = appCStatus.getMessage(); - - } - if(ApplicationControllerSupport.getCategoryOf(appCStatus).equals(StatusCategory.NORMAL)){ - errorCode = "0"; - } - } - catch(JsonProcessingException e){ - auditLogger.log(Level.ERROR, "Incorrect Payload format for action request" + action.toString(),e, e.getMessage()); - errorMessage = e.getMessage(); - } - catch(ApplicationControllerOrchestratorException e){ - auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); - errorCode = "1002"; - errorMessage = e.getMessage(); - } - catch (NoSuchMethodError e) { - auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); - errorMessage = e.getMessage(); - } - catch(Exception e){ - auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); - errorMessage = e.getMessage(); - } - } - - private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional payload, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ - if(!(payload.isPresent())){ - throw new IllegalArgumentException("Payload is not present for " + action.toString()); - } - return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); - } - - private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional payload, String vnfName, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ - if(!(payload.isPresent())){ - throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); - } - payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); - return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, payload, controllerType); - } - - private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional payload, String vnfName, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ - if(!(payload.isPresent())){ - throw new IllegalArgumentException("Payload is not present for " + action.toString()); - } - payload = PayloadClient.upgradeFormat(payload, vnfName); - return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); - } - - private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ - Optional payload = PayloadClient.resumeTrafficFormat(vnfName); - return client.vnfCommand(Action.ResumeTraffic, msoRequestId, vnfId, payload, controllerType); - } - - private Status startStopAction(Action action, String msoRequestId, String vnfId, String aicIdentity, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ - Optional payload = PayloadClient.startStopFormat(aicIdentity); - return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); - } - - private Status healthCheckAction(String msoRequestId, String vnfId, String vnfName, String vnfHostIpAddress, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ - Optional payload = PayloadClient.healthCheckFormat(vnfName, vnfHostIpAddress); - return client.vnfCommand(Action.HealthCheck, msoRequestId, vnfId, payload, controllerType); - } - - private Status snapshotAction(String msoRequestId, String vnfId, String vmId, String identityUrl, String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException{ - Optional payload = PayloadClient.snapshotFormat(vmId, identityUrl); - return client.vnfCommand(Action.Snapshot, msoRequestId, vnfId, payload, controllerType); - } - - public String getErrorMessage(){ - return errorMessage; - } - - public String getErrorCode(){ - return errorCode; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java deleted file mode 100644 index 1bb4dc7eed..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============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.appc; - -import org.onap.appc.client.lcm.api.ResponseHandler; -import org.onap.appc.client.lcm.exceptions.AppcClientException; - -public class ApplicationControllerCallback implements ResponseHandler { - - @Override - public void onResponse(T response) { - System.out.println("ON RESPONSE"); - - } - - @Override - public void onException(AppcClientException exception) { - System.out.println("ON EXCEPTION"); - - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java deleted file mode 100644 index c9e2e880e7..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * ============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.appc; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.time.Instant; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; -import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; -import org.onap.appc.client.lcm.api.ApplicationContext; -import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; -import org.onap.appc.client.lcm.exceptions.AppcClientException; -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.CommonHeader; -import org.onap.appc.client.lcm.model.Flags; -import org.onap.appc.client.lcm.model.Flags.Force; -import org.onap.appc.client.lcm.model.Flags.Mode; -import org.onap.appc.client.lcm.model.Payload; -import org.onap.appc.client.lcm.model.Status; -import org.onap.appc.client.lcm.model.ZULU; -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.springframework.beans.factory.annotation.Autowired; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFLogger.Level; -import com.att.eelf.configuration.EELFManager; - -public class ApplicationControllerClient { - - public static final String DEFAULT_CONTROLLER_TYPE = "SDNC"; - - private static final String CLIENT_NAME = "MSO"; - - private static final String API_VER = "2.00"; - private static final String ORIGINATOR_ID = "MSO"; - private static final int FLAGS_TTL = 65000; - protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - @Autowired - public ApplicationControllerSupport appCSupport; - - // APPC gave us an API where the controllerType is configured in the - // client object, which is not what we asked for. We asked for an API - // in which the client would have additional methods that could take - // the controllerType as a parameter, so that we would not need to - // maintain multiple client objects. This map should be removed when - // the (hopefully short-term) controllerType becomes obsolete. - - private final String controllerType; - - private static ConcurrentHashMap appCClients = new ConcurrentHashMap<>(); - - /** - * Creates an ApplicationControllerClient for communication with APP-C. - */ - public ApplicationControllerClient() { - this(DEFAULT_CONTROLLER_TYPE); - } - - /** - * Creates an ApplicationControllerClient for the specified controller type. - * @param controllerType the controller type: "appc" or "sdnc". - */ - public ApplicationControllerClient(String controllerType) { - if (controllerType == null) { - controllerType = DEFAULT_CONTROLLER_TYPE; - } - this.controllerType = controllerType.toUpperCase(); - appCSupport = new ApplicationControllerSupport(); - } - - /** - * Gets the controller type. - * @return the controllertype - */ - public String getControllerType() { - return controllerType; - } - - /** - * Returns the AppC client object associated with this ApplicationControllerClient. - * AppC client objects are shared objects. One is created if it does not exist. - * @return the client object, or null if creation failed - */ - public LifeCycleManagerStateful getAppCClient() { - return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); - } - - protected LifeCycleManagerStateful createAppCClient(String controllerType) { - try { - if (controllerType == null) { - controllerType = DEFAULT_CONTROLLER_TYPE; - } - controllerType = controllerType.toUpperCase(); - return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); - } catch (AppcClientException e) { - auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage()); - // This null value will cause NullPointerException when used later. - // Error handling could certainly be improved here. - return null; - } - } - - public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, - org.onap.appc.client.lcm.model.Payload payload, String requestID) - throws ApplicationControllerOrchestratorException { - Object requestObject = createRequest(action, actionIdentifiers, payload, requestID); - appCSupport.logLCMMessage(requestObject); - LifeCycleManagerStateful client = getAppCClient(); - Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); - try { - Object response = lcmMethod.invoke(client, requestObject); - return appCSupport.getStatusFromGenericResponse(response); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); - } - } - - protected Properties getLCMProperties() { - return getLCMProperties("appc"); - } - - protected Properties getLCMProperties(String controllerType) { - Properties properties = new Properties(); - Map globalProperties = PropertyConfiguration.getInstance() - .getProperties("mso.bpmn.urn.properties"); - - properties.put("topic.read", globalProperties.get("appc.client.topic.read")); - properties.put("topic.write", globalProperties.get("appc.client.topic.write")); - properties.put("SDNC-topic.read", globalProperties.get("appc.client.topic.sdnc.read")); - properties.put("SDNC-topic.write", globalProperties.get("appc.client.topic.sdnc.write")); - properties.put("topic.read.timeout", globalProperties.get("appc.client.topic.read.timeout")); - properties.put("client.response.timeout", globalProperties.get("appc.client.response.timeout")); - properties.put("poolMembers", globalProperties.get("appc.client.poolMembers")); - properties.put("controllerType", controllerType); - properties.put("client.key", globalProperties.get("appc.client.key")); - properties.put("client.secret", globalProperties.get("appc.client.secret")); - properties.put("client.name", CLIENT_NAME); - properties.put("service", globalProperties.get("appc.client.service")); - return properties; - } - - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { - Object requestObject = appCSupport.getInput(action.name()); - try { - CommonHeader commonHeader = buildCommonHeader(requestId); - requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, - commonHeader); - requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); - requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) - .invoke(requestObject, identifier); - if (payload != null) { - requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); - } - } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); - } - return requestObject; - } - - private CommonHeader buildCommonHeader(String requestId) { - CommonHeader commonHeader = new CommonHeader(); - commonHeader.setApiVer(API_VER); - commonHeader.setOriginatorId(ORIGINATOR_ID); - commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); - commonHeader.setSubRequestId(requestId); - Flags flags = new Flags(); - String flagsMode = "NORMAL"; - Mode mode = Mode.valueOf(flagsMode); - flags.setMode(mode); - String flagsForce = "FALSE"; - Force force = Force.valueOf(flagsForce); - flags.setForce(force); - flags.setTtl(FLAGS_TTL); - commonHeader.setFlags(flags); - Instant timestamp = Instant.now(); - ZULU zulu = new ZULU(timestamp.toString()); - commonHeader.setTimestamp(zulu); - return commonHeader; - } - - public Flags createRequestFlags() { - Flags flags = new Flags(); - flags.setTtl(6000); - return flags; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java deleted file mode 100644 index 744be5f28f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============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.appc; - -import java.util.Optional; - -import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; - -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.Payload; -import org.onap.appc.client.lcm.model.Status; - -public class ApplicationControllerOrchestrator { - - public Status vnfCommand(Action action, String requestId, String vnfId, Optional request, String controllerType) throws ApplicationControllerOrchestratorException { - ApplicationControllerClient client = new ApplicationControllerClient(controllerType); - Status status; - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId(vnfId); - Payload payload = null; - if (request.isPresent()) { - payload = new Payload(request.get()); - } - status = client.runCommand(action, actionIdentifiers, payload, requestId); - if (ApplicationControllerSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { - throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); - } else { - return status; - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java deleted file mode 100644 index 4692f1dcc2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============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.appc; - -public class ApplicationControllerOrchestratorException extends Exception { - - private final int appcCode; - - public ApplicationControllerOrchestratorException(String message, int code) { - super(message); - appcCode = code; - } - - public int getAppcCode() - { - return appcCode; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java deleted file mode 100644 index e3ed432dfc..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ============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.appc; - -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.springframework.stereotype.Component; - -import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; -import org.onap.appc.client.lcm.api.ResponseHandler; -import org.onap.appc.client.lcm.model.Status; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.att.eelf.configuration.EELFLogger.Level; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; - -@Component -public class ApplicationControllerSupport { - - private static final int ACCEPT_SERIES = 100; - private static final int ERROR_SERIES = 200; - private static final int REJECT_SERIES = 300; - private static final int SUCCESS_SERIES = 400; - private static final int SUCCESS_STATUS = SUCCESS_SERIES; - private static final int PARTIAL_SERIES = 500; - private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; - private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; - - protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String lcmModelPackage = "org.onap.appc.client.lcm.model"; - - /** - * @param action - * @return - * @throws ClassNotFoundException - * @throws InstantiationException - * @throws IllegalAccessException - */ - public Object getInput(String action) { - try { - return getInputClass(action).newInstance(); - } catch (IllegalAccessException | InstantiationException e) { - throw new RuntimeException( - String.format("%s : %s", "Unable to instantiate viable LCM Kit input class for action", action), e); - } - } - - /** - * @param action - * @return - * @throws ClassNotFoundException - */ - public Method getAPIMethod(String action, LifeCycleManagerStateful lcmStateful, boolean async) { - Method[] methods = lcmStateful.getClass().getMethods(); - for (Method method : methods) { - if (method.getName().equalsIgnoreCase(action)) { - Class[] methodParameterTypes = method.getParameterTypes(); - if (methodParameterTypes.length > 0) { - if (getInputClass(action).equals(methodParameterTypes[0])) { - if (async) { - if (methodParameterTypes.length == 2 - && ResponseHandler.class.isAssignableFrom(methodParameterTypes[1])) { - return method; - } - } else if (methodParameterTypes.length == 1) { - return method; - } - } - } - } - } - throw new RuntimeException(String.format("%s : %s, async=%b", - "Unable to derive viable LCM Kit API method for action", action, async)); - } - - public Status getStatusFromGenericResponse(Object response) { - Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false); - if (statusReader != null) { - try { - return (Status) statusReader.invoke(response); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - auditLogger.log(Level.ERROR, "Unable to obtain status from LCM Kit response", e, e.getMessage()); - } - } - return new Status(); - } - - public static StatusCategory getCategoryOf(Status status) { - int codeSeries = status.getCode() - (status.getCode() % 100); - switch (codeSeries) { - case ACCEPT_SERIES: - return StatusCategory.NORMAL; - case ERROR_SERIES: - case REJECT_SERIES: - return StatusCategory.ERROR; - case SUCCESS_SERIES: - return status.getCode() == SUCCESS_STATUS ? StatusCategory.NORMAL : StatusCategory.ERROR; - case PARTIAL_SERIES: - switch (status.getCode()) { - case PARTIAL_SUCCESS_STATUS: - return StatusCategory.NORMAL; - case PARTIAL_FAILURE_STATUS: - return StatusCategory.ERROR; - default: - return StatusCategory.WARNING; - } - default: - return StatusCategory.WARNING; - } - } - - public static boolean getFinalityOf(Status status) { - int codeSeries = status.getCode() - (status.getCode() % 100); - switch (codeSeries) { - case ACCEPT_SERIES: - case PARTIAL_SERIES: - return false; - case ERROR_SERIES: - case REJECT_SERIES: - case SUCCESS_SERIES: - return true; - default: - return true; - } - } - - private Method getBeanPropertyMethodFor(Class clazz, String propertyName, boolean isWriter) { - BeanInfo beanInfo; - try { - beanInfo = Introspector.getBeanInfo(clazz, Object.class); - } catch (IntrospectionException e) { - throw new RuntimeException( - String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", - clazz.getName(), propertyName, isWriter), - e); - } - PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); - for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { - if (propertyDescriptor.getName().equals(propertyName)) { - return isWriter ? propertyDescriptor.getWriteMethod() : propertyDescriptor.getReadMethod(); - } - } - throw new RuntimeException( - String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", - clazz.getName(), propertyName, isWriter)); - } - - /** - * @param action - * @return - * @throws ClassNotFoundException - */ - private Class getInputClass(String action) { - try { - return Class.forName(lcmModelPackage + '.' + action + "Input"); - } catch (ClassNotFoundException e) { - throw new RuntimeException(String.format("%s : %s using package : %s", - "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e); - } - } - - public enum StatusCategory { - NORMAL("normal"), WARNING("warning"), ERROR("error"); - - private final String category; - - private StatusCategory(final String category) { - this.category = category; - } - - @Override - public String toString() { - return category; - } - } - - public void logLCMMessage(Object message) { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(Include.NON_NULL); - ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); - String inputAsJSON; - try { - inputAsJSON = writer.writeValueAsString(message); - auditLogger.log(Level.INFO, "\nLCM Kit input message follows: \n" + inputAsJSON, null); - } catch (JsonProcessingException e) { - auditLogger.log(Level.ERROR, "Error in logging LCM Message: ", e, e.getMessage()); - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java deleted file mode 100644 index c3bf53cfde..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============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.dmaaproperties; - -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.client.dmaap.DmaapProperties; - -public class DefaultDmaapPropertiesImpl implements DmaapProperties { - - private final Map properties; - public DefaultDmaapPropertiesImpl() { - this.properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - } - @Override - public Map getProperties() { - return this.properties; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java deleted file mode 100644 index 73bad21c87..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============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.orchestration; - -import java.util.Optional; -import java.util.logging.Logger; - -import org.modelmapper.ModelMapper; -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; -import org.openecomp.mso.client.aai.AAIResourcesClient; -import org.openecomp.mso.client.aai.entities.AAIEntityObject; -import org.openecomp.mso.client.aai.objects.AAIOwningEntity; -import org.openecomp.mso.client.aai.objects.AAIProject; -import org.openecomp.mso.client.aai.objects.AAIServiceInstance; - -public class AAIOrchestrator { - - private static Logger LOGGER = Logger.getLogger("AAIOrchestrator"); - - public void createServiceInstance(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.createIfNotExists(serviceInstance.getUri(), Optional.of(serviceInstance)); - }catch(Exception ex) { - String msg = "Failed to create service instance in A&AI."; - throw new IllegalStateException(msg); - } - } - - public void deleteServiceInstance(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.delete(serviceInstance.getUri()); - } catch (Exception ex) { - String msg = "Failed to delete service instance in A&AI."; - throw new IllegalStateException(msg); - } - } - - public void createProject(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject project = modelMapper.map(serviceDecomp.getProject(), AAIProject.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.createIfNotExists(project.getUri(), Optional.of(project)); - }catch(Exception ex) { - String msg = "Failed to create project in A&AI."; - throw new IllegalStateException(msg); } - } - - public void createProjectandConnectServiceInstance(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject project = modelMapper.map(serviceDecomp.getProject(), AAIProject.class); - AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.createIfNotExists(project.getUri(), Optional.of(project)).connect(project.getUri(), serviceInstance.getUri()); - } catch(Exception ex) { - String msg = "Failed to create project and connect service instance in A&AI."; - throw new IllegalStateException(msg); - } - } - - public void createOwningEntity(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject owningEntity = modelMapper.map(serviceDecomp.getOwningEntity(), AAIOwningEntity.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.createIfNotExists(owningEntity.getUri(), Optional.of(owningEntity)); - }catch(Exception ex) { - String msg = "Failed to create owning entity in A&AI."; - throw new IllegalStateException(msg); - } - } - - public void createOwningEntityandConnectServiceInstance(ServiceDecomposition serviceDecomp) { - try{ - ModelMapper modelMapper = new ModelMapper(); - AAIEntityObject owningEntity = modelMapper.map(serviceDecomp.getOwningEntity(), AAIOwningEntity.class); - AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); - AAIResourcesClient aaiRC = this.getClient(); - aaiRC.createIfNotExists(owningEntity.getUri(), Optional.of(owningEntity)).connect(owningEntity.getUri(), serviceInstance.getUri()); - }catch(Exception ex) { - String msg = "Failed to create owning entity and connect service instance in A&AI."; - throw new IllegalStateException(msg); } - } - - protected AAIResourcesClient getClient() { - return new AAIResourcesClient(); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java deleted file mode 100644 index 4cefad2a3b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============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.orchestration; - -import java.util.Optional; -import java.util.logging.Logger; - -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 org.openecomp.mso.client.sdnc.mapper.ServiceTopologyOperationRequestMapper; -import org.openecomp.mso.client.sdnc.sync.SDNCSyncRpcClient; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -public class SDNCOrchestrator { - - private static MsoPropertiesFactory msoPF = new MsoPropertiesFactory(); - - public void createServiceInstance (ServiceDecomposition serviceDecomp) { - - try{ - msoPF.initializeMsoProperties("MSO_PROP_SDNC_ADAPTER", "mso.sdnc.properties"); - Optional msoAction = getMSOAction(serviceDecomp); - ServiceTopologyOperationRequestMapper sdncRM = new ServiceTopologyOperationRequestMapper(msoAction, SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, "CreateServiceInstance"); - SDNCRequest request = sdncRM.reqMapper(serviceDecomp); - SDNCSyncRpcClient sdncRC = new SDNCSyncRpcClient (request, msoPF); - sdncRC.run(); - } catch (Exception ex) { - throw new IllegalStateException(); - } - } - - private Optional getMSOAction (ServiceDecomposition serviceDecomp){ - String serviceType = serviceDecomp.getServiceInstance().getServiceType(); - if(serviceType == null || serviceType.equals("")){ - return Optional.empty(); - } - - return Optional.of(serviceType); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java deleted file mode 100644 index a1ef35a49d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============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.restproperties; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.client.aai.AAIProperties; -import org.openecomp.mso.client.aai.AAIVersion; - -public class AAIPropertiesImpl implements AAIProperties { - - final Map props; - - public AAIPropertiesImpl() { - this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - - } - - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL(props.get("aai.endpoint")); - } - - @Override - public String getSystemName() { - return "MSO"; - } - - @Override - public AAIVersion getDefaultVersion() { - return AAIVersion.LATEST; - } - - @Override - public String getAuth() { - return props.get("aai.auth"); - } - - @Override - public String getKey() { - return props.get("mso.msoKey"); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java deleted file mode 100644 index eccf87c09d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============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.restproperties; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.client.policy.PolicyRestProperties; - -public class PolicyRestPropertiesImpl implements PolicyRestProperties { - - - final Map props; - public PolicyRestPropertiesImpl() { - this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - - } - @Override - public URL getEndpoint() { - try { - return new URL(props.getOrDefault("policy.endpoint", "")); - } catch (MalformedURLException e) { - return null; - } - } - - @Override - public String getSystemName() { - return "MSO"; - } - - public String getClientAuth() { - return props.get("policy.client.auth"); - } - - public String getAuth() { - return props.get("policy.auth"); - } - - public String getEnvironment() { - return props.get("policy.environment"); - } - -} 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 deleted file mode 100644 index cd04fc5ef0..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 91e3a59276..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 8cf1052064..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 3e714e901d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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 msoAction; - protected final SDNCSvcOperation svcOperation; - protected final SDNCSvcAction svcAction; - protected final String requestAction; - - public SDNCRequestMapper (Optional 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 deleted file mode 100644 index b87ed00650..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============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 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 deleted file mode 100644 index 2ddafc1c17..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * ============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; - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="ResponseCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="ResponseMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -//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 deleted file mode 100644 index 331fefa677..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 3ddfdb2925..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============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. - *

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 deleted file mode 100644 index dee79898fa..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * ============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; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -//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 deleted file mode 100644 index 55d42df6e1..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java +++ /dev/null @@ -1,222 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 6e9d6757ad..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============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; -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}CallbackHeader"/>
- *         <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -//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 deleted file mode 100644 index 8b56932769..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 3d9aab666a..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 5beedb12be..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============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; - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}RequestHeader"/>
- *         <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -//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 deleted file mode 100644 index 4625bfb74f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============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; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -//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 deleted file mode 100644 index 08d3bdbad7..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 0e65a3080f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============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 features 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 deleted file mode 100644 index d905748591..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 850f5b4734..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index ce9b706760..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java +++ /dev/null @@ -1,317 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 7457b59390..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ============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");// - 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); - } -} -- cgit 1.2.3-korg