/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: Submitter.java 2062 2006-12-12 14:22:10Z drmlipp $
*
* $Log$
* Revision 1.4.4.10 2006/12/11 13:30:19 drmlipp
* Continued with result delivery.
*
* Revision 1.4.4.9 2006/12/08 08:51:43 drmlipp
* Moved generation of xforms:instance node to XForm.
*
* Revision 1.4.4.8 2006/12/07 23:17:13 mlipp
* Restructured XForm component's properties.
*
* Revision 1.4.4.7 2006/12/07 14:34:12 drmlipp
* More prefix mapping fixes.
*
* Revision 1.4.4.6 2006/12/06 22:36:11 mlipp
* Added required prefix mapping events.
*
* Revision 1.4.4.5 2006/12/06 22:16:01 mlipp
* Added prefix mapping events.
*
* Revision 1.4.4.4 2006/12/06 12:54:15 drmlipp
* Added missing model end.
*
* Revision 1.4.4.3 2006/12/06 11:49:27 drmlipp
* Initial functional version of Submitter.
*
* Revision 1.4.4.2 2006/12/05 16:38:42 drmlipp
* Continuing.
*
* Revision 1.4.4.1 2006/12/05 14:18:16 drmlipp
* Cleaned imports.
*
* Revision 1.4 2006/09/29 12:32:13 drmlipp
* Consistently using WfMOpen as projct name now.
*
* Revision 1.3 2006/09/22 08:36:27 drmlipp
* Added check for assignee.
*
* Revision 1.2 2006/09/21 15:02:31 drmlipp
* Continuing implementation.
*
* Revision 1.1 2005/11/18 15:41:43 drmlipp
* New XForms client started.
*
* Revision 1.2 2004/12/20 22:21:51 drmlipp
* Updated JNDI names.
*
* Revision 1.1.1.1 2003/06/30 20:05:12 drmlipp
* Initial import
*
* Revision 1.20 2003/06/27 08:51:46 lipp
* Fixed copyright/license information.
*
* Revision 1.19 2003/05/06 13:21:29 lipp
* Resolved cyclic dependency.
*
* Revision 1.18 2003/03/31 16:50:28 huaiyang
* Logging using common-logging.
*
* Revision 1.17 2003/02/12 16:13:16 lipp
* Improved deadlock (RemoteException) handling for tools. Imroved debug
* information.
*
* Revision 1.16 2003/02/12 11:57:30 lipp
* Improved deadlock (RemoteException) handling for tools. Imroved debug
* information.
*
* Revision 1.15 2002/12/19 21:37:43 lipp
* Reorganized interfaces.
*
* Revision 1.14 2002/10/30 16:17:53 lipp
* Getting on with WebForm.
*
* Revision 1.13 2002/10/25 14:31:32 lipp
* xform info included in XML
*
* Revision 1.12 2002/10/25 09:20:51 lipp
* Storing form data now.
*
* Revision 1.11 2002/10/24 14:25:11 lipp
* Added form attribute to submitter.
*
* Revision 1.10 2002/10/06 20:14:38 lipp
* Updated argument handling.
*
* Revision 1.9 2002/10/02 10:58:13 lipp
* Modifications for tool invocation.
*
* Revision 1.8 2002/09/17 09:20:12 lipp
* Added ApplicationNotStoppedException.
*
* Revision 1.7 2002/08/16 07:59:42 huaiyang
* Use ActivityDirectoryEJB instead of SubmitServiceEJB.
*
* Revision 1.6 2002/05/21 13:24:57 huaiyang
* Implements the method of terminate.
*
* Revision 1.5 2002/05/17 12:52:34 lipp
* Cleaned up interface to tools.
*
* Revision 1.4 2002/05/17 08:34:21 lipp
* Renamed aii/Application to aii/ToolAgent.
*
* Revision 1.3 2002/05/08 13:34:15 lipp
* New method cancel.
*
* Revision 1.2 2002/02/04 15:55:46 huaiyang
* Implement the method of execute.
*
* Revision 1.1 2002/01/31 15:33:43 huaiyang
* Initial version of a client stub for the standalone application webform.
*
*
*/
package de.danet.an.xformstool;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.rmi.RemoteException;
import de.danet.an.workflow.api.Activity;
import de.danet.an.workflow.api.FormalParameter;
import de.danet.an.workflow.api.SAXEventBuffer;
import de.danet.an.workflow.spis.aii.CannotExecuteException;
import de.danet.an.workflow.spis.aii.ContextRequester;
import de.danet.an.workflow.spis.aii.ToolAgentContext;
import de.danet.an.workflow.spis.aii.XMLArgumentTypeProvider;
import de.danet.an.workflow.tools.util.SimpleApplicationAgent;
/**
* This class serves as the implementation for the application WebForm
*/
public class Submitter extends SimpleApplicationAgent
implements XMLArgumentTypeProvider, ContextRequester, Serializable {
private static final org.apache.commons.logging.Log logger
= org.apache.commons.logging.LogFactory.getLog(Submitter.class);
public static final String APPLICATION_NAME = "de.danet.an.xformstool";
/** The form definition. */
private SAXEventBuffer form;
/** The invocation context. */
private ToolAgentContext context = null;
/* (non-Javadoc)
* @see de.danet.an.workflow.spis.aii.ContextRequester#setToolAgentContext(de.danet.an.workflow.spis.aii.ToolAgentContext)
*/
public void setToolAgentContext(ToolAgentContext context) {
this.context = context;
}
/**
* Set the value of form.
* @param newForm value to assign to form.
* @see #getForm
*/
public void setForm(SAXEventBuffer newForm) {
this.form = newForm;
if (logger.isDebugEnabled()) {
logger.debug ("Form set to:\n" + form.toString());
}
}
/**
* Executes the given activity.
*
* @param activity the activity to be executed. The supplied object
* must be serializable in order to support applications running as
* servers.
* @param formalParameters the formal parameter list as specified in the
* process definition.
* @param actualParameters the actual parameters of the application
* invocation. The map and the objects contained in the map
* must be serializable in order to support applications running as
* servers.
* @throws CannotExecuteException if execution is not possible.
* @throws RemoteException if a temporary problem occurs and the
* workflow engine should retry the tool invocation. (Usually
* thrown when a deadlock situation occurs while accessing the
* activity.)
*/
public void invoke (Activity activity, FormalParameter[] formalParameters,
Map actualParameters)
throws CannotExecuteException, RemoteException {
if (logger.isDebugEnabled()) {
logger.debug("Called for " + activity);
}
// Verify that we have an assignee (else this won't show up)
Collection actAssgnmts = activity.assignments();
if (actAssgnmts == null || actAssgnmts.size() == 0) {
throw new CannotExecuteException
(activity.toString () + " has no assignee.");
}
Object[] data = new Object[] {
context.applicationId(), form,
formalParameters, actualParameters
};
applicationDirectory()
.registerInstance (APPLICATION_NAME, activity, data, true);
}
/* (non-Javadoc)
* @see de.danet.an.workflow.spis.aii.XMLArgumentTypeProvider#requestedXMLArgumentType()
*/
public int requestedXMLArgumentType() {
return XMLArgumentTypeProvider.XML_AS_SAX;
}
}