001
014
015 package com.liferay.portlet.imagegallery.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.util.PortalUtil;
019 import com.liferay.portal.util.WebKeys;
020 import com.liferay.portlet.imagegallery.model.IGFolder;
021 import com.liferay.portlet.imagegallery.model.IGFolderConstants;
022 import com.liferay.portlet.imagegallery.model.IGImage;
023 import com.liferay.portlet.imagegallery.service.IGFolderServiceUtil;
024 import com.liferay.portlet.imagegallery.service.IGImageServiceUtil;
025
026 import javax.portlet.PortletRequest;
027
028 import javax.servlet.http.HttpServletRequest;
029
030
033 public class ActionUtil {
034
035 public static void getFolder(HttpServletRequest request) throws Exception {
036 long folderId = ParamUtil.getLong(request, "folderId");
037
038 IGFolder folder = null;
039
040 if ((folderId > 0) &&
041 (folderId != IGFolderConstants.DEFAULT_PARENT_FOLDER_ID)) {
042
043 folder = IGFolderServiceUtil.getFolder(folderId);
044 }
045
046 request.setAttribute(WebKeys.IMAGE_GALLERY_FOLDER, folder);
047 }
048
049 public static void getFolder(PortletRequest portletRequest)
050 throws Exception {
051
052 HttpServletRequest request = PortalUtil.getHttpServletRequest(
053 portletRequest);
054
055 getFolder(request);
056 }
057
058 public static void getImage(HttpServletRequest request) throws Exception {
059 long imageId = ParamUtil.getLong(request, "imageId");
060
061 IGImage image = null;
062
063 if (imageId > 0) {
064 image = IGImageServiceUtil.getImage(imageId);
065 }
066
067 request.setAttribute(WebKeys.IMAGE_GALLERY_IMAGE, image);
068 }
069
070 public static void getImage(PortletRequest portletRequest)
071 throws Exception {
072
073 HttpServletRequest request = PortalUtil.getHttpServletRequest(
074 portletRequest);
075
076 getImage(request);
077 }
078
079 }