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>
/*\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
\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
/*\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
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
/*\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
@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