diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2017-12-05 05:23:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-12-05 05:23:38 +0000 |
commit | 509a242c5ddd7dcb5211cc2d698268f44afea7df (patch) | |
tree | 200015c914de76df71a4daf8f7c3fe9532688747 /adapters | |
parent | 1e8cf3b711cb32fec8408903de5054236417a99c (diff) | |
parent | 44fa70bcf389af44484c984c5852e1aad397c43f (diff) |
Merge "Remove duplicated constants"
Diffstat (limited to 'adapters')
-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(); |