use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class ActivateVnfOperationalEnvironment method processActivateSDCRequest.
/**
* The Method to send the Activation Requests to SDC
*
* @param requestId - String
* @param operationalEnvironmentId - String
* @param serviceModelVersionIdList - List<ServiceModelList> list
* @param workloadContext - String
* @return jsonResponse - JSONObject object
*/
public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, List<ServiceModelList> serviceModelVersionIdList, String workloadContext, String vnfOperationalEnvironmentId) throws ApiException {
JSONObject jsonResponse = null;
int retryCount = 0;
try {
retryCount = Integer.parseInt(sdcRetryCount);
} catch (NumberFormatException e) {
retryCount = DEFAULT_ACTIVATE_RETRY_COUNT;
}
// loop through the serviceModelVersionId, and send request SDC
for (ServiceModelList serviceModelList : serviceModelVersionIdList) {
String serviceModelVersionId = serviceModelList.getServiceModelVersionId();
String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase();
// should insert 1 row
OperationalEnvServiceModelStatus serviceModelStatus = dbHelper.insertRecordToOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, DISTRIBUTION_STATUS_SENT, recoveryAction, retryCount, workloadContext, vnfOperationalEnvironmentId);
client.save(serviceModelStatus);
String distributionId = "";
jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
String statusCode = jsonResponse.get("statusCode").toString();
if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) {
distributionId = jsonResponse.get("distributionId").toString();
// should insert 1 row
OperationalEnvDistributionStatus distStatus = dbHelper.insertRecordToOperationalEnvDistributionStatus(distributionId, operationalEnvironmentId, serviceModelVersionId, requestId, DISTRIBUTION_STATUS_SENT, "");
client.save(distStatus);
} else {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
String dbErrorMessage = " Failure calling SDC: statusCode: " + statusCode + "; messageId: " + jsonResponse.get("messageId") + "; message: " + jsonResponse.get("message");
requestDb.updateInfraFailureCompletion(dbErrorMessage, requestId, operationalEnvironmentId);
throw new ValidateException.Builder(dbErrorMessage, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
}
}
use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class DeactivateVnfOperationalEnvironment method execute.
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
String operationalEnvironmentId = request.getOperationalEnvironmentId();
OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
if (aaiOpEnv != null) {
String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus();
if (StringUtils.isBlank(operationalEnvironmentStatus)) {
String error = "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId;
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build();
throw new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
if (operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) {
aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE");
aaiHelper.updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv);
} else if (!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) {
String error = "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId;
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build();
ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
requestDb.updateInfraFailureCompletion(error, requestId, operationalEnvironmentId);
throw validateException;
}
requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, operationalEnvironmentId);
}
}
Aggregations