1 |
5750
|
berkley
|
/**
|
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 |
5761
|
berkley
|
import java.io.UnsupportedEncodingException;
|
27 |
|
|
import java.net.URLDecoder;
|
28 |
5750
|
berkley
|
import java.util.Enumeration;
|
29 |
|
|
import java.util.Map;
|
30 |
5751
|
berkley
|
import java.util.StringTokenizer;
|
31 |
5750
|
berkley
|
|
32 |
|
|
import javax.servlet.ServletRequest;
|
33 |
|
|
import javax.servlet.http.*;
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* @author berkley
|
37 |
|
|
* Class to override getPathInfo on the servlet request
|
38 |
|
|
*/
|
39 |
|
|
public class D1HttpRequest extends HttpServletRequestWrapper
|
40 |
5776
|
berkley
|
{
|
41 |
5750
|
berkley
|
/**
|
42 |
|
|
* HttpServletRequestWrapper(HttpServletRequest request)
|
43 |
|
|
*/
|
44 |
|
|
public D1HttpRequest(ServletRequest request)
|
45 |
|
|
{
|
46 |
|
|
super((HttpServletRequest)request);
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* override getPathInfo to handle special characters
|
51 |
|
|
* @return
|
52 |
|
|
*/
|
53 |
|
|
@Override
|
54 |
5776
|
berkley
|
public String getPathInfo()
|
55 |
5750
|
berkley
|
{
|
56 |
5751
|
berkley
|
String s = super.getPathInfo();
|
57 |
|
|
System.out.println("original pathInfo: " + s);
|
58 |
5776
|
berkley
|
String reqUri = this.getRequestURI();
|
59 |
5780
|
berkley
|
System.out.println("original requestURI: " + reqUri);
|
60 |
5776
|
berkley
|
String strip = this.getContextPath() + this.getServletPath();
|
61 |
5780
|
berkley
|
System.out.println("stripping " + strip + " from requestURI");
|
62 |
5776
|
berkley
|
s = reqUri.substring(strip.length());
|
63 |
5761
|
berkley
|
try
|
64 |
|
|
{
|
65 |
|
|
s = URLDecoder.decode(s, "UTF-8");
|
66 |
|
|
}
|
67 |
|
|
catch (UnsupportedEncodingException e)
|
68 |
|
|
{
|
69 |
|
|
s = URLDecoder.decode(s);
|
70 |
|
|
}
|
71 |
5751
|
berkley
|
System.out.println("new pathinfo: " + s);
|
72 |
5750
|
berkley
|
return s;
|
73 |
|
|
}
|
74 |
|
|
}
|