001    /**
002     * Copyright (c) 2000-2012 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            @Override
043            public String getMethod() {
044                    return getHttpServletRequest().getMethod();
045            }
046    
047            public InputStream getPortletInputStream() throws IOException {
048                    return getHttpServletRequest().getInputStream();
049            }
050    
051            public BufferedReader getReader()
052                    throws IOException, UnsupportedEncodingException {
053    
054                    _calledGetReader = true;
055    
056                    return getHttpServletRequest().getReader();
057            }
058    
059            public void setCharacterEncoding(String enc)
060                    throws UnsupportedEncodingException {
061    
062                    if (_calledGetReader) {
063                            throw new IllegalStateException();
064                    }
065    
066                    getHttpServletRequest().setCharacterEncoding(enc);
067            }
068    
069            private boolean _calledGetReader;
070    
071    }