summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornancylizi <li.zi30@zte.com.cn>2016-10-21 15:57:05 +0800
committernancylizi <li.zi30@zte.com.cn>2016-10-21 17:13:05 +0800
commit019db808853d49b118e9c36f2a20667d47980873 (patch)
treee2ad535bf9edc54f1cd8a05bf7e307bbea5fb260
parent20ac436c362d77ccc5b6fae6fecf90e5f0cc5ae6 (diff)
Fix bugs TOSCA-123 GSO-33
Change-Id: Iabd06b1adc2399befd05e1411321c9beb417a94c Issue-id:TOSCA-123 GSO-33 Signed-off-by: nancylizi <li.zi30@zte.com.cn>
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java16
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java12
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java16
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java2
8 files changed, 31 insertions, 23 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
index 7019ebe0..b03946c4 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
@@ -71,7 +71,7 @@ public class TemplateDataHelper {
std.setTemplateName(st.getTemplateName());
std.setVendor(st.getVendor());
std.setVersion(st.getVersion());
- std.setCsarId(st.getCsarid());
+ std.setCsarId(st.getCsarId());
std.setType(st.getType());
std.setDownloadUri(st.getDownloadUri());
Parameters parameters = new Parameters(st.getInputs(), st.getOutputs());
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
index 7104aace..064940da 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
@@ -32,7 +32,7 @@ public class ServiceTemplate {
private String version;
- private String csarid;
+ private String csarId;
private String type;
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 ae8aaaed..8e5b749d 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
@@ -246,7 +246,7 @@ public class AriaModelParser extends AbstractModelParser {
st.setTemplateName(result.getMetadata().get("template_name"));
st.setVendor(result.getMetadata().get("template_author"));
st.setVersion(result.getMetadata().get("template_version"));
- st.setCsarid(packageId);
+ st.setCsarId(packageId);
st.setDownloadUri(downloadUri);
st.setInputs(parseInputs(result));
st.setOutputs(parseOutputs(result));
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 e22d840a..f7deaa42 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
@@ -112,7 +112,7 @@ public class ToscaYamlModelParser extends AbstractModelParser {
st.setTemplateName(result.getMetadata().get(EnumYamlServiceTemplateInfo.ID.getName()));
st.setVendor(result.getMetadata().get(EnumYamlServiceTemplateInfo.PROVIDER.getName()));
st.setVersion(result.getMetadata().get(EnumYamlServiceTemplateInfo.VERSION.getName()));
- st.setCsarid(packageId);
+ st.setCsarId(packageId);
st.setDownloadUri(stDownloadUri);
st.setInputs(parseInputs(result));
st.setOutputs(parseOutputs(result));
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
index ab206916..c796b85c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
@@ -66,10 +66,10 @@ public class PackageWrapper {
* @return Response
*/
public Response queryPackageById(String csarId) {
- ArrayList<PackageData> dbResult = new ArrayList<PackageData>();
- ArrayList<PackageMeta> result = new ArrayList<PackageMeta>();
+ PackageData dbResult = new PackageData();
+ PackageMeta result = new PackageMeta();
dbResult = PackageWrapperUtil.getPackageInfoById(csarId);
- result = PackageWrapperUtil.packageDataList2PackageMetaList(dbResult);
+ result = PackageWrapperUtil.packageData2PackageMeta(dbResult);
return Response.ok(result).build();
}
@@ -183,7 +183,7 @@ public class PackageWrapper {
new Thread(thread).start();
return Response.noContent().build();
} catch (Exception e1) {
- LOG.error("delete fail.", e1);
+ LOG.error("delete fail." + e1.getMessage());
return RestUtil.getRestException(e1.getMessage());
}
}
@@ -204,7 +204,7 @@ public class PackageWrapper {
delCsarData(csarid);
}
} catch (Exception e1) {
- LOG.error("del instance csar fail.", e1);
+ LOG.error("del instance csar fail."+ e1.getMessage());
updatePackageStatus(csarid, null, null, null, CommonConstant.PACKAGE_STATUS_DELETE_FAIL,
null);
// publishDelFinishCometdMessage(csarid, "false");
@@ -308,11 +308,9 @@ public class PackageWrapper {
* @return Response
*/
public Response downloadCsarPackagesById(String csarId) {
- ArrayList<PackageData> packageList = PackageWrapperUtil.getPackageInfoById(csarId);
+ PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId);
String packageName = null;
- if (null != packageList && packageList.size() > 0) {
- packageName = packageList.get(0).getName();
- }
+ packageName = packageData.getName();
String path = ToolUtil.getCatalogueCsarPath() + File.separator + packageName;
File csarFile = new File(path);
if (!csarFile.exists()) {
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 3ae5fef1..3a286cd3 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
@@ -137,10 +137,14 @@ public class PackageWrapperUtil {
* @param csarId package id
* @return package detail
*/
- public static ArrayList<PackageData> getPackageInfoById(String csarId) {
- ArrayList<PackageData> result = new ArrayList<PackageData>();
+ public static PackageData getPackageInfoById(String csarId) {
+ PackageData result = new PackageData();
+ ArrayList<PackageData> packageDataList = new ArrayList<PackageData>();
try {
- result = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ packageDataList = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ if (packageDataList != null && packageDataList.size() > 0) {
+ result = PackageManager.getInstance().queryPackageByCsarId(csarId).get(0);
+ }
} catch (CatalogResourceException e1) {
LOG.error("query package by csarId from db error ! " + e1.getMessage());
}
@@ -300,7 +304,7 @@ public class PackageWrapperUtil {
}
}
- private static PackageMeta packageData2PackageMeta(PackageData packageData) {
+ public static PackageMeta packageData2PackageMeta(PackageData packageData) {
PackageMeta meta = new PackageMeta();
meta.setCsarId(packageData.getCsarId());
meta.setCreateTime(packageData.getCreateTime());
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 9cfa46c3..93c7dc44 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
@@ -157,8 +157,8 @@ public class PackageWrapperTest {
@Test
public void testQueryPackageById() throws Exception {
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- metas = getPackageMetaList();
+ PackageMeta metas = new PackageMeta();
+ metas = getPackageMeta();
Response result = PackageWrapper.getInstance().queryPackageById("123456");
assertEquals(200, result.getStatus());
@@ -267,6 +267,14 @@ public class PackageWrapperTest {
private ArrayList<PackageMeta> getPackageMetaList() {
PackageMeta meta = new PackageMeta();
+ meta = getPackageMeta();
+ ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
+ metas.add(meta);
+ return metas;
+ }
+
+ private PackageMeta getPackageMeta() {
+ PackageMeta meta = new PackageMeta();
meta.setCreateTime("2016-06-29 03:33:15");
meta.setCsarId("123456");
meta.setDeletionPending(false);
@@ -283,9 +291,7 @@ public class PackageWrapperTest {
meta.setVersion("V1.0");
meta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
meta.setProcessState(EnumProcessState.valueOf("normal"));
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- metas.add(meta);
- return metas;
+ return meta;
}
private String getDownloadUriHead() {
diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
index 1cbf2ad3..175c1d80 100644
--- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
+++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
@@ -359,7 +359,7 @@ public class ServiceTemplateWrapperTest {
private ServiceTemplate getExpectServiceTemplate() {
ServiceTemplate serviceTemplate = new ServiceTemplate();
- serviceTemplate.setCsarid("123456");
+ serviceTemplate.setCsarId("123456");
serviceTemplate.setDownloadUri(MsbAddrConfig.getMsbAddress()
+ "/files/catalog-http/NSAR/ZTE/NanocellGW/v1.0/NanocellGW/Definitions/segw.yml");
InputParameter[] inputs = getServiceTemplateInputs();