Revision 5776
Added by berkley almost 14 years ago
src/edu/ucsb/nceas/metacat/restservice/D1HttpRequest.java | ||
---|---|---|
37 | 37 |
* Class to override getPathInfo on the servlet request |
38 | 38 |
*/ |
39 | 39 |
public class D1HttpRequest extends HttpServletRequestWrapper |
40 |
{ |
|
41 |
HttpServletRequest request; |
|
42 |
String lastPathElement; |
|
43 |
|
|
40 |
{ |
|
44 | 41 |
/** |
45 | 42 |
* HttpServletRequestWrapper(HttpServletRequest request) |
46 | 43 |
*/ |
47 | 44 |
public D1HttpRequest(ServletRequest request) |
48 | 45 |
{ |
49 | 46 |
super((HttpServletRequest)request); |
50 |
this.request = (HttpServletRequest)request; |
|
51 |
|
|
52 |
/*Enumeration<String> paramNames = request.getParameterNames(); |
|
53 |
while(paramNames.hasMoreElements()) |
|
54 |
{ |
|
55 |
System.out.println("paramName: " + paramNames.nextElement()); |
|
56 |
}*/ |
|
57 |
System.out.println("request uri: " + this.request.getRequestURI()); |
|
58 |
String reqUri = this.request.getRequestURI(); |
|
59 |
StringTokenizer st = new StringTokenizer(reqUri, "/"); |
|
60 |
if(st.countTokens() <= 3) |
|
61 |
{ |
|
62 |
lastPathElement = "/"; |
|
63 |
} |
|
64 |
else if(st.countTokens() > 3) |
|
65 |
{ |
|
66 |
st.nextToken(); |
|
67 |
st.nextToken(); |
|
68 |
st.nextToken(); |
|
69 |
lastPathElement = "/"; |
|
70 |
while(st.hasMoreTokens()) |
|
71 |
{ |
|
72 |
lastPathElement += st.nextToken(); |
|
73 |
lastPathElement += "/"; |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
if(lastPathElement.endsWith("/")) |
|
78 |
{ |
|
79 |
lastPathElement = lastPathElement.substring(0, lastPathElement.length() - 1); |
|
80 |
} |
|
81 | 47 |
} |
82 | 48 |
|
83 | 49 |
/** |
... | ... | |
85 | 51 |
* @return |
86 | 52 |
*/ |
87 | 53 |
@Override |
88 |
public String getPathInfo() |
|
54 |
public String getPathInfo()
|
|
89 | 55 |
{ |
90 | 56 |
String s = super.getPathInfo(); |
91 | 57 |
System.out.println("original pathInfo: " + s); |
92 |
s = this.lastPathElement; |
|
58 |
String reqUri = this.getRequestURI(); |
|
59 |
String strip = this.getContextPath() + this.getServletPath(); |
|
60 |
s = reqUri.substring(strip.length()); |
|
93 | 61 |
try |
94 | 62 |
{ |
95 | 63 |
s = URLDecoder.decode(s, "UTF-8"); |
Also available in: Unified diff
fix for member variables but in the request wrapper