diff options
11 files changed, 54 insertions, 89 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java index 0f16fdf538..ba576e36b2 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java @@ -58,7 +58,7 @@ public class UpdateVfModuleRequest extends VfRequestCommon { private Boolean failIfExists; private Boolean backout; - private Map<String,String> vfModuleParams = new HashMap<String, String>(); + private Map<String,String> vfModuleParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); public String getCloudSiteId() { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java index 6e84185704..bf50008bc7 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java @@ -34,7 +34,7 @@ public class UpdateVfModuleResponse extends VfResponseCommon { private String vnfId; private String vfModuleId; private String vfModuleStackId; - private Map<String,String> vfModuleOutputs = new HashMap<String, String>(); + private Map<String,String> vfModuleOutputs = new HashMap<>(); public UpdateVfModuleResponse() { super(); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java index 61fd9ccf87..2cd2cd49fb 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java @@ -43,7 +43,7 @@ public class UpdateVolumeGroupRequest extends VfRequestCommon { private String vnfVersion; private String vfModuleType; private String modelCustomizationUuid; - private Map<String,String> volumeGroupParams = new HashMap<String, String>(); + private Map<String,String> volumeGroupParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); public UpdateVolumeGroupRequest() { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java index babf5476e6..7f1c70314f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java @@ -39,7 +39,7 @@ public class UpdateVolumeGroupResponse extends VfResponseCommon { public UpdateVolumeGroupResponse() { super(); - this.volumeGroupOutputs = new HashMap<String, String>(); + this.volumeGroupOutputs = new HashMap<>(); } public UpdateVolumeGroupResponse( diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java index 3b7089153f..bfd0d7dee4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java @@ -108,7 +108,7 @@ public class ApplicationControllerSupport { try { return (Status) statusReader.invoke(response); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(String.format("Unable to obtain status from LCM Kit response"), e); + throw new RuntimeException("Unable to obtain status from LCM Kit response", e); } } return new Status(); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java index 6249040342..b27a2fa64e 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java @@ -67,29 +67,12 @@ public class ReadConfigTask extends BaseTask { synchronized (ReadConfigTask.class) { if (properties == null) { properties = new Properties(); - - InputStream stream = null; - - try { - stream = getClass().getResourceAsStream(thePropertiesFile); - - if (stream == null) { - throw new IOException("Resource not found: " + thePropertiesFile); - } + try (InputStream stream = getClass().getResourceAsStream(thePropertiesFile)) { properties.load(stream); - stream.close(); - stream = null; - - } finally { - if (stream != null) { - try { - stream.close(); - } catch (Exception e) { - msoLogger.debug("Exception:", e); - } - } + } catch (Exception e) { + msoLogger.debug("Exception at readResourceFile stream: " + e); } } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java index 6b3cb5a1db..af38053fac 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java @@ -76,36 +76,18 @@ public class ReadFileTask extends BaseTask { Object value = execution.getVariable(theInputVariable); if (value == null) { - InputStream xmlStream = null; - - try { - xmlStream = getClass().getResourceAsStream(theFile); - - if (xmlStream == null) { - throw new IOException("Resource not found: " + theFile); - } - - BufferedReader reader = new BufferedReader(new InputStreamReader(xmlStream)); + try (InputStream xmlStream = getClass().getResourceAsStream(theFile); + BufferedReader reader = new BufferedReader(new InputStreamReader(xmlStream))) { StringBuilder output = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { output.append(line); } - - xmlStream.close(); - xmlStream = null; - value = output.toString(); - } finally { - if (xmlStream != null) { - try { - xmlStream.close(); - } catch (Exception e) { - msoLogger.debug("Exception ", e); - } - } + } catch (Exception e) { + msoLogger.debug("Exception at readResourceFile stream: " + e); } } execution.setVariable(theInputVariable, value); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java index cf8e94a733..b4e7b7e068 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java @@ -51,7 +51,7 @@ public class CamundaTaskClient extends RequestClient{ StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
- String encryptedCredentials = null;
+ String encryptedCredentials;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
if(encryptedCredentials != null){
@@ -92,7 +92,7 @@ public class CamundaTaskClient extends RequestClient{ throws ClientProtocolException, IOException{
HttpGet get = new HttpGet(url);
msoLogger.debug("Camunda Task url is: "+ url);
- String encryptedCredentials = null;
+ String encryptedCredentials;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
if(encryptedCredentials != null){
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java index e90989deb8..6722a930ae 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java @@ -131,36 +131,36 @@ public class ResponseHandler { } private int setStatus(int statusCode){ - int status = 0; + int httpStatus; switch(statusCode) { case HttpStatus.SC_ACCEPTED: case HttpStatus.SC_OK: - status = HttpStatus.SC_ACCEPTED; + httpStatus = HttpStatus.SC_ACCEPTED; break; case HttpStatus.SC_BAD_REQUEST: - status = HttpStatus.SC_BAD_REQUEST; + httpStatus = HttpStatus.SC_BAD_REQUEST; break; case HttpStatus.SC_UNAUTHORIZED: case HttpStatus.SC_FORBIDDEN: - status = HttpStatus.SC_INTERNAL_SERVER_ERROR; + httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; break; case HttpStatus.SC_NOT_FOUND: - status = HttpStatus.SC_NOT_IMPLEMENTED; + httpStatus = HttpStatus.SC_NOT_IMPLEMENTED; break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: - status = HttpStatus.SC_BAD_GATEWAY; + httpStatus = HttpStatus.SC_BAD_GATEWAY; break; case HttpStatus.SC_SERVICE_UNAVAILABLE: - status = HttpStatus.SC_SERVICE_UNAVAILABLE; + httpStatus = HttpStatus.SC_SERVICE_UNAVAILABLE; break; case HttpStatus.SC_NO_CONTENT: - status = HttpStatus.SC_NO_CONTENT; + httpStatus = HttpStatus.SC_NO_CONTENT; break; default: - status = HttpStatus.SC_INTERNAL_SERVER_ERROR; + httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; break; } - return status; + return httpStatus; } 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 8ee106efc1..9b975facc6 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 @@ -586,20 +586,20 @@ public class MsoRequest { public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException { String queryParam = null; - Map<String, List<String>> orchestrationFilterParams = new HashMap<String, List<String>>(); + Map<String, List<String>> orchestrationFilterParams = new HashMap<>(); for (Entry<String,List<String>> entry : queryParams.entrySet()) { queryParam = entry.getKey(); try{ - if(queryParam.equalsIgnoreCase("filter")){ + if("filter".equalsIgnoreCase(queryParam)){ for(String value : entry.getValue()) { StringTokenizer st = new StringTokenizer(value, ":"); int counter=0; String mapKey=null; - List<String> orchestrationList = new ArrayList<String>(); + List<String> orchestrationList = new ArrayList<>(); while (st.hasMoreElements()) { if(counter == 0){ mapKey = st.nextElement() + ""; diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index 254ae3bf39..b426c39176 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -226,37 +226,37 @@ public class RequestsDatabase { if(instanceName != null && !instanceName.equals("")) { - if(requestScope.equals("service")){ + if("service".equals(requestScope)){ criteria.add (Restrictions.eq (SERVICE_INSTANCE_NAME, instanceName)); - } else if(requestScope.equals("vnf")){ + } else if("vnf".equals(requestScope)){ criteria.add (Restrictions.eq (VNF_INSTANCE_NAME, instanceName)); - } else if(requestScope.equals("volumeGroup")){ + } else if("volumeGroup".equals(requestScope)){ criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_NAME, instanceName)); - } else if(requestScope.equals("vfModule")){ + } else if("vfModule".equals(requestScope)){ criteria.add (Restrictions.eq (VFMODULE_INSTANCE_NAME, instanceName)); - } else if(requestScope.equals("network")){ + } else if("network".equals(requestScope)){ criteria.add (Restrictions.eq (NETWORK_INSTANCE_NAME, instanceName)); } } else { if(instanceIdMap != null){ - if(requestScope.equals("service") && instanceIdMap.get("serviceInstanceId") != null){ + if("service".equals(requestScope) && instanceIdMap.get("serviceInstanceId") != null){ criteria.add (Restrictions.eq (SERVICE_INSTANCE_ID, instanceIdMap.get("serviceInstanceId"))); } - if(requestScope.equals("vnf") && instanceIdMap.get("vnfInstanceId") != null){ + if("vnf".equals(requestScope) && instanceIdMap.get("vnfInstanceId") != null){ criteria.add (Restrictions.eq (VNF_INSTANCE_ID, instanceIdMap.get("vnfInstanceId"))); } - if(requestScope.equals("vfModule") && instanceIdMap.get("vfModuleInstanceId") != null){ + if("vfModule".equals(requestScope) && instanceIdMap.get("vfModuleInstanceId") != null){ criteria.add (Restrictions.eq (VFMODULE_INSTANCE_ID, instanceIdMap.get("vfModuleInstanceId"))); } - if(requestScope.equals("volumeGroup") && instanceIdMap.get("volumeGroupInstanceId") != null){ + if("volumeGroup".equals(requestScope) && instanceIdMap.get("volumeGroupInstanceId") != null){ criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_ID, instanceIdMap.get("volumeGroupInstanceId"))); } - if(requestScope.equals("network") && instanceIdMap.get("networkInstanceId") != null){ + if("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null){ criteria.add (Restrictions.eq (NETWORK_INSTANCE_ID, instanceIdMap.get("networkInstanceId"))); } } @@ -270,7 +270,7 @@ public class RequestsDatabase { InfraActiveRequests infraActiveRequests = null; - if(dupList != null && dupList.size() > 0){ + if(dupList != null && !dupList.isEmpty()){ infraActiveRequests = dupList.get(0); } @@ -284,40 +284,40 @@ public class RequestsDatabase { for (Map.Entry<String, List<String>> entry : orchestrationMap.entrySet()) { String mapKey = entry.getKey(); - if(mapKey.equalsIgnoreCase("serviceInstanceId")) { + if("serviceInstanceId".equalsIgnoreCase(mapKey)) { mapKey = "serviceInstanceId"; - } else if(mapKey.equalsIgnoreCase("serviceInstanceName")) { + } else if("serviceInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "serviceInstanceName"; - } else if(mapKey.equalsIgnoreCase("vnfInstanceId")){ + } else if("vnfInstanceId".equalsIgnoreCase(mapKey)){ mapKey = "vnfId"; - } else if(mapKey.equalsIgnoreCase("vnfInstanceName")) { + } else if("vnfInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "vnfName"; - } else if(mapKey.equalsIgnoreCase("vfModuleInstanceId")) { + } else if("vfModuleInstanceId".equalsIgnoreCase(mapKey)) { mapKey = "vfModuleId"; - } else if(mapKey.equalsIgnoreCase("vfModuleInstanceName")) { + } else if("vfModuleInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "vfModuleName"; - } else if(mapKey.equalsIgnoreCase("volumeGroupInstanceId")) { + } else if("volumeGroupInstanceId".equalsIgnoreCase(mapKey)) { mapKey = "volumeGroupId"; - } else if(mapKey.equalsIgnoreCase("volumeGroupInstanceName")) { + } else if("volumeGroupInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "volumeGroupName"; - } else if(mapKey.equalsIgnoreCase("networkInstanceId")) { + } else if("networkInstanceId".equalsIgnoreCase(mapKey)) { mapKey = "networkId"; - } else if(mapKey.equalsIgnoreCase("networkInstanceName")) { + } else if("networkInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "networkName"; - } else if(mapKey.equalsIgnoreCase("lcpCloudRegionId")) { + } else if("lcpCloudRegionId".equalsIgnoreCase(mapKey)) { mapKey = "aicCloudRegion"; - } else if(mapKey.equalsIgnoreCase("tenantId")) { + } else if("tenantId".equalsIgnoreCase(mapKey)) { mapKey = "tenantId"; - } else if(mapKey.equalsIgnoreCase("modelType")) { + } else if("modelType".equalsIgnoreCase(mapKey)) { mapKey = "requestScope"; - } else if(mapKey.equalsIgnoreCase("requestorId")) { + } else if("requestorId".equalsIgnoreCase(mapKey)) { mapKey = "requestorId"; - } else if(mapKey.equalsIgnoreCase("requestExecutionDate")) { + } else if("requestExecutionDate".equalsIgnoreCase(mapKey)) { mapKey = "startTime"; } String propertyValue = entry.getValue().get(1); - if (mapKey.equals("startTime")) { + if ("startTime".equals(mapKey)) { SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); try { Date thisDate = format.parse(propertyValue); |