aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateUtils.java22
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java34
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java6
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java15
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/EnumYamlServiceTemplateInfo.java44
5 files changed, 78 insertions, 43 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateUtils.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateUtils.java
index e1e89d19..ffb4a4dc 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateUtils.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateUtils.java
@@ -15,16 +15,6 @@
*/
package org.openo.commontosca.catalog.model.common;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.model.parser.yaml.yamlmodel.Plan;
-import org.openo.commontosca.catalog.model.parser.yaml.yamlmodel.ServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.esotericsoftware.yamlbeans.YamlConfig;
-import com.esotericsoftware.yamlbeans.YamlException;
-import com.esotericsoftware.yamlbeans.YamlReader;
-
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
@@ -37,6 +27,17 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.model.parser.yaml.yamlmodel.Input;
+import org.openo.commontosca.catalog.model.parser.yaml.yamlmodel.Plan;
+import org.openo.commontosca.catalog.model.parser.yaml.yamlmodel.ServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.esotericsoftware.yamlbeans.YamlConfig;
+import com.esotericsoftware.yamlbeans.YamlException;
+import com.esotericsoftware.yamlbeans.YamlReader;
+
public class TemplateUtils {
private static final Logger logger = LoggerFactory.getLogger(TemplateUtils.class);
@@ -76,6 +77,7 @@ public class TemplateUtils {
*/
private static void adjustConfig(YamlConfig config) {
config.setPropertyElementType(ServiceTemplate.class, "plans", Plan.class);
+ config.setPropertyElementType(Plan.class, "inputs", Input.class);
}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
index 2c40f832..5b777f9d 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
@@ -213,4 +213,38 @@ public abstract class AbstractModelParser {
return retList.toArray(new InputParameter[0]);
}
+
+ /**
+ * @param metadata
+ * @return
+ */
+ public String parserServiceTemplateName(Map<String, String> metadata) {
+ if (metadata.containsKey("name")) {
+ return metadata.get("name");
+ }
+ return metadata.get("template_name");
+ }
+
+ /**
+ * @param metadata
+ * @return
+ */
+ public String parserServiceTemplateVendor(Map<String, String> metadata) {
+ if (metadata.containsKey("vendor")) {
+ return metadata.get("vendor");
+ }
+ return metadata.get("template_author");
+ }
+
+ /**
+ * @param metadata
+ * @return
+ */
+ public String parserServiceTemplateVersion(Map<String, String> metadata) {
+ if (metadata.containsKey("version")) {
+ return metadata.get("version");
+ }
+ return metadata.get("template_version");
+ }
+
}
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 2501a158..d70eb932 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
@@ -243,9 +243,9 @@ public class AriaModelParser extends AbstractModelParser {
ServiceTemplate st = new ServiceTemplate();
st.setServiceTemplateId(ToolUtil.generateId());
- st.setTemplateName(result.getInstance().getMetadata().get("template_name"));
- st.setVendor(result.getInstance().getMetadata().get("template_author"));
- st.setVersion(result.getInstance().getMetadata().get("template_version"));
+ st.setTemplateName(parserServiceTemplateName(result.getInstance().getMetadata()));
+ st.setVendor(parserServiceTemplateVendor(result.getInstance().getMetadata()));
+ st.setVersion(parserServiceTemplateVersion(result.getInstance().getMetadata()));
st.setCsarId(packageId);
st.setDownloadUri(downloadUri);
st.setInputs(parseInputs(result));
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 f7deaa42..8ec78348 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
@@ -15,6 +15,10 @@
*/
package org.openo.commontosca.catalog.model.parser.yaml.zte;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
import org.openo.commontosca.catalog.common.ToolUtil;
import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
import org.openo.commontosca.catalog.db.resource.TemplateManager;
@@ -27,7 +31,6 @@ import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
import org.openo.commontosca.catalog.model.entity.ServiceTemplateOperation;
import org.openo.commontosca.catalog.model.entity.SubstitutionMapping;
import org.openo.commontosca.catalog.model.parser.AbstractModelParser;
-import org.openo.commontosca.catalog.model.parser.yaml.zte.entity.EnumYamlServiceTemplateInfo;
import org.openo.commontosca.catalog.model.parser.yaml.zte.entity.ParseYamlRequestParemeter;
import org.openo.commontosca.catalog.model.parser.yaml.zte.entity.ParseYamlResult;
import org.openo.commontosca.catalog.model.parser.yaml.zte.entity.ParseYamlResult.TopologyTemplate.Input;
@@ -37,10 +40,6 @@ import org.openo.commontosca.catalog.model.parser.yaml.zte.service.YamlParseServ
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
public class ToscaYamlModelParser extends AbstractModelParser {
private static final Logger logger = LoggerFactory.getLogger(ToscaYamlModelParser.class);
@@ -109,9 +108,9 @@ public class ToscaYamlModelParser extends AbstractModelParser {
ServiceTemplate st = new ServiceTemplate();
st.setServiceTemplateId(ToolUtil.generateId());
- st.setTemplateName(result.getMetadata().get(EnumYamlServiceTemplateInfo.ID.getName()));
- st.setVendor(result.getMetadata().get(EnumYamlServiceTemplateInfo.PROVIDER.getName()));
- st.setVersion(result.getMetadata().get(EnumYamlServiceTemplateInfo.VERSION.getName()));
+ st.setTemplateName(parserServiceTemplateName(result.getMetadata()));
+ st.setVendor(parserServiceTemplateVendor(result.getMetadata()));
+ st.setVersion(parserServiceTemplateVersion(result.getMetadata()));
st.setCsarId(packageId);
st.setDownloadUri(stDownloadUri);
st.setInputs(parseInputs(result));
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/EnumYamlServiceTemplateInfo.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/EnumYamlServiceTemplateInfo.java
index 18d457eb..a6a75ebf 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/EnumYamlServiceTemplateInfo.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/EnumYamlServiceTemplateInfo.java
@@ -16,25 +16,25 @@
package org.openo.commontosca.catalog.model.parser.yaml.zte.entity;
-public enum EnumYamlServiceTemplateInfo {
- ID {
- @Override
- public String getName() {
- return "id";
- }
- },
- VERSION {
- @Override
- public String getName() {
- return "version";
- }
- },
- PROVIDER {
- @Override
- public String getName() {
- return "vendor";
- }
- };
-
- public abstract String getName();
-}
+//public enum EnumYamlServiceTemplateInfo {
+// ID {
+// @Override
+// public String getName() {
+// return "id";
+// }
+// },
+// VERSION {
+// @Override
+// public String getName() {
+// return "version";
+// }
+// },
+// PROVIDER {
+// @Override
+// public String getName() {
+// return "vendor";
+// }
+// };
+//
+// public abstract String getName();
+//}