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.portlet.PortletURL;
025
026 import javax.servlet.http.HttpServletRequest;
027
028
031 public class FindEntryAction extends FindAction {
032
033 @Override
034 protected long getGroupId(long primaryKey) throws Exception {
035 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(primaryKey);
036
037 return entry.getGroupId();
038 }
039
040 @Override
041 protected String getPrimaryKeyParameterName() {
042 return "entryId";
043 }
044
045 @Override
046 protected String getStrutsAction(
047 HttpServletRequest request, String portletId) {
048
049 String strutsAction = StringPool.BLANK;
050
051 if (portletId.equals(PortletKeys.BLOGS_ADMIN)) {
052 strutsAction = "/blogs_admin";
053 }
054 else if (portletId.equals(PortletKeys.BLOGS)) {
055 strutsAction = "/blogs";
056 }
057 else {
058 strutsAction = "/blogs_aggregator";
059 }
060
061 boolean showAllEntries = ParamUtil.getBoolean(
062 request, "showAllEntries");
063
064 if (showAllEntries) {
065 strutsAction += "/view";
066 }
067 else {
068 strutsAction += "/view_entry";
069 }
070
071 return strutsAction;
072 }
073
074 @Override
075 protected String[] initPortletIds() {
076
077
078
079 return new String[] {
080 PortletKeys.BLOGS_ADMIN, PortletKeys.BLOGS,
081 PortletKeys.BLOGS_AGGREGATOR
082 };
083 }
084
085 @Override
086 protected void setPrimaryKeyParameter(
087 PortletURL portletURL, long primaryKey)
088 throws Exception {
089
090 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(primaryKey);
091
092 portletURL.setParameter("urlTitle", entry.getUrlTitle());
093 }
094
095 }