}
// 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) {
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;
}
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;
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.");
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();
}
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()) {
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()) {