001
014
015 package com.liferay.portlet.wiki.action;
016
017 import com.liferay.portal.kernel.dao.search.SearchContainer;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.Portal;
024 import com.liferay.portal.util.PortalUtil;
025 import com.liferay.portal.util.PortletKeys;
026 import com.liferay.portal.util.WebKeys;
027 import com.liferay.portlet.wiki.service.WikiPageServiceUtil;
028 import com.liferay.portlet.wiki.util.WikiUtil;
029 import com.liferay.util.RSSUtil;
030
031 import java.util.Locale;
032
033 import javax.servlet.http.HttpServletRequest;
034
035
038 public class RSSAction extends com.liferay.portal.struts.RSSAction {
039
040 @Override
041 protected byte[] getRSS(HttpServletRequest request) throws Exception {
042 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
043 WebKeys.THEME_DISPLAY);
044
045 long companyId = ParamUtil.getLong(request, "companyId");
046 long nodeId = ParamUtil.getLong(request, "nodeId");
047 String title = ParamUtil.getString(request, "title");
048 int max = ParamUtil.getInteger(
049 request, "max", SearchContainer.DEFAULT_DELTA);
050 String type = ParamUtil.getString(
051 request, "type", RSSUtil.FORMAT_DEFAULT);
052 double version = ParamUtil.getDouble(
053 request, "version", RSSUtil.VERSION_DEFAULT);
054 String displayStyle = ParamUtil.getString(
055 request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT);
056
057 String layoutFullURL = PortalUtil.getLayoutFullURL(
058 themeDisplay.getScopeGroupId(), PortletKeys.WIKI);
059
060 StringBundler sb = new StringBundler(4);
061
062 sb.append(layoutFullURL);
063 sb.append(Portal.FRIENDLY_URL_SEPARATOR);
064 sb.append("wiki/");
065 sb.append(nodeId);
066
067 String feedURL = sb.toString();
068
069 String entryURL = feedURL + StringPool.SLASH + title;
070
071 Locale locale = themeDisplay.getLocale();
072
073 String rss = StringPool.BLANK;
074
075 if (nodeId > 0) {
076 String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(
077 themeDisplay.getPathMain(), themeDisplay.getPlid(), nodeId,
078 title);
079
080 if (Validator.isNotNull(title)) {
081 rss = WikiPageServiceUtil.getPagesRSS(
082 companyId, nodeId, title, max, type, version, displayStyle,
083 feedURL, entryURL, attachmentURLPrefix, locale);
084 }
085 else {
086 rss = WikiPageServiceUtil.getNodePagesRSS(
087 nodeId, max, type, version, displayStyle, feedURL, entryURL,
088 attachmentURLPrefix);
089 }
090 }
091
092 return rss.getBytes(StringPool.UTF8);
093 }
094
095 }