001
014
015 package com.liferay.portlet.blogs.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.struts.FindAction;
020 import com.liferay.portal.util.PortletKeys;
021 import com.liferay.portlet.blogs.model.BlogsEntry;
022 import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
023
024 import javax.servlet.http.HttpServletRequest;
025
026
029 public class FindEntryAction extends FindAction {
030
031 @Override
032 protected long getGroupId(long primaryKey) throws Exception {
033 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(primaryKey);
034
035 return entry.getGroupId();
036 }
037
038 @Override
039 protected String getPrimaryKeyParameterName() {
040 return "entryId";
041 }
042
043 @Override
044 protected String getStrutsAction(
045 HttpServletRequest request, String portletId) {
046
047 String strutsAction = StringPool.BLANK;
048
049 if (portletId.equals(PortletKeys.BLOGS_ADMIN)) {
050 strutsAction = "/blogs_admin";
051 }
052 else if (portletId.equals(PortletKeys.BLOGS)) {
053 strutsAction = "/blogs";
054 }
055 else {
056 strutsAction = "/blogs_aggregator";
057 }
058
059 boolean showAllEntries = ParamUtil.getBoolean(
060 request, "showAllEntries");
061
062 if (showAllEntries) {
063 strutsAction += "/view";
064 }
065 else {
066 strutsAction += "/view_entry";
067 }
068
069 return strutsAction;
070 }
071
072 @Override
073 protected String[] initPortletIds() {
074
075
076
077 return new String[] {
078 PortletKeys.BLOGS_ADMIN, PortletKeys.BLOGS,
079 PortletKeys.BLOGS_AGGREGATOR
080 };
081 }
082
083 }