001    /**
002     * Copyright (c) 2000-2010 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.journalarticles.action;
016    
017    import com.liferay.portal.NoSuchGroupException;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.service.GroupLocalServiceUtil;
021    import com.liferay.portlet.journalcontent.action.WebContentAction;
022    
023    import javax.portlet.PortletConfig;
024    import javax.portlet.PortletPreferences;
025    import javax.portlet.RenderRequest;
026    import javax.portlet.RenderResponse;
027    
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     * @author Raymond Augé
035     */
036    public class ViewAction extends WebContentAction {
037    
038            public ActionForward render(
039                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
040                            RenderRequest renderRequest, RenderResponse renderResponse)
041                    throws Exception {
042    
043                    try {
044                            PortletPreferences preferences = renderRequest.getPreferences();
045    
046                            long groupId = GetterUtil.getLong(
047                                    preferences.getValue("group-id", StringPool.BLANK));
048    
049                            GroupLocalServiceUtil.getGroup(groupId);
050    
051                            return mapping.findForward("portlet.journal_articles.view");
052                    }
053                    catch (NoSuchGroupException nsge) {
054                            return mapping.findForward("/portal/portlet_not_setup");
055                    }
056            }
057    
058    }