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

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import vkc.util.StringUtils;
import vkc.view.form.BasicActionForm;

/**
 * This class represents the corresponding 
 * struts form bean used with <code>RepositoryAction</code>
 * @author Andreas Koop
 */
public class RepositoryForm extends BasicActionForm {

    private String action;
    private FormFile wfFile = null;
    
    public FormFile getWfFile() {
        return wfFile;
    }
    public void setWfFile(FormFile wfFile) {
        this.wfFile = wfFile;
    }
    
    public ActionErrors validate(ActionMapping mapping,
            HttpServletRequest request) {
        
        ActionErrors errors = new ActionErrors();
        
        if( "upload".equals(action) 
           && (wfFile == null || StringUtils.isEmpty( wfFile.getFileName())) )
            errors.add( "file.empty", new ActionError( "wf.error.file.empty" ));
        
        return errors;
    }
    
    public String getAction() {
        return action;
    }
    public void setAction(String action) {
        this.action = action;
    }
}
