001
014
015 package com.liferay.portlet.wiki.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.struts.FindAction;
019 import com.liferay.portal.util.PortletKeys;
020 import com.liferay.portlet.wiki.model.WikiNode;
021 import com.liferay.portlet.wiki.model.WikiPageResource;
022 import com.liferay.portlet.wiki.service.WikiNodeLocalServiceUtil;
023 import com.liferay.portlet.wiki.service.WikiPageResourceLocalServiceUtil;
024
025 import javax.portlet.PortletURL;
026
027 import javax.servlet.http.HttpServletRequest;
028
029
032 public class FindPageAction extends FindAction {
033
034 @Override
035 protected long getGroupId(long primaryKey) throws Exception {
036 WikiPageResource pageResource =
037 WikiPageResourceLocalServiceUtil.getPageResource(primaryKey);
038
039 WikiNode node = WikiNodeLocalServiceUtil.getNode(
040 pageResource.getNodeId());
041
042 return node.getGroupId();
043 }
044
045 @Override
046 protected String getPrimaryKeyParameterName() {
047 return "pageResourcePrimKey";
048 }
049
050 @Override
051 protected String getStrutsAction(
052 HttpServletRequest request, String portletId) {
053
054 if (portletId.equals(PortletKeys.WIKI_ADMIN)) {
055 return "/wiki_admin/view";
056 }
057 else if (portletId.equals(PortletKeys.WIKI)) {
058 return "/wiki/view";
059 }
060 else {
061 return "/wiki_display/view";
062 }
063 }
064
065 @Override
066 protected String[] initPortletIds() {
067
068
069
070 return new String[] {
071 PortletKeys.WIKI_ADMIN, PortletKeys.WIKI, PortletKeys.WIKI_DISPLAY
072 };
073 }
074
075 @Override
076 protected PortletURL processPortletURL(
077 HttpServletRequest request, PortletURL portletURL)
078 throws Exception {
079
080 long pageResourcePrimKey = ParamUtil.getLong(
081 request, getPrimaryKeyParameterName());
082
083 WikiPageResource pageResource =
084 WikiPageResourceLocalServiceUtil.getPageResource(
085 pageResourcePrimKey);
086
087 WikiNode node = WikiNodeLocalServiceUtil.getNode(
088 pageResource.getNodeId());
089
090 portletURL.setParameter("nodeName", node.getName());
091 portletURL.setParameter("title", pageResource.getTitle());
092
093 return portletURL;
094 }
095
096 }