001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.bookmarks.action;
016    
017    import com.liferay.portal.kernel.util.ParamUtil;
018    import com.liferay.portal.struts.ActionConstants;
019    import com.liferay.portal.util.PortalUtil;
020    import com.liferay.portal.util.WebKeys;
021    import com.liferay.portlet.bookmarks.model.BookmarksEntry;
022    import com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil;
023    
024    import javax.servlet.http.HttpServletRequest;
025    import javax.servlet.http.HttpServletResponse;
026    
027    import org.apache.struts.action.Action;
028    import org.apache.struts.action.ActionForm;
029    import org.apache.struts.action.ActionForward;
030    import org.apache.struts.action.ActionMapping;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     */
035    public class OpenEntryAction extends Action {
036    
037            @Override
038            public ActionForward execute(
039                            ActionMapping mapping, ActionForm form, HttpServletRequest request,
040                            HttpServletResponse response)
041                    throws Exception {
042    
043                    try {
044                            long entryId = ParamUtil.getLong(request, "entryId");
045    
046                            BookmarksEntry entry =
047                                    BookmarksEntryServiceUtil.openEntry(entryId);
048    
049                            request.setAttribute(WebKeys.FORWARD_URL, entry.getUrl());
050    
051                            return mapping.findForward(ActionConstants.COMMON_FORWARD);
052                    }
053                    catch (Exception e) {
054                            PortalUtil.sendError(e, request, response);
055    
056                            return null;
057                    }
058            }
059    
060    }