1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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[]> params) {
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          addParam(params, "p_p_id", getPortletId());
66          addParam(params, "p_p_lifecycle", "0");
67          addParam(params, "p_p_state", LiferayWindowState.EXCLUSIVE);
68          addParam(params, "p_p_mode", PortletMode.VIEW);
69      }
70  
71  }