use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class ServiceInstances method deleteInstanceGroups.
/**
* This method deletes the Instance Groups.
*
* This method will check whether the request is not duplicate in requestdb. if its not then will save as a new
* request. And will send a POST request to BEPL client to delete the Insatnce Groups.
*
* @param action
* @param instanceIdMap
* @param version
* @param requestId
* @param requestUri
* @param requestContext
* @return
* @throws ApiException
*/
public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID);
Boolean aLaCarte = true;
String apiVersion = version.substring(1);
ServiceInstancesRequest sir = new ServiceInstancesRequest();
sir.setInstanceGroupId(instanceGroupId);
String requestScope = ModelType.instanceGroup.toString();
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, null, requestScope);
requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
try {
requestHandlerUtils.validateHeaders(requestContext);
} catch (ValidationException e) {
logger.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.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, null);
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
RequestReferences referencesResponse = new RequestReferences();
referencesResponse.setRequestId(requestId);
serviceResponse.setRequestReferences(referencesResponse);
Boolean isBaseVfModule = false;
RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
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();
}
RequestClientParameter requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()).setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(instanceGroupId).build();
return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class ServiceInstanceDeleteValidatorTest method before.
@Before
public void before() {
serviceInstancesRequest = new ServiceInstancesRequest();
RequestDetails requestDetails = new RequestDetails();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setaLaCarte(true);
requestDetails.setRequestParameters(requestParameters);
serviceInstancesRequest.setRequestDetails(requestDetails);
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class VolumeGroupDeleteValidatorTest method validateFailureVnfTest.
@Test
public void validateFailureVnfTest() {
instanceIdMap.put("volumeGroupInstanceId", "1");
ServiceInstancesRequest request = new ServiceInstancesRequest();
RequestDetails details = new RequestDetails();
details.setCloudConfiguration(new CloudConfiguration());
request.setRequestDetails(details);
when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(true);
Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
assertEquals(true, result.isPresent());
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class RelatedInstancesValidationTest method testCreateVnfNetworkInstanceGroup.
@Test
public void testCreateVnfNetworkInstanceGroup() throws IOException, ValidationException {
String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json")));
ObjectMapper mapper = new ObjectMapper();
ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, 6, false, sir.getRequestDetails().getRequestParameters());
info.setRequestScope("vnf");
sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
RelatedInstancesValidation validation = new RelatedInstancesValidation();
validation.validate(info);
assertEquals(info.getVnfType(), "Test/name");
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class RelatedInstancesValidationTest method setupValidationInformation.
public ValidationInformation setupValidationInformation(String path) throws IOException {
String jsonInput = new String(Files.readAllBytes(Paths.get(path)));
ObjectMapper mapper = new ObjectMapper();
ServiceInstancesRequest sir = mapper.readValue(jsonInput, ServiceInstancesRequest.class);
ValidationInformation info = new ValidationInformation(sir, null, Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters());
info.setRequestScope("service");
sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
info.setRequestInfo(sir.getRequestDetails().getRequestInfo());
return info;
}
Aggregations