1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.ParamUtil;
28  import com.liferay.portal.model.Portlet;
29  
30  import java.util.Map;
31  
32  import javax.portlet.PortletContext;
33  import javax.portlet.PortletMode;
34  import javax.portlet.PortletPreferences;
35  import javax.portlet.PortletRequest;
36  import javax.portlet.ResourceRequest;
37  import javax.portlet.ResourceURL;
38  import javax.portlet.WindowState;
39  
40  import javax.servlet.http.HttpServletRequest;
41  
42  /**
43   * <a href="ResourceRequestImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * @author Brian Wing Shun Chan
46   */
47  public class ResourceRequestImpl
48      extends ClientDataRequestImpl implements ResourceRequest {
49  
50      public String getCacheability() {
51          return _cacheablity;
52      }
53  
54      public String getETag() {
55          return null;
56      }
57  
58      public String getLifecycle() {
59          return PortletRequest.RESOURCE_PHASE;
60      }
61  
62      public Map<String, String[]> getPrivateRenderParameterMap() {
63          return null;
64      }
65  
66      public String getResourceID() {
67          return _resourceID;
68      }
69  
70      protected ResourceRequestImpl() {
71          if (_log.isDebugEnabled()) {
72              _log.debug("Creating new instance " + hashCode());
73          }
74      }
75  
76      protected void init(
77          HttpServletRequest request, Portlet portlet,
78          InvokerPortlet invokerPortlet, PortletContext portletContext,
79          WindowState windowState, PortletMode portletMode,
80          PortletPreferences prefs, long plid) {
81  
82          super.init(
83              request, portlet, invokerPortlet, portletContext, windowState,
84              portletMode, prefs, plid);
85  
86          _cacheablity = ParamUtil.getString(
87              request, "p_p_cacheability", ResourceURL.PAGE);
88          _resourceID = request.getParameter("p_p_resource_id");
89      }
90  
91      protected void recycle() {
92          if (_log.isDebugEnabled()) {
93              _log.debug("Recycling instance " + hashCode());
94          }
95  
96          super.recycle();
97  
98          _cacheablity = null;
99          _resourceID = null;
100     }
101 
102     private static Log _log = LogFactoryUtil.getLog(ResourceRequestImpl.class);
103 
104     private String _cacheablity;
105     private String _resourceID;
106 
107 }