diff options
Diffstat (limited to 'mso-catalog-db/src/main')
19 files changed, 212 insertions, 292 deletions
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java index 26b641d883..6b27c50609 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java @@ -207,7 +207,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); @@ -368,7 +368,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByName", null); return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByName", null); @@ -530,7 +530,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null); @@ -602,7 +602,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); @@ -646,7 +646,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); @@ -673,7 +673,7 @@ public class CatalogDatabase implements Closeable { return Collections.EMPTY_LIST; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null); @@ -750,7 +750,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); @@ -876,7 +876,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); @@ -977,7 +977,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleModelName", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); @@ -1075,7 +1075,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResource", null); return resultList.get(0); @@ -1124,7 +1124,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); @@ -1141,14 +1141,13 @@ public class CatalogDatabase implements Closeable { * @return VnfRecipe object or null if none found */ public VnfRecipe getVnfRecipe(String vnfType, String action) { - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType + " and action " + action); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); query.setParameter(VNF_TYPE, vnfType); query.setParameter(ACTION, action); @@ -1160,7 +1159,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); @@ -1176,14 +1175,11 @@ public class CatalogDatabase implements Closeable { * @return VnfRecipe object or null if none found */ public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) { - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + modelName - + " and action " - + action); + LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + " and action " + action); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); query.setParameter(VNF_TYPE, modelName); query.setParameter(MODEL_VERSION, modelVersion); query.setParameter(ACTION, action); @@ -1196,7 +1192,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); @@ -1233,12 +1229,10 @@ public class CatalogDatabase implements Closeable { */ public VnfRecipe getVnfRecipeByVfModuleId(String vnfType, String vfModuleId, String action) { - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); - long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - get VNF Recipe with vfModuleId " + vfModuleId); - Query query = getSession().createQuery(hql.toString ()); + Query query = getSession().createQuery("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); query.setParameter(VF_MODULE_MODEL_UUID, vfModuleId); query.setParameter(ACTION, action); @@ -1250,7 +1244,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF Recipe Entry found", "CatalogDB", "getVnfRecipeByVfModuleId", null); @@ -1307,7 +1301,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleType", null); return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); @@ -1434,7 +1428,7 @@ public class CatalogDatabase implements Closeable { VfModule module = null; if (modules != null && ! modules.isEmpty()) { - Collections.sort (modules, new MavenLikeVersioningComparator ()); + modules.sort(new MavenLikeVersioningComparator()); Collections.reverse (modules); module = modules.get(0); } @@ -1641,7 +1635,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param getVnfResourceCustomizationByModelVersionId + * @param modelVersionId * @return VnfResourceCustomization or null if not found */ public VnfResourceCustomization getVnfResourceCustomizationByModelVersionId(String modelVersionId) { @@ -1890,7 +1884,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); @@ -1923,7 +1917,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param modelCustomizationUuid + * @param modelUuid * @return VnfResourceCustomization or null if not found */ public VnfResource getVnfResourceByModelUuid(String modelUuid) { @@ -1954,17 +1948,17 @@ public class CatalogDatabase implements Closeable { } else { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelUuid", null); } - return vnfResource; + return vnfResource; } - + public VnfResCustomToVfModuleCustom getVnfResCustomToVfModule(String vnfId, String vfId) { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - getVnfResCustomToVfModule - vnfResourceCustModelCustUuid: " + vnfId + ", vfModuleCustModelCustomUuid=" + vfId); - StringBuilder hql = new StringBuilder("FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue"); - HashMap<String, String> parameters = new HashMap<>(); + HashMap<String, String> parameters = new HashMap<>(); parameters.put("vnfIdValue", vnfId); parameters.put("vfIdValue", vfId); - VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow(hql.toString(), parameters, true); + VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow( + "FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue", parameters, true); if (vrctvmc == null) { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResCustomToVfModule", null); } else { @@ -1987,8 +1981,7 @@ public class CatalogDatabase implements Closeable { public List<VfModule> getVfModulesForVnfResource(String vnfResourceModelUuid) { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResourceModelUuid: " + vnfResourceModelUuid); - StringBuilder hql = new StringBuilder("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); query.setParameter("vnfResourceModelUUId", vnfResourceModelUuid); List<VfModule> resultList = null; try { @@ -2236,8 +2229,7 @@ public class CatalogDatabase implements Closeable { public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2247,7 +2239,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2260,8 +2252,8 @@ public class CatalogDatabase implements Closeable { public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2275,7 +2267,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2289,18 +2281,18 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllNetworksByNetworkModelCustomizationUuid - " + networkModelCustomizationUuid); - StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid"); - //Query query = getSession().createQuery(hql.toString()); + //Query query = getSession().createQuery(hql.toString()); //query.setParameter("networkModelCustomizationUuid", networkModelCustomizationUuid); //LOGGER.debug("QUERY: " + hql.toString() + ", networkModelCustomizationUuid=" + networkModelCustomizationUuid); - + //@SuppressWarnings("unchecked") //List<NetworkResourceCustomization> resultList = query.list(); - + HashMap<String, String> params = new HashMap<>(); params.put("networkModelCustomizationUuid", networkModelCustomizationUuid); - List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows(hql.toString(), params, true); + List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows( + "FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid", params, true); if (resultList.isEmpty()) { LOGGER.debug("Unable to find an NMC with nmcu=" + networkModelCustomizationUuid); @@ -2309,7 +2301,6 @@ public class CatalogDatabase implements Closeable { for (NetworkResourceCustomization nrc : resultList) { nrc.setNetworkResource(this.getNetworkResourceById(nrc.getNetworkResourceModelUuid())); } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkModelCustomizationUuid", null); return resultList; @@ -2326,9 +2317,9 @@ public class CatalogDatabase implements Closeable { String networkResourceId = nr.getModelUUID(); LOGGER.debug("Now searching for NRC's with networkResourceId = " + networkResourceId); - StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); query.setParameter("networkResourceId", networkResourceId); @SuppressWarnings("unchecked") @@ -2347,7 +2338,7 @@ public class CatalogDatabase implements Closeable { } public ArrayList<VfModuleCustomization> getAllVfmcForVrc(VnfResourceCustomization vrc) { LOGGER.debug("Catalog database: getAllVfmcForVrc - " + vrc.getModelCustomizationUuid()); - + List<VnfResCustomToVfModuleCustom> vfmcs = this.getVRCtoVFMC(vrc.getModelCustomizationUuid(), null); if (vfmcs == null || vfmcs.isEmpty()) { return new ArrayList<>(); @@ -2367,8 +2358,7 @@ public class CatalogDatabase implements Closeable { public List<VnfResourceCustomization> getAllVnfsByServiceModelUuid(String serviceModelUuid) { LOGGER.debug("Catalog database: getAllVnfsByServiceModelUuid - " + serviceModelUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelUUID = :serviceModelUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelUUID = :serviceModelUuid"); query.setParameter("serviceModelUuid", serviceModelUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2378,7 +2368,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); // Step 2 - Now query to get the related VnfResourceCustomizations @@ -2389,7 +2379,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Unable to find any related vnfs to a service with modelUuid=" + serviceModelUuid); return new ArrayList<>(); } - + ArrayList<VnfResourceCustomization> allVrcs = new ArrayList<>(); for (ServiceToResourceCustomization strc : strcs) { LOGGER.debug("Try to find VRC for mcu=" + strc.getResourceModelCustomizationUUID()); @@ -2398,13 +2388,12 @@ public class CatalogDatabase implements Closeable { allVrcs.add(vrc); } return allVrcs; - + } public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hqlService = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hqlService.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> resultList = query.list(); @@ -2412,7 +2401,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return new ArrayList<>(); } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); //now just call the method that takes the version - the service object will have the highest version @@ -2422,8 +2411,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2433,7 +2422,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return new ArrayList<>(); } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByServiceModelInvariantUuid", null); @@ -2446,8 +2435,8 @@ public class CatalogDatabase implements Closeable { return this.getAllVnfsByServiceName(serviceName); } - StringBuilder hql = new StringBuilder("FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); query.setParameter("serviceName", serviceName); query.setParameter("serviceVersion", serviceVersion); @@ -2463,8 +2452,7 @@ public class CatalogDatabase implements Closeable { public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName) { LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelName = :serviceName"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelName = :serviceName"); query.setParameter("serviceName", serviceName); @SuppressWarnings("unchecked") @@ -2473,7 +2461,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return Collections.EMPTY_LIST; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); @@ -2484,8 +2472,7 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllVnfsByVnfModelCustomizationUuid - " + vnfModelCustomizationUuid); - StringBuilder hql1 = new StringBuilder("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); - Query query1 = getSession().createQuery(hql1.toString()); + Query query1 = getSession().createQuery("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); query1.setParameter("vrcmcu", vnfModelCustomizationUuid); @SuppressWarnings("unchecked") List<VnfResourceCustomization> resultList1 = query1.list(); @@ -2494,12 +2481,12 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Found no records matching " + vnfModelCustomizationUuid); return Collections.EMPTY_LIST; } - - for (VnfResourceCustomization vrc : resultList1) { - VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); - vrc.setVnfResource(vr); - vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); - } + + for (VnfResourceCustomization vrc : resultList1) { + VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); + vrc.setVnfResource(vr); + vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); + } LOGGER.debug("Returning " + resultList1.size() + " vnf modules"); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByVnfModelCustomizationUuid", null); @@ -2534,8 +2521,7 @@ public class CatalogDatabase implements Closeable { public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2545,7 +2531,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2558,8 +2544,8 @@ public class CatalogDatabase implements Closeable { public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2571,7 +2557,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2584,8 +2570,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllAllottedResourcesByArModelCustomizationUuid - " + arModelCustomizationUuid); - StringBuilder hql = new StringBuilder("FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); query.setParameter("arModelCustomizationUuid", arModelCustomizationUuid); @SuppressWarnings("unchecked") @@ -2643,7 +2629,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2662,8 +2648,7 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2673,7 +2658,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2693,8 +2678,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); //TODO make this a unique query @@ -2706,7 +2691,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2754,7 +2739,7 @@ public class CatalogDatabase implements Closeable { } private void populateNetworkResourceType(List<NetworkResourceCustomization> resultList) { - HashMap<String, NetworkResource> networkResources = new HashMap<String, NetworkResource>(); + HashMap<String, NetworkResource> networkResources = new HashMap<>(); for (NetworkResourceCustomization nrc : resultList) { String network_id = nrc.getNetworkResourceModelUuid(); @@ -2792,12 +2777,10 @@ public class CatalogDatabase implements Closeable { public VnfRecipe getVfModuleRecipe (String vnfType, String vfModuleModelName, String action) { String vfModuleType = vnfType + "::" + vfModuleModelName; - StringBuilder hql = new StringBuilder ("FROM VfModule WHERE type = :type "); - long startTime = System.currentTimeMillis (); LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType); - Query query = getSession ().createQuery (hql.toString ()); + Query query = getSession ().createQuery ("FROM VfModule WHERE type = :type "); query.setParameter (TYPE, vfModuleType); @SuppressWarnings("unchecked") @@ -2808,20 +2791,18 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); String vfModuleId = vfMod.getModelUUID(); - StringBuilder hql1 = new StringBuilder ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - LOGGER.debug ("Catalog database - get VNF recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2833,7 +2814,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVfModuleRecipe", null); @@ -2844,7 +2825,7 @@ public class CatalogDatabase implements Closeable { * Return a VNF Module List that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION * - * @param vnfModuleType + * @param vfModuleType * @parm modelCustomizationUuid * @param asdcServiceModelVersion * @param modelVersion @@ -2900,20 +2881,19 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); String vfModuleId = vfMod.getModelUUID(); - StringBuilder hql1 = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ( + "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2925,7 +2905,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); @@ -2955,20 +2935,19 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); - String vfModuleId = vfMod.getModelName(); - - StringBuilder hql1 = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); + String vfModuleId = vfMod.getModelName(); LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ( + "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2980,7 +2959,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); @@ -3384,7 +3363,9 @@ public class CatalogDatabase implements Closeable { /** * Return a ServiceToResourceCustomization object * - * @param vfModuleModelUuid, heatFilesArtifactUuid + * @param serviceModelUuid + * @param resourceModelCustomizationUuid + * @param modelType * @return VfModuleToHeatFiles or null if none found */ public ServiceToResourceCustomization getServiceToResourceCustomization(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { @@ -3410,7 +3391,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Map<String, HeatFiles> for returning the heat files associated with a vfModule 1707 * - * @param parentHeatTemplateId + * @param vfModuleModelUuid * @return Map<String,Object> or null if none found */ public Map <String, HeatFiles> getHeatFilesForVfModule(String vfModuleModelUuid) { @@ -3626,7 +3607,7 @@ public class CatalogDatabase implements Closeable { /** * Retrieves a Heat environment from DB based on its unique key. 1707 * - * @param name the environment artifact name + * @param artifactUuid the environment artifact name * @param version the environment resource version * @return the heat environment from DB or null if not found */ @@ -3859,7 +3840,7 @@ public class CatalogDatabase implements Closeable { /** * Return the newest version of a specific Tosca CSAR Record resource (queried by Name). * - * @param ToscaCsar + * @param artifactChecksum * @return ToscaCsar object or null if none found */ public ToscaCsar getToscaCsar (String artifactChecksum) { @@ -4422,9 +4403,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelUUID * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelUuid(String modelUUID) { @@ -4444,7 +4423,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4495,7 +4474,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4554,7 +4533,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4594,7 +4573,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4606,9 +4585,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelCustomizationUuid * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) { @@ -4628,7 +4605,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4685,7 +4662,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4697,7 +4674,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VnfComponents recipe that matches a given VF_MODULE_ID, VNF_COMPONENT_TYPE, ACTION * - * @param vfModuleId + * @param vfModuleModelUUId * @param vnfComponentType * @param action * @return VnfComponentsRecipe object or null if none found @@ -4728,7 +4705,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4757,7 +4734,7 @@ public class CatalogDatabase implements Closeable { return Collections.EMPTY_LIST; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleRecipes", null); @@ -4807,7 +4784,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4819,7 +4796,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VfModule record that matches a given MODEL_NAME * - * @param modelName + * @param modelUUID * @return VfModule object or null if none found */ public VfModule getVfModuleByModelUUID (String modelUUID) { @@ -4841,7 +4818,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4882,7 +4859,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -4954,7 +4931,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -5002,7 +4979,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - modelResultList is null"); return null; } - Collections.sort(modelResultList, new MavenLikeVersioningComparator()); + modelResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(modelResultList); LOGGER.debug("Catalog database - modelResultList contains " + modelResultList.get(0).toString()); @@ -5019,7 +4996,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -5181,7 +5158,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java index daeefcce02..6fdf236a27 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java @@ -130,20 +130,12 @@ public class AllottedResourceCustomization extends MavenLikeVersioning implement } @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("modelCustomizationUuid="); - sb.append(this.modelCustomizationUuid); - sb.append(",modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append(",modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append(",created="); - sb.append(this.created); - sb.append(",ar="); - sb.append(this.ar); - - return sb.toString(); + public String toString() { + return "modelCustomizationUuid=" + this.modelCustomizationUuid + + ",modelInstanceName=" + this.modelInstanceName + + ",modelInstanceName=" + this.modelInstanceName + + ",created=" + this.created + + ",ar=" + this.ar; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java index b4c1f0594f..e22d1eb036 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java @@ -37,10 +37,6 @@ public class ArRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append(",modelName=").append(modelName); - sb.append(",arParamXSD=").append(getParamXSD()); - return sb.toString(); + return super.toString() + ",modelName=" + modelName + ",arParamXSD=" + getParamXSD(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java index 54acf12ca8..f6202b7365 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java @@ -44,15 +44,12 @@ public class HeatTemplateArtifactUuidModelUuid implements Serializable { public void setModelUuid(String modelUuid) {
this.modelUuid = modelUuid;
}
-
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("heatTemplateArtifactUuid=").append(this.heatTemplateArtifactUuid);
- sb.append(" modelUuid=").append(this.modelUuid);
- return sb.toString();
+ return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid;
}
-
+
@Override
public boolean equals (Object o) {
if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) {
@@ -73,9 +70,7 @@ public class HeatTemplateArtifactUuidModelUuid implements Serializable { public int hashCode () {
// hash code does not have to be a unique result - only that two objects that should be treated as equal
// return the same value. so this should work.
- int result;
- result = this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode();
- return result;
+ return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode();
}
}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java index 7f8c3dbacb..7ef5a4a7b9 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java @@ -89,7 +89,7 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { } /** - * @param versionStr the versionStr to set + * @param schemaVersion the versionStr to set */ public void setSchemaVersion(String schemaVersion) { this.schemaVersion = schemaVersion; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java index 4e905b62c8..eeaa363aa6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java @@ -37,10 +37,6 @@ public class NetworkRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append(",modelName=").append(modelName); - sb.append(",networkParamXSD=").append(getParamXSD()); - return sb.toString(); + return super.toString() + ",modelName=" + modelName + ",networkParamXSD=" + getParamXSD(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java index ef09fef41f..b581545182 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java @@ -103,24 +103,14 @@ public class NetworkResourceCustomization implements Serializable{ } @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("modelCustomizationUuid="); - sb.append(this.modelCustomizationUuid); - sb.append("networkResourceModelUuid="); - sb.append(this.networkResourceModelUuid); - sb.append("modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append("networkType="); - sb.append(this.networkType); - sb.append("networkTechnology="); - sb.append(this.networkTechnology); - sb.append("networkScope="); - sb.append(this.networkScope); - sb.append("networkRole="); - sb.append(this.networkRole); - - return sb.toString(); + public String toString() { + return "modelCustomizationUuid=" + this.modelCustomizationUuid + + "networkResourceModelUuid=" + this.networkResourceModelUuid + + "modelInstanceName=" + this.modelInstanceName + + "networkType=" + this.networkType + + "networkTechnology=" + this.networkTechnology + + "networkScope=" + this.networkScope + + "networkRole=" + this.networkRole; } @Override diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java index 645626d125..78f94e40c1 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java @@ -43,7 +43,7 @@ public class ServiceMacroHolder implements Serializable { public ServiceMacroHolder() { super(); this.service = null; - this.vnfResources = new ArrayList<VnfResource>(); + this.vnfResources = new ArrayList<>(); this.networkResourceCustomizations = new ArrayList<>(); this.allottedResourceCustomizations = new ArrayList<>(); this.vnfResourceCustomizations = new ArrayList<>(); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java index 59495f40c6..6515a12bc0 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java @@ -71,22 +71,16 @@ public class ServiceToAllottedResources implements Serializable { @Override public int hashCode() { - + int code = this.arModelCustomizationUuid == null ? 0 : this.arModelCustomizationUuid.hashCode(); code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); return code; } - + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("serviceModelUuid="); - sb.append(this.serviceModelUuid); - sb.append("arModelCustomizationUuid="); - sb.append(this.arModelCustomizationUuid); - - return sb.toString(); + return "serviceModelUuid=" + this.serviceModelUuid + "arModelCustomizationUuid=" + this.arModelCustomizationUuid; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java index a380a58c6b..69dc32796f 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java @@ -80,14 +80,11 @@ public class ServiceToNetworks implements Serializable { return code; } - + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServiceToNetworks mapping: "); - sb.append("serviceModelUuid=").append(this.serviceModelUuid); - sb.append(",networkModelCustomizationUuid=").append(networkModelCustomizationUuid); - return sb.toString(); + return "ServiceToNetworks mapping: " + "serviceModelUuid=" + this.serviceModelUuid + + ",networkModelCustomizationUuid=" + networkModelCustomizationUuid; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java index 783fc2df30..3ef7e6e237 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java @@ -23,7 +23,7 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable;
public class TempNetworkHeatTemplateLookup implements Serializable {
-
+
private String networkResourceModelName;
private String heatTemplateArtifactUuid;
private String aicVersionMin;
@@ -33,14 +33,14 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public TempNetworkHeatTemplateLookup() {
super();
}
-
+
public String getNetworkResourceModelName() {
return this.networkResourceModelName;
}
public void setNetworkResourceModelName(String networkResourceModelName) {
this.networkResourceModelName = networkResourceModelName;
}
-
+
public String getHeatTemplateArtifactUuid() {
return this.heatTemplateArtifactUuid;
}
@@ -50,29 +50,26 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public String getAicVersionMin() {
return this.aicVersionMin;
}
-
+
public void setAicVersionMin(String aicVersionMin) {
this.aicVersionMin = aicVersionMin;
}
-
+
public String getAicVersionMax() {
return this.aicVersionMax;
}
-
+
public void setAicVersionMax(String aicVersionMax) {
this.aicVersionMax = aicVersionMax;
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("NetworkResourceModelName=").append(this.networkResourceModelName);
- sb.append("HeatTemplateArtifactUuid=").append(this.heatTemplateArtifactUuid);
- sb.append("aicVersionMin=").append(this.aicVersionMin);
- sb.append("aicVersionMax=").append(this.aicVersionMax);
- return sb.toString();
+ return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" +
+ this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof TempNetworkHeatTemplateLookup)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java index 9f2dae5035..db3a2664a8 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java @@ -109,22 +109,22 @@ public class VfModuleCustomization implements Serializable { public void setVfModule(VfModule vfModule) {
this.vfModule = vfModule;
}
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("modelCustomizationUuid=").append(this.modelCustomizationUuid);
- sb.append("vfModuleModelUuid=").append(this.vfModuleModelUuid);
- sb.append("label=").append(this.label);
- sb.append("initalCount=").append(this.initialCount);
- sb.append("minInstances=").append(this.minInstances);
- sb.append("maxInstances=").append(this.maxInstances);
- sb.append("availabilityZoneCount=").append(this.availabilityZoneCount);
- sb.append("heatEnvironmentArtifactUuid=").append(this.heatEnvironmentArtifactUuid);
- sb.append("volEnvironmentArtifactUuid=").append(this.volEnvironmentArtifactUuid);
- sb.append("created=").append(this.created);
- return sb.toString();
+ return "modelCustomizationUuid=" + this.modelCustomizationUuid +
+ "vfModuleModelUuid=" + this.vfModuleModelUuid +
+ "label=" + this.label +
+ "initalCount=" + this.initialCount +
+ "minInstances=" + this.minInstances +
+ "maxInstances=" + this.maxInstances +
+ "availabilityZoneCount=" + this.availabilityZoneCount +
+ "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid +
+ "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid +
+ "created=" + this.created;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof VfModuleCustomization)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java index 476283e6b0..611604e830 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java @@ -46,13 +46,10 @@ public class VfModuleToHeatFiles implements Serializable { public void setHeatFilesArtifactUuid(String heatFilesArtifactUuid) { this.heatFilesArtifactUuid = heatFilesArtifactUuid; } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder (); - sb.append("vfModuleModelUuid=").append(this.vfModuleModelUuid); - sb.append(", heatFilesArtifactUuid=").append(this.heatFilesArtifactUuid); - return sb.toString (); - } + + @Override + public String toString() { + return "vfModuleModelUuid=" + this.vfModuleModelUuid + ", heatFilesArtifactUuid=" + this.heatFilesArtifactUuid; + } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java index 6eac5a23ea..30a5133bd5 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java @@ -56,12 +56,7 @@ public class VnfComponentsRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append(",vnfComponentParamXSD=").append(getParamXSD()); - sb.append(",serviceType=").append(getServiceType()); - sb.append(",vnfComponentType=").append(getVnfComponentType()); - sb.append(",vfModuleId=").append(getVfModuleModelUUId()); - return sb.toString(); + return super.toString() + ",vnfComponentParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + + ",vnfComponentType=" + getVnfComponentType() + ",vfModuleId=" + getVfModuleModelUUId(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java index 46017c2205..0dd38cbbc1 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java @@ -48,11 +48,7 @@ public class VnfRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append(",vnfParamXSD=").append(getParamXSD()); - sb.append(",serviceType=").append(getServiceType()); - sb.append(",vfModuleId=").append(getVfModuleId()); - return sb.toString(); + return super.toString() + ",vnfParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + ",vfModuleId=" + + getVfModuleId(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java index 7b2364d194..fd1e6b67b8 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java @@ -53,15 +53,14 @@ public class VnfResCustomToVfModuleCustom implements Serializable { public void setCreated(Timestamp created) {
this.created = created;
}
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("vnfResourceCustModelCustomizationUuid=").append(this.vnfResourceCustModelCustomizationUuid);
- sb.append("vfModuleCustModelCustomizationUuid=").append(this.vfModuleCustModelCustomizationUuid);
- sb.append("created=").append(this.created);
- return sb.toString();
+ return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid +
+ "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof VnfResCustomToVfModuleCustom)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java index f0b990acae..806cbeb076 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java @@ -195,7 +195,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { } public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations == null ? new ArrayList<VfModuleCustomization>() : this.vfModuleCustomizations; + return this.vfModuleCustomizations == null ? new ArrayList<>() : this.vfModuleCustomizations; } public void setVfModuleCustomizations(ArrayList<VfModuleCustomization> vfModuleCustomizations) { this.vfModuleCustomizations = vfModuleCustomizations; @@ -205,7 +205,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModuleCustomizations != null) { this.vfModuleCustomizations.add(vfmc); } else { - this.vfModuleCustomizations = new ArrayList<VfModuleCustomization>(); + this.vfModuleCustomizations = new ArrayList<>(); this.vfModuleCustomizations.add(vfmc); } } @@ -216,7 +216,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModules != null) { this.vfModules.add(vfm); } else { - this.vfModules = new HashSet<VfModule>(); + this.vfModules = new HashSet<>(); this.vfModules.add(vfm); } } @@ -225,7 +225,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModules == null || this.vfModules.size() < 1) { return null; } - ArrayList<VfModule> list = new ArrayList<VfModule>(); + ArrayList<VfModule> list = new ArrayList<>(); list.addAll(this.vfModules); return list; } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java index 151c9e594e..cb5bf64b8c 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java @@ -155,7 +155,7 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser if (this.vfModuleCustomizations != null) { this.vfModuleCustomizations.add(vfmc); } else { - this.vfModuleCustomizations = new ArrayList<VfModuleCustomization>(); + this.vfModuleCustomizations = new ArrayList<>(); this.vfModuleCustomizations.add(vfmc); } } @@ -179,21 +179,17 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser @Override public String toString() { - StringBuilder sb = new StringBuilder("VnfResourceCustomization: "); - sb.append("ModelCustUuid=").append(this.modelCustomizationUuid); - sb.append(", ModelInstanceName=").append(this.modelInstanceName); - sb.append(", vnfResourceModelUuid=").append(this.vnfResourceModelUUID); - sb.append(", creationTimestamp=").append(this.created); - sb.append(", minInstances=").append(this.minInstances); - sb.append(", maxInstances=").append(this.maxInstances); - sb.append(", availabilityZoneMaxCount=").append(this.availabilityZoneMaxCount); -// sb.append(", vnfResource:\n" + this.vnfResource == null ? "null" : this.vnfResource.toString()); - sb.append(", nfFunction=").append(this.nfFunction); - sb.append(", nfType=").append(this.nfType); - sb.append(", nfRole=").append(this.nfRole); - sb.append(", nfNamingCode=").append(this.nfNamingCode); - - return sb.toString(); + return "VnfResourceCustomization: " + "ModelCustUuid=" + this.modelCustomizationUuid + + ", ModelInstanceName=" + this.modelInstanceName + + ", vnfResourceModelUuid=" + this.vnfResourceModelUUID + + ", creationTimestamp=" + this.created + + ", minInstances=" + this.minInstances + + ", maxInstances=" + this.maxInstances + + ", availabilityZoneMaxCount=" + this.availabilityZoneMaxCount + + ", nfFunction=" + this.nfFunction + + ", nfType=" + this.nfType + + ", nfRole=" + this.nfRole + + ", nfNamingCode=" + this.nfNamingCode; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java index 564fd5a019..e42f734a64 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java @@ -51,29 +51,32 @@ public class MavenLikeVersioning implements Serializable { * */ public boolean isMoreRecentThan (String versionToCompare) { - if (versionToCompare == null || versionToCompare.trim().equals("") || this.version == null || this.version.trim().equals("")) { + if (versionToCompare == null || versionToCompare.trim().isEmpty() || this.version == null || this.version.trim().isEmpty()) { return false; } - String [] currentVersionArray = this.version.split("\\."); - String [] specifiedVersionArray = versionToCompare.split("\\."); + String[] currentVersionArray = this.version.split("\\."); + String[] specifiedVersionArray = versionToCompare.split("\\."); - int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); + int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); - for (int currentVersionIndex=0;currentVersionIndex < smalestStringLength;++currentVersionIndex) { + for (int currentVersionIndex = 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) { - if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer + .parseInt(specifiedVersionArray[currentVersionIndex])) { return false; - } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer + .parseInt(specifiedVersionArray[currentVersionIndex])) { return true; } } - - // Even if versionToCompare has more digits, it means versionToCompare is more recent - if (Integer.parseInt(currentVersionArray[smalestStringLength-1]) == Integer.parseInt(specifiedVersionArray[smalestStringLength-1])) { - return currentVersionArray.length > specifiedVersionArray.length; + try { + // Even if versionToCompare has more digits, it means versionToCompare is more recent + return Integer.parseInt(currentVersionArray[smalestStringLength - 1]) != Integer + .parseInt(specifiedVersionArray[smalestStringLength - 1]) + || currentVersionArray.length > specifiedVersionArray.length; + } catch (NumberFormatException e) { + return false; } - - return true; } /** |