-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
ControlledVocabularyServlet.java
72 lines (59 loc) · 2.27 KB
/
ControlledVocabularyServlet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.servlet;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
/**
* Servlet that handles the controlled vocabulary
*
* @author Miguel Ferreira
* @version $Revision$
*/
public class ControlledVocabularyServlet extends DSpaceServlet
{
private static Logger log =
Logger.getLogger(ControlledVocabularyServlet.class);
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
{
String ID = "";
String filter = "";
String callerUrl = request.getParameter("callerUrl");
// callerUrl must starts with URL outside DSpace request context path
if(!callerUrl.startsWith(request.getContextPath())) {
log.error("Controlled vocabulary caller URL would result in redirect outside DSpace web app: " + callerUrl + ". Rejecting request with 400 Bad Request.");
response.sendError(400, "The caller URL must be within the DSpace base URL of " + request.getContextPath());
return;
}
if (request.getParameter("ID") != null)
{
ID = request.getParameter("ID");
}
if (request.getParameter("filter") != null)
{
filter = request.getParameter("filter");
}
request.getSession()
.setAttribute("controlledvocabulary.filter", filter);
request.getSession().setAttribute("controlledvocabulary.ID", ID);
response.sendRedirect(callerUrl);
}
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
{
doDSGet(context, request, response);
}
}