Search in sources :

Example 1 with RecipeNotFoundException

use of org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException in project so by onap.

the class RequestHandlerUtils method getServiceInstanceOrchestrationURI.

public RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag, InfraActiveRequests currentActiveReq) throws ApiException {
    RecipeLookupResult recipeLookupResult = null;
    // if the aLaCarte flag is set to TRUE, the API-H should choose the VID_DEFAULT recipe for the requested action
    ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
    if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
        recipeLookupResult = getDefaultVnfUri(sir, action);
    } else if (action == Action.addMembers || action == Action.removeMembers) {
        recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
    } else if (modelInfo.getModelType().equals(ModelType.service)) {
        try {
            recipeLookupResult = getServiceURI(sir, action, alaCarteFlag);
        } catch (IOException e) {
            ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_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();
            updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
            throw validateException;
        }
    } else if (modelInfo.getModelType().equals(ModelType.vfModule) || modelInfo.getModelType().equals(ModelType.volumeGroup) || modelInfo.getModelType().equals(ModelType.vnf)) {
        try {
            recipeLookupResult = getVnfOrVfModuleUri(sir, action);
        } catch (ValidationException e) {
            ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_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();
            updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
            throw validateException;
        }
    } else if (modelInfo.getModelType().equals(ModelType.network)) {
        try {
            recipeLookupResult = getNetworkUri(sir, action);
        } catch (ValidationException e) {
            ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_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();
            updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
            throw validateException;
        }
    } else if (modelInfo.getModelType().equals(ModelType.instanceGroup)) {
        recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
    }
    if (recipeLookupResult == null) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
        updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
        throw recipeNotFoundExceptionException;
    }
    return recipeLookupResult;
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RecipeNotFoundException(org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) IOException(java.io.IOException)

Example 2 with RecipeNotFoundException

use of org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException in project so by onap.

the class InstanceManagement method getInstanceManagementWorkflowRecipe.

private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException {
    RecipeLookupResult recipeLookupResult;
    try {
        recipeLookupResult = getCustomWorkflowUri(workflowUuid);
    } catch (Exception e) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_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;
    }
    if (recipeLookupResult == null) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
        requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
        throw recipeNotFoundExceptionException;
    }
    return recipeLookupResult;
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) RecipeNotFoundException(org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException) 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) RecipeNotFoundException(org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException)

Aggregations

IOException (java.io.IOException)2 RecipeNotFoundException (org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException)2 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)2 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)2 ValidationException (org.onap.so.exceptions.ValidationException)2 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 RequestDbFailureException (org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException)1 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)1