diff options
author | Manamohan <MS00534989@Techmahindra.com> | 2019-08-16 11:45:52 +0530 |
---|---|---|
committer | Manamohan <MS00534989@Techmahindra.com> | 2019-08-16 11:45:52 +0530 |
commit | 35de0e3132b7bce8eb3c289456edafdbf4a17ba2 (patch) | |
tree | 82fcae05e311e22571a00d8e436cfaf3e16be7e5 /mso-api-handlers/mso-api-handler-infra/src/main/java/org | |
parent | f075d8a5830e36960036c18c28064e3959e03da4 (diff) |
Javadoc and logging improvement
Added Javadocs and logging for these classes.
Change-Id: I365fc0677c0d5136e4579de3947d0478b26c22d3
Issue-ID: SO-2052
Signed-off-by: Manamohan <MS00534989@Techmahindra.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java | 87 |
1 files changed, 64 insertions, 23 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 5b827d9cf8..bc9c603192 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -440,7 +440,6 @@ public class ServiceInstances extends AbstractRestHandler { requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); } - @DELETE @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @@ -589,7 +588,6 @@ public class ServiceInstances extends AbstractRestHandler { requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); } - @POST @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") @Consumes(MediaType.APPLICATION_JSON) @@ -762,6 +760,27 @@ public class ServiceInstances extends AbstractRestHandler { requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); } + /** + * This method is used for POST a request to the BPEL client (BPMN). + * + * Convert the requestJson to ServiceInstanceRequest(sir), create the msoRequest object, check whether this request + * is already being processed in requestdb for duplicate check. + * + * Based on the alacarte flag, sir and msoRequest will do the recipe lookup from the service and servicerecipe table + * of catalogdb, and get the OrchestrationURI. + * + * If the present request is not the duplicate request then this request will be saved in the requestdb. and will + * POST a request to the BPMN engine at the OrchestrationURI fetched. + * + * @param requestJSON Json fetched as body in the API call + * @param action Type of action to be performed + * @param instanceIdMap Map of instance ids of service/vnf/vf/configuration etc.. + * @param version Supported version of API + * @param requestId Unique id for the request + * @param requestUri + * @return response object + * @throws ApiException + */ public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { String serviceInstanceId; @@ -864,6 +883,7 @@ public class ServiceInstances extends AbstractRestHandler { 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(); @@ -877,6 +897,7 @@ public class ServiceInstances extends AbstractRestHandler { aLaCarte = false; } + RequestClientParameter requestClientParameter = null; try { requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) @@ -889,6 +910,7 @@ public class ServiceInstances extends AbstractRestHandler { .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(); @@ -914,6 +936,21 @@ public class ServiceInstances extends AbstractRestHandler { return action; } + /** + * 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); @@ -967,6 +1004,7 @@ public class ServiceInstances extends AbstractRestHandler { 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(); @@ -979,6 +1017,7 @@ public class ServiceInstances extends AbstractRestHandler { .setRequestAction(action.toString()).setApiVersion(apiVersion).setALaCarte(aLaCarte) .setRequestUri(requestUri).setInstanceGroupId(instanceGroupId).build(); + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope); } @@ -992,7 +1031,8 @@ public class ServiceInstances extends AbstractRestHandler { protected 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 + // 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(); // Query MSO Catalog DB @@ -1008,7 +1048,6 @@ public class ServiceInstances extends AbstractRestHandler { 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(); @@ -1027,7 +1066,6 @@ public class ServiceInstances extends AbstractRestHandler { 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(); @@ -1045,7 +1083,6 @@ public class ServiceInstances extends AbstractRestHandler { 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(); @@ -1062,7 +1099,6 @@ public class ServiceInstances extends AbstractRestHandler { 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) @@ -1112,7 +1148,8 @@ public class ServiceInstances extends AbstractRestHandler { } } - // if an aLaCarte flag was sent in the request, throw an error if the recipe was not found + // if an aLaCarte flag was sent in the request, throw an error if the recipe was + // not found RequestParameters reqParam = requestDetails.getRequestParameters(); if (reqParam != null && alaCarteFlag && recipe == null) { return null; @@ -1301,23 +1338,32 @@ public class ServiceInstances extends AbstractRestHandler { if (modelInfo.getModelType().equals(ModelType.vnf)) { // a. For a vnf request (only create, no update currently): - // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in + // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate + // catalog DB has record in // vnf_resource_customization.model_customization_uuid. - // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or + // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is + // a pre-1702 ASDC model or // pre-v3), then modelInfo.modelCustomizationName must have // been provided (else create request should be rejected). APIH should use the - // relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName - // to “join�? service_to_resource_customizations with vnf_resource_customization to confirm a + // relatedInstance.modelInfo[service].modelVersionId** + + // modelInfo[vnf].modelCustomizationName + // to “join�? service_to_resource_customizations with + // vnf_resource_customization to confirm a // vnf_resource_customization.model_customization_uuid record exists. // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use - // relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId + // relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to + // lookup modelVersionId // (MODEL_UUID) in SERVICE table. - // iii. Regardless of how the value was provided/obtained above, APIH must always populate - // vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated + // iii. Regardless of how the value was provided/obtained above, APIH must + // always populate + // vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO + // generated // during 1707 data migration if VID did not provide it originally on request. - // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN (must still be populated + // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN + // (must still be populated // in A&AI). - // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to + // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use + // modelCustomizationId to // look it up in our catalog to construct vnf-type value to pass to BPMN. VnfResource vnfResource = null; @@ -1448,14 +1494,13 @@ public class ServiceInstances extends AbstractRestHandler { throw new ValidationException("vfModuleCustomization"); } else if (vfModule == null && vfmc != null) { vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in - // VfModuleCustomization table + // VfModuleCustomization table } if (modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(vfModule.getModelUUID()); } - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( vfModule.getModelUUID(), vnfComponentType, action.toString()); if (recipe == null) { @@ -1518,7 +1563,6 @@ public class ServiceInstances extends AbstractRestHandler { return new RecipeLookupResult(vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); } - private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException { String defaultNetworkType = requestHandlerUtils.getDefaultModel(sir); @@ -1558,7 +1602,6 @@ public class ServiceInstances extends AbstractRestHandler { return recipe != null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null; } - private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { String serviceInstanceId; @@ -1597,7 +1640,6 @@ public class ServiceInstances extends AbstractRestHandler { referencesResponse.setRequestId(requestId); serviceResponse.setRequestReferences(referencesResponse); - String orchestrationUri = env.getProperty(CommonConstants.ALACARTE_ORCHESTRATION); String timeOut = env.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT); @@ -1609,7 +1651,6 @@ public class ServiceInstances extends AbstractRestHandler { 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(); |