diff options
author | kurczews <krzysztof.kurczewski@nokia.com> | 2017-12-04 09:07:36 +0100 |
---|---|---|
committer | kurczews <krzysztof.kurczewski@nokia.com> | 2017-12-04 09:07:36 +0100 |
commit | 44fa70bcf389af44484c984c5852e1aad397c43f (patch) | |
tree | fd8141968132c8e81cf0cd915c437e0083c18a9f /adapters/mso-catalog-db-adapter/src | |
parent | 777f637d0c2097d8a0805c4b7e920aa25575700f (diff) |
Remove duplicated constants
Replace duplicated regex patterns with more verbose constant
Change-Id: I21b5a1f8f00b8a8d059ab3998536b205ece892ce
Issue-ID: SO-353
Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src')
-rw-r--r-- | adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index e5147671f3..2e70391c05 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -30,8 +30,9 @@ import java.util.Map; @XmlRootElement(name = "serviceResources") @NoJackson public class QueryServiceMacroHolder extends CatalogQuery { - private ServiceMacroHolder serviceMacroHolder; - private final String template = + private ServiceMacroHolder serviceMacroHolder; + private static final String LINE_BEGINNING = "(?m)^"; + private static final String template = "{ \"serviceResources\" : {\n"+ "\t\"modelInfo\" : {\n"+ "\t\t\"modelName\" : <SERVICE_MODEL_NAME>,\n"+ @@ -46,7 +47,10 @@ public class QueryServiceMacroHolder extends CatalogQuery { "<_SERVICEALLOTTEDRESOURCES_>\n"+ "\t}}"; - public QueryServiceMacroHolder() { super(); serviceMacroHolder = new ServiceMacroHolder(); } + public QueryServiceMacroHolder() { + super(); + serviceMacroHolder = new ServiceMacroHolder(); + } public QueryServiceMacroHolder(ServiceMacroHolder vlist) { serviceMacroHolder = vlist; } public ServiceMacroHolder getServiceResources(){ return this.serviceMacroHolder; } @@ -58,7 +62,9 @@ public class QueryServiceMacroHolder extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean x) { Service service = serviceMacroHolder.getService(); - if (service == null) return "\"serviceResources\": null"; + if (service == null) { + return "\"serviceResources\": null"; + } StringBuilder buf = new StringBuilder(); Map<String, String> valueMap = new HashMap<>(); @@ -72,13 +78,13 @@ public class QueryServiceMacroHolder extends CatalogQuery { String subitem; subitem = new QueryServiceVnfs(serviceMacroHolder.getVnfResourceCustomizations()).JSON2(true, true); - valueMap.put("_SERVICEVNFS_", subitem.replaceAll("(?m)^", "\t")); + valueMap.put("_SERVICEVNFS_", subitem.replaceAll(LINE_BEGINNING, "\t")); subitem = new QueryServiceNetworks(serviceMacroHolder.getNetworkResourceCustomization()).JSON2(true, true); - valueMap.put("_SERVICENETWORKS_", subitem.replaceAll("(?m)^", "\t")); + valueMap.put("_SERVICENETWORKS_", subitem.replaceAll(LINE_BEGINNING, "\t")); subitem = new QueryAllottedResourceCustomization(serviceMacroHolder.getAllottedResourceCustomization()).JSON2(true, true); - valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll("(?m)^", "\t")); + valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t")); buf.append(this.setTemplate(template, valueMap)); return buf.toString(); |