4563 |
07 Oct 08 |
martin |
1 |
<%-- $Id$ |
4563 |
07 Oct 08 |
martin |
2 |
------------------------------------------------------------------ |
4563 |
07 Oct 08 |
martin |
Copyright (C) 2008 Martin Svensson |
4563 |
07 Oct 08 |
martin |
4 |
|
4563 |
07 Oct 08 |
martin |
5 |
This file is part of BASE - BioArray Software Environment. |
4563 |
07 Oct 08 |
martin |
6 |
Available at http://base.thep.lu.se/ |
4563 |
07 Oct 08 |
martin |
7 |
|
4563 |
07 Oct 08 |
martin |
8 |
BASE is free software; you can redistribute it and/or |
4563 |
07 Oct 08 |
martin |
9 |
modify it under the terms of the GNU General Public License |
4563 |
07 Oct 08 |
martin |
10 |
as published by the Free Software Foundation; either version 3 |
4563 |
07 Oct 08 |
martin |
11 |
of the License, or (at your option) any later version. |
4563 |
07 Oct 08 |
martin |
12 |
|
4563 |
07 Oct 08 |
martin |
13 |
BASE is distributed in the hope that it will be useful, |
4563 |
07 Oct 08 |
martin |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4563 |
07 Oct 08 |
martin |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4563 |
07 Oct 08 |
martin |
16 |
GNU General Public License for more details. |
4563 |
07 Oct 08 |
martin |
17 |
|
4563 |
07 Oct 08 |
martin |
18 |
You should have received a copy of the GNU General Public License |
4563 |
07 Oct 08 |
martin |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4563 |
07 Oct 08 |
martin |
20 |
------------------------------------------------------------------ |
4563 |
07 Oct 08 |
martin |
21 |
|
4563 |
07 Oct 08 |
martin |
22 |
@author Martin |
4563 |
07 Oct 08 |
martin |
23 |
--%> |
5558 |
28 Jan 11 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" contentType="application/json" |
4563 |
07 Oct 08 |
martin |
25 |
import="net.sf.basedb.core.SessionControl" |
4563 |
07 Oct 08 |
martin |
26 |
import="net.sf.basedb.core.DbControl" |
4563 |
07 Oct 08 |
martin |
27 |
import="net.sf.basedb.core.ArraySlide" |
5558 |
28 Jan 11 |
nicklas |
28 |
import="net.sf.basedb.core.ArrayDesign" |
4563 |
07 Oct 08 |
martin |
29 |
import="net.sf.basedb.core.PermissionDeniedException" |
4563 |
07 Oct 08 |
martin |
30 |
import="net.sf.basedb.util.Values" |
5558 |
28 Jan 11 |
nicklas |
31 |
import="net.sf.basedb.util.error.ThrowableUtil" |
4563 |
07 Oct 08 |
martin |
32 |
import="net.sf.basedb.clients.web.Base" |
4563 |
07 Oct 08 |
martin |
33 |
import="net.sf.basedb.clients.web.WebException" |
5558 |
28 Jan 11 |
nicklas |
34 |
import="org.json.simple.JSONObject" |
4563 |
07 Oct 08 |
martin |
35 |
%> |
4563 |
07 Oct 08 |
martin |
36 |
<% |
6124 |
13 Sep 12 |
nicklas |
37 |
response.setHeader("Cache-Control", "no-cache, max-age=0"); |
4563 |
07 Oct 08 |
martin |
38 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4563 |
07 Oct 08 |
martin |
39 |
final String cmd = request.getParameter("cmd"); |
4563 |
07 Oct 08 |
martin |
40 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
4563 |
07 Oct 08 |
martin |
41 |
DbControl dc = null; |
5558 |
28 Jan 11 |
nicklas |
42 |
out.clear(); |
5558 |
28 Jan 11 |
nicklas |
43 |
JSONObject json = new JSONObject(); |
5558 |
28 Jan 11 |
nicklas |
44 |
json.put("status", "ok"); |
4563 |
07 Oct 08 |
martin |
45 |
try |
4563 |
07 Oct 08 |
martin |
46 |
{ |
5558 |
28 Jan 11 |
nicklas |
47 |
if ("GetArrayDesign".equals(cmd)) |
4563 |
07 Oct 08 |
martin |
48 |
{ |
7954 |
12 May 21 |
nicklas |
49 |
dc = sc.newDbControl(":Get array design"); |
4563 |
07 Oct 08 |
martin |
50 |
ArraySlide slide = ArraySlide.getById(dc, itemId); |
4563 |
07 Oct 08 |
martin |
51 |
try |
4563 |
07 Oct 08 |
martin |
52 |
{ |
5558 |
28 Jan 11 |
nicklas |
53 |
ArrayDesign d = slide.getArrayBatch().getArrayDesign(); |
5558 |
28 Jan 11 |
nicklas |
54 |
json.put("id", d.getId()); |
5558 |
28 Jan 11 |
nicklas |
55 |
json.put("name", d.getName()); |
5558 |
28 Jan 11 |
nicklas |
56 |
json.put("description", d.getDescription()); |
5558 |
28 Jan 11 |
nicklas |
57 |
json.put("numArrays", d.getNumArrays()); |
4563 |
07 Oct 08 |
martin |
58 |
} |
5558 |
28 Jan 11 |
nicklas |
59 |
catch (PermissionDeniedException pex) |
5558 |
28 Jan 11 |
nicklas |
60 |
{} |
4563 |
07 Oct 08 |
martin |
61 |
dc.close(); |
4563 |
07 Oct 08 |
martin |
62 |
} |
4563 |
07 Oct 08 |
martin |
63 |
else |
4563 |
07 Oct 08 |
martin |
64 |
{ |
4563 |
07 Oct 08 |
martin |
65 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
4563 |
07 Oct 08 |
martin |
66 |
} |
4563 |
07 Oct 08 |
martin |
67 |
} |
5558 |
28 Jan 11 |
nicklas |
68 |
catch (Throwable t) |
5558 |
28 Jan 11 |
nicklas |
69 |
{ |
5558 |
28 Jan 11 |
nicklas |
70 |
t.printStackTrace(); |
5558 |
28 Jan 11 |
nicklas |
71 |
json.clear(); |
5558 |
28 Jan 11 |
nicklas |
72 |
json.put("status", "error"); |
5558 |
28 Jan 11 |
nicklas |
73 |
json.put("message", t.getMessage()); |
5558 |
28 Jan 11 |
nicklas |
74 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
5558 |
28 Jan 11 |
nicklas |
75 |
} |
4563 |
07 Oct 08 |
martin |
76 |
finally |
4563 |
07 Oct 08 |
martin |
77 |
{ |
5558 |
28 Jan 11 |
nicklas |
78 |
json.writeJSONString(out); |
5558 |
28 Jan 11 |
nicklas |
79 |
out.flush(); |
4563 |
07 Oct 08 |
martin |
80 |
if (dc != null) dc.close(); |
4563 |
07 Oct 08 |
martin |
81 |
} |
4563 |
07 Oct 08 |
martin |
82 |
%> |