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

Last change on this file since 6457 was 6457, checked in by Nicklas Nordborg, 9 years ago

References #1729: Move in-page <script> elements to external *.js files

Use redirect instead of forward for 'Download file' dialog so that the script is referenced with correct path.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 4.6 KB
Line 
1<%-- $Id: index.jsp 6457 2014-05-09 12:17:22Z 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 pageEncoding="UTF-8" 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,itemSubtype,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?mode=selectone";
70  }
71  else if ("SelectMultiple".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 = "select_file.jsp?mode=selectmultiple";
76  }
77  else if ("SaveAs".equals(cmd))
78  {
79    // Display the list page after updating the current context from the request parameters
80    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
81    forward = "save_as.jsp";
82  }
83  else if ("ViewItem".equals(cmd))
84  {
85    forward = "manager.jsp";
86  }
87  else if ("NewItem".equals(cmd))
88  {
89    redirect = "files/index.jsp?ID="+ID+"&cmd=NewItem&directory_id="+request.getParameter("directory_id");
90  }
91  else if ("EditItem".equals(cmd))
92  {
93    redirect = "files/index.jsp?ID="+ID+"&cmd=EditItem&item_id="+request.getParameter("item_id");
94  }
95  else if ("ShareItem".equals(cmd))
96  {
97    redirect = "files/index.jsp?ID="+ID+"&cmd=ShareItem&item_id="+request.getParameter("item_id");
98  }
99  else if ("ViewFile".equals(cmd))
100  {
101    // View the file contents of a file
102    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
103    dc = sc.newDbControl();
104    File f = File.getById(dc, cc.getId());
105    redirect = root + "filemanager/files/view/-"+ID+"-"+ f.getPath().toURLString("UTF-8");
106    dc.close();
107  }
108  else if ("DownloadFile".equals(cmd))
109  {
110    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
111    redirect = "files/download_file.jsp?ID="+ID;
112  }
113  else
114  {
115    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
116  }
117}
118finally
119{
120  if (dc != null) dc.close();
121}
122
123if (forward != null)
124{
125  sc.setSessionSetting("alert-message", message);
126  pageContext.forward(forward);
127}
128else if (redirect != null)
129{
130  sc.setSessionSetting("alert-message", message);
131  response.sendRedirect(redirect);
132}
133else if (message == null)
134{
135  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
136}
137else
138{
139  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
140}
141%>
142
Note: See TracBrowser for help on using the repository browser.