aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-core
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-core')
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java6
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java34
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java3
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java11
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java5
5 files changed, 51 insertions, 8 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java
index 60a08583..34159585 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java
@@ -87,12 +87,10 @@ public class ToolUtil {
InputStream uploadedInputStream) throws IOException {
File tmpDir = new File(dirName);
LOG.info("tmpdir = " + File.separator + dirName);
- LOG.info("tmpDir.getAbsolutePath() = " + tmpDir.getAbsolutePath());
if (!tmpDir.exists()) {
tmpDir.mkdirs();
}
-
- File file = new File(tmpDir.getAbsolutePath() + File.separator + fileName);
+ File file = new File(tmpDir + File.separator + fileName);
OutputStream os = null;
try {
int read = 0;
@@ -112,7 +110,7 @@ public class ToolUtil {
public static String getTempDir(String dirName, String fileName) {
// File tmpDir = new File(File.separator + dirName);
- return dirName + File.separator + fileName.replace(".csar", "");
+ return Class.class.getClass().getResource("/").getPath() + dirName + File.separator + fileName.replace(".csar", "");
}
public static String getUnzipDir(String dirName) {
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java
new file mode 100644
index 00000000..c4cab536
--- /dev/null
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.commontosca.catalog.entity;
+
+/**
+ * @author 00164331
+ *
+ */
+public enum EnumOnboardState {
+ onBoarded("onBoarded"), nonOnBoarded("non-onBoarded");
+
+ String value;
+
+ EnumOnboardState(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
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 c323f11a..f0a68d59 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,9 @@ 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;
try {
- ToolUtil.copyDirectory(srcPath, ToolUtil.getHttpServerPath() + dstPath, true);
+ ToolUtil.copyDirectory(srcPath, targetDir, true);
} catch (IOException e) {
flag = false;
LOGGER.error("copy file failed.errorMsg:" + e.getMessage());
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
index 7395ed16..ed20c14c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
@@ -42,6 +42,7 @@ import org.openo.commontosca.catalog.model.externalservice.lifecycle.LifeCycleSe
import org.openo.commontosca.catalog.common.ToolUtil;
import org.openo.commontosca.catalog.db.entity.PackageData;
import org.openo.commontosca.catalog.entity.CSARPackage;
+import org.openo.commontosca.catalog.entity.EnumOnboardState;
import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.entity.EnumUsageState;
import org.openo.commontosca.catalog.entity.response.PackageMeta;
@@ -146,7 +147,7 @@ public class PackageWrapperUtil {
packageMeta.setModifyTime(currentTime);
packageMeta.setOperationalState(EnumOperationalState.Disabled);
packageMeta.setUsageState(EnumUsageState.NotInUse);
- packageMeta.setOnBoardState("false");
+ packageMeta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
packageMeta.setProcessState(EnumProcessState.normal);
return packageMeta;
}
@@ -292,6 +293,14 @@ public class PackageWrapperUtil {
}
return metas;
}
+
+ public static EnumOnboardState getEnumByValue(String value) {
+ if(value == "non-onBoarded") {
+ return EnumOnboardState.nonOnBoarded;
+ } else {
+ return EnumOnboardState.onBoarded;
+ }
+ }
private static PackageMeta packageData2PackageMeta(PackageData packageData) {
PackageMeta meta = new PackageMeta();
diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
index 066710c4..f41a8cf7 100644
--- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
+++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
@@ -44,6 +44,7 @@ import org.openo.commontosca.catalog.db.dao.DaoManager;
import org.openo.commontosca.catalog.db.entity.PackageData;
import org.openo.commontosca.catalog.db.util.H2DbServer;
import org.openo.commontosca.catalog.db.util.HibernateSession;
+import org.openo.commontosca.catalog.entity.EnumOnboardState;
import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.entity.EnumProcessState;
import org.openo.commontosca.catalog.entity.EnumUsageState;
@@ -274,7 +275,7 @@ public class PackageWrapperTest {
packageData.setFormat("yml");
packageData.setModifyTime("2016-06-29 03:33:15");
packageData.setName("NanocellGW");
- packageData.setOnBoardState("false");
+ packageData.setOnBoardState("non-onBoarded");
packageData.setOperationalState("Disabled");
packageData.setProvider("ZTE");
packageData.setSize("0.93M");
@@ -310,7 +311,7 @@ public class PackageWrapperTest {
meta.setType("NSAR");
meta.setUsageState(EnumUsageState.valueOf("InUse"));
meta.setVersion("V1.0");
- meta.setOnBoardState("false");
+ meta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
meta.setProcessState(EnumProcessState.valueOf("normal"));
metas.add(meta);
return metas;