1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2010 Regents of the University of California and the
|
4
|
* National Center for Ecological Analysis and Synthesis
|
5
|
*
|
6
|
* '$Author: berkley $'
|
7
|
* '$Date: 2009-06-13 13:28:21 +0300 $'
|
8
|
*
|
9
|
* This program is free software; you can redistribute it and/or modify
|
10
|
* it under the terms of the GNU General Public License as published by
|
11
|
* the Free Software Foundation; either version 2 of the License, or
|
12
|
* (at your option) any later version.
|
13
|
*
|
14
|
* This program is distributed in the hope that it will be useful,
|
15
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
* GNU General Public License for more details.
|
18
|
*
|
19
|
* You should have received a copy of the GNU General Public License
|
20
|
* along with this program; if not, write to the Free Software
|
21
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
*/
|
23
|
|
24
|
package edu.ucsb.nceas.metacat.restservice;
|
25
|
|
26
|
import java.io.UnsupportedEncodingException;
|
27
|
import java.net.URLDecoder;
|
28
|
|
29
|
import javax.servlet.ServletRequest;
|
30
|
import javax.servlet.http.HttpServletRequest;
|
31
|
import javax.servlet.http.HttpServletRequestWrapper;
|
32
|
|
33
|
import org.apache.log4j.Logger;
|
34
|
|
35
|
/**
|
36
|
* @author berkley
|
37
|
* Class to override getPathInfo on the servlet request
|
38
|
*/
|
39
|
public class D1HttpRequest extends HttpServletRequestWrapper
|
40
|
{
|
41
|
private static Logger logMetacat = Logger.getLogger(D1HttpRequest.class);
|
42
|
/**
|
43
|
* HttpServletRequestWrapper(HttpServletRequest request)
|
44
|
*/
|
45
|
public D1HttpRequest(ServletRequest request)
|
46
|
{
|
47
|
super((HttpServletRequest)request);
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* override getPathInfo to handle special characters
|
52
|
* @return
|
53
|
*/
|
54
|
@Override
|
55
|
public String getPathInfo()
|
56
|
{
|
57
|
String s = super.getPathInfo();
|
58
|
logMetacat.debug("original pathInfo: " + s);
|
59
|
logMetacat.info("D1HttpRequest.getPathInfo - the orignial pathInfo: "+s);
|
60
|
String reqUri = this.getRequestURI();
|
61
|
logMetacat.debug("original requestURI: " + reqUri);
|
62
|
String strip = this.getContextPath() + this.getServletPath();
|
63
|
logMetacat.debug("stripping " + strip + " from requestURI");
|
64
|
s = reqUri.substring(strip.length());
|
65
|
/*try
|
66
|
{
|
67
|
s = URLDecoder.decode(s, "UTF-8");
|
68
|
}
|
69
|
catch (UnsupportedEncodingException e)
|
70
|
{
|
71
|
s = URLDecoder.decode(s);
|
72
|
}*/
|
73
|
logMetacat.debug("new pathinfo: " + s);
|
74
|
logMetacat.info("D1HttpRequest.getPathInfo - the new pathInfo: "+s);
|
75
|
return s;
|
76
|
}
|
77
|
|
78
|
}
|