/*
 * $Id: ShowRecentNewsFramesetAction.java,v 1.6 2006/10/04 03:15:07 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: ShowRecentNewsFramesetAction.java,v $
 * Revision 1.6  2006/10/04 03:15:07  marbobo
 * + Vollständige Unterstützung für Templates implementiert
 * + Alles von Virtoweb auf ProCoBa umgestellt
 *
 * Revision 1.5  2005/02/14 14:01:51  bigmac
 * Applikationsweites CSS konfigurierbar gemacht + Refactorings
 *
 * Revision 1.4  2004/10/28 19:44:01  marbobo
 * + Anpassung wegen Loginseite
 *
 * Revision 1.3  2004/09/05 19:18:16  marbobo
 * + Redirectanpassung ( Loginseite )
 *
 * Revision 1.2  2004/08/05 11:38:33  marbobo
 * + Richtige Sprache für den eingeloggten Benutzer setzen
 *
 * Revision 1.1  2004/07/27 19:34:52  marbobo
 * + Initiale Version
 *
 */
package vkc.news.action;

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.entities.VKCUser;
import vkc.db.serializer.VKCSysParameterSerializer;
import vkc.news.form.ShowRecentNewsFramesetForm;
import vkc.view.WebShare;

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

/**
 * Klasse zum Darstellen der aktuellen News
 *
 * @author marbobo
 */
public final class ShowRecentNewsFramesetAction extends Action {
    private ActionForward DEFAULT_FORWARD = new ActionForward( "/templates/${template.name}/news/showRecentNewsFrameset.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 {
		if ( VKCSysParameterSerializer.retrieveIntValue( "NEWS", "EnableNews", 0 ) == 0 ) {
			request.setAttribute( WebShare.INFO_KEY, "vkc.info.action_not_allowed" );
            
			return INFO_FORWARD;
		}

		ShowRecentNewsFramesetForm form = (ShowRecentNewsFramesetForm) f;

        VKCUser user = form.getUser();
        
        if ( user == null ) {
    		return new ActionForward( WebShare.getLoginPage(), true );
        }

        // Sprache wechseln
        setLocale( request, user.getLanguage().getLocale() );

        return DEFAULT_FORWARD;
        
	}
}