1
22
23 package com.liferay.portlet.blogs.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.theme.ThemeDisplay;
28 import com.liferay.portal.util.PortalUtil;
29 import com.liferay.portal.util.WebKeys;
30 import com.liferay.portlet.blogs.model.BlogsEntry;
31 import com.liferay.portlet.blogs.service.BlogsEntryServiceUtil;
32
33 import javax.portlet.ActionRequest;
34 import javax.portlet.RenderRequest;
35
36 import javax.servlet.http.HttpServletRequest;
37
38
44 public class ActionUtil {
45
46 public static void getEntry(ActionRequest req) throws Exception {
47 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
48
49 getEntry(httpReq);
50 }
51
52 public static void getEntry(RenderRequest req) throws Exception {
53 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
54
55 getEntry(httpReq);
56 }
57
58 public static void getEntry(HttpServletRequest req) throws Exception {
59 ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(
60 WebKeys.THEME_DISPLAY);
61
62 long entryId = ParamUtil.getLong(req, "entryId");
63
64 String urlTitle = ParamUtil.getString(req, "urlTitle");
65
66 BlogsEntry entry = null;
67
68 if (entryId > 0) {
69 entry = BlogsEntryServiceUtil.getEntry(entryId);
70 }
71 else if (Validator.isNotNull(urlTitle)) {
72 entry = BlogsEntryServiceUtil.getEntry(
73 themeDisplay.getPortletGroupId(), urlTitle);
74 }
75
76 req.setAttribute(WebKeys.BLOGS_ENTRY, entry);
77 }
78
79 }