Search in sources :

Example 51 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class E2EServiceInstances method mapReqJsonToSvcInstReq.

/**
 * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and passing it to camunda engine.
 *
 * @param e2eSir
 * @return
 */
private ServiceInstancesRequest mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    ModelInfo modelInfo = new ModelInfo();
    // ModelInvariantId
    modelInfo.setModelInvariantId(e2eSir.getService().getServiceInvariantUuid());
    // modelNameVersionId
    modelInfo.setModelNameVersionId(e2eSir.getService().getServiceUuid());
    // String modelInfoValue =
    // e2eSir.getService().getParameters().getNodeTemplateName();
    // String[] arrayOfInfo = modelInfoValue.split(":");
    // String modelName = arrayOfInfo[0];
    // String modelVersion = arrayOfInfo[1];
    // TODO: To ensure, if we dont get the values from the UUI
    String modelName = "voLTE";
    String modelVersion = "1.0";
    // modelName
    modelInfo.setModelName(modelName);
    // modelVersion
    modelInfo.setModelVersion(modelVersion);
    // modelType
    modelInfo.setModelType(ModelType.service);
    // setting modelInfo to requestDetails
    requestDetails.setModelInfo(modelInfo);
    SubscriberInfo subscriberInfo = new SubscriberInfo();
    // globalsubscriberId
    subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getGlobalSubscriberId());
    // setting subscriberInfo to requestDetails
    requestDetails.setSubscriberInfo(subscriberInfo);
    RequestInfo requestInfo = new RequestInfo();
    // instanceName
    requestInfo.setInstanceName(e2eSir.getService().getName());
    // source
    requestInfo.setSource("UUI");
    // suppressRollback
    requestInfo.setSuppressRollback(true);
    // setting requestInfo to requestDetails
    requestDetails.setRequestInfo(requestInfo);
    RequestParameters requestParameters = new RequestParameters();
    // subscriptionServiceType
    requestParameters.setSubscriptionServiceType("MOG");
    List<Map<String, Object>> userParamList = new ArrayList<>();
    Map<String, Object> userParamMap = new HashMap<>();
    // complete json request updated in the camunda
    userParamMap.put("UUIRequest", requestJSON);
    userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
    userParamList.add(userParamMap);
    requestParameters.setUserParams(userParamList);
    // setting requestParameters to requestDetails
    requestDetails.setRequestParameters(requestParameters);
    sir.setRequestDetails(requestDetails);
    return sir;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) JSONObject(org.json.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo)

Example 52 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class InstanceManagement method processCustomWorkflowRequest.

private Response processCustomWorkflowRequest(final String requestJSON, final Actions action, final Map<String, String> instanceIdMap, final String version, final String requestId, final ContainerRequestContext requestContext, final boolean aLaCarte) throws ApiException {
    String pnfName = null;
    String vnfType = null;
    String workflowUuid = null;
    String vnfInstanceId = null;
    String svcInstanceId = null;
    final String apiVersion = version.substring(1);
    if (instanceIdMap != null && !instanceIdMap.isEmpty()) {
        pnfName = instanceIdMap.get("pnfName");
        workflowUuid = instanceIdMap.get("workflowUuid");
        vnfInstanceId = instanceIdMap.get("vnfInstanceId");
        svcInstanceId = instanceIdMap.get("serviceInstanceId");
    }
    final String requestUri = requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX);
    final ServiceInstancesRequest svcInsReq = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri);
    final String requestScope = requestHandlerUtils.deriveRequestScope(action, svcInsReq, requestUri);
    InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(svcInsReq, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
    try {
        requestHandlerUtils.validateHeaders(requestContext);
    } catch (ValidationException e) {
        LOG.error("Exception occurred", e);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
        requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
        throw validateException;
    }
    requestHandlerUtils.parseRequest(svcInsReq, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
    requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
    if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) {
        vnfType = msoRequest.getVnfType(svcInsReq, requestScope);
        currentActiveReq.setVnfType(vnfType);
    }
    checkDuplicateAndBuildError(action, instanceIdMap, requestScope, currentActiveReq);
    final RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid);
    currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid);
    saveCurrentActiveRequest(currentActiveReq);
    RequestClientParameter requestClientParameter;
    try {
        requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()).setServiceInstanceId(svcInstanceId).setVnfId(vnfInstanceId).setVnfType(vnfType).setPnfCorrelationId(pnfName).setApiVersion(apiVersion).setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)).setALaCarte(aLaCarte).setRequestUri(requestUri).build();
    } catch (IOException e) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
    }
    return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ValidationException(org.onap.so.exceptions.ValidationException) IOException(java.io.IOException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestClientParameter(org.onap.so.apihandler.common.RequestClientParameter) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)

Example 53 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class OrchestrationRequests method unlockOrchestrationRequest.

@POST
@Path("/{version: [vV][4-7]}/{requestId}/unlock")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Unlock Orchestrated Requests for a given requestId", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Transactional
public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException {
    logger.debug("requestId is: {}", requestId);
    ServiceInstancesRequest sir;
    try {
        ObjectMapper mapper = new ObjectMapper();
        sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
    } catch (IOException e) {
        logger.error("Exception occurred", e);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
        ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
        throw validateException;
    }
    try {
        msoRequest.parseOrchestration(sir);
    } catch (Exception e) {
        logger.error("Exception occurred", e);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
        ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
        throw validateException;
    }
    InfraActiveRequests infraActiveRequest = infraActiveRequestLookup(requestId);
    String status = infraActiveRequest.getRequestStatus();
    if (Status.IN_PROGRESS.toString().equalsIgnoreCase(status) || Status.PENDING.toString().equalsIgnoreCase(status) || Status.PENDING_MANUAL_TASK.toString().equalsIgnoreCase(status)) {
        infraActiveRequest.setRequestStatus(Status.UNLOCKED.toString());
        infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
        infraActiveRequest.setRequestId(requestId);
        requestsDbClient.save(infraActiveRequest);
    } else {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).build();
        ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
        throw validateException;
    }
    return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build();
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) IOException(java.io.IOException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) IOException(java.io.IOException) ValidationException(org.onap.so.exceptions.ValidationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Example 54 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ServiceInstances method configurationRecipeLookup.

private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
    String serviceInstanceId;
    Boolean aLaCarte = null;
    String apiVersion = version.substring(1);
    ServiceInstancesRequest sir;
    sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri);
    String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
    InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
    if (sir.getRequestDetails().getRequestParameters() != null) {
        aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
    }
    requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
    requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
    String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
    requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, instanceName);
    ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
    RequestReferences referencesResponse = new RequestReferences();
    referencesResponse.setRequestId(requestId);
    serviceResponse.setRequestReferences(referencesResponse);
    String orchestrationUri = env.getProperty(CommonConstants.ALACARTE_ORCHESTRATION);
    String timeOut = env.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT);
    if (StringUtils.isBlank(orchestrationUri) || StringUtils.isBlank(timeOut)) {
        String error = StringUtils.isBlank(orchestrationUri) ? "ALaCarte Orchestration URI not found in properties" : "ALaCarte Recipe Timeout not found in properties";
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
        requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
        throw validateException;
    }
    serviceInstanceId = "";
    String configurationId = "";
    String pnfCorrelationId = "";
    if (sir.getServiceInstanceId() != null) {
        serviceInstanceId = sir.getServiceInstanceId();
    }
    if (sir.getConfigurationId() != null) {
        configurationId = sir.getConfigurationId();
    }
    pnfCorrelationId = getPnfCorrelationId(sir);
    try {
        infraActiveRequestsClient.save(currentActiveReq);
    } catch (Exception e) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
    }
    if (!requestScope.equalsIgnoreCase(ModelType.service.name())) {
        aLaCarte = true;
    } else if (aLaCarte == null) {
        aLaCarte = false;
    }
    RequestClientParameter requestClientParameter = null;
    try {
        requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false).setRecipeTimeout(Integer.parseInt(timeOut)).setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfCorrelationId).setConfigurationId(configurationId).setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)).setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).build();
    } catch (IOException e) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
    }
    return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) BpmnRequestBuilder(org.onap.so.apihandlerinfra.infra.rest.BpmnRequestBuilder) IOException(java.io.IOException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) RequestDbFailureException(org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException) IOException(java.io.IOException) CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException) RequestClientParameter(org.onap.so.apihandler.common.RequestClientParameter) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences)

Example 55 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ServiceInstances method serviceInstances.

public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, HashMap<String, String> queryParams) throws ApiException {
    String serviceInstanceId;
    Boolean aLaCarte = null;
    ServiceInstancesRequest sir;
    String apiVersion = version.substring(1);
    sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri);
    action = handleReplaceInstance(action, sir);
    String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
    try {
        requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action);
    } catch (ApiException e) {
        msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, requestJSON, requestHandlerUtils.getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null), sir);
        throw e;
    }
    InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
    if (sir.getRequestDetails().getRequestParameters() != null) {
        aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
    }
    requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
    if ((action == Action.replaceInstance || action == Action.replaceInstanceRetainAssignments) && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString())) && sir.getRequestDetails().getCloudConfiguration() == null) {
        CloudConfiguration cloudConfiguration = getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveReq);
        sir.getRequestDetails().setCloudConfiguration(cloudConfiguration);
        setCloudConfigurationCurrentActiveRequest(cloudConfiguration, currentActiveReq);
    }
    requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
    String instanceName = null;
    if (sir.getRequestDetails().getRequestInfo() != null) {
        instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
    }
    boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir);
    String vnfType = msoRequest.getVnfType(sir, requestScope);
    String networkType = msoRequest.getNetworkType(sir, requestScope);
    String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir);
    String vfModuleType = msoRequest.getVfModuleType(sir, requestScope);
    if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) {
        currentActiveReq.setVnfType(vnfType);
    } else if (requestScope.equalsIgnoreCase(ModelType.network.name()) && networkType != null) {
        currentActiveReq.setNetworkType(networkType);
    }
    requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, instanceName);
    ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
    RequestReferences referencesResponse = new RequestReferences();
    referencesResponse.setRequestId(requestId);
    serviceResponse.setRequestReferences(referencesResponse);
    RecipeLookupResult recipeLookupResult = requestHandlerUtils.getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
    String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag);
    ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
    ModelType modelType = requestHandlerUtils.getModelType(action, modelInfo);
    Boolean isBaseVfModule = false;
    if (modelType.equals(ModelType.vfModule)) {
        isBaseVfModule = requestHandlerUtils.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, currentActiveReq);
    }
    serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
    String vnfId = "";
    String vfModuleId = "";
    String volumeGroupId = "";
    String networkId = "";
    String pnfCorrelationId = "";
    String instanceGroupId = null;
    if (sir.getVnfInstanceId() != null) {
        vnfId = sir.getVnfInstanceId();
    }
    if (sir.getVfModuleInstanceId() != null) {
        vfModuleId = sir.getVfModuleInstanceId();
    }
    if (sir.getVolumeGroupInstanceId() != null) {
        volumeGroupId = sir.getVolumeGroupInstanceId();
    }
    if (sir.getNetworkInstanceId() != null) {
        networkId = sir.getNetworkInstanceId();
    }
    if (sir.getInstanceGroupId() != null) {
        instanceGroupId = sir.getInstanceGroupId();
    }
    pnfCorrelationId = getPnfCorrelationId(sir);
    try {
        infraActiveRequestsClient.save(currentActiveReq);
    } catch (Exception e) {
        logger.error("Exception occurred", e);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
    }
    if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance && !requestScope.equalsIgnoreCase(ModelType.vnf.name())) {
        aLaCarte = true;
    } else if (aLaCarte == null) {
        aLaCarte = false;
    }
    RequestClientParameter requestClientParameter;
    try {
        requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfCorrelationId).setVnfId(vnfId).setVfModuleId(vfModuleId).setVolumeGroupId(volumeGroupId).setNetworkId(networkId).setServiceType(serviceInstanceType).setVnfType(vnfType).setVfModuleType(vfModuleType).setNetworkType(networkType).setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)).setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(instanceGroupId).build();
    } catch (IOException e) {
        logger.error("Exception occurred", e);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
    }
    return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BpmnRequestBuilder(org.onap.so.apihandlerinfra.infra.rest.BpmnRequestBuilder) IOException(java.io.IOException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) RequestDbFailureException(org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException) IOException(java.io.IOException) CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException) RequestClientParameter(org.onap.so.apihandler.common.RequestClientParameter) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ModelType(org.onap.so.serviceinstancebeans.ModelType) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException)

Aggregations

ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)100 Test (org.junit.Test)58 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)36 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)17 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)15 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)15 IOException (java.io.IOException)11 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 ValidationException (org.onap.so.exceptions.ValidationException)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)8 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)8 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)7 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)7 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6