source: trunk/www/filemanager/index.jsp @ 4951

Last change on this file since 4951 was 4951, checked in by Nicklas Nordborg, 13 years ago

Merged patch release 2.11.1 to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 3.9 KB
Line 
1<%-- $Id: index.jsp 4951 2009-05-27 10:07:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.File"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.clients.web.Base"
32  import="net.sf.basedb.clients.web.WebException"
33  import="net.sf.basedb.util.Values"
34  import="net.sf.basedb.clients.web.util.HTML"
35%>
36<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
37<%!
38  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,size,fileType,description,actions");
39  private static final Item itemType = Item.FILE;
40%>
41<%
42final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
43final String ID = sc.getId();
44final String cmd = request.getParameter("cmd");
45final String root = request.getContextPath()+"/";
46
47String forward = null;
48String redirect = null;
49String message = null;
50DbControl dc = null;
51try
52{
53  if (cmd == null || "List".equals(cmd))
54  {
55    // Display the list page without updatinging the current context
56    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
57    forward = "manager.jsp";
58  }
59  else if ("UpdateContext".equals(cmd))
60  {
61    // Display the list page after updating the current context from the request parameters
62    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
63    forward = "manager.jsp";
64  }
65  else if ("SelectOne".equals(cmd))
66  {
67    // Display the list page after updating the current context from the request parameters
68    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
69    forward = "select_file.jsp";
70  }
71  else if ("SaveAs".equals(cmd))
72  {
73    // Display the list page after updating the current context from the request parameters
74    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
75    forward = "save_as.jsp";
76  }
77  else if ("ViewItem".equals(cmd))
78  {
79    forward = "manager.jsp";
80  }
81  else if ("EditItem".equals(cmd))
82  {
83    redirect = "files/index.jsp?ID="+ID+"&cmd=EditItem&item_id="+request.getParameter("item_id");
84  }
85  else if ("ViewFile".equals(cmd))
86  {
87    // View the file contents of a file
88    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
89    dc = sc.newDbControl();
90    File f = File.getById(dc, cc.getId());
91    redirect = root + "filemanager/files/view/-"+ID+"-"+ f.getPath().toURLString("UTF-8");
92    dc.close();
93  }
94  else if ("DownloadFile".equals(cmd))
95  {
96    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
97    forward = "files/download_file.jsp?ID="+ID;
98  }
99  else
100  {
101    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
102  }
103}
104finally
105{
106  if (dc != null) dc.close();
107}
108
109if (forward != null)
110{
111  pageContext.forward(forward);
112}
113else if (redirect != null)
114{
115  response.sendRedirect(redirect);
116}
117else if (message == null)
118{
119  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
120}
121else
122{
123  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
124}
125%>
126
Note: See TracBrowser for help on using the repository browser.