Search in sources :

Example 1 with VfModuleNotFoundException

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

the class RequestHandlerUtils method getIsBaseVfModule.

protected Boolean getIsBaseVfModule(ModelInfo modelInfo, Actions action, String vnfType, String sdcServiceModelVersion, InfraActiveRequests currentActiveReq) throws ApiException {
    // Get VF Module-specific base module indicator
    VfModule vfm = null;
    String modelVersionId = modelInfo.getModelVersionId();
    Boolean isBaseVfModule = false;
    if (modelVersionId != null) {
        vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId);
    } else if (modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null) {
        vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion());
    }
    if (vfm != null) {
        if (vfm.getIsBase()) {
            isBaseVfModule = true;
        }
    } else if (action == Action.createInstance || action == Action.updateInstance) {
        String serviceVersionText = "";
        if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty()) {
            serviceVersionText = " with version " + sdcServiceModelVersion;
        }
        String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB";
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
        VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
        updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
        throw vfModuleException;
    }
    return isBaseVfModule;
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) VfModuleNotFoundException(org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException) VfModule(org.onap.so.db.catalog.beans.VfModule)

Example 2 with VfModuleNotFoundException

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

the class ApiExceptionMapperTest method testVFModuleResponse.

@Test
public void testVFModuleResponse() {
    VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_BAD_PARAMETER).build();
    Response resp = mapper.toResponse((ApiException) vfModuleException);
    assertEquals(resp.getStatus(), HttpStatus.SC_CONFLICT);
}
Also used : Response(javax.ws.rs.core.Response) VfModuleNotFoundException(org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException) Test(org.junit.Test)

Aggregations

VfModuleNotFoundException (org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 VfModule (org.onap.so.db.catalog.beans.VfModule)1