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;
}
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);
}
Aggregations