Fix service create request body bug for so 51/48051/1
authorzhangab <zhanganbing@chinamobile.com>
Thu, 17 May 2018 13:42:04 +0000 (21:42 +0800)
committerzhangab <zhanganbing@chinamobile.com>
Thu, 17 May 2018 13:42:12 +0000 (21:42 +0800)
Change-Id: Id6e9244ad73bef791550aab9cb7813db75c2b393
Issue-ID: USECASEUI-115
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java

index 472f540..ef65476 100755 (executable)
  */\r
 package org.onap.usecaseui.server.constant;\r
 \r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;\r
 \r
 public final class Constant\r
 {\r
@@ -22,5 +26,6 @@ public final class Constant
     public static final String DATE_FORMAT= "yyyy-MM-dd HH:mm:ss";\r
 \r
     public static final String RegEX_DATE_FORMAT = "[^0-9-:]";\r
-\r
+    \r
+    public static Map<String,ServiceTemplateInput> netWorkMap  = new HashMap<String,ServiceTemplateInput>();\r
 }\r
index faf511d..abad7fb 100644 (file)
@@ -19,6 +19,7 @@ import com.google.common.io.Files;
 import okhttp3.ResponseBody;
 import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
 import org.onap.usecaseui.server.bean.lcm.TemplateInput;
+import org.onap.usecaseui.server.constant.Constant;
 import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController;
@@ -216,6 +217,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
         for (Map.Entry<String, Property> entry : properties.entrySet()) {
             String key = entry.getKey();
             if (key.endsWith("providing_service_uuid")) {
+               Constant.netWorkMap.put(String.valueOf(entry.getValue().getValue()), newServiceTemplateInput(nodeTemplate));
                 return String.valueOf(entry.getValue().getValue());
             }
         }
@@ -279,32 +281,36 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
     }
 
     private static ServiceTemplateInput newServiceTemplateInput(ToscaTemplate tosca) {
-        String invariantUUID = tosca.getMetaData().getValue("invariantUUID");
-        String uuid = tosca.getMetaData().getValue("UUID");
-        String name = tosca.getMetaData().getValue("name");
-        String type = tosca.getMetaData().getValue("type");
-        String version = tosca.getMetaData().getValue("version");
-        if (version == null) {
-            version = "";
-        }
-        String description = tosca.getMetaData().getValue("description");
-        String category = tosca.getMetaData().getValue("category");
-        String subcategory = tosca.getMetaData().getValue("subcategory");
-        String customizationUuid = tosca.getMetaData().getValue("customizationUUID");
-        if(subcategory == null) {
-            subcategory = "";
-        }
-        return new ServiceTemplateInput(
-                invariantUUID,
-                uuid,
-                name,
-                type,
-                version,
-                description,
-                category,
-                subcategory,
-                customizationUuid,
-                new ArrayList<>());
+       if(Constant.netWorkMap.containsKey(tosca.getMetaData().getValue("UUID"))){
+               return Constant.netWorkMap.get(tosca.getMetaData().getValue("UUID"));
+       }else{
+            String invariantUUID = tosca.getMetaData().getValue("invariantUUID");
+            String uuid = tosca.getMetaData().getValue("UUID");
+            String name = tosca.getMetaData().getValue("name");
+            String type = tosca.getMetaData().getValue("type");
+            String version = tosca.getMetaData().getValue("version");
+            if (version == null) {
+                version = "";
+            }
+            String description = tosca.getMetaData().getValue("description");
+            String category = tosca.getMetaData().getValue("category");
+            String subcategory = tosca.getMetaData().getValue("subcategory");
+            String customizationUuid = tosca.getMetaData().getValue("customizationUUID");
+            if(subcategory == null) {
+                subcategory = "";
+            }
+            return new ServiceTemplateInput(
+                    invariantUUID,
+                    uuid,
+                    name,
+                    type,
+                    version,
+                    description,
+                    category,
+                    subcategory,
+                    customizationUuid,
+                    new ArrayList<>());
+       }
     }
 
     private static ServiceTemplateInput newServiceTemplateInput(NodeTemplate nodeTemplate) {