From a63f675071bc892bf7d2ef6b3973bdab0f3ce820 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 31 May 2017 17:52:35 +0200
Subject: [PATCH] new api look for project meta data

---
 frontend-js/src/main/js/ServerConnector.js    |  5 ++--
 .../token=MOCK_TOKEN_ID&}                     |  0
 .../token=MOCK_TOKEN_ID&}                     |  0
 .../sample/token=MOCK_TOKEN_ID&}              |  0
 .../api/project/ProjectController.java        | 25 ++++++++++---------
 5 files changed, 15 insertions(+), 15 deletions(-)
 rename frontend-js/testFiles/apiCalls/{project/getMetaData/projectId=complex_model_with_images&token=MOCK_TOKEN_ID& => projects/complex_model_with_images/token=MOCK_TOKEN_ID&} (100%)
 rename frontend-js/testFiles/apiCalls/{project/getMetaData/projectId=complex_model_with_submaps&token=MOCK_TOKEN_ID& => projects/complex_model_with_submaps/token=MOCK_TOKEN_ID&} (100%)
 rename frontend-js/testFiles/apiCalls/{project/getMetaData/projectId=sample&token=MOCK_TOKEN_ID& => projects/sample/token=MOCK_TOKEN_ID&} (100%)

diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js
index 7bc783e5f7..6c676aabc6 100644
--- a/frontend-js/src/main/js/ServerConnector.js
+++ b/frontend-js/src/main/js/ServerConnector.js
@@ -224,10 +224,9 @@ ServerConnector.getApiUrl = function(paramObj) {
 
 ServerConnector.getProjectUrl = function(projectId, token) {
   return this.getApiUrl({
-    type : "project",
-    method : "getMetaData",
+    type : "projects",
+    method : projectId,
     params : {
-      projectId : projectId,
       token : token,
     },
   });
diff --git a/frontend-js/testFiles/apiCalls/project/getMetaData/projectId=complex_model_with_images&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID&
similarity index 100%
rename from frontend-js/testFiles/apiCalls/project/getMetaData/projectId=complex_model_with_images&token=MOCK_TOKEN_ID&
rename to frontend-js/testFiles/apiCalls/projects/complex_model_with_images/token=MOCK_TOKEN_ID&
diff --git a/frontend-js/testFiles/apiCalls/project/getMetaData/projectId=complex_model_with_submaps&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID&
similarity index 100%
rename from frontend-js/testFiles/apiCalls/project/getMetaData/projectId=complex_model_with_submaps&token=MOCK_TOKEN_ID&
rename to frontend-js/testFiles/apiCalls/projects/complex_model_with_submaps/token=MOCK_TOKEN_ID&
diff --git a/frontend-js/testFiles/apiCalls/project/getMetaData/projectId=sample&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID&
similarity index 100%
rename from frontend-js/testFiles/apiCalls/project/getMetaData/projectId=sample&token=MOCK_TOKEN_ID&
rename to frontend-js/testFiles/apiCalls/projects/sample/token=MOCK_TOKEN_ID&
diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectController.java b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectController.java
index babade2eb7..b74f04e658 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectController.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectController.java
@@ -8,6 +8,7 @@ import java.util.Map;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -23,37 +24,37 @@ import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException;
 import lcsb.mapviewer.services.SecurityException;
 
 @RestController
-@RequestMapping("/project")
 public class ProjectController extends BaseController {
 	@Autowired
 	private ProjectRestImpl projectController;
 
-	@RequestMapping(value = "/getMetaData", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
-	public ProjectMetaData getMetaData(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token)
+	@RequestMapping(value = "/projects/{projectId}", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	public ProjectMetaData getMetaData(@PathVariable(value = "projectId") String projectId, @RequestParam(value = "token") String token)
 			throws SecurityException {
 		return projectController.getMetaData(projectId, token);
 	}
 
-	@RequestMapping(value = "/getSuggestedQueryList", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getSuggestedQueryList", method = { RequestMethod.GET, RequestMethod.POST },
+			produces = { MediaType.APPLICATION_JSON_VALUE })
 	public String[] getSuggestedQueryList(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token)
 			throws SecurityException {
 		return projectController.getSuggestedQueryList(projectId, token);
 	}
 
-	@RequestMapping(value = "/getElements", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getElements", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public List<Map<String, Object>> getElements(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "id", defaultValue = "") String id,
 			@RequestParam(value = "columns", defaultValue = "") String columns, @RequestParam(value = "token") String token) throws SecurityException {
 		return projectController.getElements(projectId, id, columns, token);
 	}
 
-	@RequestMapping(value = "/getReactions", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getReactions", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public List<Map<String, Object>> getReactions(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "id", defaultValue = "") String id,
 			@RequestParam(value = "columns", defaultValue = "") String columns, @RequestParam(value = "token") String token,
 			@RequestParam(value = "participantId", defaultValue = "") String participantId) throws SecurityException {
 		return projectController.getReactions(projectId, id, columns, token, participantId);
 	}
 
-	@RequestMapping(value = "/getClosestElementsByCoordinates", method = { RequestMethod.GET, RequestMethod.POST },
+	@RequestMapping(value = "/project/getClosestElementsByCoordinates", method = { RequestMethod.GET, RequestMethod.POST },
 			produces = { MediaType.APPLICATION_JSON_VALUE })
 	public List<Map<String, Object>> getClosestElementsByCoordinates(@RequestParam(value = "projectId") String projectId,
 			@RequestParam(value = "modelId") String modelId, @RequestParam(value = "token") String token, @RequestParam(value = "coordinates") String coordinates,
@@ -74,21 +75,21 @@ public class ProjectController extends BaseController {
 		return projectController.getClosestElementsByCoordinates(projectId, modelId, token, pointCoordinates, Integer.valueOf(count));
 	}
 
-	@RequestMapping(value = "/getElementsByQuery", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getElementsByQuery", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public List<Map<String, Object>> getElementsByQuery(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token,
 			@RequestParam(value = "query") String query, @RequestParam(value = "maxElements", defaultValue = "100") Integer maxElements,
 			@RequestParam(value = "perfectMatch", defaultValue = "false") String perfectMatch) throws QueryException, SecurityException {
 		return projectController.getElementsByQuery(projectId, token, query, maxElements, perfectMatch);
 	}
 
-	@RequestMapping(value = "/getPublications", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getPublications", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public Map<String, Object> getPublications(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token,
 			@RequestParam(value = "start", defaultValue = "0") String start, @RequestParam(value = "length", defaultValue = "10") Integer length)
 			throws QueryException, SecurityException {
 		return projectController.getPublications(projectId, token, start, length);
 	}
 
-	@RequestMapping(value = "/getProjectSource", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getProjectSource", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public ResponseEntity<byte[]> getProjectSource(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId)
 			throws SecurityException, QueryException {
 
@@ -104,7 +105,7 @@ public class ProjectController extends BaseController {
 				.body(file.getFileContent());
 	}
 
-	@RequestMapping(value = "/getModelAsImage", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getModelAsImage", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public ResponseEntity<byte[]> getModelAsImage(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId,
 			@RequestParam(value = "modelId") String modelId, @RequestParam(value = "handlerClass") String handlerClass,
 			@RequestParam(value = "backgroundOverlayId", defaultValue = "") String backgroundOverlayId,
@@ -119,7 +120,7 @@ public class ProjectController extends BaseController {
 				.body(file.getFileContent());
 	}
 
-	@RequestMapping(value = "/getModelAsModelFile", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
+	@RequestMapping(value = "/project/getModelAsModelFile", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
 	public ResponseEntity<byte[]> getModelAsModelFile(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId,
 			@RequestParam(value = "modelId") String modelId, @RequestParam(value = "handlerClass") String handlerClass,
 			@RequestParam(value = "backgroundOverlayId", defaultValue = "") String backgroundOverlayId,
-- 
GitLab