2927 |
16 Nov 06 |
nicklas |
1 |
<%-- $Id$ |
2927 |
16 Nov 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg |
2927 |
16 Nov 06 |
nicklas |
4 |
|
2927 |
16 Nov 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2927 |
16 Nov 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2927 |
16 Nov 06 |
nicklas |
7 |
|
2927 |
16 Nov 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2927 |
16 Nov 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2927 |
16 Nov 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2927 |
16 Nov 06 |
nicklas |
12 |
|
2927 |
16 Nov 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2927 |
16 Nov 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2927 |
16 Nov 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2927 |
16 Nov 06 |
nicklas |
16 |
GNU General Public License for more details. |
2927 |
16 Nov 06 |
nicklas |
17 |
|
2927 |
16 Nov 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2927 |
16 Nov 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2927 |
16 Nov 06 |
nicklas |
21 |
|
2927 |
16 Nov 06 |
nicklas |
22 |
@author Nicklas |
2927 |
16 Nov 06 |
nicklas |
23 |
@version 2.0 |
2927 |
16 Nov 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
2927 |
16 Nov 06 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
2927 |
16 Nov 06 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
2927 |
16 Nov 06 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
2927 |
16 Nov 06 |
nicklas |
29 |
import="net.sf.basedb.core.ItemContext" |
2927 |
16 Nov 06 |
nicklas |
30 |
import="net.sf.basedb.clients.web.Base" |
2927 |
16 Nov 06 |
nicklas |
31 |
import="net.sf.basedb.clients.web.WebException" |
2927 |
16 Nov 06 |
nicklas |
32 |
import="net.sf.basedb.clients.web.util.HTML" |
2927 |
16 Nov 06 |
nicklas |
33 |
import="net.sf.basedb.util.Values" |
2927 |
16 Nov 06 |
nicklas |
34 |
%> |
2927 |
16 Nov 06 |
nicklas |
35 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2927 |
16 Nov 06 |
nicklas |
36 |
<%! |
2927 |
16 Nov 06 |
nicklas |
37 |
private static final ItemContext defaultContext = |
2927 |
16 Nov 06 |
nicklas |
38 |
Base.createDefaultContext("name", "name,quota,diskUsage"); |
2927 |
16 Nov 06 |
nicklas |
39 |
private static final Item itemType = Item.DISKUSAGE; |
2927 |
16 Nov 06 |
nicklas |
40 |
%> |
2927 |
16 Nov 06 |
nicklas |
41 |
<% |
2927 |
16 Nov 06 |
nicklas |
42 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2927 |
16 Nov 06 |
nicklas |
43 |
final String ID = sc.getId(); |
2927 |
16 Nov 06 |
nicklas |
44 |
final String cmd = request.getParameter("cmd"); |
2927 |
16 Nov 06 |
nicklas |
45 |
final String root = request.getContextPath()+"/"; |
2927 |
16 Nov 06 |
nicklas |
46 |
String subContext = request.getParameter("subcontext"); |
2927 |
16 Nov 06 |
nicklas |
47 |
final String overviewPage = "overview.jsp?ID="+ID; |
2929 |
17 Nov 06 |
nicklas |
48 |
final String listUsersPage = "list_users.jsp?ID="+ID; |
2929 |
17 Nov 06 |
nicklas |
49 |
final String listGroupsPage = "list_groups.jsp?ID="+ID; |
2929 |
17 Nov 06 |
nicklas |
50 |
final String viewUserPage = "view_user.jsp?ID="+ID; |
2929 |
17 Nov 06 |
nicklas |
51 |
final String viewGroupPage = "view_group.jsp?ID="+ID; |
2927 |
16 Nov 06 |
nicklas |
52 |
|
2927 |
16 Nov 06 |
nicklas |
53 |
String forward = null; |
2927 |
16 Nov 06 |
nicklas |
54 |
String redirect = null; |
2927 |
16 Nov 06 |
nicklas |
55 |
String message = null; |
2927 |
16 Nov 06 |
nicklas |
56 |
DbControl dc = null; |
2927 |
16 Nov 06 |
nicklas |
57 |
|
2927 |
16 Nov 06 |
nicklas |
58 |
try |
2927 |
16 Nov 06 |
nicklas |
59 |
{ |
2927 |
16 Nov 06 |
nicklas |
60 |
if (cmd == null || "Overview".equals(cmd)) |
2927 |
16 Nov 06 |
nicklas |
61 |
{ |
2927 |
16 Nov 06 |
nicklas |
62 |
// Display the list page without updatinging the current context |
2927 |
16 Nov 06 |
nicklas |
63 |
Base.getAndSetCurrentContext(sc, itemType, null, null, true); |
2927 |
16 Nov 06 |
nicklas |
64 |
redirect = overviewPage; |
2927 |
16 Nov 06 |
nicklas |
65 |
} |
2929 |
17 Nov 06 |
nicklas |
66 |
else if ("ListUsers".equals(cmd)) |
2927 |
16 Nov 06 |
nicklas |
67 |
{ |
4276 |
08 May 08 |
nicklas |
68 |
Base.getAndSetCurrentContext(sc, itemType, "perUser", (PageContext)null, defaultContext, true); |
2929 |
17 Nov 06 |
nicklas |
69 |
redirect = listUsersPage; |
2927 |
16 Nov 06 |
nicklas |
70 |
} |
2929 |
17 Nov 06 |
nicklas |
71 |
else if ("ListGroups".equals(cmd)) |
2927 |
16 Nov 06 |
nicklas |
72 |
{ |
4276 |
08 May 08 |
nicklas |
73 |
Base.getAndSetCurrentContext(sc, itemType, "perGroup", (PageContext)null, defaultContext, true); |
2929 |
17 Nov 06 |
nicklas |
74 |
redirect = listGroupsPage; |
2927 |
16 Nov 06 |
nicklas |
75 |
} |
2927 |
16 Nov 06 |
nicklas |
76 |
else if ("UpdateContext".equals(cmd)) |
2927 |
16 Nov 06 |
nicklas |
77 |
{ |
2927 |
16 Nov 06 |
nicklas |
78 |
// Display the list page after updating the current context from the request parameters |
2927 |
16 Nov 06 |
nicklas |
79 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, pageContext, defaultContext); |
2927 |
16 Nov 06 |
nicklas |
80 |
String ss = request.getParameter("showStatistics"); |
2927 |
16 Nov 06 |
nicklas |
81 |
if (ss != null) cc.setSetting("showStatistics", ss); |
2929 |
17 Nov 06 |
nicklas |
82 |
redirect = "perUser".equals(subContext) ? listUsersPage : "perGroup".equals(subContext) ? listGroupsPage : overviewPage; |
2927 |
16 Nov 06 |
nicklas |
83 |
} |
2927 |
16 Nov 06 |
nicklas |
84 |
else if ("LoadContext".equals(cmd)) |
2927 |
16 Nov 06 |
nicklas |
85 |
{ |
2927 |
16 Nov 06 |
nicklas |
86 |
// Display the list page after loading a saved context |
2927 |
16 Nov 06 |
nicklas |
87 |
int contextId = Values.getInt(request.getParameter("context")); |
2927 |
16 Nov 06 |
nicklas |
88 |
Base.loadContext(sc, contextId, defaultContext); |
2929 |
17 Nov 06 |
nicklas |
89 |
redirect = "perUser".equals(subContext) ? listUsersPage : "perGroup".equals(subContext) ? listGroupsPage : overviewPage; |
2927 |
16 Nov 06 |
nicklas |
90 |
} |
2929 |
17 Nov 06 |
nicklas |
91 |
else if ("ViewUser".equals(cmd)) |
2929 |
17 Nov 06 |
nicklas |
92 |
{ |
2929 |
17 Nov 06 |
nicklas |
93 |
// Display the view page for a single item |
2929 |
17 Nov 06 |
nicklas |
94 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, "perUser", pageContext, defaultContext); |
2929 |
17 Nov 06 |
nicklas |
95 |
forward = viewUserPage; |
2929 |
17 Nov 06 |
nicklas |
96 |
} |
2929 |
17 Nov 06 |
nicklas |
97 |
else if ("ViewGroup".equals(cmd)) |
2929 |
17 Nov 06 |
nicklas |
98 |
{ |
2929 |
17 Nov 06 |
nicklas |
99 |
// Display the view page for a single item |
2929 |
17 Nov 06 |
nicklas |
100 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, "perGroup", pageContext, defaultContext); |
2929 |
17 Nov 06 |
nicklas |
101 |
forward = viewGroupPage; |
2929 |
17 Nov 06 |
nicklas |
102 |
} |
2927 |
16 Nov 06 |
nicklas |
103 |
else |
2927 |
16 Nov 06 |
nicklas |
104 |
{ |
2927 |
16 Nov 06 |
nicklas |
105 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2927 |
16 Nov 06 |
nicklas |
106 |
} |
2927 |
16 Nov 06 |
nicklas |
107 |
} |
2927 |
16 Nov 06 |
nicklas |
108 |
finally |
2927 |
16 Nov 06 |
nicklas |
109 |
{ |
2927 |
16 Nov 06 |
nicklas |
110 |
if (dc != null) dc.close(); |
2927 |
16 Nov 06 |
nicklas |
111 |
} |
2927 |
16 Nov 06 |
nicklas |
112 |
|
2927 |
16 Nov 06 |
nicklas |
113 |
if (forward != null) |
2927 |
16 Nov 06 |
nicklas |
114 |
{ |
6192 |
31 Oct 12 |
nicklas |
115 |
sc.setSessionSetting("alert-message", message); |
2927 |
16 Nov 06 |
nicklas |
116 |
pageContext.forward(forward); |
2927 |
16 Nov 06 |
nicklas |
117 |
} |
2927 |
16 Nov 06 |
nicklas |
118 |
else if (redirect != null) |
2927 |
16 Nov 06 |
nicklas |
119 |
{ |
6192 |
31 Oct 12 |
nicklas |
120 |
sc.setSessionSetting("alert-message", message); |
2927 |
16 Nov 06 |
nicklas |
121 |
response.sendRedirect(redirect); |
2927 |
16 Nov 06 |
nicklas |
122 |
} |
2927 |
16 Nov 06 |
nicklas |
123 |
else if (message == null) |
2927 |
16 Nov 06 |
nicklas |
124 |
{ |
2927 |
16 Nov 06 |
nicklas |
125 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2927 |
16 Nov 06 |
nicklas |
126 |
} |
2927 |
16 Nov 06 |
nicklas |
127 |
else |
2927 |
16 Nov 06 |
nicklas |
128 |
{ |
2927 |
16 Nov 06 |
nicklas |
129 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2927 |
16 Nov 06 |
nicklas |
130 |
} |
2927 |
16 Nov 06 |
nicklas |
131 |
%> |
2927 |
16 Nov 06 |
nicklas |
132 |
|