001: /*
002: * BrowserServlet.java
003: *
004: * Version: $Revision: $
005: *
006: * Date: $Date: $
007: *
008: * Copyright (c) 2002-2007, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040: package org.dspace.app.webui.servlet.admin;
041:
042: import java.io.IOException;
043: import java.sql.SQLException;
044: import java.util.Map;
045: import java.util.Set;
046:
047: import javax.servlet.ServletException;
048: import javax.servlet.http.HttpServletRequest;
049: import javax.servlet.http.HttpServletResponse;
050:
051: import org.apache.log4j.Logger;
052: import org.dspace.authorize.AuthorizeException;
053: import org.dspace.browse.BrowseException;
054: import org.dspace.browse.BrowseIndex;
055: import org.dspace.browse.BrowserScope;
056: import org.dspace.core.Context;
057:
058: import org.dspace.app.webui.servlet.AbstractBrowserServlet;
059: import org.dspace.app.webui.util.JSPManager;
060:
061: /**
062: * Servlet for browsing through withdrawn items:
063: *
064: * @author Graham Triggs
065: * @version $Revision: $
066: */
067: public class WithdrawnBrowserServlet extends AbstractBrowserServlet {
068: /** log4j category */
069: private static Logger log = Logger
070: .getLogger(WithdrawnBrowserServlet.class);
071:
072: /**
073: * Do the usual DSpace GET method. You will notice that browse does not currently
074: * respond to POST requests.
075: */
076: protected void doDSGet(Context context, HttpServletRequest request,
077: HttpServletResponse response) throws ServletException,
078: IOException, SQLException, AuthorizeException {
079: try {
080: // all browse requests currently come to GET.
081: BrowserScope scope = getBrowserScopeForRequest(context,
082: request, response);
083:
084: // Check that we are doing an item browse
085: if (scope.getBrowseIndex() == null
086: || scope.getBrowseIndex().isItemIndex()) {
087: // And override the index in the scope with the withdrawn items
088: scope.setBrowseIndex(BrowseIndex
089: .getWithdrawnBrowseIndex());
090: } else {
091: showError(context, request, response);
092: }
093:
094: // execute browse request
095: processBrowse(context, scope, request, response);
096: } catch (BrowseException be) {
097: log.error("caught exception: ", be);
098: throw new ServletException(be);
099: }
100: }
101:
102: /**
103: * Display the error page
104: *
105: * @param context
106: * @param request
107: * @param response
108: * @throws ServletException
109: * @throws IOException
110: * @throws SQLException
111: * @throws AuthorizeException
112: */
113: protected void showError(Context context,
114: HttpServletRequest request, HttpServletResponse response)
115: throws ServletException, IOException, SQLException,
116: AuthorizeException {
117: request.setAttribute("useAdminLayout", "yes");
118:
119: JSPManager.showJSP(request, response, "/browse/error.jsp");
120: }
121:
122: /**
123: * Display the No Results page
124: *
125: * @param context
126: * @param request
127: * @param response
128: * @throws ServletException
129: * @throws IOException
130: * @throws SQLException
131: * @throws AuthorizeException
132: */
133: protected void showNoResultsPage(Context context,
134: HttpServletRequest request, HttpServletResponse response)
135: throws ServletException, IOException, SQLException,
136: AuthorizeException {
137: request.setAttribute("browseWithdrawn", "yes");
138:
139: JSPManager.showJSP(request, response, "/browse/no-results.jsp");
140: }
141:
142: /**
143: * Display the single page. This is the page which lists just the single values of a
144: * metadata browse, not individual items. Single values are links through to all the items
145: * that match that metadata value
146: *
147: * @param context
148: * @param request
149: * @param response
150: * @throws ServletException
151: * @throws IOException
152: * @throws SQLException
153: * @throws AuthorizeException
154: */
155: protected void showSinglePage(Context context,
156: HttpServletRequest request, HttpServletResponse response)
157: throws ServletException, IOException, SQLException,
158: AuthorizeException {
159: // Show an error as this currently isn't supported
160: showError(context, request, response);
161: }
162:
163: /**
164: * Display a full item listing.
165: *
166: * @param context
167: * @param request
168: * @param response
169: * @throws ServletException
170: * @throws IOException
171: * @throws SQLException
172: * @throws AuthorizeException
173: */
174: protected void showFullPage(Context context,
175: HttpServletRequest request, HttpServletResponse response)
176: throws ServletException, IOException, SQLException,
177: AuthorizeException {
178: request.setAttribute("browseWithdrawn", "yes");
179:
180: JSPManager.showJSP(request, response, "/browse/full.jsp");
181: }
182: }
|