--- a/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Fri Mar 15 13:36:48 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Fri Mar 15 14:36:07 2013 +0100
@@ -97,6 +97,9 @@
}
Project project = this.projectsRepository.findOne(project_id);
+ if(project == null) {
+ throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + project_id + " not found.");
+ }
this.checkCowebkey(cowebkey, project, EditMode.READ_ONLY);
@@ -106,11 +109,20 @@
return "renkanProjectPublish";
}
- /*@RequestMapping("/test")
- public ModelAndView projectPrompt() {
- String message = "Hello world, Spring";
+ @RequestMapping(value="/copy", method = RequestMethod.POST, params="project_id={project_id}", produces={"application/json;charset=UTF-8"})
+ public Project copyProject(@RequestParam(value="project_id") String projectId ) {
+
+ if(projectId == null || projectId.length() == 0) {
+ throw new IllegalArgumentException("RenkanContoller.renkanProject: Project id is null or empty.");
+ }
+ Project project = this.projectsRepository.findOne(projectId);
+ if(project == null) {
+ throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + projectId + " not found.");
+ }
+
+ Project newProject = this.projectsRepository.copy(project, project.getTitle() + " (copy)");
- return new ModelAndView("projectPrompt", "message", message);
- }*/
+ return newProject;
+ }
}