aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java62
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java334
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java81
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java335
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java70
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java160
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java476
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java106
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java172
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java67
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java45
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java36
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java145
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java78
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java216
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java286
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java342
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java82
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java216
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java92
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java78
25 files changed, 0 insertions, 3654 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
deleted file mode 100644
index 92e74e8de2..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.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.apihandlerinfra.tenantisolation;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.aai.AAIProperties;
-import org.openecomp.mso.client.aai.AAIVersion;
-import org.openecomp.mso.properties.MsoJavaProperties;
-
-public class AaiClientPropertiesImpl implements AAIProperties {
-
- final MsoJavaProperties props;
- public AaiClientPropertiesImpl() {
- this.props = MsoPropertiesUtils.loadMsoProperties ();
- }
-
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(props.getProperty("aai.endpoint", null));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
-
- @Override
- public AAIVersion getDefaultVersion() {
- return AAIVersion.LATEST;
- }
-
- @Override
- public String getAuth() {
- return props.getProperty("aai.auth", null);
- }
-
- @Override
- public String getKey() {
- return props.getProperty("mso.msoKey", null);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java
deleted file mode 100644
index ecbe97c637..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java
+++ /dev/null
@@ -1,334 +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.apihandlerinfra.tenantisolation;
-
-
-import java.util.HashMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestReferences;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.TenantSyncResponse;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/cloudResources")
-@Api(value="/cloudResources",description="API Requests for cloud resources - Tenant Isolation")
-public class CloudOrchestration {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private TenantIsolationRunnable tenantIsolation = null;
- private TenantIsolationRequest tenantIsolationRequest = null;
- private RequestsDatabase requestsDatabase = null;
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create an Operational Environment",response=Response.class)
- public Response createOperationEnvironment(String request, @PathParam("version") String version) {
- msoLogger.debug("Received request to Create Operational Environment");
- return cloudOrchestration(request, Action.create, null, version);
- }
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/activate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Activate an Operational Environment",response=Response.class)
- public Response activateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId) {
- msoLogger.debug("Received request to Activate an Operational Environment");
- HashMap<String, String> instanceIdMap = new HashMap<String,String>();
- instanceIdMap.put("operationalEnvironmentId", operationalEnvironmentId);
- return cloudOrchestration(request, Action.activate, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/deactivate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Deactivate an Operational Environment",response=Response.class)
- public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId) {
- msoLogger.debug("Received request to Deactivate an Operational Environment");
- HashMap<String, String> instanceIdMap = new HashMap<String,String>();
- instanceIdMap.put("operationalEnvironmentId", operationalEnvironmentId);
- return cloudOrchestration(request, Action.deactivate, instanceIdMap, version);
- }
-
-
- private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version) {
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- CloudOrchestrationRequest cor = null;
- Response response = null;
- getTenantIsolationRequest().setRequestId(requestId);
-
- try {
- cor = convertJsonToCloudOrchestrationRequest(requestJSON, action, startTime, cor);
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- getTenantIsolationRequest().parse(cor, instanceIdMap, action);
- } catch(Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- if (getTenantIsolationRequest().getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- }
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceName = cor.getRequestDetails().getRequestInfo().getInstanceName();
- String resourceType = cor.getRequestDetails().getRequestInfo().getResourceType().name();
- InfraActiveRequests dup = null;
- String messageAppend = null;
- try {
- dup = duplicateCheck(action, instanceIdMap, startTime, instanceName, resourceType);
-
- if(dup != null) {
- messageAppend = "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + ").";
- }
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- if(dup == null && (Action.activate.equals(action) || Action.deactivate.equals(action))) {
- dup = getRequestsDatabase().checkVnfIdStatus(cor.getOperationalEnvironmentId());
- if(dup != null) {
- messageAppend = "OperationalEnvironmentId is not COMPLETED.";
- }
- }
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if(dup != null) {
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(resourceType + "InstanceId");
- }
- String dupMessage = "Error: Locked instance - This " + resourceType + " (" + instance + ") " + messageAppend + " The existing request must finish or be cleaned up before proceeding.";
-
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
- MsoException.ServiceException,
- dupMessage,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
-
- msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, dupMessage);
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceId = null;
- try {
- if(instanceIdMap != null && instanceIdMap.get("operationalEnvironmentId") != null) {
- instanceId = instanceIdMap.get("operationalEnvironmentId");
- } else {
- instanceId = UUIDChecker.generateUUID(msoLogger);
- getTenantIsolationRequest().setOperationalEnvironmentId(instanceId);
- cor.setOperationalEnvironmentId(instanceId);
- }
-
- msoLogger.debug("Creating record in Request DB");
- getTenantIsolationRequest().createRequestRecord(Status.IN_PROGRESS, action);
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Exception while creating record in DB " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- OperationalEnvironment opEnv = cor.getRequestDetails().getRequestParameters().getOperationalEnvironmentType();
- String operationalEnvType = opEnv != null ? opEnv.name() : null;
-
- TenantIsolationRunnable runnable = getThread();
- runnable.setAction(action);
- runnable.setCor(cor);
- runnable.setOperationalEnvType(operationalEnvType);
- runnable.setRequestId(requestId);
-
- Thread thread = new Thread(runnable);
- thread.start();
- } catch(Exception e) {
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating a new Thread", "APIH", null, null);
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Failed creating a Thread " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- getTenantIsolationRequest().updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, "Exception while creating a new Thread");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Exception while creating a new Thread");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- String encodedValue = new String(instanceId.getBytes("UTF-8"));
- msoLogger.debug ("InstanceId: " + instanceId + " encoded to " + encodedValue);
-
- TenantSyncResponse tenantResponse = new TenantSyncResponse();
- RequestReferences reqReference = new RequestReferences();
- reqReference.setInstanceId(encodedValue);
- reqReference.setRequestId(requestId);
- tenantResponse.setRequestReferences(reqReference);
-
- response = Response.ok(tenantResponse).build();
-
- msoLogger.debug ("Successful Sync response " + response.getEntity() + " with status code " + response.getStatus());
-
- return response;
- } catch(Exception e) {
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while building sync response", "APIH", null, null);
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Failed sending Sync Response " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- getTenantIsolationRequest().updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, "Exception while sending sync Response");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Exception while sending sync Response");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
- }
-
- private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime,
- String instanceName, String requestScope) throws Exception {
- InfraActiveRequests dup = null;
- try {
- dup = getRequestsDatabase().checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
- throw new Exception(e);
- }
- return dup;
- }
-
- private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, long startTime,
- CloudOrchestrationRequest cor) throws Exception {
- CloudOrchestrationRequest new_cor = null;
- try{
- msoLogger.debug("Converting incoming JSON request to Object");
- ObjectMapper mapper = new ObjectMapper();
- new_cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- if (getTenantIsolationRequest().getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- throw new Exception(e);
- }
- return new_cor;
- }
-
- public TenantIsolationRequest getTenantIsolationRequest() {
- if(tenantIsolationRequest == null) {
- tenantIsolationRequest = new TenantIsolationRequest();
- }
- return tenantIsolationRequest;
- }
-
- public void setTenantIsolationRequest(TenantIsolationRequest tenantIsolationRequest) {
- this.tenantIsolationRequest = tenantIsolationRequest;
- }
-
- public RequestsDatabase getRequestsDatabase() {
- if(requestsDatabase == null) {
- requestsDatabase = RequestsDatabase.getInstance();
- }
- return requestsDatabase;
- }
-
- public void setRequestsDatabase(RequestsDatabase requestsDatabase) {
- this.requestsDatabase = requestsDatabase;
- }
-
- public TenantIsolationRunnable getThread() {
- if(tenantIsolation == null) {
- tenantIsolation = new TenantIsolationRunnable();
- }
- return tenantIsolation;
- }
-
- public void setThread(TenantIsolationRunnable thread) {
- this.tenantIsolation = thread;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java
deleted file mode 100644
index 5e6c1ecd60..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java
+++ /dev/null
@@ -1,81 +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.apihandlerinfra.tenantisolation;
-
-import java.io.Serializable;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class CloudOrchestrationRequest implements Serializable {
-
- private static final long serialVersionUID = -4959169541182257787L;
- @JsonProperty("requestDetails")
- private RequestDetails requestDetails;
- @JsonProperty("operationalEnvironmentId")
- private String operationalEnvironmentId;
- @JsonProperty("distribution")
- private Distribution distribution;
- @JsonProperty("distributionId")
- private String distributionId;
-
- public String getOperationalEnvironmentId() {
- return operationalEnvironmentId;
- }
-
- public void setOperationalEnvironmentId(String operationalEnvironmentId) {
- this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
- public RequestDetails getRequestDetails() {
- return requestDetails;
- }
-
- public void setRequestDetails(RequestDetails requestDetails){
- this.requestDetails = requestDetails;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- @Override
- public String toString() {
- return "ServiceInstancesRequest [requestDetails=" + requestDetails
- + ", operationalEnvironmentId=" + operationalEnvironmentId
- + ", distribution=" + distribution
- + ", distributionId=" + distributionId + "]";
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
deleted file mode 100644
index a580a483c2..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
+++ /dev/null
@@ -1,335 +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.apihandlerinfra.tenantisolation;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.http.HttpStatus;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.Messages;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.InstanceReferences;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Request;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestStatus;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/cloudResourcesRequests")
-@Api(value="/cloudResourcesRequests",description="API GET Requests for cloud resources - Tenant Isolation")
-public class CloudResourcesOrchestration {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private RequestsDatabase requestsDB = null;
-
- @POST
- @Path("/{version: [vV][1]}/{requestId}/unlock")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Unlock CloudOrchestration requests for a specified requestId")
- public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) {
- TenantIsolationRequest msoRequest = new TenantIsolationRequest(requestId);
- InfraActiveRequests requestDB = null;
- Request request = null;
- CloudOrchestrationRequest cor = null;
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try{
- msoRequest.parseOrchestration(cor);
- } catch (Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- requestDB = getRequestsDB().getRequestFromInfraActive(requestId);
-
- if(requestDB == null) {
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
-
- }else{
- request = mapInfraActiveRequestToRequest(requestDB);
- RequestStatus reqStatus = request.getRequestStatus();
- Status status = Status.valueOf(reqStatus.getRequestState());
- if(status == Status.IN_PROGRESS || status == Status.PENDING || status == Status.PENDING_MANUAL_TASK){
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED);
- reqStatus.setRequestState(Status.UNLOCKED.toString ());
- getRequestsDB().updateInfraStatus (requestId,
- Status.UNLOCKED.toString (),
- Constants.MODIFIED_BY_APIHANDLER);
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "RequestId " + requestId + " has been unlocked");
-
- }else{
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- }
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
-
- }
-
- return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build ();
- }
-
- @GET
- @Path("/{version:[vV][1]}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Get status of an Operational Environment based on filter criteria",response=Response.class)
- public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version ) {
- MsoLogger.setServiceName ("getOperationEnvironmentStatusFilter");
- UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
-
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- List<String> requestIdKey = queryParams.get("requestId");
-
- if(queryParams.size() == 1 && requestIdKey != null) {
- msoLogger.debug ("Entered requestId GET OperationalEnvironment Request");
- String requestId = requestIdKey.get(0);
-
- CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse();
- TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest (requestId);
- InfraActiveRequests requestDB = null;
-
- try {
- requestDB = getRequestsDB().getRequestFromInfraActive(requestId);
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- // TODO Will need to set Status for tenantIsolationRequest
- // tenantIsolationRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = tenantIsolationRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if(requestDB == null) {
- Response resp = tenantIsolationRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- Request request = mapInfraActiveRequestToRequest(requestDB);
- cloudOrchestrationGetResponse.setRequest(request);
- return Response.status(200).entity(cloudOrchestrationGetResponse).build();
-
- } else {
- msoLogger.debug ("Entered GET OperationalEnvironment filter Request");
- TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest ();
- List<InfraActiveRequests> activeRequests = null;
- CloudOrchestrationRequestList orchestrationList = null;
-
- try{
- Map<String, String> orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams);
- activeRequests = getRequestsDB().getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
- orchestrationList = new CloudOrchestrationRequestList();
- List<CloudOrchestrationResponse> requestLists = new ArrayList<CloudOrchestrationResponse>();
-
- for(InfraActiveRequests infraActive : activeRequests){
-
- Request request = mapInfraActiveRequestToRequest(infraActive);
- CloudOrchestrationResponse requestList = new CloudOrchestrationResponse();
- requestList.setRequest(request);
- requestLists.add(requestList);
- }
- orchestrationList.setRequestList(requestLists);
-
- }catch(Exception e){
- msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e);
- Response response = tenantIsolationRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- "Get CloudOrchestration Request with Filters Failed. " + e.getMessage(),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get CloudOrchestration Request with Filters Failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
- return Response.status(200).entity(orchestrationList).build();
- }
- }
-
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) {
- Request request = new Request();
- request.setRequestId(requestDB.getRequestId());
- request.setRequestScope(requestDB.getRequestScope());
- request.setRequestType(requestDB.getRequestAction());
-
- InstanceReferences ir = new InstanceReferences();
-
- if(requestDB.getOperationalEnvId() != null)
- ir.setOperationalEnvironmentId(requestDB.getOperationalEnvId());
- if(requestDB.getOperationalEnvName() != null)
- ir.setOperationalEnvName(requestDB.getOperationalEnvName());
- if(requestDB.getRequestorId() != null)
- ir.setRequestorId(requestDB.getRequestorId());
-
- request.setInstanceReferences(ir);
- String requestBody = requestDB.getRequestBody();
- RequestDetails requestDetails = null;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- requestDetails = mapper.readValue(requestBody, RequestDetails.class);
-
- }catch(Exception e){
- msoLogger.debug("Exception caught mapping requestBody to RequestDetails");
- }
-
- request.setRequestDetails(requestDetails);
- String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT";
- request.setStartTime(startTimeStamp);
-
- RequestStatus status = new RequestStatus();
- if(requestDB.getStatusMessage() != null){
- status.setStatusMessage(requestDB.getStatusMessage());
- }
-
- if(requestDB.getEndTime() != null){
- String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT";
- status.setTimeStamp(endTimeStamp);
- }
-
- if(requestDB.getRequestStatus() != null){
- status.setRequestState(requestDB.getRequestStatus());
- }
-
- if(requestDB.getProgress() != null){
- status.setPercentProgress(requestDB.getProgress().toString());
- }
-
- request.setRequestStatus(status);
-
- return request;
- }
-
- public RequestsDatabase getRequestsDB() {
- if(requestsDB == null) {
- requestsDB = RequestsDatabase.getInstance();
- }
- return requestsDB;
- }
-
- public void setRequestsDB(RequestsDatabase requestsDB) {
- this.requestsDB = requestsDB;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java
deleted file mode 100644
index fc6d1a551f..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java
+++ /dev/null
@@ -1,70 +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.apihandlerinfra.tenantisolation;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.ws.rs.core.MediaType;
-
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.grm.GRMProperties;
-import org.openecomp.mso.properties.MsoJavaProperties;
-
-public class GrmClientPropertiesImpl implements GRMProperties {
-
- final MsoJavaProperties props;
-
- public GrmClientPropertiesImpl() {
- this.props = MsoPropertiesUtils.loadMsoProperties ();
- }
-
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(props.getProperty("grm.endpoint", null));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
-
- @Override
- public String getDefaultVersion() {
- return "v1";
- }
-
- @Override
- public String getUsername() {
- return props.getProperty("grm.username", null);
- }
-
- @Override
- public String getPassword() {
- return props.getProperty("grm.password", null);
- }
-
- @Override
- public String getContentType() {
- return MediaType.APPLICATION_JSON;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java
deleted file mode 100644
index eb5306a155..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java
+++ /dev/null
@@ -1,160 +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.apihandlerinfra.tenantisolation;
-
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.ValidationException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpStatus;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Status;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.serviceinstancebeans.RequestError;
-import org.openecomp.mso.serviceinstancebeans.ServiceException;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-import com.wordnik.swagger.jaxrs.PATCH;
-
-@Path("/modelDistributions")
-@Api(value="/modelDistributions",description="API Requests for Model Distributions")
-public class ModelDistributionRequest {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private TenantIsolationRunnable tenantIsolation = null;
-
- @PATCH
- @Path("/{version:[vV][1]}/distributions/{distributionId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Update model distribution status",response=Response.class)
- public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, @PathParam("distributionId") String distributionId) {
- long startTime = System.currentTimeMillis ();
- Distribution distributionRequest = null;
-
- try {
- ObjectMapper mapper = new ObjectMapper();
- distributionRequest = mapper.readValue(requestJSON, Distribution.class);
- } catch(Exception e) {
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- parse(distributionRequest);
- } catch(Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- Response response = buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- CloudOrchestrationRequest cor = new CloudOrchestrationRequest();
- cor.setDistribution(distributionRequest);
- cor.setDistributionId(distributionId);
-
- TenantIsolationRunnable runnable = getThread();
- runnable.setAction(Action.distributionStatus);
- runnable.setCor(cor);
- runnable.setOperationalEnvType(null);
- runnable.setRequestId(null);
-
- Thread thread = new Thread(runnable);
- thread.start();
-
- return Response.ok().build();
- }
-
- private void parse(Distribution distributionRequest) throws ValidationException {
- if(distributionRequest.getStatus() == null) {
- throw new ValidationException("status");
- }
-
- if(StringUtils.isBlank(distributionRequest.getErrorReason()) && Status.DISTRIBUTION_COMPLETE_ERROR.equals(distributionRequest.getStatus())) {
- throw new ValidationException("errorReason");
- }
- }
-
- private Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, String text,
- String messageId, List<String> variables) {
- RequestError re = new RequestError();
- ServiceException se = new ServiceException();
- se.setMessageId(messageId);
- se.setText(text);
- if(variables != null){
- if(variables != null){
- for(String variable: variables){
- se.getVariables().add(variable);
- }
- }
- }
- re.setServiceException(se);
-
- String requestErrorStr = null;
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_DEFAULT);
- requestErrorStr = mapper.writeValueAsString(re);
- }catch(Exception e){
- msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
- }
-
- return Response.status (httpResponseCode).entity(requestErrorStr).build ();
- }
-
- public TenantIsolationRunnable getThread() {
- if(tenantIsolation == null) {
- tenantIsolation = new TenantIsolationRunnable();
- }
- return tenantIsolation;
- }
-
- public void setThread(TenantIsolationRunnable thread) {
- this.tenantIsolation = thread;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java
deleted file mode 100644
index e39c1d7ef1..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java
+++ /dev/null
@@ -1,54 +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.apihandlerinfra.tenantisolation;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.ActivateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.ActivateVnfStatusOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.CreateEcompOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.CreateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.OperationalEnvironmentProcess;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-
-public class OperationalEnvironmentProcessFactory {
-
- public OperationalEnvironmentProcess getOperationalEnvironmentProcess(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws Exception{
-
- if(Action.create.equals(action)) {
- if(OperationalEnvironment.ECOMP.name().equalsIgnoreCase(operationalEnvType)) {
- return new CreateEcompOperationalEnvironment(cor, requestId);
- } else if(OperationalEnvironment.VNF.name().equalsIgnoreCase(operationalEnvType)) {
- return new CreateVnfOperationalEnvironment(cor, requestId);
- } else {
- throw new Exception("Invalid OperationalEnvironment Type specified for Create Action");
- }
- } else if(Action.activate.equals(action)) {
- return new ActivateVnfOperationalEnvironment(cor, requestId);
- } else if(Action.deactivate.equals(action)) {
- return new DeactivateVnfOperationalEnvironment(cor, requestId);
- } else if(Action.distributionStatus.equals(action)) {
- return new ActivateVnfStatusOperationalEnvironment(cor, requestId);
- } else {
- throw new Exception("Invalid Action specified: " + action);
- }
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
deleted file mode 100644
index ce9d7b3a30..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
+++ /dev/null
@@ -1,476 +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.apihandlerinfra.tenantisolation;
-
-import java.sql.Timestamp;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.lang3.StringUtils;
-import org.hibernate.Session;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Manifest;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstance;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestInfo;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestParameters;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ResourceType;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType;
-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.RequestsDatabase;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
-import org.openecomp.mso.serviceinstancebeans.PolicyException;
-import org.openecomp.mso.serviceinstancebeans.RequestError;
-import org.openecomp.mso.serviceinstancebeans.ServiceException;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class TenantIsolationRequest {
-
- private String requestId;
- private String requestJSON;
- private RequestInfo requestInfo;
-
- private String errorMessage;
- private String errorCode;
- private String httpResponse;
- private String responseBody;
- private RequestStatusType status;
- private CloudOrchestrationRequest cor;
- private String operationalEnvironmentId;
- private long progress = Constants.PROGRESS_REQUEST_RECEIVED;
- private String requestScope;
-
-
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
-
- TenantIsolationRequest (String requestId) {
- this.requestId = requestId;
- MsoLogger.setLogContext (requestId, null);
- }
-
- TenantIsolationRequest () {
- MsoLogger.setLogContext (requestId, null);
- }
-
- void parse(CloudOrchestrationRequest request, HashMap<String,String> instanceIdMap, Action action) throws ValidationException {
- msoLogger.debug ("Validating the Cloud Orchestration request");
- this.cor = request;
- this.requestInfo = request.getRequestDetails().getRequestInfo();
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- requestJSON = mapper.writeValueAsString(request.getRequestDetails());
-
- } catch(Exception e){
- throw new ValidationException ("Parse ServiceInstanceRequest to JSON string");
- }
-
- String envId = null;
- if(instanceIdMap != null) {
- envId = instanceIdMap.get("operationalEnvironmentId");
- if(envId != null && !UUIDChecker.isValidUUID (envId)){
- throw new ValidationException ("operationalEnvironmentId");
- }
- cor.setOperationalEnvironmentId(envId);
- }
-
- this.operationalEnvironmentId = envId;
-
- RequestDetails requestDetails = request.getRequestDetails();
- RequestParameters requestParameters = requestDetails.getRequestParameters();
-
- requestInfoValidation(action, requestInfo);
-
- requestParamsValidation(action, requestParameters);
-
- relatedInstanceValidation(action, requestDetails, requestParameters);
-
- }
-
- private void relatedInstanceValidation(Action action, RequestDetails requestDetails, RequestParameters requestParameters) throws ValidationException {
- RelatedInstanceList[] instanceList = requestDetails.getRelatedInstanceList();
-
- if((Action.activate.equals(action) || Action.deactivate.equals(action)) && OperationalEnvironment.ECOMP.equals(requestParameters.getOperationalEnvironmentType())) {
- throw new ValidationException("operationalEnvironmentType in requestParameters");
- }
-
- if(!Action.deactivate.equals(action) && OperationalEnvironment.VNF.equals(requestParameters.getOperationalEnvironmentType())) {
- if(instanceList != null && instanceList.length > 0) {
- for(RelatedInstanceList relatedInstanceList : instanceList){
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
-
- if(relatedInstance.getResourceType() == null) {
- throw new ValidationException("ResourceType in relatedInstance");
- }
-
- if(!empty(relatedInstance.getInstanceName()) && !relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format");
- }
-
- if (empty (relatedInstance.getInstanceId ())) {
- throw new ValidationException ("instanceId in relatedInstance");
- }
-
- if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
- throw new ValidationException ("instanceId format in relatedInstance");
- }
- }
- } else {
- throw new ValidationException ("relatedInstanceList");
- }
- }
- }
-
- private void requestParamsValidation(Action action, RequestParameters requestParameters) throws ValidationException {
-
- if(requestParameters != null) {
- if(!Action.deactivate.equals(action) && requestParameters.getOperationalEnvironmentType() == null) {
- throw new ValidationException ("OperationalEnvironmentType");
- }
-
- if (Action.create.equals(action) && empty(requestParameters.getTenantContext())) {
- throw new ValidationException ("Tenant Context");
- }
- if (!Action.deactivate.equals(action) && empty(requestParameters.getWorkloadContext())) {
- throw new ValidationException ("Workload Context");
- }
-
- Manifest manifest = requestParameters.getManifest();
-
- if(Action.activate.equals(action)) {
- if(manifest == null) {
- throw new ValidationException ("Manifest on Activate");
- } else {
- List<ServiceModelList> serviceModelList = manifest.getServiceModelList();
-
- if(serviceModelList.size() == 0) {
- throw new ValidationException (" empty ServiceModelList");
- }
-
- for(ServiceModelList list : serviceModelList) {
- if(empty(list.getServiceModelVersionId())) {
- throw new ValidationException ("ServiceModelVersionId");
- }
-
- if (!UUIDChecker.isValidUUID (list.getServiceModelVersionId())) {
- throw new ValidationException ("ServiceModelVersionId format");
- }
-
- if(list.getRecoveryAction() == null) {
- throw new ValidationException ("RecoveryAction");
- }
- }
- }
- }
- } else if(!Action.deactivate.equals(action)) {
- throw new ValidationException("request Parameters");
- }
- }
-
- private void requestInfoValidation(Action action, RequestInfo requestInfo) throws ValidationException {
-
- if(Action.create.equals(action) && empty(requestInfo.getInstanceName())) {
- throw new ValidationException ("instanceName");
- }
-
- if(!empty(requestInfo.getInstanceName()) && !requestInfo.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format");
- }
-
- if (empty(requestInfo.getSource())) {
- throw new ValidationException ("source");
- }
-
- if(empty(requestInfo.getRequestorId())) {
- throw new ValidationException ("requestorId");
- }
-
- ResourceType resourceType = requestInfo.getResourceType();
- if(resourceType == null) {
- throw new ValidationException ("resourceType");
- }
-
- this.requestScope = resourceType.name();
- }
-
- void parseOrchestration (CloudOrchestrationRequest cor) throws ValidationException {
-
- msoLogger.debug ("Validating the Orchestration request");
-
- this.cor = cor;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- //mapper.configure(Feature.WRAP_ROOT_VALUE, true);
- requestJSON = mapper.writeValueAsString(cor.getRequestDetails());
-
- } catch(Exception e){
- throw new ValidationException ("Parse CloudOrchestrationRequest to JSON string", e);
- }
-
- this.requestInfo = cor.getRequestDetails().getRequestInfo();
-
- if (this.requestInfo == null) {
- throw new ValidationException ("requestInfo");
- }
-
- if (empty (requestInfo.getSource ())) {
- throw new ValidationException ("source");
- }
- if (empty (requestInfo.getRequestorId ())) {
- throw new ValidationException ("requestorId");
- }
- }
-
- public void createRequestRecord (Status status, Action action) {
- Session session = null;
- try {
-
- session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
- session.beginTransaction ();
-
- if (null == cor) {
- cor = new CloudOrchestrationRequest();
- }
-
- InfraActiveRequests aq = new InfraActiveRequests ();
- aq.setRequestId (requestId);
-
- aq.setRequestAction(action.name());
- aq.setAction(action.name());
-
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
-
- aq.setStartTime (startTimeStamp);
-
- if (requestInfo != null) {
-
- if(requestInfo.getSource() != null){
- aq.setSource(requestInfo.getSource());
- }
- if(requestInfo.getRequestorId() != null) {
- aq.setRequestorId(requestInfo.getRequestorId());
- }
- if(requestInfo.getResourceType() != null) {
- aq.setRequestScope(requestInfo.getResourceType().name());
- }
- }
-
- if(ResourceType.operationalEnvironment.name().equalsIgnoreCase(requestScope)) {
- aq.setOperationalEnvId(operationalEnvironmentId);
- aq.setOperationalEnvName(requestInfo.getInstanceName());
- }
-
- aq.setRequestBody (this.requestJSON);
-
- aq.setRequestStatus (status.toString ());
- aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
-
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (this.errorMessage);
- aq.setResponseBody (this.responseBody);
- aq.setProgress(new Long(100));
-
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- } else if(status == Status.IN_PROGRESS) {
- aq.setProgress(Constants.PROGRESS_REQUEST_IN_PROGRESS);
- }
-
- msoLogger.debug ("About to insert a record");
-
- session.save (aq);
- session.getTransaction ().commit ();
- session.close ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e);
- if (session != null) {
- session.close ();
- }
- if (!status.equals (Status.FAILED)) {
- throw e;
- }
- }
- }
-
-
- public Map<String, String> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException {
- String queryParam = null;
- Map<String, String> orchestrationFilterParams = new HashMap<String, String>();
-
- for (Entry<String,List<String>> entry : queryParams.entrySet()) {
- queryParam = entry.getKey();
- try{
- for(String value : entry.getValue()) {
- if(StringUtils.isBlank(value)) {
- throw new Exception(queryParam + " value");
- }
- orchestrationFilterParams.put(queryParam, value);
- }
- }catch(Exception e){
- throw new ValidationException (e.getMessage());
- }
- }
-
- return orchestrationFilterParams;
- }
-
- /**
- * Build Error Response for Exception handling.
- *
- * @param int
- * @param httpResponseCode the HTTP response code
- * @param exceptionType.
- * @param text the error description
- * @param messageId
- * @return the web service response
- *
- */
- public Response buildServiceErrorResponse (int httpResponseCode,
- MsoException exceptionType,
- String text,
- String messageId,
- List<String> variables) {
-
- this.errorCode = messageId;
-
- if (text != null) {
- this.errorMessage = text;
- }
- else {
- this.errorMessage = "";
- }
- this.httpResponse = Integer.toString(httpResponseCode);
- if(errorMessage.length() > 1999){
- errorMessage = errorMessage.substring(0, 1999);
- }
-
- RequestError re = new RequestError();
-
- if(exceptionType.name().equals("PolicyException")){
-
- PolicyException pe = new PolicyException();
- pe.setMessageId(messageId);
- pe.setText(text);
- if(variables != null){
- for(String variable: variables){
- pe.getVariables().add(variable);
- }
- }
- re.setPolicyException(pe);
-
- } else {
-
- ServiceException se = new ServiceException();
- se.setMessageId(messageId);
- se.setText(text);
- if(variables != null){
- if(variables != null){
- for(String variable: variables){
- se.getVariables().add(variable);
- }
- }
- }
- re.setServiceException(se);
- }
-
- String requestErrorStr = null;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_DEFAULT);
- requestErrorStr = mapper.writeValueAsString(re);
- }catch(Exception e){
- msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
- }
-
-
- return Response.status (httpResponseCode).entity(requestErrorStr).build ();
-
- }
-
- private static boolean empty(String s) {
- return (s == null || s.trim().isEmpty());
- }
-
- public String getRequestId () {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public void updateFinalStatus(Status failed) {
- try {
- (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
- status.toString (),
- this.errorMessage,
- this.progress,
- this.responseBody,
- Constants.MODIFIED_BY_APIHANDLER);
- } catch (Exception e) {
- msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
- msoLogger.debug ("Exception: ", e);
- }
- }
-
- public void setStatus (RequestStatusType status) {
- this.status = status;
- switch (status) {
- case FAILED:
- case COMPLETE:
- this.progress = Constants.PROGRESS_REQUEST_COMPLETED;
- break;
- case IN_PROGRESS:
- this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS;
- break;
- }
- }
-
- public String getOperationalEnvironmentId() {
- return operationalEnvironmentId;
- }
-
- public void setOperationalEnvironmentId(String operationalEnvironmentId) {
- this.operationalEnvironmentId = operationalEnvironmentId;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
deleted file mode 100644
index 167b88fbc8..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.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.apihandlerinfra.tenantisolation;
-
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.OperationalEnvironmentProcess;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public class TenantIsolationRunnable implements Runnable {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private OperationalEnvironmentProcessFactory factory = null;
- private Action action;
- private String operationalEnvType;
- private CloudOrchestrationRequest cor;
- private String requestId;
- protected RequestsDBHelper requestDb;
-
- @Override
- public void run() {
- msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType);
- try {
- OperationalEnvironmentProcess isolation = getFactory().getOperationalEnvironmentProcess(action, operationalEnvType, cor, requestId);
- isolation.execute();
- } catch(Exception e) {
- msoLogger.debug ("Exception during Thread initiation: ", e);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, null, e);
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, cor.getOperationalEnvironmentId());
- }
- }
-
- public Action getAction() {
- return action;
- }
-
- public void setAction(Action action) {
- this.action = action;
- }
-
- public String getOperationalEnvType() {
- return operationalEnvType;
- }
-
- public void setOperationalEnvType(String operationalEnvType) {
- this.operationalEnvType = operationalEnvType;
- }
-
- public CloudOrchestrationRequest getCor() {
- return cor;
- }
-
- public void setCor(CloudOrchestrationRequest cor) {
- this.cor = cor;
- }
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public OperationalEnvironmentProcessFactory getFactory() {
- if(factory == null) {
- factory = new OperationalEnvironmentProcessFactory();
- }
- return factory;
- }
-
- public void setFactory(OperationalEnvironmentProcessFactory factory) {
- this.factory = factory;
- }
-
- protected RequestsDBHelper getRequestDb() {
- if(requestDb == null) {
- requestDb = new RequestsDBHelper();
- }
- return requestDb;
- }
-
- protected void setRequestsDBHelper(RequestsDBHelper helper) {
- this.requestDb = helper;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
deleted file mode 100644
index 1f3457e6e0..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
+++ /dev/null
@@ -1,172 +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.apihandlerinfra.tenantisolation.dmaap;
-
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
-"operationalEnvironmentId",
-"operationalEnvironmentName",
-"operationalEnvironmentType",
-"tenantContext",
-"workloadContext"
-})
-
-public class CreateEcompOperationEnvironmentBean {
-
-@JsonProperty("operationalEnvironmentId")
-private String operationalEnvironmentId;
-@JsonProperty("operationalEnvironmentName")
-private String operationalEnvironmentName;
-@JsonProperty("operationalEnvironmentType")
-private String operationalEnvironmentType;
-@JsonProperty("tenantContext")
-private String tenantContext;
-@JsonProperty("workloadContext")
-private String workloadContext;
-@JsonProperty("action")
-private String action;
-
-
-/**
-* No args constructor for use in serialization
-*
-*/
-public CreateEcompOperationEnvironmentBean() {
- }
-
-/**
-*
-* @param operationalEnvironmentId
-* @param operationalEnvironmentName
-* @param operationalEnvironmentType
-* @param tenantContext
-* @param workloadContext
-*/
-public CreateEcompOperationEnvironmentBean(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String tenantContext, String workloadContext, String action) {
-super();
-this.operationalEnvironmentId = operationalEnvironmentId;
-this.operationalEnvironmentName = operationalEnvironmentName;
-this.operationalEnvironmentType = operationalEnvironmentType;
-this.tenantContext = tenantContext;
-this.workloadContext = workloadContext;
-this.action = action;
- }
-
-@JsonProperty("operationalEnvironmentId")
-public String getOperationalEnvironmentId() {
-return operationalEnvironmentId;
- }
-
-@JsonProperty("operationalEnvironmentId")
-public void setOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
-return this;
- }
-
-
-@JsonProperty("operationalEnvironmentName")
-public String getoperationalEnvironmentName() {
-return operationalEnvironmentName;
- }
-
-@JsonProperty("operationalEnvironmentName")
-public void setoperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
-return this;
- }
-
-@JsonProperty("operationalEnvironmentType")
-public String getoperationalEnvironmentType() {
-return operationalEnvironmentType;
- }
-
-@JsonProperty("operationalEnvironmentType")
-public void setoperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
-return this;
- }
-
-@JsonProperty("tenantContext")
-public String gettenantContext() {
-return tenantContext;
- }
-
-@JsonProperty("tenantContext")
-public void settenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
- }
-
-public CreateEcompOperationEnvironmentBean withTenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
-return this;
- }
-
-@JsonProperty("workloadContext")
-public String getworkloadContext() {
-return workloadContext;
- }
-
-@JsonProperty("workloadContext")
-public void setworkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
- }
-
-public CreateEcompOperationEnvironmentBean withWorkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
-return this;
- }
-
-
-@JsonProperty("action")
-public String getaction() {
-return action;
- }
-
-@JsonProperty("action")
-public void setaction(String action) {
-this.action = action;
- }
-
-public CreateEcompOperationEnvironmentBean withaction(String action) {
-this.action = action;
-return this;
- }
-
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
deleted file mode 100644
index 4d47acdd22..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
+++ /dev/null
@@ -1,67 +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.apihandlerinfra.tenantisolation.dmaap;
-
-import java.io.IOException;
-
-
-import org.openecomp.mso.client.dmaap.DmaapPublisher;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class DmaapOperationalEnvClient {
-
-
- protected String buildRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String tenantContext, String workloadContext, String action )
- throws JsonProcessingException {
- final CreateEcompOperationEnvironmentBean operationalEnv = new CreateEcompOperationEnvironmentBean();
- operationalEnv.withOperationalEnvironmentId(operationalEnvironmentId)
- .withOperationalEnvironmentName(operationalEnvironmentName)
- .withOperationalEnvironmentType(operationalEnvironmentType)
- .withTenantContext(tenantContext)
- .withWorkloadContext(workloadContext)
- .withaction(action);
-
- return this.getJson(operationalEnv);
-
- }
-
- protected String getJson(CreateEcompOperationEnvironmentBean obj) throws JsonProcessingException {
-
- final ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(obj);
-
- }
-
- protected DmaapPublisher getPublisher() throws IOException {
- return new OperationalEnvironmentPublisher();
- }
-
- public void dmaapPublishOperationalEnvRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType,
- String tenantContext, String workloadContext, String action ) throws Exception {
-
- String request = this.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType, tenantContext, workloadContext, action);
- final DmaapPublisher publisher = this.getPublisher();
- publisher.send(request);
-
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java
deleted file mode 100644
index 3ce4759577..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.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.apihandlerinfra.tenantisolation.dmaap;
-
-import java.util.Map;
-
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.dmaap.DmaapProperties;
-import org.openecomp.mso.properties.MsoJavaProperties;
-
-public class DmaapPropertiesImpl implements DmaapProperties {
-
- private final Map<String, String> props;
-
- public DmaapPropertiesImpl () {
-
- MsoJavaProperties properties = MsoPropertiesUtils.loadMsoProperties();
- this.props = properties.asMap();
- }
-
- @Override
- public Map<String, String> getProperties() {
-
- return this.props;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java
deleted file mode 100644
index 36c1085655..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java
+++ /dev/null
@@ -1,58 +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.apihandlerinfra.tenantisolation.dmaap;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Optional;
-
-import org.openecomp.mso.client.dmaap.DmaapPublisher;
-
-public class OperationalEnvironmentPublisher extends DmaapPublisher {
-
-
- public OperationalEnvironmentPublisher() throws FileNotFoundException, IOException {
- super();
- }
-
- @Override
- public String getUserName() {
-
- return this.msoProperties.get("so.operational-environment.dmaap.username");
- }
-
- @Override
- public String getPassword() {
-
- return this.msoProperties.get("so.operational-environment.dmaap.password");
- }
-
- @Override
- public String getTopic() {
-
- return this.msoProperties.get("so.operational-environment.publisher.topic");
- }
-
- @Override
- public Optional<String> getHost() {
- return Optional.ofNullable(this.msoProperties.get("so.operational-environment.dmaap.host"));
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java
deleted file mode 100644
index 993c7dc9b7..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.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.apihandlerinfra.tenantisolation.exceptions;
-
-public class AAIClientCallFailed extends Exception {
-
- public AAIClientCallFailed(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java
deleted file mode 100644
index 3e9009d2e3..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java
+++ /dev/null
@@ -1,34 +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.apihandlerinfra.tenantisolation.exceptions;
-
-public class AsdcClientCallFailed extends Exception {
-
- public AsdcClientCallFailed(String message, Throwable cause) {
- super(message, cause);
- }
-
- public AsdcClientCallFailed(String message) {
- super(message);
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java
deleted file mode 100644
index 279a93e1b7..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.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.apihandlerinfra.tenantisolation.exceptions;
-
-public class TenantIsolationException extends Exception {
-
- private static final long serialVersionUID = 6948152225371031774L;
-
- public TenantIsolationException() {
- super();
-
- }
-
- public TenantIsolationException(String msg) {
- super ("Tenant Isolation error: " + msg);
-
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
deleted file mode 100644
index c431da66ee..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
+++ /dev/null
@@ -1,145 +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.apihandlerinfra.tenantisolation.helpers;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Map;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
-import org.openecomp.mso.client.aai.AAIObjectType;
-import org.openecomp.mso.client.aai.AAIResourcesClient;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
-import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
-import org.openecomp.mso.client.aai.entities.uri.Depth;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class AAIClientHelper {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- public AAIClientHelper() {
- super();
- }
-
- public AAIClientHelper(String serviceName, String requestId) {
- super();
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext(requestId, "");
- }
-
- /**
- * Get managing ECOMP Environment Info from A&AI
- * @param id = operationalEnvironmentId
- * @return AAIResultWrapper object
- */
- public AAIResultWrapper getAaiOperationalEnvironment(String id) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
- uri.depth(Depth.ZERO); //Do not return relationships if any
- AAIResourcesClient aaiClient = this.getClient();
- AAIResultWrapper result = aaiClient.get(uri);
- return result;
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
-
- /**
- * Update managing ECOMP Environment Info from A&AI
- * @param id = operationalEnvironmentId
- * @param AAIOperationalEnvironment object
- */
- public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.update(uri, aaiRequest);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
-
- public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.update(uri, payload);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- /**
- * Create an Operational Environment object in A&AI
- * @param AAIOperationalEnvironment object
- */
- public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId());
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.create(uri, operationalEnvironment);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- /**
- * Create a relationship between ECOMP managing and VNF Operational Environments
- * @param managingEcompOperationalEnvironmentId
- * @param vnfOperationalEnvironmentId
- * @throws Exception
- */
- public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) throws Exception {
- try {
- AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, managingEcompOperationalEnvironmentId);
- AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.connect(vnfEnvUri, ecompEnvUri);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- private void logStackTrace(Exception e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- msoLogger.debug(sw.toString());
- }
-
- protected AAIResourcesClient getClient() {
- return new AAIResourcesClient();
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
deleted file mode 100644
index 58b78d7e8b..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
+++ /dev/null
@@ -1,78 +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.apihandlerinfra.tenantisolation.helpers;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-
-public class AAIClientObjectBuilder {
-
- private CloudOrchestrationRequest cloudOrchestrationRequest;
-
- public AAIClientObjectBuilder(CloudOrchestrationRequest request) {
- this.cloudOrchestrationRequest = request;
- }
-
- /**
- * Create an AAIOperationalEnvironment object.
- * @param environmentId
- * @param environmentName
- * @param environmentType
- * @param envrionmentStatus
- * @param tenantContext
- * @param workloadContext
- * @return
- * @throws JsonProcessingException
- */
- @Deprecated
- public static AAIOperationalEnvironment createAAIOperationalEnvironment(
- String environmentId,
- String environmentName,
- String environmentType,
- String envrionmentStatus,
- String tenantContext,
- String workloadContext) {
-
- AAIOperationalEnvironment oe = new AAIOperationalEnvironment();
- oe.setOperationalEnvironmentId(environmentId);
- oe.setOperationalEnvironmentName(environmentName);
- oe.setOperationalEnvironmentType(environmentType);
- oe.setOperationalEnvironmentStatus(envrionmentStatus);
- oe.setTenantContext(tenantContext);
- oe.setWorkloadContext(workloadContext);
-
- return oe;
- }
-
-
- public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status) {
- AAIOperationalEnvironment env = new AAIOperationalEnvironment();
- env.setOperationalEnvironmentId(this.cloudOrchestrationRequest.getOperationalEnvironmentId());
- env.setOperationalEnvironmentName(this.cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName());
- env.setOperationalEnvironmentType(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
- env.setOperationalEnvironmentStatus(status);
- env.setTenantContext(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getTenantContext());
- env.setWorkloadContext(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getWorkloadContext());
- return env;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java
deleted file mode 100644
index 2575013609..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java
+++ /dev/null
@@ -1,216 +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.apihandlerinfra.tenantisolation.helpers;
-
-import java.util.UUID;
-
-import javax.ws.rs.core.UriBuilder;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient;
-import org.openecomp.mso.rest.RESTConfig;
-
-public class AsdcClientHelper {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
-
- private JSONObject asdcResponseJsonObj;
-
- protected MsoJavaProperties properties;
-
- public static final String ASDC_CONTENT_TYPE = "application/json";
- public static final String ASDC_ACCEPT_TYPE = "application/json";
-
- protected String instanceid;
- protected String userid;
- protected String asdcEndpoint;
- protected String basicAuthCred;
- protected String uri;
-
- public static String PARTIAL_ASDC_URI = "/sdc/v1/catalog/services/";
-
- public AsdcClientHelper(MsoJavaProperties properties) {
- this.properties = properties;
- setAsdcProperties();
-
- };
-
- /**
- * properties should be set during instantiation of this object
- */
- private void setAsdcProperties() {
- String asdcClientAuth = this.properties.getProperty("mso.asdc.client.auth", null);
- String msoKey = this.properties.getProperty("mso.msoKey", null);
- this.basicAuthCred = this.properties.decrypt(asdcClientAuth, msoKey);
- this.asdcEndpoint = this.properties.getProperty("asdc.endpoint", null);
- this.userid = this.properties.getProperty("asdc.activate.userid", null);
- this.instanceid = this.properties.getProperty("asdc.activate.instanceid", null);
-
- }
-
- /**
- * Send POST request to ASDC for operational activation
- * @param uri - /sdc/v1/catalog/services/{serviceUUID}/distribution/{opEnvId}/activate
- * @param jsonPayload - json string value of 'workloadContext'.
- * @return JSONObject
- */
- public JSONObject postActivateOperationalEnvironment(String serviceModelVersionId, String operationalEnvironmentId, String workloadContext) {
-
- try {
-
- String url = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
- msoLogger.debug(" ASDC url : " + url);
- String jsonPayload = this.buildJsonWorkloadContext(workloadContext);
- msoLogger.debug(" ASDC jsonPayload : " + jsonPayload);
- asdcResponseJsonObj = new JSONObject();
-
- if ( basicAuthCred == null || "".equals(basicAuthCred) ) {
- String errorMessage = " ** ERROR: ASDC credentials 'mso.asdc.client.auth' not setup in properties file!";
- throw new AsdcClientCallFailed(errorMessage);
- }
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = setRestClient(config);
- client.addAuthorizationHeader(basicAuthCred);
-
- APIResponse apiResponse = setHttpPostResponse(client, jsonPayload);
- int statusCode = apiResponse.getStatusCode();
- msoLogger.debug(" ASDC return code : " + statusCode);
- String responseData = apiResponse.getResponseBodyAsString();
- msoLogger.debug(" ASDC responseData : " + responseData);
- asdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode);
-
- } catch (Exception ex) {
- msoLogger.debug("calling ASDC Exception message: " + ex.getMessage());
- String errorMessage = " Encountered Error while calling ASDC POST Activate. " + ex.getMessage();
- msoLogger.debug(errorMessage);
- asdcResponseJsonObj.put("statusCode", "500");
- asdcResponseJsonObj.put("messageId", "");
- asdcResponseJsonObj.put("message", errorMessage);
-
- }
- return asdcResponseJsonObj;
-
- }
-
- /**
- * set RESTClient
- * @return RestClient object
- */
- public RESTClient setRestClient(RESTConfig config) throws Exception {
-
- RESTClient client = new RESTClient(config).addHeader("X-ECOMP-InstanceID", instanceid)
- .addHeader("X-ECOMP-RequestID", UUID.randomUUID().toString())
- .addHeader("Content-Type", AsdcClientHelper.ASDC_CONTENT_TYPE)
- .addHeader("Accept", AsdcClientHelper.ASDC_ACCEPT_TYPE)
- .addHeader("USER_ID", userid);
- return client;
-
- }
-
- public APIResponse setHttpPostResponse(RESTClient client, String jsonPayload) throws Exception {
- return client.httpPost(jsonPayload);
-
- }
-
-
- public JSONObject enhanceJsonResponse(JSONObject asdcResponseJsonObj, int statusCode) {
-
- if (statusCode == 202) { // Accepted
- asdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
- asdcResponseJsonObj.put("messageId", "");
- asdcResponseJsonObj.put("message", "Success");
-
- } else { // error
- String message = "Undefined Error Message!";
- String messageId = "";
- if (asdcResponseJsonObj.has("requestError") ) {
- JSONObject requestErrorObj = asdcResponseJsonObj.getJSONObject("requestError");
- if (asdcResponseJsonObj.getJSONObject("requestError").has("serviceException") ) {
- message = requestErrorObj.getJSONObject("serviceException").getString("text");
- messageId = requestErrorObj.getJSONObject("serviceException").getString("messageId");
- }
- if (asdcResponseJsonObj.getJSONObject("requestError").has("policyException") ) {
- message = requestErrorObj.getJSONObject("policyException").getString("text");
- messageId = requestErrorObj.getJSONObject("policyException").getString("messageId");
- }
-
- }
- asdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
- asdcResponseJsonObj.put("messageId", messageId);
- asdcResponseJsonObj.put("message", message);
- }
-
- return asdcResponseJsonObj;
-
- }
-
- /**
- * Build Uri
- * @return String uri
- */
- public String buildUriBuilder(String serviceModelVersionId, String operationalEnvironmentId) {
- String path = serviceModelVersionId + "/distribution/" + operationalEnvironmentId +"/activate";
- UriBuilder uriBuilder = UriBuilder.fromPath(asdcEndpoint + AsdcClientHelper.PARTIAL_ASDC_URI)
- .path(path);
- return uriBuilder.build().toString();
- }
-
- /**
- * Build JSON context
- * @return String json
- */
- public String buildJsonWorkloadContext(String workloadContext) {
- return new JSONObject().put("workloadContext", workloadContext).toString();
-
- }
-
- /**
- * get asdc instanceId of this object
- */
- public String getAsdcInstanceId() {
- return this.instanceid;
- }
-
- /**
- * get asdc asdcEndpoint of this object
- */
- public String getAsdcEndpoint() {
- return this.asdcEndpoint;
- }
-
- /**
- * get asdc asdcUserId of this object
- */
- public String getAsdcUserId() {
- return this.userid;
- }
-
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
deleted file mode 100644
index 1bfe979f4f..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ /dev/null
@@ -1,286 +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.apihandlerinfra.tenantisolation.process;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-
-public class ActivateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "ActivateVnfOperationalEnvironment";
- private AsdcClientHelper asdcClientHelper = null;
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
- private String errorMessage = "";
-
- private String operationalEnvironmentId = "";
- private int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
- private boolean successIndicator = false;
-
- MsoJavaProperties properties;
- OperationalEnvDistributionStatusDb activateDistributionDb = null;
- OperationalEnvDistributionStatus queryDistributionDbResponse = null;
- OperationalEnvServiceModelStatusDb activateServiceModelDb = null;
- OperationalEnvServiceModelStatus queryServiceModelResponse = null;
-
- /**
- * The class constructor with loadProperties()
- * @param CloudOrchestrationRequest - object
- * @param requestId - string
- */
- public ActivateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- this.properties = MsoPropertiesUtils.loadMsoProperties();
- asdcClientHelper = new AsdcClientHelper(properties);
- }
-
- @Override
- protected String getServiceName() {
- return ActivateVnfOperationalEnvironment.SERVICE_NAME;
- }
-
- /**
- * The Point-Of-Entry from APIH with VID request to send activate request
- * @return void - nothing
- */
- @Override
- public void execute() {
-
- methodName = "execute() method. ";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- activateDistributionDb = getOperationalEnvDistributionStatusDb();
- activateServiceModelDb = getOperationalEnvServiceModelStatusDb();
-
- try {
-
- msoLogger.debug("Start of extracting variables from Input.");
- msoLogger.debug(" requestId: " + requestId);
- msoLogger.debug(" cloudOrchestrationRequest: " + request.toString());
- String operationalEnvironmentId = request.getOperationalEnvironmentId();
- this.operationalEnvironmentId = operationalEnvironmentId;
- msoLogger.debug(" operationalEnvironmentId: " + this.operationalEnvironmentId);
- String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
- List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
- msoLogger.debug(" serviceModelVersionIdList size(): " + serviceModelVersionIdList.size());
- msoLogger.debug("End of extracting variables from Input.");
-
- msoLogger.debug("Start of getting AAIOperationalEnvironment Object.");
- AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
- String workloadContext = operationalEnv.getWorkloadContext();
- msoLogger.debug(" aai workloadContext: " + workloadContext);
- if (vidWorkloadContext.equals(workloadContext)) {
- msoLogger.debug(" vid workloadContext matched with aai record, continue!");
- } else {
- errorMessage = " The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext;
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
- msoLogger.debug("End of getting AAIOperationalEnvironment Object.");
-
- msoLogger.debug("Start of sending activation request to ASDC.");
- processActivateASDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
- msoLogger.debug("End of sending activation request to ASDC.");
-
- msoLogger.debug("** OVERALL status of flow: Processed ALL " + serviceModelVersionIdList.size() + " activation requests are SUCCESSFUL!");
- successIndicator = true;
- msoLogger.debug("End of " + classMethodMessage);
-
- } catch (Exception ex) {
- errorMessage = "** OVERALL status of flow: " + methodName + ex.getMessage();
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
-
- }
-
- }
-
-
- /**
- * The Method to send the Activation Requests to ASDC
- * @param requestId - string
- * @param operationalEnvironmentId - string
- * @param List<ServiceModelList> serviceModelVersionIdList - list
- * @param workloadContext - string
- * @return void - nothing
- */
- public void processActivateASDCRequest(String requestId, String operationalEnvironmentId,
- List<ServiceModelList> serviceModelVersionIdList, String workloadContext) throws TenantIsolationException, AsdcClientCallFailed {
-
- int retryCount = 0;
- String retryCountString = properties.getProperty("mso.tenant.isolation.retry.count", null);
- try {
- retryCount = Integer.parseInt(retryCountString);
- msoLogger.debug(" ** Used Properties File retryCount: " + retryCount);
- } catch (NumberFormatException e) {
- retryCount = DEFAULT_ACTIVATE_RETRY_COUNT;
- msoLogger.debug(" ** Used Default retryCount: " + retryCount + " Exception: " + e.getMessage());
- }
-
- msoLogger.debug(" ** serviceModelVersionIdList: " + serviceModelVersionIdList.size());
-
- // loop through the serviceModelVersionId, and send request ASDC
- for(ServiceModelList serviceModelList : serviceModelVersionIdList){
- String serviceModelVersionId = serviceModelList.getServiceModelVersionId();
- String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase();
- msoLogger.debug(" ** serviceModelVersionId: " + serviceModelVersionId + "; recoveryAction: " + recoveryAction);
- // should insert 1 row
- activateServiceModelDb.insertOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, "SENT", recoveryAction, retryCount, workloadContext);
-
- JSONObject jsonResponse = null;
- String distributionId = "";
- try {
- jsonResponse = asdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
- msoLogger.debug(" JSONObject jsonResponse:" + jsonResponse.toString());
- String statusCode = jsonResponse.get("statusCode").toString();
- if (statusCode.equals("202")) {
- distributionId = jsonResponse.get("distributionId").toString();
-
- // should insert 1 row
- activateDistributionDb.insertOperationalEnvDistributionStatus(distributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", requestId);
-
- } else {
- errorMessage = " Failure calling ASDC: statusCode: " + statusCode +
- "; messageId: " + jsonResponse.get("messageId") +
- "; message: " + jsonResponse.get("message");
- msoLogger.debug(errorMessage);
- throw new AsdcClientCallFailed(errorMessage);
-
- }
-
- } catch (Exception ex) {
- errorMessage = " Encountered Exception in " + methodName + " Exception: " + ex.getMessage();
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
-
- }
-
- }
-
- /**
- * Get AAIOperationalEnvironment object
- * @param String operationalEnvironmentId
- * @return object AAIOperationalEnvironment
- */
- public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
-
- AAIOperationalEnvironment operationalEnv = null;
- getAaiHelper();
-
- try {
- AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
- operationalEnv = aaiResult.asBean(AAIOperationalEnvironment.class).get();
- } catch (JsonParseException e) {
- msoLogger.error(" **** JsonParseException: ", e);
- } catch (JsonMappingException e) {
- msoLogger.error(" **** JsonMappingException: ", e);
- } catch (IOException e) {
- msoLogger.error(" **** IOException: ", e);
- } catch (Exception e) {
- msoLogger.error(" **** Exception: ", e);
- }
-
- return operationalEnv;
-
- }
-
-
- /**
- * Overall Success indicator
- * @return true or false
- */
- public boolean isSuccess() {
- return successIndicator;
- }
-
- /**
- * Set to new OperationalEnvDistributionStatusDb
- * @return void
- */
- public void setOperationalEnvDistributionStatusDb (OperationalEnvDistributionStatusDb activateDistributionDb) {
- this.activateDistributionDb = activateDistributionDb;
- }
-
- /**
- * Set to new OperationalEnvServiceModelStatusDb
- * @return void
- */
- public void setOperationalEnvServiceModelStatusDb (OperationalEnvServiceModelStatusDb activateServiceModelDb) {
- this.activateServiceModelDb = activateServiceModelDb;
- }
-
- /**
- * Set to new AsdcClientHelper
- * @return void
- */
- public void setAsdcClientHelper (AsdcClientHelper asdcClientHelper) {
- this.asdcClientHelper = asdcClientHelper;
- }
-
- /**
- * get OperationalEnvDistributionStatusDb instance
- */
- public OperationalEnvDistributionStatusDb getOperationalEnvDistributionStatusDb() {
- if(this.activateDistributionDb == null) {
- this.activateDistributionDb = OperationalEnvDistributionStatusDb.getInstance();
- }
- return this.activateDistributionDb;
- }
-
- /**
- * get OperationalEnvServiceModelStatusDb instance
- */
- public OperationalEnvServiceModelStatusDb getOperationalEnvServiceModelStatusDb() {
- if(this.activateServiceModelDb == null) {
- this.activateServiceModelDb = OperationalEnvServiceModelStatusDb.getInstance();
- }
- return this.activateServiceModelDb;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
deleted file mode 100644
index 7ef0da61f5..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
+++ /dev/null
@@ -1,342 +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.apihandlerinfra.tenantisolation.process;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.DistributionStatus;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-
-
-public class ActivateVnfStatusOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "ActivateVnfStatusOperationalEnvironment";
- private AsdcClientHelper asdcClientHelper = null;
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
- private String errorMessage = "";
-
- private String operationalEnvironmentId = "";
- private boolean successIndicator = false;
-
- MsoJavaProperties properties;
- OperationalEnvDistributionStatusDb activateDistributionDb = null;
- OperationalEnvDistributionStatus queryDistributionDbResponse = null;
- OperationalEnvServiceModelStatusDb activateServiceModelDb = null;
- OperationalEnvServiceModelStatus queryServiceModelResponse = null;
-
- /**
- * The class constructor with loadProperties()
- * @param CloudOrchestrationRequest - object
- * @param requestId - string
- */
- public ActivateVnfStatusOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- this.properties = MsoPropertiesUtils.loadMsoProperties();
- asdcClientHelper = new AsdcClientHelper(properties);
- }
-
- @Override
- protected String getServiceName() {
- return ActivateVnfStatusOperationalEnvironment.SERVICE_NAME;
- }
-
-
- /**
- * The Point-Of-Entry from APIH with activate status from ASDC
- * @return void - nothing
- */
- @Override
- public void execute() {
-
- methodName = "execute() method. ";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- activateDistributionDb = getOperationalEnvDistributionStatusDb();
- activateServiceModelDb = getOperationalEnvServiceModelStatusDb();
-
- try {
-
- String asdcDistributionId = request.getDistributionId();
- Distribution distributionObject = request.getDistribution();
- msoLogger.debug(" ** asdcDistributionId: " + asdcDistributionId + ";" + " status: " + request.getDistribution().getStatus());
-
- // Distribution, Query for operationalEnvironmentId, serviceModelVersionId
- queryDistributionDbResponse = activateDistributionDb.getOperationalEnvDistributionStatus(asdcDistributionId);
-
- if(queryDistributionDbResponse == null) {
- throw new TenantIsolationException("DistributionId doesn't exist in the DB: " + asdcDistributionId);
- }
-
- String operationalEnvironmentId = queryDistributionDbResponse.getOperationalEnvId();
- this.operationalEnvironmentId = operationalEnvironmentId;
- String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId();
-
- // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString
- queryServiceModelResponse = activateServiceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId);
- String origRequestId = queryServiceModelResponse.getRequestId();
- this.requestId = origRequestId;
-
- msoLogger.debug("Start of processing activation status.");
- processActivateASDCStatus(asdcDistributionId, distributionObject);
- msoLogger.debug("End of processing activation status.");
-
- // After EVERY status processed, need to query the status of all service modelId
- // to determine the OVERALL status if "COMPLETE" or "FAILURE":
- checkOrUpdateOverallStatus(origRequestId, operationalEnvironmentId);
-
- msoLogger.debug("End of " + classMethodMessage);
-
- } catch (Exception ex) {
- errorMessage = "** OVERALL status of flow: " + methodName + ex.getMessage();
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
-
- }
-
- }
-
- /**
- * The Method to process the Activation Status from ASDC
- * @param asdcDistributionId - string
- * @param Distribution - object
- * @return void - nothing
- */
- public void processActivateASDCStatus(String asdcDistributionId, Distribution asdcStatus) throws TenantIsolationException {
-
- String operationalEnvironmentId = queryDistributionDbResponse.getOperationalEnvId();
- String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId();
-
- String origRequestId = queryServiceModelResponse.getRequestId();
- String recoveryAction = queryServiceModelResponse.getRecoveryAction();
- int retryCount = queryServiceModelResponse.getRetryCount();
- String workloadContext = queryServiceModelResponse.getWorkloadContext();
-
- // Validate/process status
- if (asdcStatus.getStatus().toString().equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString())) {
- // should update 1 row, update status to "DISTRIBUTION_COMPLETE_OK"
- activateDistributionDb.updateOperationalEnvDistributionStatus(asdcStatus.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
- // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!)
- activateServiceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, asdcStatus.getStatus().toString(), 0);
-
- } else {
-
- // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY"
- if (recoveryAction.equals("RETRY") & retryCount > 0) {
- // RESEND / RETRY serviceModelVersionId to ASDC
- JSONObject jsonResponse = null;
- String newDistributionId = "";
- try {
- jsonResponse = asdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
- String statusCode = jsonResponse.get("statusCode").toString();
- if (statusCode.equals("202")) {
- newDistributionId = jsonResponse.get("distributionId").toString();
-
- // should insert 1 row, NEW distributionId for old serviceModelServiceId
- activateDistributionDb.insertOperationalEnvDistributionStatus(newDistributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", origRequestId);
-
- // update retryCount (less 1) for the serviceModelServiceId
- retryCount = retryCount - 1;
- // should update 1 row, original insert
- activateServiceModelDb.updateOperationalEnvRetryCountStatusPerReqId(operationalEnvironmentId, serviceModelVersionId, asdcStatus.getStatus().toString(), retryCount, origRequestId);
-
- // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!).
- activateDistributionDb.updateOperationalEnvDistributionStatus(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
-
- } else {
- errorMessage = " Failure calling ASDC: statusCode: " + statusCode +
- "; messageId: " + jsonResponse.get("messageId") +
- "; message: " + jsonResponse.get("message");
- msoLogger.debug(errorMessage);
- throw new AsdcClientCallFailed(errorMessage);
-
- }
-
- } catch (Exception ex) {
- errorMessage = " Encountered Exception in " + methodName + " Exception: " + ex.getMessage();
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
-
-
- } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP'
-
- if (recoveryAction.equals("SKIP") || recoveryAction.equals("ABORT")) {
- String modifiedStatus = "";
- if (recoveryAction.equals("SKIP")) { // considered SUCCESS
- modifiedStatus = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString();
- } else {
- if (recoveryAction.equals("ABORT")) {
- modifiedStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); // ABORT, error
- }
- }
- // should update 1 row, modified status & retryCount set 0
- activateServiceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, modifiedStatus, 0);
- // should update 1 row, modified status
- activateDistributionDb.updateOperationalEnvDistributionStatus(modifiedStatus, asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
-
- } else {
- // RETRY & Count = 0 (do nothing!)
- }
- }
-
- }
-
- }
-
- /**
- * The Method to check the overall status of the Activation for an operationalEnvironmentId
- * @param origRequestId - string
- * @param operationalEnvironmentId - string
- * @return void - nothing
- * @throws Exception
- */
- public void checkOrUpdateOverallStatus(String origRequestId, String operationalEnvironmentId) throws Exception {
-
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = activateServiceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, origRequestId);
- msoLogger.debug(" **** queryServiceModelResponseList.size(): " + queryServiceModelResponseList.size());
-
- String status = "Waiting";
- int count = 0;
- // loop through the statuses of the service model
- for (OperationalEnvServiceModelStatus queryServiceModelResponse : queryServiceModelResponseList) {
- status = queryServiceModelResponse.getServiceModelVersionDistrStatus();
- // all should be OK to be completed.
- if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString()) &&
- (queryServiceModelResponse.getRetryCount() == 0))) {
- status = "Completed";
- count ++;
- }
- // one error with zero retry, means all are failures.
- if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString()) &&
- (queryServiceModelResponse.getRetryCount() == 0))) {
- status = "Failure";
- count = queryServiceModelResponseList.size();
- break;
- }
-
- }
-
- // "DISTRIBUTION_COMPLETE_OK" : Completed / Successful
- if (status == "Completed" && queryServiceModelResponseList.size() == count) {
- executeAAIPatch(operationalEnvironmentId);
- String messageStatus = "Overall Activation process is complete. " + status;
- successIndicator = true;
- msoLogger.debug(messageStatus);
- // Update DB to COMPLETION
- getRequestDb().updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId);
- } else {
- // "DISTRIBUTION_COMPLETE_ERROR" : Failure
- if (status == "Failure" && queryServiceModelResponseList.size() == count) {
- errorMessage = "Overall Activation process is a Failure. " + status;
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
- } else {
- msoLogger.debug(" **** Still waiting for more distribution status!"); // 1+ rows
- }
- }
-
- }
-
- private void executeAAIPatch(String operationalEnvironmentId) throws Exception {
- msoLogger.debug("Start of AA&I UPDATE client call in ActivateVnfStatusOperationalEnvironment");
-
- Map<String, String> payload = new HashMap<>();
- payload.put("operational-environment-status", "ACTIVE");
- getAaiHelper().updateAaiOperationalEnvironment(operationalEnvironmentId, payload);
-
- msoLogger.debug("End of AA&I UPDATE client call in ActivateVnfStatusOperationalEnvironment");
- }
-
- /**
- * Overall Success indicator
- * @return true or false
- */
- public boolean isSuccess() {
- return successIndicator;
- }
-
- /**
- * Set to new OperationalEnvDistributionStatusDb
- * @return void
- */
- public void setOperationalEnvDistributionStatusDb (OperationalEnvDistributionStatusDb activateDistributionDb) {
- this.activateDistributionDb = activateDistributionDb;
- }
-
- /**
- * Set to new OperationalEnvServiceModelStatusDb
- * @return void
- */
- public void setOperationalEnvServiceModelStatusDb (OperationalEnvServiceModelStatusDb activateServiceModelDb) {
- this.activateServiceModelDb = activateServiceModelDb;
- }
-
-
- /**
- * Set to new AsdcClientHelper
- * @return void
- */
- public void setAsdcClientHelper (AsdcClientHelper asdcClientHelper) {
- this.asdcClientHelper = asdcClientHelper;
- }
-
- /**
- * get OperationalEnvDistributionStatusDb instance
- */
- public OperationalEnvDistributionStatusDb getOperationalEnvDistributionStatusDb() {
- if(this.activateDistributionDb == null) {
- this.activateDistributionDb = OperationalEnvDistributionStatusDb.getInstance();
- }
- return this.activateDistributionDb;
- }
-
- /**
- * get OperationalEnvServiceModelStatusDb instance
- */
- public OperationalEnvServiceModelStatusDb getOperationalEnvServiceModelStatusDb() {
- if(this.activateServiceModelDb == null) {
- this.activateServiceModelDb = OperationalEnvServiceModelStatusDb.getInstance();
- }
- return this.activateServiceModelDb;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
deleted file mode 100644
index 3dd1b72ca6..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
+++ /dev/null
@@ -1,82 +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.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-
-public class CreateEcompOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "CreateEcompOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
-
-
- public CreateEcompOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
-
- protected DmaapOperationalEnvClient getDmaapClient() {
- return new DmaapOperationalEnvClient();
- }
-
-
- @Override
- public void execute() {
- try {
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
- msoLogger.debug("CloudOrchestrationRequest: " + request.toString());
-
- //Create ECOMP Managing Environment object in A&AI
- getAaiHelper().createOperationalEnvironment(getAaiClientObjectBuilder().buildAAIOperationalEnvironment("ACTIVE"));
- msoLogger.debug("ECOMP operational environment created in A&AI.");
-
- // Call client to publish to DMaap
- getDmaapClient().dmaapPublishOperationalEnvRequest(getRequest().getOperationalEnvironmentId(),
- getRequest().getRequestDetails().getRequestInfo().getInstanceName(),
- getRequest().getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString(),
- getRequest().getRequestDetails().getRequestParameters().getTenantContext(),
- getRequest().getRequestDetails().getRequestParameters().getWorkloadContext(),
- "Create");
- msoLogger.debug("ECOMP operational environment published in Dmaap/ASDC.");
-
- //Update request database
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- catch (Exception e) {
- msoLogger.error("exception while publishing operational environment", e);
- msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.UnknownError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- }
-
-
- @Override
- protected String getServiceName() {
- return CreateEcompOperationalEnvironment.SERVICE_NAME;
- }
-
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
deleted file mode 100644
index a235526887..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
+++ /dev/null
@@ -1,216 +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.apihandlerinfra.tenantisolation.process;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.client.grm.GRMClient;
-import org.openecomp.mso.client.grm.beans.OperationalInfo;
-import org.openecomp.mso.client.grm.beans.Property;
-import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
-import org.openecomp.mso.client.grm.beans.Version;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.apache.commons.lang3.StringUtils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class CreateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "CreateVnfOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private ObjectMapper mapper = new ObjectMapper();
- private GRMClient grmClient;
-
- public CreateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
-
- @Override
- public void execute() {
- try {
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
- //Retrieve ECOMP Managing environment info in A&AI
- AAIResultWrapper aaiResultWrapper = getAaiHelper().getAaiOperationalEnvironment(getEcompManagingEnvironmentId());
- AAIOperationalEnvironment aaiEnv = mapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class);
-
- //Find ECOMP environments in GRM
- msoLogger.debug(" Start of GRM findRunningServicesAsString");
- String searchKey = getSearchKey(aaiEnv);
- String tenantContext = getTenantContext().toUpperCase();
- String jsonResponse = getGRMClient().findRunningServicesAsString(searchKey, 1, tenantContext);
- ServiceEndPointList sel = getObjectMapper().readValue(jsonResponse, ServiceEndPointList.class);
- if(sel.getServiceEndPointList().size() == 0) {
- throw new TenantIsolationException("GRM did not find any matches for " + searchKey + " in " + tenantContext);
- }
- //Replicate end-point for VNF Operating environment in GRM
- List<ServiceEndPointRequest> serviceEndpointRequestList = buildEndPointRequestList(sel);
- int ctr = 0;
- int total = serviceEndpointRequestList.size();
- for(ServiceEndPointRequest request : serviceEndpointRequestList) {
- msoLogger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + request.getServiceEndPoint().getName());
- getGRMClient().addServiceEndPoint(request);
- }
-
- //Create VNF operating in A&AI
- getAaiHelper().createOperationalEnvironment(getAaiClientObjectBuilder().buildAAIOperationalEnvironment("INACTIVE"));
- getAaiHelper().createRelationship(getRequest().getOperationalEnvironmentId(), getEcompManagingEnvironmentId());
-
- //Update request database
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- catch(Exception e) {
- msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.DataError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, getRequest().getOperationalEnvironmentId());
- }
- }
-
-
- protected String getEcompManagingEnvironmentId() throws TenantIsolationException {
- RelatedInstanceList[] relatedInstances = getRequest().getRequestDetails().getRelatedInstanceList();
- if (relatedInstances.length > 0 && relatedInstances[0].getRelatedInstance() != null) {
- return relatedInstances[0].getRelatedInstance().getInstanceId();
- } else {
- throw new TenantIsolationException("Unable to get Managing ECOMP Environment ID, request related instance list is empty!");
- }
- }
-
-
- protected String getTenantContext() throws TenantIsolationException {
- if(!StringUtils.isEmpty(getRequest().getRequestDetails().getRequestParameters().getTenantContext())) {
- return getRequest().getRequestDetails().getRequestParameters().getTenantContext();
- }
- else {
- throw new TenantIsolationException("Tenant Context is missing from request!");
- }
- }
-
-
- private List<ServiceEndPointRequest> buildEndPointRequestList(ServiceEndPointList serviceEndPointList) throws TenantIsolationException {
- List<ServiceEndPoint> endpointList = serviceEndPointList.getServiceEndPointList();
- msoLogger.debug("Number of service endpoints from GRM: " + endpointList.size());
- List<ServiceEndPointRequest> serviceEndPointRequestList = new ArrayList<ServiceEndPointRequest>();
- for(ServiceEndPoint serviceEndpoint : endpointList) {
- serviceEndPointRequestList.add(buildServiceEndpoint(serviceEndpoint));
- }
- return serviceEndPointRequestList;
- }
-
-
- private ServiceEndPointRequest buildServiceEndpoint(ServiceEndPoint serviceEndpoint) throws TenantIsolationException {
-
- //@TODO: handle nulls? Put in a ServiceEndpointWrapper class which will check for nulls and flatten access to fields
- Version ver = new Version();
- ver.setMajor(serviceEndpoint.getVersion().getMajor());
- ver.setMinor(serviceEndpoint.getVersion().getMinor());
- ver.setPatch(serviceEndpoint.getVersion().getPatch());
-
- ServiceEndPoint endpoint = new ServiceEndPoint();
- endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName()));
-
- endpoint.setVersion(ver);
- endpoint.setHostAddress(serviceEndpoint.getHostAddress());
- endpoint.setListenPort(serviceEndpoint.getListenPort());
- endpoint.setLatitude(serviceEndpoint.getLatitude());
- endpoint.setLongitude(serviceEndpoint.getLongitude());
- endpoint.setContextPath(serviceEndpoint.getContextPath());
- endpoint.setRouteOffer(serviceEndpoint.getRouteOffer());
-
- OperationalInfo operInfo = new OperationalInfo();
- operInfo.setCreatedBy(serviceEndpoint.getOperationalInfo().getCreatedBy());
- operInfo.setUpdatedBy(serviceEndpoint.getOperationalInfo().getUpdatedBy());
-
- endpoint.setOperationalInfo(operInfo);
- endpoint.setProperties(serviceEndpoint.getProperties());
-
- String env = getEnvironmentName(serviceEndpoint.getProperties());
-
- ServiceEndPointRequest serviceEndPontRequest = new ServiceEndPointRequest();
- serviceEndPontRequest.setEnv(env);
- serviceEndPontRequest.setServiceEndPoint(endpoint);
-
- return serviceEndPontRequest;
- }
-
-
- protected String getEnvironmentName(List<Property> props) {
- String env = "";
- for(Property prop : props) {
- if(prop.getName().equalsIgnoreCase("Environment")) {
- env = prop.getValue();
- }
- }
- return env;
- }
-
-
- protected String buildServiceNameForVnf(String fqName) throws TenantIsolationException {
- // Service name format is: {tenantContext}.{workloadContext}.{serviceName} e.g. TEST.ECOMP_PSL.Inventory
- // We need to extract the serviceName, in the above example: "Inventory"
- String[] tokens = fqName.split("[.]");
- String serviceName;
- if(tokens.length > 0) {
- serviceName = tokens[tokens.length-1];
- }
- else {
- throw new TenantIsolationException("Fully qualified service name is null.");
- }
- String tenantContext = getRequest().getRequestDetails().getRequestParameters().getTenantContext();
- String workloadContext = getRequest().getRequestDetails().getRequestParameters().getWorkloadContext();
- return tenantContext + "." + workloadContext + "." + serviceName;
- }
-
-
- protected GRMClient getGRMClient() {
- if(this.grmClient == null) {
- this.grmClient = new GRMClient();
- }
- return this.grmClient;
- }
-
-
- protected String getSearchKey(AAIOperationalEnvironment aaiEnv) {
- return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*";
- }
-
- protected ObjectMapper getObjectMapper() {
- return mapper;
- }
-
-
- @Override
- protected String getServiceName() {
- return CreateVnfOperationalEnvironment.SERVICE_NAME;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
deleted file mode 100644
index b419a0ccd0..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
+++ /dev/null
@@ -1,92 +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.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class DeactivateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "DeactivateVnfOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getName();
-
- public DeactivateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
- @Override
- public void execute() {
- String methodName = "deactivateOperationalEnvironment() method.";
- String classMethodMessage = className + " " + methodName;
-
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
-
- String operationalEnvironmentId = getRequest().getOperationalEnvironmentId();
- msoLogger.debug("Deactivate OperationalEnvironment on " + operationalEnvironmentId);
- try {
- msoLogger.debug("Start of AA&I Get client call in " + classMethodMessage);
-
- AAIResultWrapper aaiResult = getAaiHelper().getAaiOperationalEnvironment(operationalEnvironmentId);
- AAIOperationalEnvironment aaiOpEnv = aaiResult.asBean(AAIOperationalEnvironment.class).get();
- String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus();
-
- msoLogger.debug("OperationalEnvironmentStatus is :" + operationalEnvironmentStatus);
- msoLogger.debug(" End of AA&I Get client call in " + classMethodMessage);
-
- if(operationalEnvironmentStatus == null) {
- String error = "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId;
- throw new TenantIsolationException(error);
- }
-
- if(operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) {
- msoLogger.debug("Start of AA&I UPDATE client call in " + classMethodMessage);
-
- aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE");
- getAaiHelper().updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv);
-
- msoLogger.debug(" End of AA&I UPDATE client call in " + classMethodMessage);
- } else if(!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) {
- String error = "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId;
- throw new TenantIsolationException(error);
- }
-
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, operationalEnvironmentId);
-
- } catch(Exception e) {
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.DataError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, operationalEnvironmentId);
- }
-
- msoLogger.debug("End of " + classMethodMessage);
- }
-
- @Override
- protected String getServiceName() {
- return DeactivateVnfOperationalEnvironment.SERVICE_NAME;
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java
deleted file mode 100644
index 9c2d443215..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java
+++ /dev/null
@@ -1,78 +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.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public abstract class OperationalEnvironmentProcess {
-
- protected String requestId;
- protected CloudOrchestrationRequest request;
- protected AAIClientObjectBuilder aaiClientObjectBuilder;
- protected AAIClientHelper aaiHelper;
- protected RequestsDBHelper requestDb;
-
- public OperationalEnvironmentProcess(CloudOrchestrationRequest request, String requestId) {
- this.requestId = requestId;
- this.request = request;
- this.aaiClientObjectBuilder = new AAIClientObjectBuilder(getRequest());
- }
-
- protected String getRequestId() {
- return this.requestId;
- }
-
- protected CloudOrchestrationRequest getRequest() {
- return this.request;
- }
-
- protected AAIClientHelper getAaiHelper() {
- if(this.aaiHelper == null) {
- this.aaiHelper = new AAIClientHelper(getServiceName(), getRequestId());
- }
- return this.aaiHelper;
- }
-
- protected void setAaiHelper(AAIClientHelper helper) {
- this.aaiHelper = helper;
- }
-
- protected AAIClientObjectBuilder getAaiClientObjectBuilder() {
- return this.aaiClientObjectBuilder;
- }
-
- protected RequestsDBHelper getRequestDb() {
- if(requestDb == null) {
- requestDb = new RequestsDBHelper();
- }
- return requestDb;
- }
-
- protected void setRequestsDBHelper(RequestsDBHelper helper) {
- this.requestDb = helper;
- }
-
- protected abstract String getServiceName();
- public abstract void execute();
-}