aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2019-08-21 13:26:49 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-21 13:26:49 +0000
commita7221b99f36b572ba896160e7878b92fb65e8145 (patch)
tree8e35c2016292404763ed303299d00b71483b5531 /mso-api-handlers
parentd71a9c0da606fb8bb3fe39de438562a9dd2304a5 (diff)
parent35de0e3132b7bce8eb3c289456edafdbf4a17ba2 (diff)
Merge "Javadoc and logging improvement"
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java87
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 b1d38983ec..9b72bdc608 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
@@ -444,7 +444,6 @@ public class ServiceInstances extends AbstractRestHandler {
requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
-
@DELETE
@Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@@ -593,7 +592,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)
@@ -766,6 +764,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 {
return serviceInstances(requestJSON, action, instanceIdMap, version, requestId, requestUri, null);
@@ -877,6 +896,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();
@@ -890,6 +910,7 @@ public class ServiceInstances extends AbstractRestHandler {
aLaCarte = false;
}
+
RequestClientParameter requestClientParameter = null;
try {
requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId)
@@ -902,6 +923,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();
@@ -927,6 +949,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);
@@ -980,6 +1017,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();
@@ -992,6 +1030,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);
}
@@ -1005,7 +1044,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
@@ -1021,7 +1061,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();
@@ -1040,7 +1079,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();
@@ -1058,7 +1096,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();
@@ -1075,7 +1112,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)
@@ -1125,7 +1161,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;
@@ -1314,23 +1351,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;
@@ -1461,14 +1507,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) {
@@ -1531,7 +1576,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);
@@ -1571,7 +1615,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;
@@ -1610,7 +1653,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);
@@ -1622,7 +1664,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();