From 470d7b843979d62e56204575ddd35a45c8ebca90 Mon Sep 17 00:00:00 2001
From: tudtianus <tudtianus@gmail.com>
Date: Sat, 30 Jun 2018 19:18:09 +0200
Subject: [PATCH] fix: redirection in editdescription

---
 .../journal/view/ProjectDescriptionView.java  | 22 +++++++++++++++----
 .../src/main/webapp/pages/editDescription.jsp |  2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java
index 4190c2fe..6c93b009 100644
--- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java
+++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java
@@ -15,6 +15,8 @@ import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.lang.invoke.MethodType;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 
 /**
@@ -44,14 +46,26 @@ public class ProjectDescriptionView {
 
     //save Description
     @POST
-    @Consumes(MediaType.TEXT_HTML)
-    @Path("/saveText/{text}")
-    public Response saveProjectText(@PathParam("text")String text){
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_PLAIN)
+    @Path("/saveText")
+    public Response saveProjectText(@FormParam("student")String student,@FormParam("project")String project,@FormParam("text")String text){
         log.debug(">>> saveText: " + text);
 
         descriptionService.saveProjectText(text);
 
-        log.debug(">>> saveText");
+        //TODO token
+        try {
+            URI location = new URI("../pages/eportfolio.jsp?token=test");
+            log.debug("<<< saveText: redirect to "  +location.toString());
+            return Response.temporaryRedirect(location).build();
+
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+            log.debug("saveText: redirect failed" );
+        }
+
+        log.debug("<<< saveText");log.debug(">>> saveText");
 
         return Response.ok().build();
     }
diff --git a/gemeinsamforschen/src/main/webapp/pages/editDescription.jsp b/gemeinsamforschen/src/main/webapp/pages/editDescription.jsp
index a5673151..d4266111 100644
--- a/gemeinsamforschen/src/main/webapp/pages/editDescription.jsp
+++ b/gemeinsamforschen/src/main/webapp/pages/editDescription.jsp
@@ -56,7 +56,7 @@
 
                                 <div class="description-form-buttons">
                                     <input type="submit">
-                                    <button> Zur&uuml;ck </button>
+                                    <a href="eportfolio.jsp?token=test">Zur&uuml;ck</a>
                                 </div>
 
                             </div>
-- 
GitLab