diff options
author | 2016-10-31 15:26:27 +0800 | |
---|---|---|
committer | 2016-10-31 15:26:27 +0800 | |
commit | 00f08550ffc1e4c9acc6ed41eb6d6661112c991d (patch) | |
tree | 35afcdde61900ea87e1da089d8006627b4c20bb4 /catalog-core/catalog-mgr/src/main/java | |
parent | f75bb848b5ad5e15838c3519c1903754fa9e63d7 (diff) |
Ignore query service template exception when delete its data.
Change-Id: Ie3c3e9459892076e55648fd168ac09897d105599
Issue-id: TOSCA-148
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'catalog-core/catalog-mgr/src/main/java')
-rw-r--r-- | catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/service/ModelService.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/service/ModelService.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/service/ModelService.java index 5a9d7dd6..a2684025 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/service/ModelService.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/service/ModelService.java @@ -22,8 +22,11 @@ import org.openo.commontosca.catalog.model.entity.ServiceTemplateOperation; import org.openo.commontosca.catalog.model.plan.wso2.Wso2ServiceConsumer; import org.openo.commontosca.catalog.model.wrapper.ServiceTemplateWrapper; import org.openo.commontosca.catalog.resources.CatalogBadRequestException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ModelService { + private static final Logger logger = LoggerFactory.getLogger(ModelService.class); private static final ModelService instance = new ModelService(); @@ -38,7 +41,12 @@ public class ModelService { * @throws CatalogResourceException e2 */ public void delete(String packageId) throws CatalogBadRequestException, CatalogResourceException { - ServiceTemplate st = ServiceTemplateWrapper.getInstance().getServiceTemplateByCsarId(packageId); + logger.info("delete package model data begin."); + + ServiceTemplate st = getServiceTemplateByCsarIdIgnoreError(packageId); + if (st == null) { + return; + } TemplateManager.getInstance().deleteServiceTemplateById(st.getServiceTemplateId()); TemplateManager.getInstance().deleteServiceTemplateMapping(null, st.getServiceTemplateId()); @@ -49,6 +57,20 @@ public class ModelService { Wso2ServiceConsumer.deletePackage(op.getPackageName()); } } + + logger.info("delete package model data end."); + } + + private ServiceTemplate getServiceTemplateByCsarIdIgnoreError(String packageId) { + try{ + return ServiceTemplateWrapper.getInstance().getServiceTemplateByCsarId(packageId); + } catch (CatalogBadRequestException ignore) { + logger.info("delete package model data ignore.", ignore); + } catch (CatalogResourceException ignore) { + logger.info("delete package model data ignore.", ignore); + } + + return null; } } |