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

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

References #1545: Publish news as a rss feed

Added servlet RssNewsFeed to serve rss document. It will cache the current news so it should not be too heavy even if clients update often.

The feed includes all public news and the broadcast message that the admin can set in the Administrate -> Broadcast message dialog.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.3 KB
Line 
1<%-- $Id: submit_server.jsp 5478 2010-11-05 10:38:08Z 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  import="net.sf.basedb.clients.web.servlet.RssNewsFeed"
38%>
39<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
40<%
41SessionControl sc = Base.getExistingSessionControl(pageContext, true);
42String ID = sc.getId();
43String cmd = request.getParameter("cmd");
44String root = request.getContextPath()+"/";
45
46String forward = null;
47String redirect = null;
48String message = null;
49
50DbControl dc = sc.newDbControl();
51try
52{
53  if ("SaveSettings".equals(cmd))
54  {
55    Client server = Client.getById(dc, sc.getClientId());
56
57    // File transfer tab
58    Long bytes = new Long(0);
59    ClientDefaultSetting transferRate = server.getDefaultSetting("server.transferRate");
60    boolean unlimited = Values.getBoolean(request.getParameter("unlimited"));
61    String rate = Values.getStringOrNull(request.getParameter("transfer_rate"));
62    if (!unlimited && rate != null)
63    {
64      bytes = Values.parseBytes(rate, null);
65      if (bytes == null)
66      {
67        throw new WebException("popup", "Invalid byte value", "The value {1} is not a valid value.", rate);
68      }
69    }
70    transferRate.setValue(bytes.toString());
71
72    // About tab
73    ClientDefaultSetting adminName = server.getDefaultSetting("server.admin.name");
74    ClientDefaultSetting adminEmail = server.getDefaultSetting("server.admin.email");
75    ClientDefaultSetting about = server.getDefaultSetting("server.about");
76    adminName.setValue(Values.getString(request.getParameter("name")));
77    adminEmail.setValue(Values.getString(request.getParameter("email")));
78    about.setValue(Values.getString(request.getParameter("about")));
79
80    // Get account tab
81    ClientDefaultSetting getAccount = server.getDefaultSetting("server.get.account");
82    getAccount.setValue(Values.getString(request.getParameter("account")));
83
84    // Forgotten password tab
85    ClientDefaultSetting forgottenPassword = server.getDefaultSetting("server.forgotten.password");
86    forgottenPassword.setValue(Values.getString(request.getParameter("password")));
87
88    //Links tab
89    ClientDefaultSetting helplink = server.getDefaultSetting("server.links.help");
90    ClientDefaultSetting faqlink = server.getDefaultSetting("server.links.faq");
91    ClientDefaultSetting reportbuglink = server.getDefaultSetting("server.links.reportbug");
92    helplink.setValue(Values.getString(request.getParameter("help")));
93    faqlink.setValue(Values.getString(request.getParameter("faq")));
94    reportbuglink.setValue(Values.getString(request.getParameter("reportbug")));
95 
96    dc.commit();
97    sc.reloadSettings(true, false);
98    message = "Settings saved";
99  }
100  else if ("RestartServer".equals(cmd))
101  {
102    Application.stop();
103    Application.start();
104    message = "The server has been restarted. You must log in again.";
105  }
106  else if ("SetBroadcastMessage".equals(cmd))
107  {
108    String title = Values.getStringOrNull(request.getParameter("title"));
109    String broadcastMessage = Values.getStringOrNull(request.getParameter("message"));
110    boolean denyLogin = Values.getBoolean(request.getParameter("denyLogin"));
111   
112    if (title != null)
113    {
114      application.setAttribute("broadcast.title", title);
115      application.setAttribute("broadcast.message", broadcastMessage);
116      application.setAttribute("broadcast.deny-login", denyLogin);
117      message = "Message is now sent";
118    }
119    else
120    {
121      application.removeAttribute("broadcast.title"); 
122      application.removeAttribute("broadcast.message"); 
123      application.removeAttribute("broadcast.deny-login"); 
124      message = "Message is now disabled";
125    }
126    RssNewsFeed.reset();
127  }
128  else
129  {
130    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
131  }
132}
133finally
134{
135  if (dc != null) dc.close();
136}
137if (forward != null)
138{
139  pageContext.forward(forward);
140}
141else if (redirect != null)
142{
143  response.sendRedirect(redirect);
144}
145else if (message == null)
146{
147  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
148}
149else
150{
151  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
152}
153%>
154
Note: See TracBrowser for help on using the repository browser.