diff options
Diffstat (limited to 'catalog-core/catalog-mgr/src/main/java')
5 files changed, 12 insertions, 20 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java index dea67c83..5880df0c 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java @@ -38,8 +38,7 @@ public class HttpFileManagerImpl implements FileManager { } // File dstFile = new File(ToolUtil.getHttpServerPath() + dstPath); // LOGGER.info("dstFile AbsolutePath:" + dstFile.getAbsolutePath()); - String targetDir = - Class.class.getClass().getResource("/").getPath() + ToolUtil.getHttpServerPath() + dstPath; + String targetDir = ToolUtil.getHttpServerAbsolutePath() + dstPath; try { ToolUtil.copyDirectory(srcPath, targetDir, true); } catch (IOException e1) { @@ -60,7 +59,7 @@ public class HttpFileManagerImpl implements FileManager { public boolean delete(String srcPath) { boolean flag = true; LOGGER.info("start delete file from http server.srcPath:" + srcPath); - flag = ToolUtil.deleteDir(new File(ToolUtil.getHttpServerPath() + srcPath)); + flag = ToolUtil.deleteDir(new File(ToolUtil.getHttpServerAbsolutePath() + srcPath)); LOGGER.info("delete file from http server end.flag:" + flag); return flag; } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/ToolUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/ToolUtil.java index 931c5f33..2ceffb48 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/ToolUtil.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/ToolUtil.java @@ -170,8 +170,8 @@ public class ToolUtil { } } - public static String getHttpServerPath() { - return HttpServerPathConfig.getHttpServerPath(); + public static String getHttpServerAbsolutePath() { + return Class.class.getClass().getResource("/").getPath() + HttpServerPathConfig.getHttpServerPath(); } /** 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 4d2134fe..4b44a6ce 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 @@ -16,7 +16,7 @@ package org.openo.commontosca.catalog.model.parser; -import org.openo.commontosca.catalog.common.MsbAddrConfig; +import org.openo.commontosca.catalog.common.Config; import org.openo.commontosca.catalog.common.ToolUtil; import org.openo.commontosca.catalog.db.exception.CatalogResourceException; import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse; @@ -47,9 +47,8 @@ public abstract class AbstractModelParser { throws CatalogResourceException; public String copyTemporaryFile2HttpServer(String fileLocation) throws CatalogResourceException { - String destPath = Class.class.getClass().getResource("/").getPath() - + org.openo.commontosca.catalog.filemanage.http.ToolUtil.getHttpServerPath() - + toTempFileLocalPath(fileLocation); + String destPath = org.openo.commontosca.catalog.filemanage.http.ToolUtil.getHttpServerAbsolutePath() + + toTempFilePath(fileLocation); if (!org.openo.commontosca.catalog.filemanage.http.ToolUtil.copyFile( fileLocation, destPath, true)) { throw new CatalogResourceException("Copy Temporary To HttpServer Failed."); @@ -57,17 +56,11 @@ public abstract class AbstractModelParser { return destPath; } - public String getUrl(String uri) { - String url = null; - if ((MsbAddrConfig.getMsbAddress().endsWith("/")) && uri.startsWith("/")) { - url = MsbAddrConfig.getMsbAddress() + uri.substring(1); - } - url = MsbAddrConfig.getMsbAddress() + uri; - String urlresult = url.replace("\\", "/"); - return urlresult; + public String getUrlOnHttpServer(String path) { + return Config.getConfigration().getHttpServerAddr() + "/" + path; } - protected String toTempFileLocalPath(String fileLocation) { + protected String toTempFilePath(String fileLocation) { return File.separator + "temp" + File.separator + (new File(fileLocation)).getName(); } 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 33c1676a..70e8ff50 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 @@ -290,7 +290,7 @@ public class AriaModelParser extends AbstractModelParser { private AriaParserResult getAriaParserResult(String fileLocation) throws CatalogResourceException { String destPath = copyTemporaryFile2HttpServer(fileLocation); try { - String url = getUrl(toTempFileLocalPath(fileLocation)); + String url = getUrlOnHttpServer(toTempFilePath(fileLocation)); return AriaParserServiceConsumer.parseCsarPackage(url); } finally { if (destPath != null && !destPath.isEmpty() && (new File(destPath)).exists()) { 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 5b599987..760e31b4 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 @@ -81,7 +81,7 @@ public class ToscaYamlModelParser extends AbstractModelParser { private ParseYamlResult getParseYamlResult(String fileLocation) throws CatalogResourceException { String destPath = copyTemporaryFile2HttpServer(fileLocation); try { - String url = getUrl(toTempFileLocalPath(fileLocation)); + String url = getUrlOnHttpServer(toTempFilePath(fileLocation)); return YamlParseServiceConsumer.getServiceTemplates(comboRequest(url)); } finally { if (destPath != null && !destPath.isEmpty() && (new File(destPath)).exists()) { |