source: trunk/www/admin/server/submit_server.jsp @ 5426

Last change on this file since 5426 was 5426, checked in by Nicklas Nordborg, 12 years ago

References #1514: Fix character encoding of jsp files

  • Add pageEncoding="UTF-8" to all JSP files.
  • Add @charset="UTF-8"; to all CSS files.
  • Add charset="UTF-8" to all <script> tags

This should at least make Eclipse happy and hopefully allow other editors to automatically select the correct encoding.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1<%-- $Id: submit_server.jsp 5426 2010-09-24 09:18:50Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.Application"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.User"
31  import="net.sf.basedb.core.Client"
32  import="net.sf.basedb.core.ClientDefaultSetting"
33  import="net.sf.basedb.clients.web.Base"
34  import="net.sf.basedb.clients.web.WebException"
35  import="net.sf.basedb.clients.web.util.HTML"
36  import="net.sf.basedb.util.Values"
37%>
38<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
39<%
40SessionControl sc = Base.getExistingSessionControl(pageContext, true);
41String ID = sc.getId();
42String cmd = request.getParameter("cmd");
43String root = request.getContextPath()+"/";
44
45String forward = null;
46String redirect = null;
47String message = null;
48
49DbControl dc = sc.newDbControl();
50try
51{
52  if ("SaveSettings".equals(cmd))
53  {
54    Client server = Client.getById(dc, sc.getClientId());
55
56    // File transfer tab
57    Long bytes = new Long(0);
58    ClientDefaultSetting transferRate = server.getDefaultSetting("server.transferRate");
59    boolean unlimited = Values.getBoolean(request.getParameter("unlimited"));
60    String rate = Values.getStringOrNull(request.getParameter("transfer_rate"));
61    if (!unlimited && rate != null)
62    {
63      bytes = Values.parseBytes(rate, null);
64      if (bytes == null)
65      {
66        throw new WebException("popup", "Invalid byte value", "The value {1} is not a valid value.", rate);
67      }
68    }
69    transferRate.setValue(bytes.toString());
70
71    // About tab
72    ClientDefaultSetting adminName = server.getDefaultSetting("server.admin.name");
73    ClientDefaultSetting adminEmail = server.getDefaultSetting("server.admin.email");
74    ClientDefaultSetting about = server.getDefaultSetting("server.about");
75    adminName.setValue(Values.getString(request.getParameter("name")));
76    adminEmail.setValue(Values.getString(request.getParameter("email")));
77    about.setValue(Values.getString(request.getParameter("about")));
78
79    // Get account tab
80    ClientDefaultSetting getAccount = server.getDefaultSetting("server.get.account");
81    getAccount.setValue(Values.getString(request.getParameter("account")));
82
83    // Forgotten password tab
84    ClientDefaultSetting forgottenPassword = server.getDefaultSetting("server.forgotten.password");
85    forgottenPassword.setValue(Values.getString(request.getParameter("password")));
86
87    //Links tab
88    ClientDefaultSetting helplink = server.getDefaultSetting("server.links.help");
89    ClientDefaultSetting faqlink = server.getDefaultSetting("server.links.faq");
90    ClientDefaultSetting reportbuglink = server.getDefaultSetting("server.links.reportbug");
91    helplink.setValue(Values.getString(request.getParameter("help")));
92    faqlink.setValue(Values.getString(request.getParameter("faq")));
93    reportbuglink.setValue(Values.getString(request.getParameter("reportbug")));
94 
95    dc.commit();
96    sc.reloadSettings(true, false);
97    message = "Settings saved";
98  }
99  else if ("RestartServer".equals(cmd))
100  {
101    Application.stop();
102    Application.start();
103    message = "The server has been restarted. You must log in again.";
104  }
105  else if ("SetBroadcastMessage".equals(cmd))
106  {
107    String title = Values.getStringOrNull(request.getParameter("title"));
108    String broadcastMessage = Values.getStringOrNull(request.getParameter("message"));
109    boolean denyLogin = Values.getBoolean(request.getParameter("denyLogin"));
110   
111    if (title != null)
112    {
113      application.setAttribute("broadcast.title", title);
114      application.setAttribute("broadcast.message", broadcastMessage);
115      application.setAttribute("broadcast.deny-login", denyLogin);
116      message = "Message is now sent";
117    }
118    else
119    {
120      application.removeAttribute("broadcast.title"); 
121      application.removeAttribute("broadcast.message"); 
122      application.removeAttribute("broadcast.deny-login"); 
123      message = "Message is now disabled";
124    }
125  }
126  else
127  {
128    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
129  }
130}
131finally
132{
133  if (dc != null) dc.close();
134}
135if (forward != null)
136{
137  pageContext.forward(forward);
138}
139else if (redirect != null)
140{
141  response.sendRedirect(redirect);
142}
143else if (message == null)
144{
145  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
146}
147else
148{
149  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
150}
151%>
152
Note: See TracBrowser for help on using the repository browser.