diff options
author | Jian Huang <huang.jian12@zte.com.cn> | 2016-10-24 06:23:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@open-o.org> | 2016-10-24 06:23:26 +0000 |
commit | ea43742d81428a94a7cfe79e82ba4b04ed6824bf (patch) | |
tree | fbc90d37336efa35a233be17453bede942f35180 /catalog-core | |
parent | 157beda320194c22899c31c8c680fadf86deaf2e (diff) | |
parent | f10ce48ceff2c5b266203cc85f9df7f666b2a16c (diff) |
Merge "Add log information. Change status of Service template from usage State to operation status." into sun
Diffstat (limited to 'catalog-core')
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 |