Merge "Enable blueprintprocessor and vlantag-api"
[ccsdk/apps.git] / ms / controllerblueprints / modules / service / src / main / java / org / onap / ccsdk / apps / controllerblueprints / service / rs / ModelTypeRest.java
index 2fa6431..0f485a0 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
@@ -19,8 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import org.springframework.stereotype.Component;\r
-import org.springframework.stereotype.Service;\r
+import org.springframework.http.MediaType;\r
 import org.springframework.web.bind.annotation.*;\r
 \r
 import java.util.List;\r
@@ -29,7 +29,7 @@ import java.util.List;
  * {@inheritDoc}\r
  */\r
 @RestController\r
-@RequestMapping("/api/v1/model-type")\r
+@RequestMapping(value = "/api/v1/model-type")\r
 public class ModelTypeRest {\r
 \r
     private ModelTypeService modelTypeService;\r
@@ -43,50 +43,30 @@ public class ModelTypeRest {
         this.modelTypeService = modelTypeService;\r
     }\r
 \r
-    @GetMapping(path = "/{name}")\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
+    @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {\r
+        return modelTypeService.getModelTypeByName(name);\r
     }\r
 \r
-    @GetMapping(path = "/search/{tags}")\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
+    @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {\r
+        return modelTypeService.searchModelTypes(tags);\r
     }\r
 \r
-    @GetMapping(path = "/by-definition/{definitionType}")\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
+    List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) {\r
+        return modelTypeService.getModelTypeByDefinitionType(definitionType);\r
     }\r
 \r
-    @PostMapping(path = "/")\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
+    public void deleteModelTypeByName(@PathVariable(value = "name") String name) {\r
+        modelTypeService.deleteByModelName(name);\r
     }\r
 }\r