Project

General

Profile

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.util.Enumeration;
27
import java.util.Map;
28

    
29
import javax.servlet.ServletRequest;
30
import javax.servlet.http.*;
31

    
32
/**
33
 * @author berkley
34
 * Class to override getPathInfo on the servlet request
35
 */
36
public class D1HttpRequest extends HttpServletRequestWrapper
37
{
38
    HttpServletRequest request;
39
    String lastPathElement;
40
    
41
    /**
42
     * HttpServletRequestWrapper(HttpServletRequest request) 
43
     */
44
    public D1HttpRequest(ServletRequest request)
45
    {
46
        super((HttpServletRequest)request);
47
        this.request = (HttpServletRequest)request;
48
        
49
        /*Enumeration<String> paramNames = request.getParameterNames();
50
        while(paramNames.hasMoreElements())
51
        {
52
            System.out.println("paramName: " + paramNames.nextElement());
53
        }*/
54
        System.out.println("request uri: " + this.request.getRequestURI());
55
        String reqUri = this.request.getRequestURI();
56
        this.lastPathElement = reqUri.substring(reqUri.lastIndexOf("/"), reqUri.length());
57
    }
58
    
59
    /**
60
     * override getPathInfo to handle special characters
61
     * @return
62
     */
63
    @Override
64
    public String getPathInfo()
65
    {
66
        //String s = super.getPathInfo();
67
        String s = this.lastPathElement;
68
        System.out.println("pathinfo: " + s);
69
        return s;
70
    }
71
}
(1-1/5)