Fixed issues in api-handler 29/13029/1
authorseshukm <seshu.kumar.m@huawei.com>
Mon, 18 Sep 2017 07:40:27 +0000 (13:10 +0530)
committerseshukm <seshu.kumar.m@huawei.com>
Mon, 18 Sep 2017 07:40:27 +0000 (13:10 +0530)
Issue-Id: SO-141

Change-Id: Ib08122f5e811ee7638edb59220b34d09fec36329
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java

index f9fd9c3..27a21ec 100644 (file)
@@ -87,8 +87,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
 \r
        private MsoLogger logger;\r
        \r
-       private Service catalogService;\r
-       \r
        private static final Pattern lastDigit = Pattern.compile("(\\d+)$");\r
 \r
        public ToscaResourceInstaller()  {\r
@@ -98,7 +96,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
        //@Override\r
        public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct)\r
                        throws ArtifactInstallerException {\r
-               CatalogDatabase db = CatalogDatabase.getInstance();\r
                boolean status = false;\r
                VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;\r
                \r
@@ -178,8 +175,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                try {\r
 \r
                        \r
-                       String vfModuleModelUUID = null;\r
-                       \r
                        createToscaCsar(toscaResourceStruct);\r
                        \r
                        catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());\r
@@ -225,10 +220,10 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                                // get the Main IArtifactInfo\r
 \r
                                HeatTemplate heatMainTemplate = null;\r
-                               HeatEnvironment heatEnv = null;\r
+                               HeatEnvironment heatEnv;\r
                                \r
                                HeatTemplate heatVolumeTemplate = null;\r
-                               HeatEnvironment heatVolumeEnv = null;\r
+                               HeatEnvironment heatVolumeEnv;\r
                                \r
                                \r
                                IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();\r
@@ -571,8 +566,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                                logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(),\r
                                                vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);\r
                        } else {\r
-                               String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.";\r
-                               String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");\r
+                           String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");\r
                                logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);\r
                                catalogDB.rollback();\r
                                throw new ArtifactInstallerException(\r
@@ -642,7 +636,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
 //             heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());\r
                heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());\r
                \r
-               List<String> typeList = new ArrayList<String>();\r
+               List<String> typeList = new ArrayList<>();\r
                typeList.add(ASDCConfiguration.HEAT_NESTED);\r
                typeList.add(ASDCConfiguration.HEAT_ARTIFACT);\r
                \r
@@ -684,7 +678,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                // TODO Set the label\r
 //             heatEnvironment.setAsdcLabel("Label");\r
                \r
-               List<String> typeList = new ArrayList<String>();\r
+               List<String> typeList = new ArrayList<>();\r
                typeList.add(ASDCConfiguration.HEAT);\r
                typeList.add(ASDCConfiguration.HEAT_VOL);\r
                \r
@@ -835,7 +829,6 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
        \r
        private static void createVFModule(Group group, NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData) {\r
                VfModule vfModule = new VfModule();\r
-               boolean isBase = false;\r
                \r
                Metadata vfMetadata = group.getMetadata();\r
                \r
@@ -895,7 +888,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                        vfModule.setVnfResourceModelUUId(toscaResourceStructure.getCatalogVnfResource().getModelUuid());                \r
                        \r
                        String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);\r
-                       if(vfModuleType != null && vfModuleType.equalsIgnoreCase("Base")){\r
+                       if(vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)){\r
                                vfModule.setIsBase(1);  \r
                        }else {\r
                                vfModule.setIsBase(0);\r
@@ -1100,7 +1093,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
        private static String testNull(Object object) {\r
                if (object == null) {\r
                        return "";\r
-               } else if (object.equals("null")) {\r
+               } else if ("null".equals(object)) {\r
                        return null;\r
                }else if (object instanceof Integer) {\r
                        return object.toString();\r
index f3273cf..f6abcc3 100644 (file)
@@ -143,6 +143,7 @@ public class ManualTasks {
 \r
                        msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);\r
                } catch (Exception e) {\r
+                   msoLogger.debug ("Exception:", e);\r
                        msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);\r
                        msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);\r
                        Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,\r
index eab232d..5328780 100644 (file)
@@ -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);
index e32f153..66a14db 100644 (file)
@@ -73,10 +73,10 @@ import com.wordnik.swagger.annotations.ApiOperation;
 @Api(value="/serviceInstances",description="API Requests for Service Instances")
 public class ServiceInstances {
 
-       private HashMap<String, String> instanceIdMap = new HashMap<String,String>();
+       private HashMap<String, String> 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<String> variables = new ArrayList<String>();
+                       List<String> 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{
index 8db4548..254ae3b 100644 (file)
@@ -332,7 +332,7 @@ public class RequestsDatabase {
                                }    
                        }
                        catch (Exception e){
-                               msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage());
+                               msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage(), e);
                                return null;
                        }
                }