001
014
015 package com.liferay.portlet.bookmarks.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.kernel.workflow.WorkflowConstants;
019 import com.liferay.portal.struts.ActionConstants;
020 import com.liferay.portal.util.PortalUtil;
021 import com.liferay.portal.util.WebKeys;
022 import com.liferay.portlet.bookmarks.NoSuchEntryException;
023 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
024 import com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil;
025
026 import javax.servlet.http.HttpServletRequest;
027 import javax.servlet.http.HttpServletResponse;
028
029 import org.apache.struts.action.Action;
030 import org.apache.struts.action.ActionForm;
031 import org.apache.struts.action.ActionForward;
032 import org.apache.struts.action.ActionMapping;
033
034
037 public class OpenEntryAction extends Action {
038
039 @Override
040 public ActionForward execute(
041 ActionMapping actionMapping, ActionForm actionForm,
042 HttpServletRequest request, HttpServletResponse response)
043 throws Exception {
044
045 try {
046 long entryId = ParamUtil.getLong(request, "entryId");
047
048 BookmarksEntry entry = BookmarksEntryServiceUtil.getEntry(entryId);
049
050 if (entry.isInTrash()) {
051 int status = ParamUtil.getInteger(
052 request, "status", WorkflowConstants.STATUS_APPROVED);
053
054 if (status != WorkflowConstants.STATUS_IN_TRASH) {
055 throw new NoSuchEntryException("{entryId=" + entryId + "}");
056 }
057 }
058
059 entry = BookmarksEntryServiceUtil.openEntry(entry);
060
061 request.setAttribute(WebKeys.FORWARD_URL, entry.getUrl());
062
063 return actionMapping.findForward(ActionConstants.COMMON_FORWARD);
064 }
065 catch (Exception e) {
066 PortalUtil.sendError(e, request, response);
067
068 return null;
069 }
070 }
071
072 }