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 com.liferay.portal.kernel.util.ParamUtil;
018    import com.liferay.portal.kernel.util.Validator;
019    import com.liferay.portal.model.Portlet;
020    
021    import java.util.Map;
022    
023    import javax.portlet.PortletContext;
024    import javax.portlet.PortletMode;
025    import javax.portlet.PortletPreferences;
026    import javax.portlet.PortletRequest;
027    import javax.portlet.ResourceRequest;
028    import javax.portlet.ResourceURL;
029    import javax.portlet.WindowState;
030    
031    import javax.servlet.http.HttpServletRequest;
032    
033    /**
034     * @author Brian Wing Shun Chan
035     */
036    public class ResourceRequestImpl
037            extends ClientDataRequestImpl implements ResourceRequest {
038    
039            public String getCacheability() {
040                    return _cacheablity;
041            }
042    
043            public String getETag() {
044                    return null;
045            }
046    
047            public String getLifecycle() {
048                    return PortletRequest.RESOURCE_PHASE;
049            }
050    
051            public Map<String, String[]> getPrivateRenderParameterMap() {
052                    return null;
053            }
054    
055            public String getResourceID() {
056                    return _resourceID;
057            }
058    
059            protected void init(
060                    HttpServletRequest request, Portlet portlet,
061                    InvokerPortlet invokerPortlet, PortletContext portletContext,
062                    WindowState windowState, PortletMode portletMode,
063                    PortletPreferences preferences, long plid) {
064    
065                    if (Validator.isNull(windowState.toString())) {
066                            windowState = WindowState.NORMAL;
067                    }
068    
069                    if (Validator.isNull(portletMode.toString())) {
070                            portletMode = PortletMode.VIEW;
071                    }
072    
073                    super.init(
074                            request, portlet, invokerPortlet, portletContext, windowState,
075                            portletMode, preferences, plid);
076    
077                    _cacheablity = ParamUtil.getString(
078                            request, "p_p_cacheability", ResourceURL.PAGE);
079                    _resourceID = request.getParameter("p_p_resource_id");
080            }
081    
082            private String _cacheablity;
083            private String _resourceID;
084    
085    }