001
014
015 package com.liferay.portlet.blogs.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.StringPool;
020 import com.liferay.portal.kernel.workflow.WorkflowConstants;
021 import com.liferay.portal.model.Layout;
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.WebKeys;
026 import com.liferay.portlet.blogs.service.BlogsEntryServiceUtil;
027 import com.liferay.util.RSSUtil;
028
029 import java.util.Date;
030
031 import javax.servlet.http.HttpServletRequest;
032
033
036 public class RSSAction extends com.liferay.portal.struts.RSSAction {
037
038 @Override
039 protected byte[] getRSS(HttpServletRequest request) throws Exception {
040 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
041 WebKeys.THEME_DISPLAY);
042
043 Layout layout = themeDisplay.getLayout();
044
045 long plid = ParamUtil.getLong(request, "p_l_id");
046 long companyId = ParamUtil.getLong(request, "companyId");
047 long groupId = ParamUtil.getLong(request, "groupId");
048 long organizationId = ParamUtil.getLong(request, "organizationId");
049 int status = WorkflowConstants.STATUS_APPROVED;
050 int max = ParamUtil.getInteger(
051 request, "max", SearchContainer.DEFAULT_DELTA);
052 String type = ParamUtil.getString(
053 request, "type", RSSUtil.FORMAT_DEFAULT);
054 double version = ParamUtil.getDouble(
055 request, "version", RSSUtil.VERSION_DEFAULT);
056 String displayStyle = ParamUtil.getString(
057 request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT);
058
059 String feedURL =
060 themeDisplay.getPortalURL() + themeDisplay.getPathMain() +
061 "/blogs/find_entry?";
062
063 String entryURL = feedURL;
064
065 String rss = StringPool.BLANK;
066
067 if (companyId > 0) {
068 feedURL = StringPool.BLANK;
069
070 rss = BlogsEntryServiceUtil.getCompanyEntriesRSS(
071 companyId, new Date(), status, max, type, version, displayStyle,
072 feedURL, entryURL, themeDisplay);
073 }
074 else if (groupId > 0) {
075 feedURL += "p_l_id=" + plid;
076
077 entryURL = feedURL;
078
079 rss = BlogsEntryServiceUtil.getGroupEntriesRSS(
080 groupId, new Date(), status, max, type, version, displayStyle,
081 feedURL, entryURL, themeDisplay);
082 }
083 else if (organizationId > 0) {
084 feedURL = StringPool.BLANK;
085
086 rss = BlogsEntryServiceUtil.getOrganizationEntriesRSS(
087 organizationId, new Date(), status, max, type, version,
088 displayStyle, feedURL, entryURL, themeDisplay);
089 }
090 else if (layout != null) {
091 groupId = themeDisplay.getScopeGroupId();
092
093 feedURL =
094 PortalUtil.getLayoutFullURL(themeDisplay) +
095 Portal.FRIENDLY_URL_SEPARATOR + "blogs/rss";
096
097 entryURL = feedURL;
098
099 rss = BlogsEntryServiceUtil.getGroupEntriesRSS(
100 groupId, new Date(), status, max, type, version, displayStyle,
101 feedURL, entryURL, themeDisplay);
102 }
103
104 return rss.getBytes(StringPool.UTF8);
105 }
106
107 }