1730 |
20 Dec 05 |
nicklas |
1 |
<%-- $Id$ |
1730 |
20 Dec 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Johan Enell, Jari Häkkinen, Nicklas Nordborg |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg, Martin Svensson |
1730 |
20 Dec 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
1730 |
20 Dec 05 |
nicklas |
9 |
|
1730 |
20 Dec 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
1730 |
20 Dec 05 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
1730 |
20 Dec 05 |
nicklas |
13 |
of the License, or (at your option) any later version. |
1730 |
20 Dec 05 |
nicklas |
14 |
|
1730 |
20 Dec 05 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
1730 |
20 Dec 05 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1730 |
20 Dec 05 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1730 |
20 Dec 05 |
nicklas |
18 |
GNU General Public License for more details. |
1730 |
20 Dec 05 |
nicklas |
19 |
|
1730 |
20 Dec 05 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1730 |
20 Dec 05 |
nicklas |
22 |
------------------------------------------------------------------ |
1730 |
20 Dec 05 |
nicklas |
23 |
|
1730 |
20 Dec 05 |
nicklas |
24 |
@author Nicklas |
1730 |
20 Dec 05 |
nicklas |
25 |
@version 2.0 |
4253 |
28 Apr 08 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
1730 |
20 Dec 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
1730 |
20 Dec 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
2677 |
28 Sep 06 |
nicklas |
30 |
import="net.sf.basedb.core.BasicItem" |
1730 |
20 Dec 05 |
nicklas |
31 |
import="net.sf.basedb.core.Item" |
2677 |
28 Sep 06 |
nicklas |
32 |
import="net.sf.basedb.core.ItemContext" |
1787 |
18 Jan 06 |
nicklas |
33 |
import="net.sf.basedb.core.ItemQuery" |
1730 |
20 Dec 05 |
nicklas |
34 |
import="net.sf.basedb.core.PluginDefinition" |
1730 |
20 Dec 05 |
nicklas |
35 |
import="net.sf.basedb.core.PluginConfiguration" |
1730 |
20 Dec 05 |
nicklas |
36 |
import="net.sf.basedb.core.PluginParameter" |
1730 |
20 Dec 05 |
nicklas |
37 |
import="net.sf.basedb.core.ParameterType" |
1730 |
20 Dec 05 |
nicklas |
38 |
import="net.sf.basedb.core.StringParameterType" |
1730 |
20 Dec 05 |
nicklas |
39 |
import="net.sf.basedb.core.IntegerParameterType" |
1754 |
11 Jan 06 |
nicklas |
40 |
import="net.sf.basedb.core.LongParameterType" |
1754 |
11 Jan 06 |
nicklas |
41 |
import="net.sf.basedb.core.FloatParameterType" |
1754 |
11 Jan 06 |
nicklas |
42 |
import="net.sf.basedb.core.DoubleParameterType" |
1730 |
20 Dec 05 |
nicklas |
43 |
import="net.sf.basedb.core.ItemParameterType" |
1754 |
11 Jan 06 |
nicklas |
44 |
import="net.sf.basedb.core.DateParameterType" |
5437 |
01 Oct 10 |
nicklas |
45 |
import="net.sf.basedb.core.TimestampParameterType" |
1730 |
20 Dec 05 |
nicklas |
46 |
import="net.sf.basedb.core.BooleanParameterType" |
1730 |
20 Dec 05 |
nicklas |
47 |
import="net.sf.basedb.core.FileParameterType" |
2147 |
04 Apr 06 |
nicklas |
48 |
import="net.sf.basedb.core.PathParameterType" |
1730 |
20 Dec 05 |
nicklas |
49 |
import="net.sf.basedb.core.File" |
1730 |
20 Dec 05 |
nicklas |
50 |
import="net.sf.basedb.core.Path" |
1730 |
20 Dec 05 |
nicklas |
51 |
import="net.sf.basedb.core.Job" |
4311 |
23 May 08 |
nicklas |
52 |
import="net.sf.basedb.core.JobAgent" |
1730 |
20 Dec 05 |
nicklas |
53 |
import="net.sf.basedb.core.Type" |
4265 |
05 May 08 |
nicklas |
54 |
import="net.sf.basedb.core.Experiment" |
4265 |
05 May 08 |
nicklas |
55 |
import="net.sf.basedb.core.InternalJobQueue" |
1730 |
20 Dec 05 |
nicklas |
56 |
import="net.sf.basedb.core.BaseException" |
3518 |
20 Jun 07 |
nicklas |
57 |
import="net.sf.basedb.core.PermissionDeniedException" |
1730 |
20 Dec 05 |
nicklas |
58 |
import="net.sf.basedb.core.PluginConfigurationRequest" |
1730 |
20 Dec 05 |
nicklas |
59 |
import="net.sf.basedb.core.PluginExecutionRequest" |
1730 |
20 Dec 05 |
nicklas |
60 |
import="net.sf.basedb.core.PluginResponse" |
1787 |
18 Jan 06 |
nicklas |
61 |
import="net.sf.basedb.core.Include" |
4327 |
03 Jun 08 |
martin |
62 |
import="net.sf.basedb.core.SimpleProgressReporter" |
5480 |
08 Nov 10 |
nicklas |
63 |
import="net.sf.basedb.core.StringUtil" |
1787 |
18 Jan 06 |
nicklas |
64 |
import="net.sf.basedb.core.query.Hql" |
1787 |
18 Jan 06 |
nicklas |
65 |
import="net.sf.basedb.core.query.Expressions" |
1787 |
18 Jan 06 |
nicklas |
66 |
import="net.sf.basedb.core.query.Restrictions" |
1787 |
18 Jan 06 |
nicklas |
67 |
import="net.sf.basedb.core.query.Orders" |
1787 |
18 Jan 06 |
nicklas |
68 |
import="net.sf.basedb.core.plugin.Plugin" |
1730 |
20 Dec 05 |
nicklas |
69 |
import="net.sf.basedb.core.plugin.Response" |
1787 |
18 Jan 06 |
nicklas |
70 |
import="net.sf.basedb.core.plugin.GuiContext" |
1787 |
18 Jan 06 |
nicklas |
71 |
import="net.sf.basedb.core.plugin.InteractivePlugin" |
2854 |
02 Nov 06 |
nicklas |
72 |
import="net.sf.basedb.core.plugin.ExportOutputStream" |
4330 |
10 Jun 08 |
martin |
73 |
import="net.sf.basedb.core.signal.Signal" |
4330 |
10 Jun 08 |
martin |
74 |
import="net.sf.basedb.core.signal.SignalHandler" |
4330 |
10 Jun 08 |
martin |
75 |
import="net.sf.basedb.core.signal.SignalTarget" |
5590 |
16 Mar 11 |
nicklas |
76 |
import="net.sf.basedb.core.signal.SimpleSignalSender" |
1730 |
20 Dec 05 |
nicklas |
77 |
import="net.sf.basedb.clients.web.Base" |
1730 |
20 Dec 05 |
nicklas |
78 |
import="net.sf.basedb.clients.web.WebException" |
3518 |
20 Jun 07 |
nicklas |
79 |
import="net.sf.basedb.clients.web.DuplicateWizardException" |
2738 |
17 Oct 06 |
nicklas |
80 |
import="net.sf.basedb.util.Values" |
3438 |
04 Jun 07 |
nicklas |
81 |
import="net.sf.basedb.util.ContextUtil" |
3438 |
04 Jun 07 |
nicklas |
82 |
import="net.sf.basedb.util.ContextUtil.ContextResult" |
2942 |
22 Nov 06 |
nicklas |
83 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
1730 |
20 Dec 05 |
nicklas |
84 |
import="net.sf.basedb.clients.web.util.HTML" |
2854 |
02 Nov 06 |
nicklas |
85 |
import="net.sf.basedb.clients.web.util.ServletExportOutputStream" |
4330 |
10 Jun 08 |
martin |
86 |
import="net.sf.basedb.clients.web.util.SimpleSignalProgressReporter" |
1730 |
20 Dec 05 |
nicklas |
87 |
import="java.util.List" |
1787 |
18 Jan 06 |
nicklas |
88 |
import="java.util.LinkedList" |
1750 |
10 Jan 06 |
nicklas |
89 |
import="java.util.Arrays" |
1787 |
18 Jan 06 |
nicklas |
90 |
import="java.util.Map" |
1787 |
18 Jan 06 |
nicklas |
91 |
import="java.util.HashMap" |
2664 |
26 Sep 06 |
nicklas |
92 |
import="java.util.LinkedHashMap" |
2195 |
26 Apr 06 |
nicklas |
93 |
import="java.util.Set" |
2195 |
26 Apr 06 |
nicklas |
94 |
import="java.util.HashSet" |
4254 |
28 Apr 08 |
nicklas |
95 |
import="java.util.EnumSet" |
2942 |
22 Nov 06 |
nicklas |
96 |
import="java.io.PrintWriter" |
4253 |
28 Apr 08 |
nicklas |
97 |
%> |
4253 |
28 Apr 08 |
nicklas |
98 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4253 |
28 Apr 08 |
nicklas |
99 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
1730 |
20 Dec 05 |
nicklas |
100 |
|
4253 |
28 Apr 08 |
nicklas |
101 |
<%! |
4254 |
28 Apr 08 |
nicklas |
102 |
private static final Set<Item> EXPERIMENT_CONTEXTS = |
4254 |
28 Apr 08 |
nicklas |
103 |
EnumSet.of(Item.EXPERIMENT, Item.BIOASSAYSET, Item.BIOASSAY); |
4254 |
28 Apr 08 |
nicklas |
104 |
|
4962 |
08 Jun 09 |
nicklas |
105 |
private static String getJspPage(PluginConfigurationRequest request, |
4962 |
08 Jun 09 |
nicklas |
106 |
PluginDefinition plugin, String defaultPage, String root) |
1787 |
18 Jan 06 |
nicklas |
107 |
{ |
1787 |
18 Jan 06 |
nicklas |
108 |
String jspPage = request.getRequestInformation().getJspPage(); |
1787 |
18 Jan 06 |
nicklas |
109 |
if (jspPage == null) |
1787 |
18 Jan 06 |
nicklas |
110 |
{ |
1787 |
18 Jan 06 |
nicklas |
111 |
jspPage = defaultPage; |
1787 |
18 Jan 06 |
nicklas |
112 |
} |
4962 |
08 Jun 09 |
nicklas |
113 |
else if (jspPage.startsWith("/")) |
4962 |
08 Jun 09 |
nicklas |
114 |
{ |
4962 |
08 Jun 09 |
nicklas |
115 |
// The path is absolute... if it starts with the context root |
4962 |
08 Jun 09 |
nicklas |
116 |
// it must be removed because we are doing a forward action |
4962 |
08 Jun 09 |
nicklas |
117 |
if (jspPage.startsWith(root)) jspPage = jspPage.substring(root.length()-1); |
4962 |
08 Jun 09 |
nicklas |
118 |
} |
1787 |
18 Jan 06 |
nicklas |
119 |
else |
1787 |
18 Jan 06 |
nicklas |
120 |
{ |
1787 |
18 Jan 06 |
nicklas |
121 |
String className = plugin.getClassName(); |
1787 |
18 Jan 06 |
nicklas |
122 |
int lastDot = className.lastIndexOf('.'); |
1875 |
01 Feb 06 |
nicklas |
123 |
String packageName = lastDot == -1 ? "" : className.substring(0, lastDot+1); |
1787 |
18 Jan 06 |
nicklas |
124 |
jspPage = "/plugins/"+packageName.replace('.', '/')+jspPage; |
1787 |
18 Jan 06 |
nicklas |
125 |
} |
3518 |
20 Jun 07 |
nicklas |
126 |
jspPage += "?requestId="+System.identityHashCode(request); |
1787 |
18 Jan 06 |
nicklas |
127 |
return jspPage; |
1787 |
18 Jan 06 |
nicklas |
128 |
} |
4254 |
28 Apr 08 |
nicklas |
129 |
private static Experiment getCurrentExperiment(DbControl dc, GuiContext context) |
4254 |
28 Apr 08 |
nicklas |
130 |
{ |
4254 |
28 Apr 08 |
nicklas |
131 |
if (!EXPERIMENT_CONTEXTS.contains(context.getItem())) return null; |
4254 |
28 Apr 08 |
nicklas |
132 |
SessionControl sc = dc.getSessionControl(); |
4254 |
28 Apr 08 |
nicklas |
133 |
ItemContext expCtx = sc.getCurrentContext(Item.EXPERIMENT); |
4254 |
28 Apr 08 |
nicklas |
134 |
if (expCtx.getId() == 0) return null; |
4254 |
28 Apr 08 |
nicklas |
135 |
return Experiment.getById(dc, expCtx.getId()); |
4254 |
28 Apr 08 |
nicklas |
136 |
} |
4253 |
28 Apr 08 |
nicklas |
137 |
%> |
1787 |
18 Jan 06 |
nicklas |
138 |
|
4253 |
28 Apr 08 |
nicklas |
139 |
<% |
1730 |
20 Dec 05 |
nicklas |
140 |
final String root = request.getContextPath()+"/"; |
1730 |
20 Dec 05 |
nicklas |
141 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1730 |
20 Dec 05 |
nicklas |
142 |
final String ID = sc.getId(); |
1730 |
20 Dec 05 |
nicklas |
143 |
final String cmd = request.getParameter("cmd"); |
3518 |
20 Jun 07 |
nicklas |
144 |
final boolean warnIfOpen = Values.getBoolean(request.getParameter("warnIfOpen"), true); |
3518 |
20 Jun 07 |
nicklas |
145 |
final boolean anotherIsOpen = sc.getSessionSetting("plugin.configure.plugin") != null; |
1730 |
20 Dec 05 |
nicklas |
146 |
|
1730 |
20 Dec 05 |
nicklas |
147 |
DbControl dc = null; |
1730 |
20 Dec 05 |
nicklas |
148 |
String forward = null; |
1730 |
20 Dec 05 |
nicklas |
149 |
String message = null; |
1730 |
20 Dec 05 |
nicklas |
150 |
String redirect = null; |
1730 |
20 Dec 05 |
nicklas |
151 |
try |
1730 |
20 Dec 05 |
nicklas |
152 |
{ |
1730 |
20 Dec 05 |
nicklas |
153 |
|
1787 |
18 Jan 06 |
nicklas |
154 |
if ("SelectPlugin".equals(cmd)) |
1730 |
20 Dec 05 |
nicklas |
155 |
{ |
1787 |
18 Jan 06 |
nicklas |
156 |
Item itemType = Item.valueOf(request.getParameter("item_type")); |
1945 |
09 Feb 06 |
nicklas |
157 |
String subContext = Values.getString(request.getParameter("subcontext"), ""); |
1787 |
18 Jan 06 |
nicklas |
158 |
GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type")); |
2868 |
07 Nov 06 |
nicklas |
159 |
GuiContext context = new GuiContext(itemType, contextType, subContext); |
1787 |
18 Jan 06 |
nicklas |
160 |
Plugin.MainType mainType = Plugin.MainType.valueOf(request.getParameter("main_type")); |
3592 |
23 Jul 07 |
nicklas |
161 |
String pluginType = request.getParameter("plugin_type"); |
3438 |
04 Jun 07 |
nicklas |
162 |
|
3592 |
23 Jul 07 |
nicklas |
163 |
ItemQuery<PluginDefinition> pluginQuery = PluginDefinition.getQuery(context, pluginType); |
3438 |
04 Jun 07 |
nicklas |
164 |
pluginQuery.restrict( |
1787 |
18 Jan 06 |
nicklas |
165 |
Restrictions.eq( |
1787 |
18 Jan 06 |
nicklas |
166 |
Hql.property("mainType"), |
1787 |
18 Jan 06 |
nicklas |
167 |
Expressions.integer(mainType.getValue()) |
1787 |
18 Jan 06 |
nicklas |
168 |
) |
1787 |
18 Jan 06 |
nicklas |
169 |
); |
5615 |
19 Apr 11 |
nicklas |
170 |
pluginQuery.restrict(Restrictions.eq(Hql.property("disabled"), Expressions.parameter("isDisabled", false))); |
3438 |
04 Jun 07 |
nicklas |
171 |
pluginQuery.order(Orders.asc(Hql.property("name"))); |
3438 |
04 Jun 07 |
nicklas |
172 |
pluginQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); |
3438 |
04 Jun 07 |
nicklas |
173 |
|
3438 |
04 Jun 07 |
nicklas |
174 |
ItemQuery<PluginConfiguration> configQuery = PluginConfiguration.getQuery(); |
3438 |
04 Jun 07 |
nicklas |
175 |
configQuery.restrict( |
3438 |
04 Jun 07 |
nicklas |
176 |
Restrictions.eq( |
3438 |
04 Jun 07 |
nicklas |
177 |
Hql.property("pluginDefinition"), |
3438 |
04 Jun 07 |
nicklas |
178 |
Expressions.parameter("plugin") |
3438 |
04 Jun 07 |
nicklas |
179 |
) |
3438 |
04 Jun 07 |
nicklas |
180 |
); |
5629 |
09 May 11 |
nicklas |
181 |
configQuery.restrict(Restrictions.gt(Hql.property("parameterVersion"), Expressions.integer(0))); |
8107 |
23 Jan 23 |
nicklas |
182 |
configQuery.restrict(Restrictions.eq(Hql.property("disabled"), Expressions.parameter("isDisabled", false))); |
3438 |
04 Jun 07 |
nicklas |
183 |
configQuery.order(Orders.asc(Hql.property("name"))); |
3438 |
04 Jun 07 |
nicklas |
184 |
configQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); |
3438 |
04 Jun 07 |
nicklas |
185 |
|
7954 |
12 May 21 |
nicklas |
186 |
dc = sc.newDbControl(":Select "+mainType+" plug-in"); |
3438 |
04 Jun 07 |
nicklas |
187 |
Object currentItem = null; |
3438 |
04 Jun 07 |
nicklas |
188 |
if (contextType == GuiContext.Type.ITEM) |
1787 |
18 Jan 06 |
nicklas |
189 |
{ |
3438 |
04 Jun 07 |
nicklas |
190 |
currentItem = itemType.getById(dc, sc.getCurrentContext(itemType).getId()); |
1787 |
18 Jan 06 |
nicklas |
191 |
} |
3438 |
04 Jun 07 |
nicklas |
192 |
List<ContextResult> contextResult = ContextUtil.checkContext(dc, pluginQuery, configQuery, context, currentItem); |
1787 |
18 Jan 06 |
nicklas |
193 |
dc.close(); |
3438 |
04 Jun 07 |
nicklas |
194 |
|
3495 |
14 Jun 07 |
nicklas |
195 |
boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), false); |
3438 |
04 Jun 07 |
nicklas |
196 |
int totalPlugins = ContextUtil.countUsuablePlugins(contextResult); |
3438 |
04 Jun 07 |
nicklas |
197 |
Set<String> contextMessages = ContextUtil.getContextMessages(contextResult, showWarnings, true); |
3438 |
04 Jun 07 |
nicklas |
198 |
|
1944 |
08 Feb 06 |
nicklas |
199 |
if (totalPlugins == 0) |
1787 |
18 Jan 06 |
nicklas |
200 |
{ |
5917 |
19 Dec 11 |
nicklas |
201 |
String msg = "<b>No plugins can be used in this context, for the following reasons:</b><br><ul><li>"; |
2392 |
16 Jun 06 |
nicklas |
202 |
if (contextMessages.size() == 0) |
2392 |
16 Jun 06 |
nicklas |
203 |
{ |
3438 |
04 Jun 07 |
nicklas |
204 |
msg += "Could not find any plugins that you have permission to use</ul>"; |
2392 |
16 Jun 06 |
nicklas |
205 |
} |
2392 |
16 Jun 06 |
nicklas |
206 |
else |
2392 |
16 Jun 06 |
nicklas |
207 |
{ |
2392 |
16 Jun 06 |
nicklas |
208 |
msg += Values.getString(contextMessages, "<li>", true) + "</ul>"; |
2392 |
16 Jun 06 |
nicklas |
209 |
} |
3438 |
04 Jun 07 |
nicklas |
210 |
throw new WebException("popup", "No usable plugins found", msg); |
1787 |
18 Jan 06 |
nicklas |
211 |
} |
2430 |
27 Jun 06 |
nicklas |
212 |
sc.setSessionSetting("MESSAGES", contextMessages); |
3438 |
04 Jun 07 |
nicklas |
213 |
sc.setSessionSetting("PLUGINS", contextResult); |
3518 |
20 Jun 07 |
nicklas |
214 |
if (totalPlugins == 1 && contextMessages.size() == 0 && !(warnIfOpen && anotherIsOpen)) |
1875 |
01 Feb 06 |
nicklas |
215 |
{ |
3536 |
29 Jun 07 |
martin |
216 |
// Only one plug-in, that can be used, exists, find it in contextResult and |
3536 |
29 Jun 07 |
martin |
217 |
//go directly to parameter input page |
3536 |
29 Jun 07 |
martin |
218 |
int i = 0; |
3536 |
29 Jun 07 |
martin |
219 |
PluginDefinition thePlugin = null; |
3559 |
16 Jul 07 |
nicklas |
220 |
PluginConfiguration theConfig = null; |
3536 |
29 Jun 07 |
martin |
221 |
while (i < contextResult.size() && thePlugin == null) |
3536 |
29 Jun 07 |
martin |
222 |
{ |
3536 |
29 Jun 07 |
martin |
223 |
if (contextResult.get(i).isInContext()) |
3536 |
29 Jun 07 |
martin |
224 |
{ |
3536 |
29 Jun 07 |
martin |
225 |
thePlugin = contextResult.get(i).getPluginDefinition(); |
3559 |
16 Jul 07 |
nicklas |
226 |
theConfig = contextResult.get(i).getPluginConfiguration(); |
3536 |
29 Jun 07 |
martin |
227 |
} |
3536 |
29 Jun 07 |
martin |
228 |
i++; |
3536 |
29 Jun 07 |
martin |
229 |
} |
1875 |
01 Feb 06 |
nicklas |
230 |
int pluginDefinitionId = thePlugin.getId(); |
3438 |
04 Jun 07 |
nicklas |
231 |
int pluginConfigurationId = theConfig == null ? 0 : theConfig.getId(); |
1875 |
01 Feb 06 |
nicklas |
232 |
forward = "index.jsp?cmd=NewJob"+ |
1875 |
01 Feb 06 |
nicklas |
233 |
"&plugindefinition_id="+pluginDefinitionId+ |
1875 |
01 Feb 06 |
nicklas |
234 |
"&pluginconfiguration_id="+pluginConfigurationId; |
1875 |
01 Feb 06 |
nicklas |
235 |
} |
1875 |
01 Feb 06 |
nicklas |
236 |
else |
1875 |
01 Feb 06 |
nicklas |
237 |
{ |
1875 |
01 Feb 06 |
nicklas |
238 |
forward = "select_plugin.jsp"; |
1875 |
01 Feb 06 |
nicklas |
239 |
} |
1787 |
18 Jan 06 |
nicklas |
240 |
} |
1787 |
18 Jan 06 |
nicklas |
241 |
else if ("ConfigurePlugin".equals(cmd)) |
1787 |
18 Jan 06 |
nicklas |
242 |
{ |
3518 |
20 Jun 07 |
nicklas |
243 |
if (warnIfOpen && anotherIsOpen) |
3518 |
20 Jun 07 |
nicklas |
244 |
{ |
3518 |
20 Jun 07 |
nicklas |
245 |
throw new DuplicateWizardException(); |
3518 |
20 Jun 07 |
nicklas |
246 |
} |
1730 |
20 Dec 05 |
nicklas |
247 |
int pluginConfigurationId = Values.getInt(request.getParameter("pluginconfiguration_id")); |
1730 |
20 Dec 05 |
nicklas |
248 |
|
7954 |
12 May 21 |
nicklas |
249 |
dc = sc.newDbControl(":Configure plugin"); |
1773 |
16 Jan 06 |
nicklas |
250 |
PluginConfiguration pluginConfig = PluginConfiguration.getById(dc, pluginConfigurationId); |
1787 |
18 Jan 06 |
nicklas |
251 |
PluginDefinition plugin = pluginConfig.getPluginDefinition(); |
2512 |
10 Aug 06 |
nicklas |
252 |
|
2512 |
10 Aug 06 |
nicklas |
253 |
if (!plugin.supportsConfigurations()) |
2512 |
10 Aug 06 |
nicklas |
254 |
{ |
2512 |
10 Aug 06 |
nicklas |
255 |
throw new WebException("popup", "Configurations are not supported", |
2512 |
10 Aug 06 |
nicklas |
256 |
"The plugin {1} doesn't support configurations.", HTML.encodeTags(plugin.getName())); |
2512 |
10 Aug 06 |
nicklas |
257 |
} |
1773 |
16 Jan 06 |
nicklas |
258 |
PluginConfigurationRequest pcRequest = pluginConfig.configure(); |
1730 |
20 Dec 05 |
nicklas |
259 |
|
1730 |
20 Dec 05 |
nicklas |
260 |
sc.setSessionSetting("plugin.configure.request", pcRequest); |
1875 |
01 Feb 06 |
nicklas |
261 |
sc.setSessionSetting("plugin.configure.job", null); |
1787 |
18 Jan 06 |
nicklas |
262 |
sc.setSessionSetting("plugin.configure.plugin", plugin); |
1773 |
16 Jan 06 |
nicklas |
263 |
sc.setSessionSetting("plugin.configure.config", pluginConfig); |
2270 |
17 May 06 |
nicklas |
264 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2270 |
17 May 06 |
nicklas |
265 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
4962 |
08 Jun 09 |
nicklas |
266 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
1730 |
20 Dec 05 |
nicklas |
267 |
} |
1730 |
20 Dec 05 |
nicklas |
268 |
|
1787 |
18 Jan 06 |
nicklas |
269 |
else if ("NewJob".equals(cmd)) |
1730 |
20 Dec 05 |
nicklas |
270 |
{ |
3559 |
16 Jul 07 |
nicklas |
271 |
if (warnIfOpen && anotherIsOpen) |
3559 |
16 Jul 07 |
nicklas |
272 |
{ |
3559 |
16 Jul 07 |
nicklas |
273 |
throw new DuplicateWizardException(); |
3559 |
16 Jul 07 |
nicklas |
274 |
} |
2738 |
17 Oct 06 |
nicklas |
275 |
String pluginClass = request.getParameter("plugin_class"); |
1730 |
20 Dec 05 |
nicklas |
276 |
int pluginDefinitionId = Values.getInt(request.getParameter("plugindefinition_id")); |
1730 |
20 Dec 05 |
nicklas |
277 |
int pluginConfigurationId = Values.getInt(request.getParameter("pluginconfiguration_id")); |
1789 |
18 Jan 06 |
nicklas |
278 |
Item itemType = Item.valueOf(request.getParameter("item_type")); |
1945 |
09 Feb 06 |
nicklas |
279 |
String subContext = Values.getString(request.getParameter("subcontext"), ""); |
2677 |
28 Sep 06 |
nicklas |
280 |
ItemContext currentContext = sc.getCurrentContext(itemType, subContext); |
1789 |
18 Jan 06 |
nicklas |
281 |
GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type")); |
2868 |
07 Nov 06 |
nicklas |
282 |
GuiContext context = new GuiContext(itemType, contextType, subContext); |
1730 |
20 Dec 05 |
nicklas |
283 |
|
7954 |
12 May 21 |
nicklas |
284 |
dc = sc.newDbControl(":Create job"); |
2738 |
17 Oct 06 |
nicklas |
285 |
PluginDefinition plugin = pluginClass == null ? |
2738 |
17 Oct 06 |
nicklas |
286 |
PluginDefinition.getById(dc, pluginDefinitionId) : PluginDefinition.getByClassName(dc, pluginClass); |
1730 |
20 Dec 05 |
nicklas |
287 |
PluginConfiguration pluginConfig = pluginConfigurationId == 0 ? null : PluginConfiguration.getById(dc, pluginConfigurationId); |
4254 |
28 Apr 08 |
nicklas |
288 |
Job job = Job.getNew(dc, plugin, pluginConfig, getCurrentExperiment(dc, context)); |
1787 |
18 Jan 06 |
nicklas |
289 |
String jobName = Values.getStringOrNull(request.getParameter("job_name")); |
1787 |
18 Jan 06 |
nicklas |
290 |
job.setName(jobName == null ? "Run plugin: " + plugin.getName() : jobName); |
1787 |
18 Jan 06 |
nicklas |
291 |
job.setDescription(request.getParameter("job_description")); |
1730 |
20 Dec 05 |
nicklas |
292 |
|
1789 |
18 Jan 06 |
nicklas |
293 |
PluginConfigurationRequest pcRequest = job.configure(context); |
1773 |
16 Jan 06 |
nicklas |
294 |
sc.setSessionSetting("plugin.configure.request", pcRequest); |
1773 |
16 Jan 06 |
nicklas |
295 |
sc.setSessionSetting("plugin.configure.job", job); |
1773 |
16 Jan 06 |
nicklas |
296 |
sc.setSessionSetting("plugin.configure.plugin", plugin); |
1773 |
16 Jan 06 |
nicklas |
297 |
sc.setSessionSetting("plugin.configure.config", pluginConfig); |
2270 |
17 May 06 |
nicklas |
298 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2270 |
17 May 06 |
nicklas |
299 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
2677 |
28 Sep 06 |
nicklas |
300 |
sc.setSessionSetting("plugin.configure.currentContext", currentContext); |
4962 |
08 Jun 09 |
nicklas |
301 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
1730 |
20 Dec 05 |
nicklas |
302 |
} |
1730 |
20 Dec 05 |
nicklas |
303 |
|
2745 |
18 Oct 06 |
nicklas |
304 |
else if ("CopyJob".equals(cmd)) |
2745 |
18 Oct 06 |
nicklas |
305 |
{ |
7954 |
12 May 21 |
nicklas |
306 |
dc = sc.newDbControl(":Copy job"); |
2745 |
18 Oct 06 |
nicklas |
307 |
int jobId = Values.getInt(request.getParameter("job_id")); |
2745 |
18 Oct 06 |
nicklas |
308 |
Job copyFrom = Job.getById(dc, jobId); |
2745 |
18 Oct 06 |
nicklas |
309 |
PluginDefinition plugin = copyFrom.getPluginDefinition(); |
2745 |
18 Oct 06 |
nicklas |
310 |
PluginConfiguration pluginConfig = copyFrom.getPluginConfiguration(); |
2745 |
18 Oct 06 |
nicklas |
311 |
|
2745 |
18 Oct 06 |
nicklas |
312 |
Item itemType = Item.valueOf(request.getParameter("item_type")); |
2745 |
18 Oct 06 |
nicklas |
313 |
String subContext = Values.getString(request.getParameter("subcontext"), ""); |
2745 |
18 Oct 06 |
nicklas |
314 |
ItemContext currentContext = sc.getCurrentContext(itemType, subContext); |
2745 |
18 Oct 06 |
nicklas |
315 |
GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type")); |
2868 |
07 Nov 06 |
nicklas |
316 |
GuiContext context = new GuiContext(itemType, contextType, subContext); |
4254 |
28 Apr 08 |
nicklas |
317 |
|
4254 |
28 Apr 08 |
nicklas |
318 |
Job job = Job.getNew(dc, plugin, pluginConfig, getCurrentExperiment(dc, context)); |
4254 |
28 Apr 08 |
nicklas |
319 |
job.copyParametersFrom(copyFrom); |
2745 |
18 Oct 06 |
nicklas |
320 |
|
2745 |
18 Oct 06 |
nicklas |
321 |
PluginConfigurationRequest pcRequest = job.configure(context); |
2745 |
18 Oct 06 |
nicklas |
322 |
sc.setSessionSetting("plugin.configure.request", pcRequest); |
2745 |
18 Oct 06 |
nicklas |
323 |
sc.setSessionSetting("plugin.configure.job", job); |
2745 |
18 Oct 06 |
nicklas |
324 |
sc.setSessionSetting("plugin.configure.plugin", plugin); |
2745 |
18 Oct 06 |
nicklas |
325 |
sc.setSessionSetting("plugin.configure.config", pluginConfig); |
2745 |
18 Oct 06 |
nicklas |
326 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2745 |
18 Oct 06 |
nicklas |
327 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
2745 |
18 Oct 06 |
nicklas |
328 |
sc.setSessionSetting("plugin.configure.currentContext", currentContext); |
4962 |
08 Jun 09 |
nicklas |
329 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
2745 |
18 Oct 06 |
nicklas |
330 |
} |
2745 |
18 Oct 06 |
nicklas |
331 |
|
2185 |
25 Apr 06 |
nicklas |
332 |
else if ("ConfigureJob".equals(cmd)) |
2185 |
25 Apr 06 |
nicklas |
333 |
{ |
7954 |
12 May 21 |
nicklas |
334 |
dc = sc.newDbControl(":Configure job"); |
2185 |
25 Apr 06 |
nicklas |
335 |
|
2185 |
25 Apr 06 |
nicklas |
336 |
int jobId = Values.getInt(request.getParameter("job_id")); |
2185 |
25 Apr 06 |
nicklas |
337 |
Job job = Job.getById(dc, jobId); |
2185 |
25 Apr 06 |
nicklas |
338 |
|
2185 |
25 Apr 06 |
nicklas |
339 |
//Item itemType = Item.valueOf(request.getParameter("item_type")); |
2185 |
25 Apr 06 |
nicklas |
340 |
//String subContext = Values.getString(request.getParameter("subcontext"), ""); |
2185 |
25 Apr 06 |
nicklas |
341 |
//GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type")); |
4379 |
05 Aug 08 |
nicklas |
342 |
GuiContext context = job.getLastGuiContext(); |
2185 |
25 Apr 06 |
nicklas |
343 |
|
2185 |
25 Apr 06 |
nicklas |
344 |
PluginDefinition plugin = job.getPluginDefinition(); |
2185 |
25 Apr 06 |
nicklas |
345 |
PluginConfiguration pluginConfig = job.getPluginConfiguration(); |
2185 |
25 Apr 06 |
nicklas |
346 |
|
4379 |
05 Aug 08 |
nicklas |
347 |
PluginConfigurationRequest pcRequest = job.configure(context); |
2185 |
25 Apr 06 |
nicklas |
348 |
sc.setSessionSetting("plugin.configure.request", pcRequest); |
2185 |
25 Apr 06 |
nicklas |
349 |
sc.setSessionSetting("plugin.configure.job", job); |
2185 |
25 Apr 06 |
nicklas |
350 |
sc.setSessionSetting("plugin.configure.plugin", plugin); |
2185 |
25 Apr 06 |
nicklas |
351 |
sc.setSessionSetting("plugin.configure.config", pluginConfig); |
2270 |
17 May 06 |
nicklas |
352 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2270 |
17 May 06 |
nicklas |
353 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
4962 |
08 Jun 09 |
nicklas |
354 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
2185 |
25 Apr 06 |
nicklas |
355 |
} |
2185 |
25 Apr 06 |
nicklas |
356 |
|
1730 |
20 Dec 05 |
nicklas |
357 |
else if ("SetParameters".equals(cmd)) |
1730 |
20 Dec 05 |
nicklas |
358 |
{ |
2677 |
28 Sep 06 |
nicklas |
359 |
int maxRecent = Base.getMaxRecent(sc); |
7605 |
26 Feb 19 |
nicklas |
360 |
PluginConfigurationRequest pcRequest = sc.getSessionSetting("plugin.configure.request"); |
3574 |
19 Jul 07 |
nicklas |
361 |
String requestId = request.getParameter("requestId"); |
3574 |
19 Jul 07 |
nicklas |
362 |
if (requestId != null && !requestId.equals(Integer.toString(System.identityHashCode(pcRequest)))) |
3518 |
20 Jun 07 |
nicklas |
363 |
{ |
3518 |
20 Jun 07 |
nicklas |
364 |
throw new WebException("popup", "Invalid request ID", "Data in your configuration wizard has become corrupted. Please re-start and try again."); |
3518 |
20 Jun 07 |
nicklas |
365 |
} |
1730 |
20 Dec 05 |
nicklas |
366 |
List<PluginParameter<?>> parameters = pcRequest.getRequestInformation().getParameters(); |
2942 |
22 Nov 06 |
nicklas |
367 |
List<Throwable> parseErrors = new LinkedList<Throwable>(); |
7605 |
26 Feb 19 |
nicklas |
368 |
ItemContext currentContext = sc.getSessionSetting("plugin.configure.currentContext"); |
2992 |
01 Dec 06 |
enell |
369 |
// Clear old errors |
2992 |
01 Dec 06 |
enell |
370 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2992 |
01 Dec 06 |
enell |
371 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
1875 |
01 Feb 06 |
nicklas |
372 |
if (parameters != null && parameters.size() > 0) |
1730 |
20 Dec 05 |
nicklas |
373 |
{ |
7954 |
12 May 21 |
nicklas |
374 |
dc = sc.newDbControl(":Set plug-in parameters"); |
1875 |
01 Feb 06 |
nicklas |
375 |
for (PluginParameter<?> param : parameters) |
1730 |
20 Dec 05 |
nicklas |
376 |
{ |
7604 |
25 Feb 19 |
nicklas |
377 |
ParameterType<?> pType = param.getParameterType(); |
1875 |
01 Feb 06 |
nicklas |
378 |
if (pType != null) |
1730 |
20 Dec 05 |
nicklas |
379 |
{ |
1875 |
01 Feb 06 |
nicklas |
380 |
String[] sValues = request.getParameterValues("parameter:"+param.getName()); |
4974 |
15 Jun 09 |
nicklas |
381 |
boolean emptyIsNull = Values.getBoolean(request.getParameter("parameter:" + param.getName() + ":emptyIsNull")); |
4974 |
15 Jun 09 |
nicklas |
382 |
if (emptyIsNull) |
4974 |
15 Jun 09 |
nicklas |
383 |
{ |
4974 |
15 Jun 09 |
nicklas |
384 |
for (int i = 0; i < sValues.length; ++i) |
4974 |
15 Jun 09 |
nicklas |
385 |
{ |
4974 |
15 Jun 09 |
nicklas |
386 |
if ("".equals(sValues[i])) sValues[i] = null; |
4974 |
15 Jun 09 |
nicklas |
387 |
} |
4974 |
15 Jun 09 |
nicklas |
388 |
} |
1875 |
01 Feb 06 |
nicklas |
389 |
Object[] oValues = null; |
2942 |
22 Nov 06 |
nicklas |
390 |
try |
1730 |
20 Dec 05 |
nicklas |
391 |
{ |
2942 |
22 Nov 06 |
nicklas |
392 |
if (sValues != null) |
1759 |
12 Jan 06 |
nicklas |
393 |
{ |
2942 |
22 Nov 06 |
nicklas |
394 |
if (pType instanceof StringParameterType) |
1787 |
18 Jan 06 |
nicklas |
395 |
{ |
2942 |
22 Nov 06 |
nicklas |
396 |
oValues = sValues; |
2942 |
22 Nov 06 |
nicklas |
397 |
} |
2942 |
22 Nov 06 |
nicklas |
398 |
else if (pType instanceof IntegerParameterType) |
2942 |
22 Nov 06 |
nicklas |
399 |
{ |
2942 |
22 Nov 06 |
nicklas |
400 |
oValues = Values.getInt(sValues); |
2942 |
22 Nov 06 |
nicklas |
401 |
} |
2942 |
22 Nov 06 |
nicklas |
402 |
else if (pType instanceof LongParameterType) |
2942 |
22 Nov 06 |
nicklas |
403 |
{ |
2942 |
22 Nov 06 |
nicklas |
404 |
oValues = Values.getLong(sValues); |
2942 |
22 Nov 06 |
nicklas |
405 |
} |
2942 |
22 Nov 06 |
nicklas |
406 |
else if (pType instanceof FloatParameterType) |
2942 |
22 Nov 06 |
nicklas |
407 |
{ |
2942 |
22 Nov 06 |
nicklas |
408 |
oValues = Values.getFloat(sValues); |
2942 |
22 Nov 06 |
nicklas |
409 |
} |
2942 |
22 Nov 06 |
nicklas |
410 |
else if (pType instanceof DoubleParameterType) |
2942 |
22 Nov 06 |
nicklas |
411 |
{ |
2942 |
22 Nov 06 |
nicklas |
412 |
oValues = Values.getDouble(sValues); |
2942 |
22 Nov 06 |
nicklas |
413 |
} |
2942 |
22 Nov 06 |
nicklas |
414 |
else if (pType instanceof BooleanParameterType) |
2942 |
22 Nov 06 |
nicklas |
415 |
{ |
2942 |
22 Nov 06 |
nicklas |
416 |
oValues = Type.BOOLEAN.parseStrings(sValues); |
2942 |
22 Nov 06 |
nicklas |
417 |
} |
2942 |
22 Nov 06 |
nicklas |
418 |
else if (pType instanceof DateParameterType) |
2942 |
22 Nov 06 |
nicklas |
419 |
{ |
2942 |
22 Nov 06 |
nicklas |
420 |
oValues = Values.getDate(sValues, FormatterFactory.getDateFormatter(sc)); |
2942 |
22 Nov 06 |
nicklas |
421 |
} |
5437 |
01 Oct 10 |
nicklas |
422 |
else if (pType instanceof TimestampParameterType) |
5437 |
01 Oct 10 |
nicklas |
423 |
{ |
5437 |
01 Oct 10 |
nicklas |
424 |
oValues = Values.getDate(sValues, FormatterFactory.getDateTimeFormatter(sc)); |
5437 |
01 Oct 10 |
nicklas |
425 |
} |
2942 |
22 Nov 06 |
nicklas |
426 |
else if (pType instanceof ItemParameterType) |
2942 |
22 Nov 06 |
nicklas |
427 |
{ |
2942 |
22 Nov 06 |
nicklas |
428 |
Integer[] itemId = Values.getInt(sValues); |
2942 |
22 Nov 06 |
nicklas |
429 |
oValues = new Object[itemId.length]; |
7606 |
27 Feb 19 |
nicklas |
430 |
Item iType = Item.fromClass((Class)pType.getParameterClass()); |
2942 |
22 Nov 06 |
nicklas |
431 |
for (int i = 0; i < itemId.length; ++i) |
1875 |
01 Feb 06 |
nicklas |
432 |
{ |
2942 |
22 Nov 06 |
nicklas |
433 |
Integer id = itemId[i]; |
2942 |
22 Nov 06 |
nicklas |
434 |
if (id != null && id != 0) |
2677 |
28 Sep 06 |
nicklas |
435 |
{ |
2942 |
22 Nov 06 |
nicklas |
436 |
BasicItem item = iType.getById(dc, id); |
2942 |
22 Nov 06 |
nicklas |
437 |
oValues[i] = item; |
2942 |
22 Nov 06 |
nicklas |
438 |
if (currentContext != null) |
2942 |
22 Nov 06 |
nicklas |
439 |
{ |
7703 |
11 Apr 19 |
nicklas |
440 |
currentContext.setRecent(iType, item, maxRecent); |
2942 |
22 Nov 06 |
nicklas |
441 |
} |
2677 |
28 Sep 06 |
nicklas |
442 |
} |
1875 |
01 Feb 06 |
nicklas |
443 |
} |
1787 |
18 Jan 06 |
nicklas |
444 |
} |
2942 |
22 Nov 06 |
nicklas |
445 |
else if (pType instanceof FileParameterType) |
1875 |
01 Feb 06 |
nicklas |
446 |
{ |
2942 |
22 Nov 06 |
nicklas |
447 |
oValues = new Object[sValues.length]; |
2942 |
22 Nov 06 |
nicklas |
448 |
for (int i = 0; i < sValues.length; ++i) |
2677 |
28 Sep 06 |
nicklas |
449 |
{ |
2942 |
22 Nov 06 |
nicklas |
450 |
File file = File.getByPath(dc, new Path(sValues[i], Path.Type.FILE), false); |
2942 |
22 Nov 06 |
nicklas |
451 |
oValues[i] = file; |
2942 |
22 Nov 06 |
nicklas |
452 |
if (currentContext != null) |
2942 |
22 Nov 06 |
nicklas |
453 |
{ |
7703 |
11 Apr 19 |
nicklas |
454 |
currentContext.setRecent(Item.FILE, file, maxRecent); |
2942 |
22 Nov 06 |
nicklas |
455 |
} |
2677 |
28 Sep 06 |
nicklas |
456 |
} |
1875 |
01 Feb 06 |
nicklas |
457 |
} |
2942 |
22 Nov 06 |
nicklas |
458 |
else if (pType instanceof PathParameterType) |
2942 |
22 Nov 06 |
nicklas |
459 |
{ |
2942 |
22 Nov 06 |
nicklas |
460 |
oValues = sValues; |
2942 |
22 Nov 06 |
nicklas |
461 |
} |
1787 |
18 Jan 06 |
nicklas |
462 |
} |
1759 |
12 Jan 06 |
nicklas |
463 |
} |
2942 |
22 Nov 06 |
nicklas |
464 |
catch (Throwable t) |
2942 |
22 Nov 06 |
nicklas |
465 |
{ |
2942 |
22 Nov 06 |
nicklas |
466 |
parseErrors.add(t); |
2942 |
22 Nov 06 |
nicklas |
467 |
} |
1875 |
01 Feb 06 |
nicklas |
468 |
pcRequest.setParameterValues(param.getName(), oValues == null ? null : Arrays.asList(oValues)); |
1730 |
20 Dec 05 |
nicklas |
469 |
} |
1730 |
20 Dec 05 |
nicklas |
470 |
} |
7954 |
12 May 21 |
nicklas |
471 |
dc.close(); |
1730 |
20 Dec 05 |
nicklas |
472 |
} |
2942 |
22 Nov 06 |
nicklas |
473 |
PluginResponse pluginResponse = null; |
2942 |
22 Nov 06 |
nicklas |
474 |
Response.Status status = null; |
2942 |
22 Nov 06 |
nicklas |
475 |
if (parseErrors.size() == 0) |
2942 |
22 Nov 06 |
nicklas |
476 |
{ |
2942 |
22 Nov 06 |
nicklas |
477 |
pluginResponse = pcRequest.invoke(); |
2942 |
22 Nov 06 |
nicklas |
478 |
status = pluginResponse.getStatus(); |
2942 |
22 Nov 06 |
nicklas |
479 |
} |
2942 |
22 Nov 06 |
nicklas |
480 |
else |
2942 |
22 Nov 06 |
nicklas |
481 |
{ |
2942 |
22 Nov 06 |
nicklas |
482 |
status = Response.Status.ERROR; |
2942 |
22 Nov 06 |
nicklas |
483 |
} |
2854 |
02 Nov 06 |
nicklas |
484 |
if (status == Response.Status.DONE || status == Response.Status.EXECUTE_IMMEDIATELY) |
1730 |
20 Dec 05 |
nicklas |
485 |
{ |
7605 |
26 Feb 19 |
nicklas |
486 |
Job job = sc.getSessionSetting("plugin.configure.job"); |
1759 |
12 Jan 06 |
nicklas |
487 |
if (job != null) |
1759 |
12 Jan 06 |
nicklas |
488 |
{ |
5480 |
08 Nov 10 |
nicklas |
489 |
String suggestedJobName = pluginResponse.getSuggestedJobName(); |
5480 |
08 Nov 10 |
nicklas |
490 |
if (suggestedJobName != null) job.setName(StringUtil.trimString(suggestedJobName, Job.MAX_NAME_LENGTH)); |
2643 |
15 Sep 06 |
nicklas |
491 |
sc.setSessionSetting("plugin.configure.response", pluginResponse); |
2643 |
15 Sep 06 |
nicklas |
492 |
forward = "finish_job.jsp"; |
1759 |
12 Jan 06 |
nicklas |
493 |
} |
1773 |
16 Jan 06 |
nicklas |
494 |
else |
1773 |
16 Jan 06 |
nicklas |
495 |
{ |
7954 |
12 May 21 |
nicklas |
496 |
dc = sc.newDbControl(":Save plug-in parameters"); |
2655 |
22 Sep 06 |
nicklas |
497 |
pluginResponse.saveParameters(dc); |
2655 |
22 Sep 06 |
nicklas |
498 |
dc.commit(); |
2655 |
22 Sep 06 |
nicklas |
499 |
sc.setSessionSetting("plugin.configure.request", null); |
2655 |
22 Sep 06 |
nicklas |
500 |
sc.setSessionSetting("plugin.configure.plugin", null); |
2655 |
22 Sep 06 |
nicklas |
501 |
sc.setSessionSetting("plugin.configure.config", null); |
2677 |
28 Sep 06 |
nicklas |
502 |
sc.setSessionSetting("plugin.configure.currentContext", null); |
1773 |
16 Jan 06 |
nicklas |
503 |
message = "Plugin configured"; |
1773 |
16 Jan 06 |
nicklas |
504 |
} |
1730 |
20 Dec 05 |
nicklas |
505 |
} |
1730 |
20 Dec 05 |
nicklas |
506 |
else if (status == Response.Status.CONTINUE) |
1730 |
20 Dec 05 |
nicklas |
507 |
{ |
1730 |
20 Dec 05 |
nicklas |
508 |
pcRequest = pluginResponse.getNextRequest(); |
1730 |
20 Dec 05 |
nicklas |
509 |
sc.setSessionSetting("plugin.configure.request", pcRequest); |
7605 |
26 Feb 19 |
nicklas |
510 |
PluginDefinition plugin = sc.getSessionSetting("plugin.configure.plugin"); |
4962 |
08 Jun 09 |
nicklas |
511 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
1730 |
20 Dec 05 |
nicklas |
512 |
} |
1730 |
20 Dec 05 |
nicklas |
513 |
else if (status == Response.Status.ERROR) |
1730 |
20 Dec 05 |
nicklas |
514 |
{ |
7605 |
26 Feb 19 |
nicklas |
515 |
PluginDefinition plugin = sc.getSessionSetting("plugin.configure.plugin"); |
2942 |
22 Nov 06 |
nicklas |
516 |
if (parseErrors.size() > 0) |
2942 |
22 Nov 06 |
nicklas |
517 |
{ |
2942 |
22 Nov 06 |
nicklas |
518 |
sc.setSessionSetting("plugin.configure.errors.message", |
2942 |
22 Nov 06 |
nicklas |
519 |
parseErrors.size() + " parameter value(s) are invalid"); |
2942 |
22 Nov 06 |
nicklas |
520 |
sc.setSessionSetting("plugin.configure.errors.list", parseErrors); |
2942 |
22 Nov 06 |
nicklas |
521 |
} |
2942 |
22 Nov 06 |
nicklas |
522 |
else |
2942 |
22 Nov 06 |
nicklas |
523 |
{ |
2942 |
22 Nov 06 |
nicklas |
524 |
sc.setSessionSetting("plugin.configure.errors.message", pluginResponse.getMessage()); |
2942 |
22 Nov 06 |
nicklas |
525 |
sc.setSessionSetting("plugin.configure.errors.list", pluginResponse.getErrorList()); |
2942 |
22 Nov 06 |
nicklas |
526 |
} |
4962 |
08 Jun 09 |
nicklas |
527 |
forward = getJspPage(pcRequest, plugin, "configure.jsp", root); |
1730 |
20 Dec 05 |
nicklas |
528 |
} |
2854 |
02 Nov 06 |
nicklas |
529 |
else if (status == Response.Status.DOWNLOAD_IMMEDIATELY) |
2854 |
02 Nov 06 |
nicklas |
530 |
{ |
2854 |
02 Nov 06 |
nicklas |
531 |
sc.setSessionSetting("plugin.configure.response", pluginResponse); |
2854 |
02 Nov 06 |
nicklas |
532 |
forward = "download_immediately.jsp"; |
2854 |
02 Nov 06 |
nicklas |
533 |
} |
2854 |
02 Nov 06 |
nicklas |
534 |
else |
2854 |
02 Nov 06 |
nicklas |
535 |
{ |
2854 |
02 Nov 06 |
nicklas |
536 |
throw new WebException("popup", "Unknown response from plugin", status.toString()); |
2854 |
02 Nov 06 |
nicklas |
537 |
} |
1730 |
20 Dec 05 |
nicklas |
538 |
} |
2643 |
15 Sep 06 |
nicklas |
539 |
else if ("FinishNewJob".equals(cmd)) |
2643 |
15 Sep 06 |
nicklas |
540 |
{ |
7954 |
12 May 21 |
nicklas |
541 |
dc = sc.newDbControl(":Save job"); |
7605 |
26 Feb 19 |
nicklas |
542 |
Job job = sc.getSessionSetting("plugin.configure.job"); |
4379 |
05 Aug 08 |
nicklas |
543 |
if (job.isInDatabase()) |
4379 |
05 Aug 08 |
nicklas |
544 |
{ |
5060 |
19 Aug 09 |
nicklas |
545 |
dc.reattachItem(job, false); |
4379 |
05 Aug 08 |
nicklas |
546 |
} |
4379 |
05 Aug 08 |
nicklas |
547 |
else |
4379 |
05 Aug 08 |
nicklas |
548 |
{ |
4379 |
05 Aug 08 |
nicklas |
549 |
dc.saveItem(job); |
4379 |
05 Aug 08 |
nicklas |
550 |
} |
4379 |
05 Aug 08 |
nicklas |
551 |
|
7605 |
26 Feb 19 |
nicklas |
552 |
PluginResponse pluginResponse = sc.getSessionSetting("plugin.configure.response"); |
4311 |
23 May 08 |
nicklas |
553 |
boolean executeImmediately = |
4311 |
23 May 08 |
nicklas |
554 |
pluginResponse != null && pluginResponse.getStatus() == Response.Status.EXECUTE_IMMEDIATELY; |
2643 |
15 Sep 06 |
nicklas |
555 |
|
2643 |
15 Sep 06 |
nicklas |
556 |
job.setName(Values.getStringOrNull(request.getParameter("name"))); |
2643 |
15 Sep 06 |
nicklas |
557 |
job.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
2643 |
15 Sep 06 |
nicklas |
558 |
job.setSendMessage(Values.getBoolean(request.getParameter("send_message"))); |
3480 |
13 Jun 07 |
martin |
559 |
job.setRemoveJobWhenFinished(Values.getBoolean(request.getParameter("remove_job"))); |
7317 |
03 Apr 17 |
nicklas |
560 |
if (!Values.getBoolean(request.getParameter("resume_from_breakpoint"))) |
7317 |
03 Apr 17 |
nicklas |
561 |
{ |
7317 |
03 Apr 17 |
nicklas |
562 |
job.clearExecuteCommand(); |
7317 |
03 Apr 17 |
nicklas |
563 |
} |
4311 |
23 May 08 |
nicklas |
564 |
if (!executeImmediately) |
4311 |
23 May 08 |
nicklas |
565 |
{ |
4311 |
23 May 08 |
nicklas |
566 |
int agentId = Values.getInt(request.getParameter("agent_id"), -1); |
4311 |
23 May 08 |
nicklas |
567 |
if (agentId >= 0) |
4311 |
23 May 08 |
nicklas |
568 |
{ |
4311 |
23 May 08 |
nicklas |
569 |
job.setJobAgent(agentId == 0 ? null : JobAgent.getById(dc, agentId)); |
4311 |
23 May 08 |
nicklas |
570 |
} |
4311 |
23 May 08 |
nicklas |
571 |
} |
4311 |
23 May 08 |
nicklas |
572 |
|
2673 |
28 Sep 06 |
nicklas |
573 |
if (pluginResponse != null) pluginResponse.saveParameters(dc); |
2643 |
15 Sep 06 |
nicklas |
574 |
dc.commit(); |
2643 |
15 Sep 06 |
nicklas |
575 |
redirect = "../../views/jobs/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+job.getId(); |
2643 |
15 Sep 06 |
nicklas |
576 |
sc.setSessionSetting("plugin.configure.job", null); |
2643 |
15 Sep 06 |
nicklas |
577 |
sc.setSessionSetting("plugin.configure.request", null); |
2643 |
15 Sep 06 |
nicklas |
578 |
sc.setSessionSetting("plugin.configure.response", null); |
2643 |
15 Sep 06 |
nicklas |
579 |
sc.setSessionSetting("plugin.configure.plugin", null); |
2643 |
15 Sep 06 |
nicklas |
580 |
sc.setSessionSetting("plugin.configure.config", null); |
2677 |
28 Sep 06 |
nicklas |
581 |
sc.setSessionSetting("plugin.configure.currentContext", null); |
4311 |
23 May 08 |
nicklas |
582 |
if (executeImmediately) |
2854 |
02 Nov 06 |
nicklas |
583 |
{ |
2854 |
02 Nov 06 |
nicklas |
584 |
PluginExecutionRequest executionRequest = pluginResponse.getExecutionRequest(null); |
4265 |
05 May 08 |
nicklas |
585 |
executionRequest.registerSignalReceiver(InternalJobQueue.getSignalReceiver()); |
4253 |
28 Apr 08 |
nicklas |
586 |
Thread t = new Thread(executionRequest); |
2854 |
02 Nov 06 |
nicklas |
587 |
t.setPriority(Thread.currentThread().getPriority() - 1); |
2854 |
02 Nov 06 |
nicklas |
588 |
t.start(); |
2854 |
02 Nov 06 |
nicklas |
589 |
} |
2643 |
15 Sep 06 |
nicklas |
590 |
} |
2854 |
02 Nov 06 |
nicklas |
591 |
else if ("ExportImmediately".equals(cmd)) |
2854 |
02 Nov 06 |
nicklas |
592 |
{ |
6319 |
09 Sep 13 |
nicklas |
593 |
out.clearBuffer(); |
7605 |
26 Feb 19 |
nicklas |
594 |
PluginResponse pluginResponse = sc.getSessionSetting("plugin.configure.response"); |
2854 |
02 Nov 06 |
nicklas |
595 |
ExportOutputStream exportStream = new ServletExportOutputStream(response); |
4330 |
10 Jun 08 |
martin |
596 |
SimpleSignalProgressReporter progress = new SimpleSignalProgressReporter(null); |
4327 |
03 Jun 08 |
martin |
597 |
sc.setSessionSetting("plugin.configure.progress.reporter", progress); |
2942 |
22 Nov 06 |
nicklas |
598 |
try |
2942 |
22 Nov 06 |
nicklas |
599 |
{ |
4327 |
03 Jun 08 |
martin |
600 |
pluginResponse.downloadImmediately(exportStream, progress); |
2942 |
22 Nov 06 |
nicklas |
601 |
} |
2942 |
22 Nov 06 |
nicklas |
602 |
catch (Throwable t) |
2942 |
22 Nov 06 |
nicklas |
603 |
{ |
2942 |
22 Nov 06 |
nicklas |
604 |
PrintWriter pw = new PrintWriter(exportStream, true); |
2942 |
22 Nov 06 |
nicklas |
605 |
t.printStackTrace(pw); |
2942 |
22 Nov 06 |
nicklas |
606 |
pw.flush(); |
2942 |
22 Nov 06 |
nicklas |
607 |
pw.close(); |
2942 |
22 Nov 06 |
nicklas |
608 |
} |
2860 |
03 Nov 06 |
nicklas |
609 |
exportStream.flush(); |
2860 |
03 Nov 06 |
nicklas |
610 |
exportStream.close(); |
2854 |
02 Nov 06 |
nicklas |
611 |
sc.setSessionSetting("plugin.configure.job", null); |
2854 |
02 Nov 06 |
nicklas |
612 |
sc.setSessionSetting("plugin.configure.request", null); |
2854 |
02 Nov 06 |
nicklas |
613 |
sc.setSessionSetting("plugin.configure.response", null); |
2854 |
02 Nov 06 |
nicklas |
614 |
sc.setSessionSetting("plugin.configure.plugin", null); |
2854 |
02 Nov 06 |
nicklas |
615 |
sc.setSessionSetting("plugin.configure.config", null); |
2854 |
02 Nov 06 |
nicklas |
616 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
2854 |
02 Nov 06 |
nicklas |
617 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
2854 |
02 Nov 06 |
nicklas |
618 |
sc.setSessionSetting("plugin.configure.currentContext", null); |
2860 |
03 Nov 06 |
nicklas |
619 |
return; |
2854 |
02 Nov 06 |
nicklas |
620 |
} |
3518 |
20 Jun 07 |
nicklas |
621 |
else if ("CancelWizard".equals(cmd)) |
3518 |
20 Jun 07 |
nicklas |
622 |
{ |
7605 |
26 Feb 19 |
nicklas |
623 |
PluginConfigurationRequest pcRequest = sc.setSessionSetting("plugin.configure.request", null); |
7605 |
26 Feb 19 |
nicklas |
624 |
SimpleSignalProgressReporter progress = sc.getSessionSetting("plugin.configure.progress.reporter"); |
5590 |
16 Mar 11 |
nicklas |
625 |
if (progress != null) progress.sendToAll(new SimpleSignalSender(Signal.ABORT)); |
3518 |
20 Jun 07 |
nicklas |
626 |
if (pcRequest != null) pcRequest.done(); |
3518 |
20 Jun 07 |
nicklas |
627 |
sc.setSessionSetting("plugin.configure.response", null); |
3518 |
20 Jun 07 |
nicklas |
628 |
sc.setSessionSetting("plugin.configure.plugin", null); |
3518 |
20 Jun 07 |
nicklas |
629 |
sc.setSessionSetting("plugin.configure.config", null); |
3518 |
20 Jun 07 |
nicklas |
630 |
sc.setSessionSetting("plugin.configure.job", null); |
3518 |
20 Jun 07 |
nicklas |
631 |
sc.setSessionSetting("plugin.configure.errors.message", null); |
3518 |
20 Jun 07 |
nicklas |
632 |
sc.setSessionSetting("plugin.configure.errors.list", null); |
4342 |
17 Jun 08 |
martin |
633 |
sc.setSessionSetting("plugin.configure.currentContext", null); |
4343 |
17 Jun 08 |
martin |
634 |
sc.setSessionSetting("plugin.configure.progress.reporter", null); |
3518 |
20 Jun 07 |
nicklas |
635 |
redirect = root + "common/close_popup.jsp?refresh_opener=0&wait=0"; |
3518 |
20 Jun 07 |
nicklas |
636 |
} |
1787 |
18 Jan 06 |
nicklas |
637 |
else |
1787 |
18 Jan 06 |
nicklas |
638 |
{ |
1787 |
18 Jan 06 |
nicklas |
639 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1787 |
18 Jan 06 |
nicklas |
640 |
} |
1730 |
20 Dec 05 |
nicklas |
641 |
} |
1730 |
20 Dec 05 |
nicklas |
642 |
finally |
1730 |
20 Dec 05 |
nicklas |
643 |
{ |
1730 |
20 Dec 05 |
nicklas |
644 |
if (dc != null) dc.close(); |
1730 |
20 Dec 05 |
nicklas |
645 |
} |
1730 |
20 Dec 05 |
nicklas |
646 |
|
1730 |
20 Dec 05 |
nicklas |
647 |
if (forward != null) |
1730 |
20 Dec 05 |
nicklas |
648 |
{ |
6192 |
31 Oct 12 |
nicklas |
649 |
sc.setSessionSetting("alert-message", message); |
1730 |
20 Dec 05 |
nicklas |
650 |
pageContext.forward(forward); |
1730 |
20 Dec 05 |
nicklas |
651 |
} |
1730 |
20 Dec 05 |
nicklas |
652 |
else if (redirect != null) |
1730 |
20 Dec 05 |
nicklas |
653 |
{ |
6192 |
31 Oct 12 |
nicklas |
654 |
sc.setSessionSetting("alert-message", message); |
1730 |
20 Dec 05 |
nicklas |
655 |
response.sendRedirect(redirect); |
1730 |
20 Dec 05 |
nicklas |
656 |
} |
1730 |
20 Dec 05 |
nicklas |
657 |
else if (message == null) |
1730 |
20 Dec 05 |
nicklas |
658 |
{ |
1730 |
20 Dec 05 |
nicklas |
659 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1730 |
20 Dec 05 |
nicklas |
660 |
} |
1730 |
20 Dec 05 |
nicklas |
661 |
else |
1730 |
20 Dec 05 |
nicklas |
662 |
{ |
1730 |
20 Dec 05 |
nicklas |
663 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1730 |
20 Dec 05 |
nicklas |
664 |
} |
4253 |
28 Apr 08 |
nicklas |
665 |
%> |