]> WPIA git - gigi.git/commitdiff
add: guide the user back when ttp request is missing.
authorFelix Dörre <felix@dogcraft.de>
Mon, 10 Nov 2014 17:41:32 +0000 (18:41 +0100)
committerJanis Streib <janis@dogcraft.de>
Wed, 31 Dec 2014 01:36:08 +0000 (02:36 +0100)
src/org/cacert/gigi/output/template/SprintfCommand.java
src/org/cacert/gigi/pages/admin/TTPAdminPage.java

index 17ef23a8240d7181c428b2d432ac371ca3c0f6d2..8d42af44f4b76f5e7fff844a8e6d28f20604dff7 100644 (file)
@@ -1,7 +1,7 @@
 package org.cacert.gigi.output.template;
 
 import java.io.PrintWriter;
-import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
 import org.cacert.gigi.localisation.Language;
@@ -12,17 +12,17 @@ public final class SprintfCommand implements Outputable {
 
     private final String text;
 
-    private final LinkedList<String> store;
+    private final String[] store;
 
-    public SprintfCommand(String text, LinkedList<String> store) {
+    public SprintfCommand(String text, List<String> store) {
         this.text = text;
-        this.store = store;
+        this.store = store.toArray(new String[store.size()]);
     }
 
     @Override
     public void output(PrintWriter out, Language l, Map<String, Object> vars) {
         String[] parts = l.getTranslation(text).split("%s", -1);
-        String[] myvars = store.toArray(new String[store.size()]);
+        String[] myvars = store;
         out.print(HTMLEncoder.encodeHTML(parts[0]));
         for (int j = 1; j < parts.length; j++) {
             String var = myvars[j - 1];
index cc9a536d8d2970d7330658a0811d7bff617ff125..ff0c1c35029902e29f1f91f96b8f721c4ccb1d77 100644 (file)
@@ -1,6 +1,7 @@
 package org.cacert.gigi.pages.admin;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -13,6 +14,7 @@ import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.Form;
 import org.cacert.gigi.output.template.IterableDataset;
+import org.cacert.gigi.output.template.SprintfCommand;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.pages.error.PageNotFound;
 
@@ -45,7 +47,8 @@ public class TTPAdminPage extends Page {
             int id = Integer.parseInt(path.substring(1 + PATH.length()));
             User u = User.getById(id);
             if (u == null || !u.isInGroup(TTP_APPLICANT)) {
-                req.setAttribute(PageNotFound.MESSAGE_ATTRIBUTE, "The TTP-request is not available anymore.");
+                SprintfCommand command = new SprintfCommand("The TTP-request is not available anymore. You might want to go %sback%s.", Arrays.asList("!\"<a href='" + PATH + "'>", "!\"</a>"));
+                req.setAttribute(PageNotFound.MESSAGE_ATTRIBUTE, command);
                 resp.sendError(404);
                 return;
             }