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.util.RSSUtil;
029
030 import java.util.Locale;
031
032 import javax.servlet.http.HttpServletRequest;
033
034
037 public class RSSAction extends com.liferay.portal.struts.RSSAction {
038
039 @Override
040 protected byte[] getRSS(HttpServletRequest request) throws Exception {
041 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
042 WebKeys.THEME_DISPLAY);
043
044 long companyId = ParamUtil.getLong(request, "companyId");
045 long nodeId = ParamUtil.getLong(request, "nodeId");
046 String title = ParamUtil.getString(request, "title");
047 int max = ParamUtil.getInteger(
048 request, "max", SearchContainer.DEFAULT_DELTA);
049 String type = ParamUtil.getString(
050 request, "type", RSSUtil.FORMAT_DEFAULT);
051 double version = ParamUtil.getDouble(
052 request, "version", RSSUtil.VERSION_DEFAULT);
053 String displayStyle = ParamUtil.getString(
054 request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT);
055
056 String layoutFullURL = PortalUtil.getLayoutFullURL(
057 themeDisplay.getScopeGroupId(), PortletKeys.WIKI);
058
059 StringBundler sb = new StringBundler(4);
060
061 sb.append(layoutFullURL);
062 sb.append(Portal.FRIENDLY_URL_SEPARATOR);
063 sb.append("wiki/");
064 sb.append(String.valueOf(nodeId));
065
066 String feedURL = sb.toString();
067
068 String entryURL = feedURL + StringPool.SLASH + title;
069
070 Locale locale = themeDisplay.getLocale();
071
072 String rss = StringPool.BLANK;
073
074 if ((nodeId > 0) && Validator.isNotNull(title)) {
075 rss = WikiPageServiceUtil.getPagesRSS(
076 companyId, nodeId, title, max, type, version, displayStyle,
077 feedURL, entryURL, locale);
078 }
079 else if (nodeId > 0) {
080 rss = WikiPageServiceUtil.getNodePagesRSS(
081 nodeId, max, type, version, displayStyle, feedURL, entryURL);
082 }
083
084 return rss.getBytes(StringPool.UTF8);
085 }
086
087 }