aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java290
-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
6 files changed, 1100 insertions, 0 deletions
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
new file mode 100644
index 0000000000..24111c43c2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -0,0 +1,290 @@
+/*-
+ * ============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.debug(" **** JsonParseException: " + e.getMessage());
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ msoLogger.debug(" **** JsonMappingException: " + e.getMessage());
+ e.printStackTrace();
+ } catch (IOException e) {
+ msoLogger.debug(" **** IOException: " + e.getMessage());
+ e.printStackTrace();
+ } catch (Exception e) {
+ msoLogger.debug(" **** Exception: " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ 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
new file mode 100644
index 0000000000..7ef0da61f5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
@@ -0,0 +1,342 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..1ce3c5e06d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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) {
+ e.printStackTrace();
+ 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
new file mode 100644
index 0000000000..a235526887
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
@@ -0,0 +1,216 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..b419a0ccd0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
@@ -0,0 +1,92 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..9c2d443215
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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();
+}