001    /**
002     * Copyright (c) 2000-2013 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            @Override
031            public String getCharacterEncoding() {
032                    return getHttpServletRequest().getCharacterEncoding();
033            }
034    
035            @Override
036            public int getContentLength() {
037                    return getHttpServletRequest().getContentLength();
038            }
039    
040            @Override
041            public String getContentType() {
042                    return getHttpServletRequest().getContentType();
043            }
044    
045            @Override
046            public String getMethod() {
047                    return getHttpServletRequest().getMethod();
048            }
049    
050            @Override
051            public InputStream getPortletInputStream() throws IOException {
052                    return getHttpServletRequest().getInputStream();
053            }
054    
055            @Override
056            public BufferedReader getReader()
057                    throws IOException, UnsupportedEncodingException {
058    
059                    _calledGetReader = true;
060    
061                    return getHttpServletRequest().getReader();
062            }
063    
064            @Override
065            public void setCharacterEncoding(String enc)
066                    throws UnsupportedEncodingException {
067    
068                    if (_calledGetReader) {
069                            throw new IllegalStateException();
070                    }
071    
072                    getHttpServletRequest().setCharacterEncoding(enc);
073            }
074    
075            private boolean _calledGetReader;
076    
077    }