0
|
1
|
|
2 package nabble.view.web.tools;
|
|
3
|
|
4 import nabble.model.SystemProperties;
|
|
5 import nabble.view.lib.Jtp;
|
|
6
|
|
7 import javax.servlet.ServletException;
|
|
8 import javax.servlet.http.HttpServlet;
|
|
9 import javax.servlet.http.HttpServletRequest;
|
|
10 import javax.servlet.http.HttpServletResponse;
|
|
11 import java.io.IOException;
|
|
12 import java.io.PrintWriter;
|
|
13
|
|
14
|
|
15 public final class AdminNotice extends HttpServlet {
|
|
16
|
|
17 protected void service(HttpServletRequest request,HttpServletResponse response)
|
|
18 throws ServletException, IOException
|
|
19 {
|
|
20 PrintWriter out = response.getWriter();
|
|
21
|
|
22 boolean isSave = request.getParameter("save") != null;
|
|
23 boolean isPreview = request.getParameter("preview") != null;
|
|
24 String errorMsg = null;
|
|
25 String text = request.getParameter("text");
|
|
26 if (isSave) {
|
|
27 if (text == null || text.trim().length() == 0) {
|
|
28 SystemProperties.remove("administrator.notice");
|
|
29 } else {
|
|
30 SystemProperties.set("administrator.notice", text.trim());
|
|
31 String version = SystemProperties.get("administrator.notice.version");
|
|
32 int versionNumber = version == null? 0 : Integer.valueOf(version);
|
|
33 versionNumber++;
|
|
34 SystemProperties.set("administrator.notice.version", String.valueOf(versionNumber));
|
|
35 }
|
|
36 response.sendRedirect("/tools/");
|
|
37 return;
|
|
38 } else {
|
|
39 text = text == null? SystemProperties.get("administrator.notice") : text;
|
|
40 }
|
|
41
|
|
42 out.print( "\n<html>\n <head>\n <title>Administrator Notice</title>\n </head>\n <body style=\"font: .8em Verdana, Serif;\">\n <div>\n <a href=\"/tools/\">Tools</a>\n </div>\n\n <h1>Administrator Notice</h1>\n\n " );
|
|
43 if (errorMsg != null) {
|
|
44 out.print( "\n <div style=\"color:red;padding:.5em;margin-bottom:1em\">" );
|
|
45 out.print( (errorMsg) );
|
|
46 out.print( "</div>\n " );
|
|
47 }
|
|
48 out.print( "\n\n " );
|
|
49 if (isPreview) {
|
|
50 out.print( "\n <div style=\"background:#ffffcc;padding:.5em;margin:.5em 0 1em\">" );
|
|
51 out.print( (text) );
|
|
52 out.print( "</div>\n " );
|
|
53 }
|
|
54 out.print( "\n\n <form action=\"AdminNotice.jtp\">\n <textarea name=\"text\" style=\"width:100%;height:10em\">" );
|
|
55 out.print( (Jtp.hideNull(text)) );
|
|
56 out.print( "</textarea>\n <input type=\"submit\" name=\"preview\" value=\"Preview >>\">\n " );
|
|
57 if (isPreview) {
|
|
58 out.print( "\n <input type=\"submit\" name=\"save\" value=\"Save Notice\">\n " );
|
|
59 }
|
|
60 out.print( "\n </form>\n\n </body>\n</html>\n" );
|
|
61
|
|
62 }
|
|
63
|
|
64 }
|
|
65
|