Controller Blueprints Microservice 15/65415/1
authorBrinda Santh <brindasanth@in.ibm.com>
Sun, 9 Sep 2018 23:00:59 +0000 (19:00 -0400)
committerBrinda Santh <brindasanth@in.ibm.com>
Sun, 9 Sep 2018 23:00:59 +0000 (19:00 -0400)
Add Common Error Handling for ModelType, ServiceTemplate and ResourceDictionary Rest Services.

Change-Id: I8fa78bc4b1c38fd6149238da566e0867f64ffcc5
Issue-ID: CCSDK-522
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java

index 082b150..988cad0 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -44,48 +45,28 @@ public class ModelTypeRest {
 \r
     @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
-        try {\r
-            return modelTypeService.getModelTypeByName(name);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(1000, e.getMessage(), e);\r
-        }\r
+        return modelTypeService.getModelTypeByName(name);\r
     }\r
 \r
     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
-        try {\r
-            return modelTypeService.searchModelTypes(tags);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(1001, e.getMessage(), e);\r
-        }\r
+        return modelTypeService.searchModelTypes(tags);\r
     }\r
 \r
     @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {\r
-        try {\r
-            return modelTypeService.getModelTypeByDefinitionType(definitionType);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(1002, e.getMessage(), e);\r
-        }\r
+        return modelTypeService.getModelTypeByDefinitionType(definitionType);\r
     }\r
 \r
     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {\r
-        try {\r
-            return modelTypeService.saveModel(modelType);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(1100, e.getMessage(), e);\r
-        }\r
+        return modelTypeService.saveModel(modelType);\r
     }\r
 \r
     @DeleteMapping(path = "/{name}")\r
     public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
-        try {\r
-            modelTypeService.deleteByModelName(name);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(1400, e.getMessage(), e);\r
-        }\r
+        modelTypeService.deleteByModelName(name);\r
     }\r
 }\r
index a4aced6..e0cf6c6 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -47,51 +48,32 @@ public class ResourceDictionaryRest {
     public @ResponseBody\r
     ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)\r
             throws BluePrintException {\r
-        try {\r
-            return resourceDictionaryService.saveResourceDictionary(dataDictionary);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(4100, e.getMessage(), e);\r
-        }\r
+        return resourceDictionaryService.saveResourceDictionary(dataDictionary);\r
     }\r
 \r
     @DeleteMapping(path = "/{name}")\r
     public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
-        try {\r
-            resourceDictionaryService.deleteResourceDictionary(name);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(4400, e.getMessage(), e);\r
-        }\r
+        resourceDictionaryService.deleteResourceDictionary(name);\r
     }\r
 \r
     @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
-        try {\r
-            return resourceDictionaryService.getResourceDictionaryByName(name);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(4001, e.getMessage(), e);\r
-        }\r
+        return resourceDictionaryService.getResourceDictionaryByName(name);\r
     }\r
 \r
     @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)\r
             throws BluePrintException {\r
-        try {\r
-            return resourceDictionaryService.searchResourceDictionaryByNames(names);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(4002, e.getMessage(), e);\r
-        }\r
+        return resourceDictionaryService.searchResourceDictionaryByNames(names);\r
     }\r
 \r
     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
-        try {\r
-            return resourceDictionaryService.searchResourceDictionaryByTags(tags);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(4003, e.getMessage(), e);\r
-        }\r
+        return resourceDictionaryService.searchResourceDictionaryByTags(tags);\r
+\r
     }\r
 \r
 }\r
index a22285b..caa6bba 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -49,53 +50,33 @@ public class ServiceTemplateRest {
     @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
-        try {\r
-            return serviceTemplateService.enrichServiceTemplate(serviceTemplate);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(3500, e.getMessage(), e);\r
-        }\r
+        return serviceTemplateService.enrichServiceTemplate(serviceTemplate);\r
     }\r
 \r
     @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
-        try {\r
-            return serviceTemplateService.validateServiceTemplate(serviceTemplate);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(3501, e.getMessage(), e);\r
-        }\r
+        return serviceTemplateService.validateServiceTemplate(serviceTemplate);\r
     }\r
 \r
     @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {\r
-        try {\r
-            return serviceTemplateService.autoMap(resourceAssignments);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(3502, e.getMessage(), e);\r
-        }\r
+        return serviceTemplateService.autoMap(resourceAssignments);\r
     }\r
 \r
     @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)\r
             throws BluePrintException {\r
-        try {\r
-            return serviceTemplateService.validateResourceAssignments(resourceAssignments);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(3503, e.getMessage(), e);\r
-        }\r
+        return serviceTemplateService.validateResourceAssignments(resourceAssignments);\r
     }\r
 \r
     @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
     public @ResponseBody\r
     List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)\r
             throws BluePrintException {\r
-        try {\r
-            return serviceTemplateService.generateResourceAssignments(templateContent);\r
-        } catch (Exception e) {\r
-            throw new BluePrintException(3504, e.getMessage(), e);\r
-        }\r
+        return serviceTemplateService.generateResourceAssignments(templateContent);\r
     }\r
 \r
 }\r