From 311c1cf6d87a6c9b72581d218fb07526847e461d Mon Sep 17 00:00:00 2001 From: seshukm Date: Mon, 18 Sep 2017 13:10:27 +0530 Subject: Fixed issues in api-handler Issue-Id: SO-141 Change-Id: Ib08122f5e811ee7638edb59220b34d09fec36329 Signed-off-by: seshukm --- .../openecomp/mso/apihandlerinfra/ManualTasks.java | 1 + .../openecomp/mso/apihandlerinfra/MsoRequest.java | 2 +- .../mso/apihandlerinfra/ServiceInstances.java | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java index f3273cf144..f6abcc35b1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java @@ -143,6 +143,7 @@ public class ManualTasks { msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null); } catch (Exception e) { + msoLogger.debug ("Exception:", e); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null); msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java index eab232d4d5..5328780b21 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java @@ -149,7 +149,7 @@ public class MsoRequest { RequestError re = new RequestError(); - if(exceptionType.name().equals("PolicyException")){ + if("PolicyException".equals(exceptionType.name())){ PolicyException pe = new PolicyException(); pe.setMessageId(messageId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index e32f1535d4..66a14db610 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -73,10 +73,10 @@ import com.wordnik.swagger.annotations.ApiOperation; @Api(value="/serviceInstances",description="API Requests for Service Instances") public class ServiceInstances { - private HashMap instanceIdMap = new HashMap(); + private HashMap instanceIdMap = new HashMap<>(); private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; @POST @Path("/{version:[vV][3-5]}") @@ -404,7 +404,7 @@ public class ServiceInstances { String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); try { - if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance))){ + if(!(instanceName==null && "service".equals(requestScope) && (action == Action.createInstance || action == Action.activateInstance))){ dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); } } catch (Exception e) { @@ -423,7 +423,7 @@ public class ServiceInstances { if (dup != null) { // Found the duplicate record. Return the appropriate error. - String instance = null; + String instance; if(instanceName != null){ instance = instanceName; }else{ @@ -533,7 +533,7 @@ public class ServiceInstances { String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion (); // Get VF Module-specific base module indicator - VfModule vfm = null; + VfModule vfm; String modelVersionId = msoRequest.getModelInfo().getModelVersionId(); @@ -627,7 +627,7 @@ public class ServiceInstances { // Capture audit event msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - System.out.println("URL : " + requestClient.getUrl ()); + msoLogger.debug ("URL : " + requestClient.getUrl ()); response = requestClient.post(requestId, isBaseVfModule, recipeLookupResult.getRecipeTimeout (), action.name (), serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, @@ -684,7 +684,7 @@ public class ServiceInstances { msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody); return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build (); } else { - List variables = new ArrayList(); + List variables = new ArrayList<>(); variables.add(bpelStatus + ""); String camundaJSONResponseBody = respHandler.getResponseBody (); if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) { @@ -754,7 +754,7 @@ public class ServiceInstances { // TODO need to make this a configurable property String defaultServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - Service serviceRecord = null; + Service serviceRecord; ModelInfo modelInfo = msoRequest.getModelInfo(); if(msoRequest.getALaCarteFlag()){ serviceRecord = db.getServiceByModelName(defaultServiceModelName); @@ -840,7 +840,7 @@ public class ServiceInstances { // 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; - VnfResourceCustomization vrc = null; + VnfResourceCustomization vrc; // Validation for vnfResource if(modelCustomizationId!=null) { @@ -893,7 +893,7 @@ public class ServiceInstances { if(!msoRequest.getALaCarteFlag()) { VfModuleCustomization vfmc = null; - VnfResourceCustomization vnfrc = null; + VnfResourceCustomization vnfrc; VfModule vfModule = null; if( modelInfo.getModelCustomizationId() != null) { @@ -971,7 +971,7 @@ public class ServiceInstances { ModelInfo modelInfo = msoRequest.getModelInfo(); String modelName = modelInfo.getModelName(); - Recipe recipe = null; + Recipe recipe; if(msoRequest.getALaCarteFlag()){ recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); }else{ -- cgit 1.2.3-korg