/*
 * $Id: ShowNewsAction.java,v 1.5 2006/10/04 03:15:07 marbobo Exp $
 * 
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 * 
 * $Log: ShowNewsAction.java,v $
 * Revision 1.5  2006/10/04 03:15:07  marbobo
 * + Vollständige Unterstützung für Templates implementiert
 * + Alles von Virtoweb auf ProCoBa umgestellt
 *
 * Revision 1.4  2005/02/14 14:01:51  bigmac
 * Applikationsweites CSS konfigurierbar gemacht + Refactorings
 *
 * Revision 1.3  2004/11/02 21:42:31  marbobo
 * + Einige Funktionen für Gast-Benutzer gesperrt
 * + WebShare.LOGIN_PAGE mit WebShare.getLoginPage() ersetzt
 *
 * Revision 1.2  2004/07/26 13:31:16  marbobo
 * + Umgeschrieben
 *
 * Revision 1.1  2004/07/26 12:40:54  marbobo
 * + Nack vkc.news verschoben
 */
package vkc.news.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import vkc.db.serializer.VKCSysParameterSerializer;
import vkc.news.form.ShowNewsForm;
import vkc.view.WebShare;

public class ShowNewsAction extends Action {
    private ActionForward DEFAULT_FORWARD = new ActionForward( "/templates/${template.name}/news/showNews.jsp" );

    private ActionForward INFO_FORWARD = 
		new ActionForward( "/templates/${template.name}/common/InfoPage.jsp" );

	public ActionForward execute( ActionMapping mapping,
								  ActionForm f,
								  HttpServletRequest request,
								  HttpServletResponse response )
	throws Exception {
		ShowNewsForm form = (ShowNewsForm)f;

		if ( VKCSysParameterSerializer.retrieveIntValue( "NEWS", "EnableNews", 0 ) == 0 ) {
			request.setAttribute( WebShare.INFO_KEY, "vkc.info.action_not_allowed" );
            
			return INFO_FORWARD;
		}

		if ( form.getUser().isGuestUser() ) {
			request.setAttribute( WebShare.INFO_KEY, "vkc.info.access_denied" );
			
			return INFO_FORWARD;
		}

		return handleInitializeAction( form, request );
	}
	
	private ActionForward handleInitializeAction( ShowNewsForm form, HttpServletRequest request ) {
		return DEFAULT_FORWARD;
	}
}