1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.portlet;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.util.StringPool;
19  import com.liferay.portal.kernel.util.Validator;
20  
21  import java.util.Map;
22  
23  import javax.portlet.PortletMode;
24  
25  /**
26   * <a href="RSSFriendlyURLMapper.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public abstract class RSSFriendlyURLMapper extends BaseFriendlyURLMapper {
31  
32      public String buildPath(LiferayPortletURL portletURL) {
33          String friendlyURLPath = null;
34  
35          boolean rss = GetterUtil.getBoolean(portletURL.getParameter("rss"));
36  
37          if (rss) {
38              friendlyURLPath = StringPool.SLASH + getMapping() + "/rss";
39  
40              portletURL.addParameterIncludedInPath("rss");
41          }
42  
43          if (Validator.isNotNull(friendlyURLPath)) {
44              portletURL.addParameterIncludedInPath("p_p_id");
45          }
46  
47          return friendlyURLPath;
48      }
49  
50      public void populateParams(
51          String friendlyURLPath, Map<String, String[]> parameterMap) {
52  
53          int x = friendlyURLPath.indexOf(StringPool.SLASH, 1);
54  
55          if (x == -1) {
56              return;
57          }
58  
59          String rss = friendlyURLPath.substring(x + 1);
60  
61          if (!rss.equals("rss")) {
62              return;
63          }
64  
65          addParameter(parameterMap, "p_p_id", getPortletId());
66          addParameter(parameterMap, "p_p_lifecycle", "0");
67          addParameter(parameterMap, "p_p_state", LiferayWindowState.EXCLUSIVE);
68          addParameter(parameterMap, "p_p_mode", PortletMode.VIEW);
69      }
70  
71  }