aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-core
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2016-10-26 16:23:24 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2016-10-26 16:23:24 +0800
commit5e21de34c68f18c7d78899df5622c2bf755d5b8b (patch)
treef5d7de984ec62c4c13b6d51eb948fc948bf2e794 /catalog-core
parent0f4c8814e91030c7b994e8cc783a464e8f318f21 (diff)
Directly use the response of aria parser as RawData,
instead of serializing from memory object. Change-Id: I9939987715afae95e4fbe1fb37e118f310b652b1 Issue-id: OCS-132 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'catalog-core')
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/SubstitutionMapping.java7
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/entity/AriaParserResult.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java1
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java24
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/service/YamlParseServiceConsumer.java4
7 files changed, 29 insertions, 13 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/SubstitutionMapping.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/SubstitutionMapping.java
index 41249385..cadbb34a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/SubstitutionMapping.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/SubstitutionMapping.java
@@ -15,18 +15,21 @@
*/
package org.openo.commontosca.catalog.model.entity;
+import java.util.HashMap;
+import java.util.Map;
+
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
-import java.util.HashMap;
-import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonIgnore;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SubstitutionMapping {
+ @JsonIgnore
private String serviceTemplateId;
private String nodeType;
private Map<String, String[]> requirements = new HashMap<String, String[]>();
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
index d70eb932..bfebe15d 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
@@ -72,7 +72,7 @@ public class AriaModelParser extends AbstractModelParser {
st.setType(getTemplateType(getSubstitutionType(result), ntList).toString());
// save to db
TemplateManager.getInstance().addServiceTemplate(
- TemplateDataHelper.convert2TemplateData(st, ToolUtil.toJson(result), ntList));
+ TemplateDataHelper.convert2TemplateData(st, result.getRawData(), ntList));
// substitution
SubstitutionMapping stm = parseSubstitutionMapping(st.getServiceTemplateId(), result);
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/entity/AriaParserResult.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/entity/AriaParserResult.java
index 7e80c901..f2968fd5 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/entity/AriaParserResult.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/entity/AriaParserResult.java
@@ -29,6 +29,8 @@ import lombok.NoArgsConstructor;
public class AriaParserResult {
private Issue[] issues;
private Instance instance = new Instance();
+
+ private String rawData;
// private Type[] types;
// private Model model;
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
index 5c18a851..1701c60f 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
@@ -51,6 +51,7 @@ public class AriaParserServiceConsumer {
IAriaParserRest.class);
String strResult = parseProxy.parse(request);
AriaParserResult result = new Gson().fromJson(strResult, AriaParserResult.class);
+ result.setRawData(strResult);
validateResult(result, strResult);
return result;
} catch (Exception e) {
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
index 8ec78348..7f57075b 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
@@ -59,7 +59,7 @@ public class ToscaYamlModelParser extends AbstractModelParser {
st.setType(getTemplateType(getSubstitutionType(result), ntList).toString());
// save to db
TemplateManager.getInstance().addServiceTemplate(
- TemplateDataHelper.convert2TemplateData(st, ToolUtil.toJson(result), ntList));
+ TemplateDataHelper.convert2TemplateData(st, result.getRawData(), ntList));
// substitution
SubstitutionMapping stm = parseSubstitutionMapping(st.getServiceTemplateId(), result);
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java
index 1089dc3d..5bdab1c2 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java
@@ -15,6 +15,17 @@
*/
package org.openo.commontosca.catalog.model.parser.yaml.zte.entity;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
import org.openo.commontosca.catalog.common.ToolUtil;
import com.google.gson.Gson;
@@ -23,13 +34,9 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
public class ParseYamlResult {
private String toscaDefinitionsVersion;
private String description;
@@ -40,7 +47,8 @@ public class ParseYamlResult {
private TopologyTemplate topologyTemplate;
private Map<String, String> metadata;
private JsonObject plans;
-
+
+ private String rawData;
public String getToscaDefinitionsVersion() {
return toscaDefinitionsVersion;
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/service/YamlParseServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/service/YamlParseServiceConsumer.java
index d6e9286e..2d9bd045 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/service/YamlParseServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/service/YamlParseServiceConsumer.java
@@ -46,7 +46,9 @@ public class YamlParseServiceConsumer {
ConsumerFactory.createConsumer(MsbUtil.getYamlParseBaseUrl(), config,
IYamlParseRest.class);
String jsonStr = yamlParseProxy.parse(request);
- return new Gson().fromJson(jsonStr, ParseYamlResult.class);
+ ParseYamlResult result = new Gson().fromJson(jsonStr, ParseYamlResult.class);
+ result.setRawData(jsonStr);
+ return result;
} catch (Exception e1) {
throw new CatalogResourceException("Call parser api failed.", e1);
}