summaryrefslogtreecommitdiffstats
path: root/catalog-core
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2016-10-24 11:13:00 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2016-10-24 11:13:00 +0800
commite366e9da3eec5de359ef6d3450438f2d5c9fd97b (patch)
tree47c4e49c85c2c645bbf33cd9aa951534db7df026 /catalog-core
parent8c845695a6807a7455597a825ef66dc51228f938 (diff)
Add log information.
Change status of Service template from usage State to operation status. Change-Id: I6c6df768ecb7b996cbbf484b5afd1a896bc74130 Issue-id: TOSCA-122 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'catalog-core')
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java3
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java15
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/TemplateResource.java40
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java5
4 files changed, 33 insertions, 30 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
index 4eb61d45..fe6acc2a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
@@ -61,7 +61,8 @@ public class AriaParserServiceConsumer {
private static void validateResult(String strResult) throws CatalogResourceException {
AriaParserExceptionResult except = new Gson().fromJson(strResult, AriaParserExceptionResult.class);
if (except.getIssues() != null && except.getIssues().length > 0) {
- throw new CatalogResourceException("Aria parser return failure message: " + except.getIssues()[0].getMessage());
+ logger.error("Aria parser return failure message: " + strResult);
+ throw new CatalogResourceException("Aria parser return failure message: " + strResult);
}
}
}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
index bee3bd6e..c381c8aa 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
@@ -15,6 +15,10 @@
*/
package org.openo.commontosca.catalog.model.wrapper;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.openo.commontosca.catalog.common.ToolUtil;
import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
import org.openo.commontosca.catalog.db.entity.PackageData;
@@ -22,6 +26,7 @@ import org.openo.commontosca.catalog.db.entity.ServiceTemplateData;
import org.openo.commontosca.catalog.db.entity.ServiceTemplateMappingData;
import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
import org.openo.commontosca.catalog.db.resource.TemplateManager;
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.model.common.TemplateDataHelper;
import org.openo.commontosca.catalog.model.entity.InputParameter;
import org.openo.commontosca.catalog.model.entity.NfvTemplate;
@@ -36,10 +41,6 @@ import org.openo.commontosca.catalog.resources.CatalogBadRequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class ServiceTemplateWrapper {
private static ServiceTemplateWrapper instance;
@@ -83,10 +84,12 @@ public class ServiceTemplateWrapper {
* @return service template list
* @throws CatalogResourceException e
*/
- public ServiceTemplate[] getServiceTemplates(String status, boolean deletionPending)
+ public ServiceTemplate[] getServiceTemplates(EnumOperationalState status, boolean deletionPending)
throws CatalogResourceException {
PackageData pd = new PackageData();
- pd.setUsageState(status);
+ if (status != null) {
+ pd.setOperationalState(status.toString());
+ }
pd.setDeletionPending(String.valueOf(deletionPending));
List<ServiceTemplateData> stdList =
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/TemplateResource.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/TemplateResource.java
index 73ae9d7f..aabeae63 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/TemplateResource.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/TemplateResource.java
@@ -15,9 +15,27 @@
*/
package org.openo.commontosca.catalog.resources;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.jetty.http.HttpStatus;
import org.openo.commontosca.catalog.common.CommonErrorResponse;
import org.openo.commontosca.catalog.common.ToolUtil;
import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.model.entity.InputParameter;
import org.openo.commontosca.catalog.model.entity.NodeTemplate;
import org.openo.commontosca.catalog.model.entity.Parameters;
@@ -26,32 +44,12 @@ import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
import org.openo.commontosca.catalog.model.entity.ServiceTemplateOperation;
import org.openo.commontosca.catalog.model.entity.ServiceTemplateRawData;
import org.openo.commontosca.catalog.model.parser.AbstractModelParser;
-import org.openo.commontosca.catalog.model.parser.yaml.aria.AriaModelParser;
import org.openo.commontosca.catalog.model.parser.yaml.zte.ToscaYamlModelParser;
import org.openo.commontosca.catalog.model.service.ModelService;
import org.openo.commontosca.catalog.model.wrapper.ServiceTemplateWrapper;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.eclipse.jetty.http.HttpStatus;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
import com.codahale.metrics.annotation.Timed;
/**
@@ -116,7 +114,7 @@ public class TemplateResource {
response = CommonErrorResponse.class)})
@Timed
public Response getServiceTemplates(
- @ApiParam(value = "template status") @QueryParam("status") String status,
+ @ApiParam(value = "template status") @QueryParam("status") EnumOperationalState status,
@ApiParam(value = "delay to delete") @QueryParam("deletionPending") boolean deletionPending) {
try {
ServiceTemplate[] sts =
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 175c1d80..7087b220 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
@@ -45,6 +45,7 @@ import org.openo.commontosca.catalog.db.resource.PackageManager;
import org.openo.commontosca.catalog.db.resource.TemplateManager;
import org.openo.commontosca.catalog.db.util.H2DbServer;
import org.openo.commontosca.catalog.db.util.HibernateSession;
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.model.entity.InputParameter;
import org.openo.commontosca.catalog.model.entity.NodeTemplate;
import org.openo.commontosca.catalog.model.entity.OutputParameter;
@@ -151,8 +152,8 @@ public class ServiceTemplateWrapperTest {
ServiceTemplate[] result1 = serviceTemplateWrapper.getServiceTemplates(null, false);
assertEquals(expectResult, result1);
- ServiceTemplate[] result2 = serviceTemplateWrapper.getServiceTemplates("InUse", false);
- assertEquals(expectResult, result2);
+ ServiceTemplate[] result2 = serviceTemplateWrapper.getServiceTemplates(EnumOperationalState.Enabled, false);
+ assertEquals(new ServiceTemplate[0], result2);
}
@Test