1713 |
14 Dec 05 |
nicklas |
1 |
<%-- $Id$ |
1713 |
14 Dec 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 |
1713 |
14 Dec 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/ |
1713 |
14 Dec 05 |
nicklas |
8 |
|
1713 |
14 Dec 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
1713 |
14 Dec 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 |
1713 |
14 Dec 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
1713 |
14 Dec 05 |
nicklas |
13 |
|
1713 |
14 Dec 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
1713 |
14 Dec 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1713 |
14 Dec 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1713 |
14 Dec 05 |
nicklas |
17 |
GNU General Public License for more details. |
1713 |
14 Dec 05 |
nicklas |
18 |
|
1713 |
14 Dec 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/>. |
1713 |
14 Dec 05 |
nicklas |
21 |
------------------------------------------------------------------ |
1713 |
14 Dec 05 |
nicklas |
22 |
|
1713 |
14 Dec 05 |
nicklas |
23 |
@author Nicklas |
1713 |
14 Dec 05 |
nicklas |
24 |
@version 2.0 |
1713 |
14 Dec 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
1713 |
14 Dec 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
1713 |
14 Dec 05 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
1713 |
14 Dec 05 |
nicklas |
29 |
import="net.sf.basedb.core.ItemContext" |
1933 |
07 Feb 06 |
nicklas |
30 |
import="net.sf.basedb.core.PermissionDeniedException" |
1713 |
14 Dec 05 |
nicklas |
31 |
import="net.sf.basedb.clients.web.Base" |
1749 |
10 Jan 06 |
nicklas |
32 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
33 |
import="net.sf.basedb.util.Values" |
1713 |
14 Dec 05 |
nicklas |
34 |
import="net.sf.basedb.clients.web.util.HTML" |
1933 |
07 Feb 06 |
nicklas |
35 |
import="java.util.Enumeration" |
1713 |
14 Dec 05 |
nicklas |
36 |
%> |
1713 |
14 Dec 05 |
nicklas |
37 |
<% |
1713 |
14 Dec 05 |
nicklas |
38 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1713 |
14 Dec 05 |
nicklas |
39 |
final String ID = sc.getId(); |
1713 |
14 Dec 05 |
nicklas |
40 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
1933 |
07 Feb 06 |
nicklas |
41 |
final String subContext = request.getParameter("subcontext"); |
1713 |
14 Dec 05 |
nicklas |
42 |
final String cmd = request.getParameter("cmd"); |
1713 |
14 Dec 05 |
nicklas |
43 |
final String root = request.getContextPath()+"/"; |
1713 |
14 Dec 05 |
nicklas |
44 |
|
1713 |
14 Dec 05 |
nicklas |
45 |
String forward = null; |
1713 |
14 Dec 05 |
nicklas |
46 |
String redirect = null; |
1713 |
14 Dec 05 |
nicklas |
47 |
String message = null; |
1713 |
14 Dec 05 |
nicklas |
48 |
|
1713 |
14 Dec 05 |
nicklas |
49 |
if ("SaveCurrentContext".equals(cmd)) |
1713 |
14 Dec 05 |
nicklas |
50 |
{ |
1713 |
14 Dec 05 |
nicklas |
51 |
String name = Values.getStringOrNull(request.getParameter("name")); |
1713 |
14 Dec 05 |
nicklas |
52 |
boolean overwrite = Values.getBoolean(request.getParameter("overwrite")); |
1726 |
19 Dec 05 |
nicklas |
53 |
boolean isPublic = Values.getBoolean(request.getParameter("public")); |
1933 |
07 Feb 06 |
nicklas |
54 |
sc.saveCurrentContextAs(itemType, subContext, name, overwrite, isPublic); |
1713 |
14 Dec 05 |
nicklas |
55 |
message = "Preset saved"; |
1713 |
14 Dec 05 |
nicklas |
56 |
} |
1744 |
09 Jan 06 |
nicklas |
57 |
else if ("DeleteContext".equals(cmd)) |
1744 |
09 Jan 06 |
nicklas |
58 |
{ |
1933 |
07 Feb 06 |
nicklas |
59 |
int contextId = Values.getInt(request.getParameter("context_id")); |
1933 |
07 Feb 06 |
nicklas |
60 |
sc.deleteContext(contextId); |
1933 |
07 Feb 06 |
nicklas |
61 |
redirect = "manage.jsp?ID=" + ID + "&item_type="+itemType.name()+"&subcontext="+subContext; |
1744 |
09 Jan 06 |
nicklas |
62 |
} |
1749 |
10 Jan 06 |
nicklas |
63 |
else if ("DeleteContexts".equals(cmd)) |
1749 |
10 Jan 06 |
nicklas |
64 |
{ |
1933 |
07 Feb 06 |
nicklas |
65 |
int numRemoved = 0; |
1933 |
07 Feb 06 |
nicklas |
66 |
int numTotal = 0; |
1933 |
07 Feb 06 |
nicklas |
67 |
Enumeration<String> names = request.getParameterNames(); |
1933 |
07 Feb 06 |
nicklas |
68 |
while (names.hasMoreElements()) |
1933 |
07 Feb 06 |
nicklas |
69 |
{ |
1933 |
07 Feb 06 |
nicklas |
70 |
int id = Values.getInt(names.nextElement(), -1); |
1933 |
07 Feb 06 |
nicklas |
71 |
if (id != -1) |
1933 |
07 Feb 06 |
nicklas |
72 |
{ |
1933 |
07 Feb 06 |
nicklas |
73 |
try |
1933 |
07 Feb 06 |
nicklas |
74 |
{ |
1933 |
07 Feb 06 |
nicklas |
75 |
numTotal++; |
1933 |
07 Feb 06 |
nicklas |
76 |
sc.deleteContext(id); |
1933 |
07 Feb 06 |
nicklas |
77 |
numRemoved++; |
1933 |
07 Feb 06 |
nicklas |
78 |
} |
1933 |
07 Feb 06 |
nicklas |
79 |
catch (PermissionDeniedException ex) |
1933 |
07 Feb 06 |
nicklas |
80 |
{} |
1933 |
07 Feb 06 |
nicklas |
81 |
} |
1933 |
07 Feb 06 |
nicklas |
82 |
} |
1933 |
07 Feb 06 |
nicklas |
83 |
if (numTotal != numRemoved) |
1933 |
07 Feb 06 |
nicklas |
84 |
{ |
1933 |
07 Feb 06 |
nicklas |
85 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1933 |
07 Feb 06 |
nicklas |
86 |
} |
6192 |
31 Oct 12 |
nicklas |
87 |
redirect = "manage.jsp?ID=" + ID + "&item_type="+itemType.name()+"&subcontext="+subContext; |
1749 |
10 Jan 06 |
nicklas |
88 |
} |
1744 |
09 Jan 06 |
nicklas |
89 |
else if ("LoadContext".equals(cmd)) |
1744 |
09 Jan 06 |
nicklas |
90 |
{ |
2003 |
16 Feb 06 |
nicklas |
91 |
final ItemContext current = sc.getCurrentContext(itemType, subContext); |
1744 |
09 Jan 06 |
nicklas |
92 |
int contextId = Values.getInt(request.getParameter("context_id")); |
1749 |
10 Jan 06 |
nicklas |
93 |
ItemContext newContext = sc.loadContext(contextId); |
1749 |
10 Jan 06 |
nicklas |
94 |
if (current != null && newContext != null) |
1749 |
10 Jan 06 |
nicklas |
95 |
{ |
1749 |
10 Jan 06 |
nicklas |
96 |
// Copy list of default columns so it is available in the loaded context |
1749 |
10 Jan 06 |
nicklas |
97 |
newContext.setObject("defaultColumns", current.getObject("defaultColumns")); |
1749 |
10 Jan 06 |
nicklas |
98 |
} |
1749 |
10 Jan 06 |
nicklas |
99 |
message = "Preset loaded"; |
1744 |
09 Jan 06 |
nicklas |
100 |
} |
1749 |
10 Jan 06 |
nicklas |
101 |
else |
1749 |
10 Jan 06 |
nicklas |
102 |
{ |
1749 |
10 Jan 06 |
nicklas |
103 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1749 |
10 Jan 06 |
nicklas |
104 |
} |
1713 |
14 Dec 05 |
nicklas |
105 |
|
1713 |
14 Dec 05 |
nicklas |
106 |
if (forward != null) |
1713 |
14 Dec 05 |
nicklas |
107 |
{ |
6192 |
31 Oct 12 |
nicklas |
108 |
sc.setSessionSetting("alert-message", message); |
1713 |
14 Dec 05 |
nicklas |
109 |
pageContext.forward(forward); |
1713 |
14 Dec 05 |
nicklas |
110 |
} |
1713 |
14 Dec 05 |
nicklas |
111 |
else if (redirect != null) |
1713 |
14 Dec 05 |
nicklas |
112 |
{ |
6192 |
31 Oct 12 |
nicklas |
113 |
sc.setSessionSetting("alert-message", message); |
1713 |
14 Dec 05 |
nicklas |
114 |
response.sendRedirect(redirect); |
1713 |
14 Dec 05 |
nicklas |
115 |
} |
1713 |
14 Dec 05 |
nicklas |
116 |
else if (message == null) |
1713 |
14 Dec 05 |
nicklas |
117 |
{ |
1713 |
14 Dec 05 |
nicklas |
118 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1713 |
14 Dec 05 |
nicklas |
119 |
} |
1713 |
14 Dec 05 |
nicklas |
120 |
else |
1713 |
14 Dec 05 |
nicklas |
121 |
{ |
1713 |
14 Dec 05 |
nicklas |
122 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1713 |
14 Dec 05 |
nicklas |
123 |
} |
1713 |
14 Dec 05 |
nicklas |
124 |
%> |