diff options
author | 2016-10-19 11:47:17 +0800 | |
---|---|---|
committer | 2016-10-19 11:47:17 +0800 | |
commit | 537dbf3c6bb923156f51fe7e21be798777a1689b (patch) | |
tree | dffa2b8327c587f004a63f69ba5605e795f748ad /catalog-core/catalog-mgr | |
parent | e81b7ee0258a74effcfba1f32fc9a141e717dd58 (diff) |
To fix the gaps between catalog model manager and aria parser.
Change-Id: I36430decf0092f75cd0f191d841f8f6b48f23b4d
Issue-id: TOSCA-122
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'catalog-core/catalog-mgr')
3 files changed, 22 insertions, 20 deletions
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 3cf16bd3..49c1fcf1 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 @@ -18,6 +18,7 @@ package org.openo.commontosca.catalog.model.parser.yaml.aria; import org.openo.commontosca.catalog.common.ToolUtil; import org.openo.commontosca.catalog.db.exception.CatalogResourceException; import org.openo.commontosca.catalog.db.resource.TemplateManager; +import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse; import org.openo.commontosca.catalog.model.common.TemplateDataHelper; import org.openo.commontosca.catalog.model.entity.InputParameter; import org.openo.commontosca.catalog.model.entity.NodeTemplate; @@ -34,8 +35,8 @@ import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserRes import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserResult.Output; import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserResult.Substitution.Mapping; import org.openo.commontosca.catalog.model.parser.yaml.aria.service.AriaParserServiceConsumer; +import org.openo.commontosca.catalog.wrapper.PackageWrapper; -import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -53,11 +54,11 @@ public class AriaModelParser extends AbstractModelParser { */ @Override public String parse(String packageId, String fileLocation) throws CatalogResourceException { - AriaParserResult result = getAriaParserResult(fileLocation); + String stFileLocation = parseServiceTemplateFileName(packageId, fileLocation); + AriaParserResult result = getAriaParserResult(packageId, fileLocation, stFileLocation); // service template - ServiceTemplate st = parseServiceTemplate( - result, packageId, parseServiceTemplateFileName(packageId, fileLocation)); + ServiceTemplate st = parseServiceTemplate(result, packageId, stFileLocation); // workflow ServiceTemplateOperation[] operations = parseOperations(fileLocation); st.setOperations(operations); @@ -290,16 +291,10 @@ public class AriaModelParser extends AbstractModelParser { return retList.toArray(new OutputParameter[0]); } - private AriaParserResult getAriaParserResult(String fileLocation) throws CatalogResourceException { - String destPath = copyTemporaryFile2HttpServer(fileLocation); - try { - String url = getUrlOnHttpServer(toTempFilePath(fileLocation)); - return AriaParserServiceConsumer.parseCsarPackage(url); - } finally { - if (destPath != null && !destPath.isEmpty() && (new File(destPath)).exists()) { - (new File(destPath)).delete(); - } - } + private AriaParserResult getAriaParserResult(String packageId, String fileLocation, String stFileLocation) throws CatalogResourceException { + CsarFileUriResponse stDownloadUri = + PackageWrapper.getInstance().getCsarFileDownloadUri(packageId, stFileLocation); + return AriaParserServiceConsumer.parseCsarPackage(stDownloadUri.getDownloadUri()); } } 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 3d87ab20..2b5e0edb 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 @@ -15,14 +15,14 @@ */ package org.openo.commontosca.catalog.model.parser.yaml.aria.entity; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + @Data @NoArgsConstructor @AllArgsConstructor @@ -36,7 +36,14 @@ public class AriaParserResult { private Map<String, Input> inputs; private Map<String, Output> outpus; - + public Map<String, String> getMetadata() { + if (this.metadata == null) { + return new HashMap<>(); + } + + return metadata; + } + @Data public class Node { private String id; diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java index 8ba537f2..df9e50d3 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java @@ -28,7 +28,7 @@ import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserReq public interface IAriaParserRest { @POST - @Path("/indirect/plan") + @Path("/indirect/instance") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) String parse(AriaParserRequest request) throws Exception; |