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