001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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            @Override
039            public ActionForward render(
040                            ActionMapping actionMapping, ActionForm actionForm,
041                            PortletConfig portletConfig, RenderRequest renderRequest,
042                            RenderResponse renderResponse)
043                    throws Exception {
044    
045                    try {
046                            PortletPreferences preferences = renderRequest.getPreferences();
047    
048                            long groupId = GetterUtil.getLong(
049                                    preferences.getValue("groupId", StringPool.BLANK));
050    
051                            GroupLocalServiceUtil.getGroup(groupId);
052    
053                            return actionMapping.findForward("portlet.journal_articles.view");
054                    }
055                    catch (NoSuchGroupException nsge) {
056                            return actionMapping.findForward("/portal/portlet_not_setup");
057                    }
058            }
059    
060    }