diff --git a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java index cd062d9fe12dd885b60d6484fa220d8cc57ce422..8d25fe87ae2542a236113e053220d6dd1d2fb081 100644 --- a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java @@ -63,7 +63,7 @@ public class ArticlesApi { @ApiOperation(value = "Create an article", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Article created")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.POST) + @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.POST) public ResponseEntity<Void> addAnArticle( @RequestBody @ApiParam(value = "Article to create", required = true) Article article, Principal principal) throws NotFoundException { User user = MIPApplication.getUser(principal); @@ -85,7 +85,7 @@ public class ArticlesApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<Article> getAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); @@ -101,7 +101,7 @@ public class ArticlesApi { @ApiOperation(value = "Update an article", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Article updated")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.PUT) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.PUT) public ResponseEntity<Void> updateAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @RequestBody @ApiParam(value = "Article to update", required = true) Article article, Principal principal) throws NotFoundException { @@ -119,7 +119,7 @@ public class ArticlesApi { @ApiOperation(value = "Delete an article", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Article deleted")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.DELETE) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.DELETE) public ResponseEntity<Void> deleteAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { // do some magic! diff --git a/src/main/java/org/hbp/mip/controllers/DatasetsApi.java b/src/main/java/org/hbp/mip/controllers/DatasetsApi.java index d4be2cd033bb7bc033bcb7894aba7f12a5df0cb7..e4047d18bcad304e5d9a2caa92c97e573647e279 100644 --- a/src/main/java/org/hbp/mip/controllers/DatasetsApi.java +++ b/src/main/java/org/hbp/mip/controllers/DatasetsApi.java @@ -27,7 +27,7 @@ public class DatasetsApi { @ApiOperation(value = "Get a dataset", notes = "", response = Dataset.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "/{code}", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{code}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<Dataset> getADataset( @ApiParam(value = "code", required = true) @PathVariable("code") String code) throws NotFoundException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); diff --git a/src/main/java/org/hbp/mip/controllers/GroupsApi.java b/src/main/java/org/hbp/mip/controllers/GroupsApi.java index 2cbe4dc5ce044ec356a1060a7101aa29b2ec9e5c..bee57f824d2e22e18e78be375aec65737c3dda06 100644 --- a/src/main/java/org/hbp/mip/controllers/GroupsApi.java +++ b/src/main/java/org/hbp/mip/controllers/GroupsApi.java @@ -25,7 +25,7 @@ public class GroupsApi { @ApiOperation(value = "Get the root group (containing all subgroups)", notes = "", response = Group.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<Group> getTheRootGroup() throws NotFoundException { String rootCode = "root"; Session session = HibernateUtil.getSessionFactory().getCurrentSession(); diff --git a/src/main/java/org/hbp/mip/controllers/ModelsApi.java b/src/main/java/org/hbp/mip/controllers/ModelsApi.java index bc28a1301b580f36b8b8fb918694f6234ad770f8..a6bbd0a188020913cf0725e34e44867cd7086fd4 100644 --- a/src/main/java/org/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/org/hbp/mip/controllers/ModelsApi.java @@ -71,7 +71,7 @@ public class ModelsApi { @ApiOperation(value = "Create a model", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Model created")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.POST) + @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.POST) public ResponseEntity<Void> addAModel( @RequestBody @ApiParam(value = "Model to create", required = true) Model model, Principal principal) throws NotFoundException { User user = MIPApplication.getUser(principal); @@ -111,7 +111,7 @@ public class ModelsApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<Model> getAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); @@ -127,7 +127,7 @@ public class ModelsApi { @ApiOperation(value = "Update a model", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Model updated")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.PUT) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.PUT) public ResponseEntity<Void> updateAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @RequestBody @ApiParam(value = "Model to update", required = true) Model model, Principal principal) throws NotFoundException { @@ -145,7 +145,7 @@ public class ModelsApi { @ApiOperation(value = "Delete a model", notes = "", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Model deleted")}) - @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.DELETE) + @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.DELETE) public ResponseEntity<Void> deleteAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { // do some magic! diff --git a/src/main/java/org/hbp/mip/controllers/RequestsApi.java b/src/main/java/org/hbp/mip/controllers/RequestsApi.java index 15d5bf398bf71873d927b830508e14491bc9944a..ac4968792d8025dd8bc7bad085dd8f5f07ea56e8 100644 --- a/src/main/java/org/hbp/mip/controllers/RequestsApi.java +++ b/src/main/java/org/hbp/mip/controllers/RequestsApi.java @@ -11,10 +11,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; /** @@ -26,20 +22,36 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class RequestsApi { - private static String RESPONSE_SRC = "/home/mirco/Workspace/GitLab/mip/target/classes/data/requestExample.json"; - @ApiOperation(value = "", notes = "", response = Group.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success")}) @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.POST) public ResponseEntity<String> postRequests() throws NotFoundException { - // Read data from file - String response = ""; - try { - response = new String(Files.readAllBytes(Paths.get(RESPONSE_SRC))); - } catch (IOException e) { - e.printStackTrace(); - } + // Mock data + String response = + "{\n" + + " \"code\": \"ib8ehpl4ic8cc0oc480w84w00cg4g0\",\n" + + " \"date\": \"2016-01-18T13:56:14+0100\",\n" + + " \"header\": [\n" + + " \"MidTemp\"\n" + + " ],\n" + + " \"data\": {\n" + + " \"MidTemp\": [\n" + + " 18422,\n" + + " 16972,\n" + + " 17330,\n" + + " 16398,\n" + + " 21614,\n" + + " 21386,\n" + + " 20474,\n" + + " 19867,\n" + + " 20398,\n" + + " 19741,\n" + + " 18595,\n" + + " 18018\n" + + " ]\n" + + " }\n" + + "}\n"; return new ResponseEntity<Group>(HttpStatus.OK).ok(response); } diff --git a/src/main/java/org/hbp/mip/controllers/UsersApi.java b/src/main/java/org/hbp/mip/controllers/UsersApi.java index 9b9d4b01dabe986f73d332f27db2046668e7774b..a2e80e253bd55edebb44b3a462b5deb1c0456ff5 100644 --- a/src/main/java/org/hbp/mip/controllers/UsersApi.java +++ b/src/main/java/org/hbp/mip/controllers/UsersApi.java @@ -26,7 +26,7 @@ public class UsersApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{username}", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{username}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<User> getAUser( @ApiParam(value = "username", required = true) @PathVariable("username") String username) throws NotFoundException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); diff --git a/src/main/java/org/hbp/mip/controllers/VariablesApi.java b/src/main/java/org/hbp/mip/controllers/VariablesApi.java index 80bdf4718dfba95882206151f418687ede3effdb..ce2f8dd8a909787718eb31cb0c233f2e61fd6d6d 100644 --- a/src/main/java/org/hbp/mip/controllers/VariablesApi.java +++ b/src/main/java/org/hbp/mip/controllers/VariablesApi.java @@ -33,7 +33,7 @@ public class VariablesApi { @ApiOperation(value = "Get variables", notes = "", response = Variable.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<List<Variable>> getVariables( @ApiParam(value = "List of groups formatted like : (\"val1\", \"val2\", ...)") @RequestParam(value = "group", required = false) String group, @ApiParam(value = "List of subgroups formatted like : (\"val1\", \"val2\", ...)") @RequestParam(value = "subgroup", required = false) String subgroup, @@ -76,7 +76,7 @@ public class VariablesApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{code}", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{code}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<Variable> getAVariable( @ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code) throws NotFoundException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); @@ -93,7 +93,7 @@ public class VariablesApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{code}/values", produces = {"application/json"}, method = RequestMethod.GET) + @RequestMapping(value = "/{code}/values", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) public ResponseEntity<List<Value>> getValuesFromAVariable( @ApiParam(value = "code", required = true) @PathVariable("code") String code, @ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q) throws NotFoundException { diff --git a/src/test/db b/src/test/db index 94643e89555c876e5286933f8216f67c9bc559be..5e9b8d4352b1c9d4f2269e1c97672c1f5973070f 160000 --- a/src/test/db +++ b/src/test/db @@ -1 +1 @@ -Subproject commit 94643e89555c876e5286933f8216f67c9bc559be +Subproject commit 5e9b8d4352b1c9d4f2269e1c97672c1f5973070f