001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet;
016    
017    import java.io.BufferedReader;
018    import java.io.IOException;
019    import java.io.InputStream;
020    import java.io.UnsupportedEncodingException;
021    
022    import javax.portlet.ClientDataRequest;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public abstract class ClientDataRequestImpl
028            extends PortletRequestImpl implements ClientDataRequest {
029    
030            public String getCharacterEncoding() {
031                    return getHttpServletRequest().getCharacterEncoding();
032            }
033    
034            public int getContentLength() {
035                    return getHttpServletRequest().getContentLength();
036            }
037    
038            public String getContentType() {
039                    return getHttpServletRequest().getContentType();
040            }
041    
042            public String getMethod() {
043                    return getHttpServletRequest().getMethod();
044            }
045    
046            public InputStream getPortletInputStream() throws IOException {
047                    return getHttpServletRequest().getInputStream();
048            }
049    
050            public BufferedReader getReader()
051                    throws IOException, UnsupportedEncodingException {
052    
053                    _calledGetReader = true;
054    
055                    return getHttpServletRequest().getReader();
056            }
057    
058            public void setCharacterEncoding(String enc)
059                    throws UnsupportedEncodingException {
060    
061                    if (_calledGetReader) {
062                            throw new IllegalStateException();
063                    }
064    
065                    getHttpServletRequest().setCharacterEncoding(enc);
066            }
067    
068            private boolean _calledGetReader;
069    
070    }