/*
 * $Id: SetupRepositoryAction.java,v 1.2 2004/09/20 10:26:12 koppy Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 * 
 * Created on 15.07.2004
 *
 * $Log: SetupRepositoryAction.java,v $
 * Revision 1.2  2004/09/20 10:26:12  koppy
 * +javadoc Dokumentation
 *
 * Revision 1.1  2004/08/30 14:49:57  koppy
 * Initiale Version der Workflow-Komponente
 *
 */
package vkc.workflow.web;

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.entities.VKCUser;
import vkc.util.ServletUtils;
import vkc.workflow.WorkflowServiceFactory;
import vkc.workflow.service.VKCWorkflowService;
import vkc.workflow.service.WfMConnection;
import vkc.workflow.service.manager.RepositoryManager;

/**
 * This struts action class is used
 * to set neccessary request attributes so the view component
 * can access them.
 * 
 * @author Andreas Koop
 */
public class SetupRepositoryAction extends Action {

    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        VKCUser 		user 			= ServletUtils.getUser( request );
        VKCWorkflowService wfService 	= WorkflowServiceFactory.getWorkflowService();
        RepositoryManager rep 			= wfService.getRepositoryManager();
        WfMConnection sConn				= new WfMConnection( user.getUser(), user.getClearPassword());
        
        request.setAttribute( "package.infos", rep.getPackageInfos(sConn) );
        
        return mapping.getInputForward();
    }
}
