From 537dbf3c6bb923156f51fe7e21be798777a1689b Mon Sep 17 00:00:00 2001 From: YuanHu Date: Wed, 19 Oct 2016 11:47:17 +0800 Subject: To fix the gaps between catalog model manager and aria parser. Change-Id: I36430decf0092f75cd0f191d841f8f6b48f23b4d Issue-id: TOSCA-122 Signed-off-by: YuanHu --- .../model/parser/yaml/aria/AriaModelParser.java | 23 +++++++++------------- .../parser/yaml/aria/entity/AriaParserResult.java | 17 +++++++++++----- .../parser/yaml/aria/service/IAriaParserRest.java | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'catalog-core/catalog-mgr') 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 inputs; private Map outpus; - + public Map 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; -- cgit 1.2.3-korg