source: extensions/net.sf.basedb.genepattern/trunk/resources/submit.jsp @ 1106

Last change on this file since 1106 was 1106, checked in by Nicklas Nordborg, 14 years ago

Fixes #224: Add a "Test" button on the GenePattern? 'edit server' page

Now using Ajax to do the test which means that we don't need to 'forward' from the servlet and we only need BASE 2.12.0.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 3.4 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23--%>
24<%@ page
25  pageEncoding="UTF-8"
26  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.Presets"
32  import="net.sf.basedb.core.Presets.Preset"
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 redirect = null;
46String message = null;
47
48try
49{
50  if ("SaveServer".equals(cmd))
51  {
52    String presetsXml = sc.getUserClientSetting("net.sf.basedb.genepattern.options");
53    Presets presets = new Presets();
54    if (presetsXml != null) presets.loadFrom(presetsXml);
55    String originalGpServer = request.getParameter("originalGpServer");
56    String gpServer = request.getParameter("gpServer");
57    Preset server = presets.getPreset(gpServer);
58    if ("".equals(originalGpServer))
59    {
60      // Adding a new server - check if one already exists
61      if (server.getSetting("server.login") != null)
62      {
63        throw new WebException("popup", "Server exists", "The server {1} already exists", gpServer);
64      }
65    }
66    else if (!gpServer.equals(originalGpServer))
67    {
68      // The URL of an existing server has been modified
69      presets.deletePreset(originalGpServer);
70    }
71    server.setSetting("server.login", request.getParameter("gpLogin"));
72    server.setSetting("server.password", request.getParameter("gpPassword"));
73    sc.setUserClientSetting("net.sf.basedb.genepattern.options", presets.asXml());
74    message = gpServer + " saved";
75  }
76  else if ("RemoveServer".equals(cmd))
77  {
78    String presetsXml = sc.getUserClientSetting("net.sf.basedb.genepattern.options");
79    Presets presets = new Presets();
80    if (presetsXml != null) presets.loadFrom(presetsXml);
81    String gpServer = request.getParameter("gpServer");
82    presets.deletePreset(gpServer);
83    sc.setUserClientSetting("net.sf.basedb.genepattern.options", presets.asXml());
84    message = gpServer + " deleted";   
85  }
86  else
87  {
88    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
89  }
90}
91finally
92{}
93if (message == null)
94{
95  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=0&wait=0");
96}
97else
98{
99  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
100}
101%>
102
Note: See TracBrowser for help on using the repository browser.