/*
Copyright (c) 2002, Matthias Bauer, LIVINGLOGIC AG, BAYREUTH
All rights reserved.

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are 
met:

    1. Redistributions of source code must retain the above copyright 
       notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright 
       notice, this list of conditions and the following disclaimer in the 
       documentation and/or other materials provided with the distribution.
    3. The end-user documentation included with the redistribution, if
       any, must include the following acknowlegement:
       "This product includes software developed by 
        Matthias Bauer, LIVINGLOGIC AG, BAYREUTH 
        (http://www.livinglogic.de/)."
       Alternately, this acknowlegement may appear in the software itself,
       if and wherever such third-party acknowlegements normally appear.
    4. Neither the name of Matthias Bauer, nor the LIVINGLOGIC AG nor the 
       names of the other contributors may be used to endorse or promote 
       products derived from this software without specific prior written
       permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
*/

package es.ejie.frmk.presentacion.operacion;

import java.io.IOException;

import javax.servlet.ServletException;
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 org.apache.struts.action.ActionServlet;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.config.ModuleConfig;

import es.ejie.frmk.control.excepciones.Q70GestorDeExcepciones;
import es.ejie.frmk.infraestructura.traza.Q70TraceLevel;
import es.ejie.frmk.infraestructura.traza.Q70Traza;

/**
 * The workflow request processor through which any action request is 
 * run in order to get the chance to do the workflow state checks. The 
 * logic is not implemented here, but in WorkflowRequestProcessorLogic.
 * 
 * @author M. Bauer
 * @version 1.0
 */

public class Q70ProcesadorOperacionDePresentacion extends RequestProcessor implements Q70AdaptadorLogicaOperacionDePresentacion
{
	/**
	 * Constante que indica el componente al que pertenece dicha clase. Es
	 * necesario para el uso del log de trazas.
	 */
	private static final String COMPONENTE = "OPERACION_PRESENTACION";
	
	/**
	 * Instancia del log de trazas
	 */
	private static Q70Traza tr = Q70Traza.getSingleton();
		
	/**
	 * The Q70LogicaOperacionDePresentacion instance we are using 
	 */
	Q70LogicaOperacionDePresentacion logic;
	
	public ActionServlet getServlet()
	{
		return super.servlet;
	}

	public void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward)
		throws IOException, ServletException
	{
		super.processForwardConfig(request, response, forward);
	}
	

	public HttpServletRequest processMultipart(HttpServletRequest request)
	{
		return super.processMultipart(request);
	}

	public String processPath(HttpServletRequest request, HttpServletResponse response)
		throws IOException
	{
		return super.processPath(request, response);
	}

	public void processLocale(HttpServletRequest request, HttpServletResponse response)
	{
		super.processLocale(request, response);
	}

	public void processContent(HttpServletRequest request, HttpServletResponse response)
	{
		super.processContent(request, response);
	}

	public void processNoCache(HttpServletRequest request, HttpServletResponse response)
	{
		super.processNoCache(request, response);
	}

	public boolean processPreprocess(HttpServletRequest request,HttpServletResponse response)
	{
		return super.processPreprocess(request, response);
	}

	public ActionMapping processMapping(HttpServletRequest request, HttpServletResponse response, String path)
		throws IOException
	{
		return super.processMapping(request, response, path);
	}

	public boolean processRoles(HttpServletRequest request, HttpServletResponse response,
		ActionMapping mapping) throws IOException, ServletException
	{
		return super.processRoles(request, response, mapping);
	}

	public ActionForm processActionForm(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
	{
		return super.processActionForm(request, response, mapping);
	}

	public void processPopulate(HttpServletRequest request, HttpServletResponse response,
		ActionForm form, ActionMapping mapping) throws ServletException
	{
		super.processPopulate(request, response, form, mapping);
	}

	public boolean processValidate(HttpServletRequest request, HttpServletResponse response,
		ActionForm form, ActionMapping mapping) throws IOException, ServletException
	{
		return super.processValidate(request, response, form, mapping);
	}

	public boolean processForward(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
		throws IOException, ServletException
	{
		return super.processForward(request, response, mapping);
	}

	public boolean processInclude(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
		throws IOException, ServletException
	{
		return super.processInclude(request, response, mapping);
	}

	public Action processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) 
		throws IOException
	{
		return super.processActionCreate(request, response, mapping);
	}

	public ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action,
		ActionForm form, ActionMapping mapping) throws IOException, ServletException
	{
		return super.processActionPerform(request, response, action, form, mapping);
	}

	/**
	 * <p>Process an <code>HttpServletRequest</code> and create the
	 * corresponding <code>HttpServletResponse</code>.</p>
	 *
	 * @param request The servlet request we are processing
	 * @param response The servlet response we are creating
	 *
	 * @exception IOException if an input/output error occurs
	 * @exception ServletException if a processing exception occurs
	 */
	public void process(HttpServletRequest request,
						HttpServletResponse response)
		throws IOException, ServletException
	{
		try
		{
			if (null == logic)
			{
				logic = new Q70LogicaOperacionDePresentacion(this);
			}
			if (tr.isTraceActive())
			{
				tr.trace(COMPONENTE, Q70TraceLevel.INFO, "Procesando petición.");
			}
			logic.process(request, response);
		}
		catch (Throwable t)
		{
			Q70GestorDeExcepciones.getSingleton().recogerThrowable(new Q70OperacionDePresentacionException(this.getClass().toString(),"process","Throwable recogida.",t),request,response);
		}
	}
	/**
	 * @see org.apache.struts.action.RequestProcessor#init(org.apache.struts.action.ActionServlet, org.apache.struts.config.ModuleConfig)
	 */
	public void init(ActionServlet servlet, ModuleConfig moduleConfig)
		throws ServletException
	{
		super.init(servlet, moduleConfig);
	}
	

	/**
	 * @see org.apache.struts.action.RequestProcessor#processException(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Exception, org.apache.struts.action.ActionForm, org.apache.struts.action.ActionMapping)
	 */
	protected ActionForward processException(HttpServletRequest request,HttpServletResponse response,Exception exception,ActionForm form,ActionMapping mapping)
		throws IOException, ServletException {
			
			Q70GestorDeExcepciones.getSingleton().recogerThrowable(new Q70OperacionDePresentacionException(this.getClass().toString(),"processException","Excepción capturada por el Q70ProcesadorOperacionDePresentacion.",exception),request,response);
		//return super.processException(request,response,exception,form,mapping);
		return null;
	}

}