1102 |
29 May 09 |
nicklas |
1 |
<%-- $Id$ |
1102 |
29 May 09 |
nicklas |
2 |
------------------------------------------------------------------ |
1102 |
29 May 09 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
1102 |
29 May 09 |
nicklas |
4 |
|
1102 |
29 May 09 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
1102 |
29 May 09 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
1102 |
29 May 09 |
nicklas |
7 |
|
1102 |
29 May 09 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
1102 |
29 May 09 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
1102 |
29 May 09 |
nicklas |
10 |
as published by the Free Software Foundation; either version 2 |
1102 |
29 May 09 |
nicklas |
11 |
of the License, or (at your option) any later version. |
1102 |
29 May 09 |
nicklas |
12 |
|
1102 |
29 May 09 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
1102 |
29 May 09 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1102 |
29 May 09 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1102 |
29 May 09 |
nicklas |
16 |
GNU General Public License for more details. |
1102 |
29 May 09 |
nicklas |
17 |
|
1102 |
29 May 09 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
1102 |
29 May 09 |
nicklas |
19 |
along with this program; if not, write to the Free Software |
1102 |
29 May 09 |
nicklas |
20 |
Foundation, Inc., 59 Temple Place - Suite 330, |
1102 |
29 May 09 |
nicklas |
21 |
Boston, MA 02111-1307, USA. |
1102 |
29 May 09 |
nicklas |
22 |
------------------------------------------------------------------ |
1102 |
29 May 09 |
nicklas |
23 |
|
1102 |
29 May 09 |
nicklas |
24 |
@author Nicklas |
1102 |
29 May 09 |
nicklas |
25 |
--%> |
1102 |
29 May 09 |
nicklas |
26 |
<%@ page |
1102 |
29 May 09 |
nicklas |
27 |
pageEncoding="UTF-8" |
1102 |
29 May 09 |
nicklas |
28 |
session="false" |
1102 |
29 May 09 |
nicklas |
29 |
import="net.sf.basedb.core.Application" |
1102 |
29 May 09 |
nicklas |
30 |
import="net.sf.basedb.core.BioAssaySet" |
1102 |
29 May 09 |
nicklas |
31 |
import="net.sf.basedb.core.Experiment" |
1102 |
29 May 09 |
nicklas |
32 |
import="net.sf.basedb.core.Directory" |
1102 |
29 May 09 |
nicklas |
33 |
import="net.sf.basedb.core.User" |
1102 |
29 May 09 |
nicklas |
34 |
import="net.sf.basedb.core.DbControl" |
1102 |
29 May 09 |
nicklas |
35 |
import="net.sf.basedb.core.SessionControl" |
1102 |
29 May 09 |
nicklas |
36 |
import="net.sf.basedb.core.Path" |
1102 |
29 May 09 |
nicklas |
37 |
import="net.sf.basedb.core.Presets" |
1102 |
29 May 09 |
nicklas |
38 |
import="net.sf.basedb.core.Presets.Preset" |
1102 |
29 May 09 |
nicklas |
39 |
import="net.sf.basedb.clients.web.Base" |
1102 |
29 May 09 |
nicklas |
40 |
import="net.sf.basedb.clients.web.util.HTML" |
1102 |
29 May 09 |
nicklas |
41 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
1102 |
29 May 09 |
nicklas |
42 |
import="net.sf.basedb.util.Values" |
1102 |
29 May 09 |
nicklas |
43 |
%> |
1102 |
29 May 09 |
nicklas |
44 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1102 |
29 May 09 |
nicklas |
45 |
<% |
1102 |
29 May 09 |
nicklas |
46 |
final SessionControl sc = Base.getExistingSessionControl(request, true); |
1102 |
29 May 09 |
nicklas |
47 |
final String ID = sc.getId(); |
1102 |
29 May 09 |
nicklas |
48 |
final float scale = Base.getScale(sc); |
1102 |
29 May 09 |
nicklas |
49 |
final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options"); |
1102 |
29 May 09 |
nicklas |
50 |
|
1102 |
29 May 09 |
nicklas |
51 |
final String gpServer = Values.getStringOrNull(request.getParameter("gpServer")); |
1108 |
04 Jun 09 |
nicklas |
52 |
String presetsXml = sc.getUserDefaultSetting("net.sf.basedb.genepattern.options"); |
1102 |
29 May 09 |
nicklas |
53 |
Presets presets = new Presets(); |
1102 |
29 May 09 |
nicklas |
54 |
if (presetsXml != null) presets.loadFrom(presetsXml); |
1102 |
29 May 09 |
nicklas |
55 |
Preset server = gpServer == null ? presets.getDefault() : presets.getPreset(gpServer); |
1126 |
15 Jun 09 |
nicklas |
56 |
if (server.getSetting("base.url") == null) |
1126 |
15 Jun 09 |
nicklas |
57 |
{ |
1126 |
15 Jun 09 |
nicklas |
58 |
final String scheme = request.getScheme(); |
1126 |
15 Jun 09 |
nicklas |
59 |
final String serverName = request.getServerName(); |
1126 |
15 Jun 09 |
nicklas |
60 |
final int serverPort = request.getServerPort(); |
1126 |
15 Jun 09 |
nicklas |
61 |
server.setSetting("base.url", scheme + "://" + serverName + ":" + serverPort); |
1126 |
15 Jun 09 |
nicklas |
62 |
} |
1102 |
29 May 09 |
nicklas |
63 |
String title = "Options for " + (gpServer == null ? "new" : gpServer); |
1102 |
29 May 09 |
nicklas |
64 |
%> |
1102 |
29 May 09 |
nicklas |
65 |
<base:page type="popup" title="<%=HTML.encodeTags(title)%>"> |
1106 |
02 Jun 09 |
nicklas |
66 |
<base:head scripts="ajax.js"> |
1102 |
29 May 09 |
nicklas |
67 |
<script language="JavaScript"> |
1102 |
29 May 09 |
nicklas |
68 |
function validate() |
1102 |
29 May 09 |
nicklas |
69 |
{ |
1102 |
29 May 09 |
nicklas |
70 |
var frm = document.forms['options']; |
1102 |
29 May 09 |
nicklas |
71 |
if (frm.gpServer.value == '') |
1102 |
29 May 09 |
nicklas |
72 |
{ |
1102 |
29 May 09 |
nicklas |
73 |
alert('A server URL must be specified'); |
1102 |
29 May 09 |
nicklas |
74 |
frm.gpServer.focus(); |
1102 |
29 May 09 |
nicklas |
75 |
return false; |
1102 |
29 May 09 |
nicklas |
76 |
} |
1102 |
29 May 09 |
nicklas |
77 |
else if (frm.gpLogin.value == '') |
1102 |
29 May 09 |
nicklas |
78 |
{ |
1102 |
29 May 09 |
nicklas |
79 |
alert('A login must be specified'); |
1102 |
29 May 09 |
nicklas |
80 |
frm.gpServer.focus(); |
1102 |
29 May 09 |
nicklas |
81 |
return false; |
1102 |
29 May 09 |
nicklas |
82 |
} |
1126 |
15 Jun 09 |
nicklas |
83 |
else if (frm.baseUrl.value == '') |
1126 |
15 Jun 09 |
nicklas |
84 |
{ |
1126 |
15 Jun 09 |
nicklas |
85 |
alert('The URL to BASE must be specified'); |
1126 |
15 Jun 09 |
nicklas |
86 |
frm.baseUrl.focus(); |
1126 |
15 Jun 09 |
nicklas |
87 |
return false; |
1126 |
15 Jun 09 |
nicklas |
88 |
} |
1102 |
29 May 09 |
nicklas |
89 |
return true; |
1102 |
29 May 09 |
nicklas |
90 |
} |
1102 |
29 May 09 |
nicklas |
91 |
|
1102 |
29 May 09 |
nicklas |
92 |
function saveSettings() |
1102 |
29 May 09 |
nicklas |
93 |
{ |
1102 |
29 May 09 |
nicklas |
94 |
if (validate()) document.forms['options'].submit(); |
1102 |
29 May 09 |
nicklas |
95 |
} |
1104 |
29 May 09 |
nicklas |
96 |
function testServer() |
1104 |
29 May 09 |
nicklas |
97 |
{ |
1104 |
29 May 09 |
nicklas |
98 |
if (!validate()) return; |
1104 |
29 May 09 |
nicklas |
99 |
var frm = document.forms['options']; |
1117 |
10 Jun 09 |
nicklas |
100 |
var url = '<%=homeUrl%>/Ajax.servlet?cmd=TestLogin'; |
1117 |
10 Jun 09 |
nicklas |
101 |
url += '&server=' + encodeURIComponent(frm.gpServer.value); |
1104 |
29 May 09 |
nicklas |
102 |
url += '&login=' + encodeURIComponent(frm.gpLogin.value); |
1104 |
29 May 09 |
nicklas |
103 |
url += '&password=' + encodeURIComponent(frm.gpPassword.value); |
1106 |
02 Jun 09 |
nicklas |
104 |
var request = Ajax.getXmlHttpRequest(); |
1106 |
02 Jun 09 |
nicklas |
105 |
request.open("GET", url, true); |
1106 |
02 Jun 09 |
nicklas |
106 |
Ajax.setReadyStateHandler(request, testResult); |
1106 |
02 Jun 09 |
nicklas |
107 |
request.send(null); |
1106 |
02 Jun 09 |
nicklas |
108 |
document.getElementById('testStatus').innerHTML = 'Testing'; |
1117 |
10 Jun 09 |
nicklas |
109 |
document.getElementById('testReport').innerHTML = 'Please wait. . .'; |
1117 |
10 Jun 09 |
nicklas |
110 |
setTimeout('testResult(null)', 15000); |
1117 |
10 Jun 09 |
nicklas |
111 |
setTimeout('showProgress()', 250); |
1104 |
29 May 09 |
nicklas |
112 |
} |
1117 |
10 Jun 09 |
nicklas |
113 |
function showProgress() |
1117 |
10 Jun 09 |
nicklas |
114 |
{ |
1117 |
10 Jun 09 |
nicklas |
115 |
var progress = document.getElementById('testReport'); |
1117 |
10 Jun 09 |
nicklas |
116 |
if (progress.innerHTML.indexOf('Please wait') == 0) |
1117 |
10 Jun 09 |
nicklas |
117 |
{ |
1117 |
10 Jun 09 |
nicklas |
118 |
progress.innerHTML += ' .'; |
1117 |
10 Jun 09 |
nicklas |
119 |
setTimeout('showProgress()', 250); |
1117 |
10 Jun 09 |
nicklas |
120 |
} |
1117 |
10 Jun 09 |
nicklas |
121 |
} |
1106 |
02 Jun 09 |
nicklas |
122 |
|
1106 |
02 Jun 09 |
nicklas |
123 |
function testResult(request) |
1106 |
02 Jun 09 |
nicklas |
124 |
{ |
1117 |
10 Jun 09 |
nicklas |
125 |
if (document.getElementById('testReport').innerHTML.indexOf('Please wait') != 0) return; |
1106 |
02 Jun 09 |
nicklas |
126 |
var frm = document.forms['options']; |
1117 |
10 Jun 09 |
nicklas |
127 |
var responseText = request != null ? request.responseText : 'status:error\nstacktrace:No response from server'; |
1117 |
10 Jun 09 |
nicklas |
128 |
var response = Ajax.parseResponse(responseText); |
1106 |
02 Jun 09 |
nicklas |
129 |
var testStatus; |
1106 |
02 Jun 09 |
nicklas |
130 |
var testReport; |
1117 |
10 Jun 09 |
nicklas |
131 |
if (response.isError()) |
1106 |
02 Jun 09 |
nicklas |
132 |
{ |
1117 |
10 Jun 09 |
nicklas |
133 |
testStatus = 'Test failed'; |
1117 |
10 Jun 09 |
nicklas |
134 |
var stacktrace = response.getElements()[0]['stacktrace']; |
1126 |
15 Jun 09 |
nicklas |
135 |
testReport = '<div class="error stacktrace" style="width: 350px; height: 15em; overflow: auto;">' + stacktrace + '</div>'; |
1106 |
02 Jun 09 |
nicklas |
136 |
} |
1106 |
02 Jun 09 |
nicklas |
137 |
else |
1106 |
02 Jun 09 |
nicklas |
138 |
{ |
1117 |
10 Jun 09 |
nicklas |
139 |
testStatus = 'Test result'; |
1117 |
10 Jun 09 |
nicklas |
140 |
testReport = 'Test of <b>' + frm.gpServer.value + '</b> was successful'; |
1106 |
02 Jun 09 |
nicklas |
141 |
} |
1106 |
02 Jun 09 |
nicklas |
142 |
document.getElementById('testStatus').innerHTML = testStatus; |
1106 |
02 Jun 09 |
nicklas |
143 |
document.getElementById('testReport').innerHTML = testReport; |
1106 |
02 Jun 09 |
nicklas |
144 |
} |
1102 |
29 May 09 |
nicklas |
145 |
</script> |
1102 |
29 May 09 |
nicklas |
146 |
</base:head> |
1102 |
29 May 09 |
nicklas |
147 |
<base:body> |
1102 |
29 May 09 |
nicklas |
148 |
<form action="submit.jsp?ID=<%=ID%>" method="post" name="options" onsubmit="return false;"> |
1106 |
02 Jun 09 |
nicklas |
149 |
<input type="hidden" name="cmd" value="SaveServer"> |
1106 |
02 Jun 09 |
nicklas |
150 |
<input type="hidden" name="originalGpServer" value="<%=HTML.encodeTags(server.getName())%>"> |
1106 |
02 Jun 09 |
nicklas |
151 |
|
1102 |
29 May 09 |
nicklas |
152 |
<h3 class="docked"><%=HTML.encodeTags(title)%></h3> |
1102 |
29 May 09 |
nicklas |
153 |
<div class="boxedbottom"> |
1117 |
10 Jun 09 |
nicklas |
154 |
<table class="form" cellspacing="0" width="100%"> |
1102 |
29 May 09 |
nicklas |
155 |
<tr> |
1126 |
15 Jun 09 |
nicklas |
156 |
<td class="prompt">GenePattern server</td> |
1126 |
15 Jun 09 |
nicklas |
157 |
<td colspan="2"><input class="text required" type="text" name="gpServer" size="45" |
1126 |
15 Jun 09 |
nicklas |
158 |
value="<%=HTML.encodeTags(server.getName())%>" |
1126 |
15 Jun 09 |
nicklas |
159 |
title="The URL to the GenePattern server"></td> |
1102 |
29 May 09 |
nicklas |
160 |
</tr> |
1102 |
29 May 09 |
nicklas |
161 |
<tr> |
1126 |
15 Jun 09 |
nicklas |
162 |
<td class="subprompt">-login</td> |
1126 |
15 Jun 09 |
nicklas |
163 |
<td colspan="2"><input class="text required" type="text" name="gpLogin" size="45" |
1126 |
15 Jun 09 |
nicklas |
164 |
value="<%=HTML.encodeTags(server.getSetting("server.login"))%>" |
1126 |
15 Jun 09 |
nicklas |
165 |
title="Your login to the above GenePattern server"></td> |
1102 |
29 May 09 |
nicklas |
166 |
</tr> |
1102 |
29 May 09 |
nicklas |
167 |
<tr> |
1126 |
15 Jun 09 |
nicklas |
168 |
<td class="subprompt">-password</td> |
1106 |
02 Jun 09 |
nicklas |
169 |
<td><input class="text" type="password" name="gpPassword" size="30" |
1126 |
15 Jun 09 |
nicklas |
170 |
value="<%=HTML.encodeTags(server.getSetting("server.password"))%>" |
1126 |
15 Jun 09 |
nicklas |
171 |
title="Leave empty if no password is needed"> |
1106 |
02 Jun 09 |
nicklas |
172 |
</td> |
1126 |
15 Jun 09 |
nicklas |
173 |
<td> |
1126 |
15 Jun 09 |
nicklas |
174 |
<table border="0" cellspacing="0" cellpadding="0"> |
1126 |
15 Jun 09 |
nicklas |
175 |
<tr><td><base:button onclick="testServer();" title="Test" |
1126 |
15 Jun 09 |
nicklas |
176 |
image="<%=homeUrl + "/images/genepattern.gif" %>" /></td></tr> |
1126 |
15 Jun 09 |
nicklas |
177 |
</table> |
1126 |
15 Jun 09 |
nicklas |
178 |
</td> |
1102 |
29 May 09 |
nicklas |
179 |
</tr> |
1106 |
02 Jun 09 |
nicklas |
180 |
<tr> |
1126 |
15 Jun 09 |
nicklas |
181 |
<td class="prompt">BASE server</td> |
1126 |
15 Jun 09 |
nicklas |
182 |
<td colspan="2"><input type="text" class="text required" name="baseUrl" size="45" |
1126 |
15 Jun 09 |
nicklas |
183 |
value="<%=HTML.encodeTags(server.getSetting("base.url"))%>" |
1126 |
15 Jun 09 |
nicklas |
184 |
title="The URL to this BASE server as seen from the GenePattern server"> |
1126 |
15 Jun 09 |
nicklas |
185 |
</td> |
1126 |
15 Jun 09 |
nicklas |
186 |
</tr> |
1126 |
15 Jun 09 |
nicklas |
187 |
<tr> |
1106 |
02 Jun 09 |
nicklas |
188 |
<td class="prompt" id="testStatus"></td> |
1126 |
15 Jun 09 |
nicklas |
189 |
<td id="testReport" colspan="2"> |
1106 |
02 Jun 09 |
nicklas |
190 |
</td> |
1106 |
02 Jun 09 |
nicklas |
191 |
</tr> |
1102 |
29 May 09 |
nicklas |
192 |
</table> |
1102 |
29 May 09 |
nicklas |
193 |
</div> |
1117 |
10 Jun 09 |
nicklas |
194 |
</form> |
1102 |
29 May 09 |
nicklas |
195 |
<p> |
1102 |
29 May 09 |
nicklas |
196 |
<table align="center"> |
1102 |
29 May 09 |
nicklas |
197 |
<tr> |
1126 |
15 Jun 09 |
nicklas |
198 |
<td width="50%"><base:button onclick="saveSettings();" title="Save" /></td> |
1126 |
15 Jun 09 |
nicklas |
199 |
<td width="50%"><base:button onclick="window.close();" title="Cancel" /></td> |
1102 |
29 May 09 |
nicklas |
200 |
</tr> |
1102 |
29 May 09 |
nicklas |
201 |
</table> |
1102 |
29 May 09 |
nicklas |
202 |
</base:body> |
1102 |
29 May 09 |
nicklas |
203 |
</base:page> |