001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: Submitter.java,v 1.5 2006/12/12 14:22:10 drmlipp Exp $
021: *
022: * $Log: Submitter.java,v $
023: * Revision 1.5 2006/12/12 14:22:10 drmlipp
024: * Merged XForms client from branch.
025: *
026: * Revision 1.4.4.10 2006/12/11 13:30:19 drmlipp
027: * Continued with result delivery.
028: *
029: * Revision 1.4.4.9 2006/12/08 08:51:43 drmlipp
030: * Moved generation of xforms:instance node to XForm.
031: *
032: * Revision 1.4.4.8 2006/12/07 23:17:13 mlipp
033: * Restructured XForm component's properties.
034: *
035: * Revision 1.4.4.7 2006/12/07 14:34:12 drmlipp
036: * More prefix mapping fixes.
037: *
038: * Revision 1.4.4.6 2006/12/06 22:36:11 mlipp
039: * Added required prefix mapping events.
040: *
041: * Revision 1.4.4.5 2006/12/06 22:16:01 mlipp
042: * Added prefix mapping events.
043: *
044: * Revision 1.4.4.4 2006/12/06 12:54:15 drmlipp
045: * Added missing model end.
046: *
047: * Revision 1.4.4.3 2006/12/06 11:49:27 drmlipp
048: * Initial functional version of Submitter.
049: *
050: * Revision 1.4.4.2 2006/12/05 16:38:42 drmlipp
051: * Continuing.
052: *
053: * Revision 1.4.4.1 2006/12/05 14:18:16 drmlipp
054: * Cleaned imports.
055: *
056: * Revision 1.4 2006/09/29 12:32:13 drmlipp
057: * Consistently using WfMOpen as projct name now.
058: *
059: * Revision 1.3 2006/09/22 08:36:27 drmlipp
060: * Added check for assignee.
061: *
062: * Revision 1.2 2006/09/21 15:02:31 drmlipp
063: * Continuing implementation.
064: *
065: * Revision 1.1 2005/11/18 15:41:43 drmlipp
066: * New XForms client started.
067: *
068: * Revision 1.2 2004/12/20 22:21:51 drmlipp
069: * Updated JNDI names.
070: *
071: * Revision 1.1.1.1 2003/06/30 20:05:12 drmlipp
072: * Initial import
073: *
074: * Revision 1.20 2003/06/27 08:51:46 lipp
075: * Fixed copyright/license information.
076: *
077: * Revision 1.19 2003/05/06 13:21:29 lipp
078: * Resolved cyclic dependency.
079: *
080: * Revision 1.18 2003/03/31 16:50:28 huaiyang
081: * Logging using common-logging.
082: *
083: * Revision 1.17 2003/02/12 16:13:16 lipp
084: * Improved deadlock (RemoteException) handling for tools. Imroved debug
085: * information.
086: *
087: * Revision 1.16 2003/02/12 11:57:30 lipp
088: * Improved deadlock (RemoteException) handling for tools. Imroved debug
089: * information.
090: *
091: * Revision 1.15 2002/12/19 21:37:43 lipp
092: * Reorganized interfaces.
093: *
094: * Revision 1.14 2002/10/30 16:17:53 lipp
095: * Getting on with WebForm.
096: *
097: * Revision 1.13 2002/10/25 14:31:32 lipp
098: * xform info included in XML
099: *
100: * Revision 1.12 2002/10/25 09:20:51 lipp
101: * Storing form data now.
102: *
103: * Revision 1.11 2002/10/24 14:25:11 lipp
104: * Added form attribute to submitter.
105: *
106: * Revision 1.10 2002/10/06 20:14:38 lipp
107: * Updated argument handling.
108: *
109: * Revision 1.9 2002/10/02 10:58:13 lipp
110: * Modifications for tool invocation.
111: *
112: * Revision 1.8 2002/09/17 09:20:12 lipp
113: * Added ApplicationNotStoppedException.
114: *
115: * Revision 1.7 2002/08/16 07:59:42 huaiyang
116: * Use ActivityDirectoryEJB instead of SubmitServiceEJB.
117: *
118: * Revision 1.6 2002/05/21 13:24:57 huaiyang
119: * Implements the method of terminate.
120: *
121: * Revision 1.5 2002/05/17 12:52:34 lipp
122: * Cleaned up interface to tools.
123: *
124: * Revision 1.4 2002/05/17 08:34:21 lipp
125: * Renamed aii/Application to aii/ToolAgent.
126: *
127: * Revision 1.3 2002/05/08 13:34:15 lipp
128: * New method cancel.
129: *
130: * Revision 1.2 2002/02/04 15:55:46 huaiyang
131: * Implement the method of execute.
132: *
133: * Revision 1.1 2002/01/31 15:33:43 huaiyang
134: * Initial version of a client stub for the standalone application webform.
135: *
136: *
137: */
138: package de.danet.an.xformstool;
139:
140: import java.io.Serializable;
141:
142: import java.util.Collection;
143: import java.util.Map;
144:
145: import java.rmi.RemoteException;
146:
147: import de.danet.an.workflow.api.Activity;
148: import de.danet.an.workflow.api.FormalParameter;
149: import de.danet.an.workflow.api.SAXEventBuffer;
150:
151: import de.danet.an.workflow.spis.aii.CannotExecuteException;
152: import de.danet.an.workflow.spis.aii.ContextRequester;
153: import de.danet.an.workflow.spis.aii.ToolAgentContext;
154: import de.danet.an.workflow.spis.aii.XMLArgumentTypeProvider;
155: import de.danet.an.workflow.tools.util.SimpleApplicationAgent;
156:
157: /**
158: * This class serves as the implementation for the application WebForm
159: */
160: public class Submitter extends SimpleApplicationAgent implements
161: XMLArgumentTypeProvider, ContextRequester, Serializable {
162:
163: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
164: .getLog(Submitter.class);
165:
166: public static final String APPLICATION_NAME = "de.danet.an.xformstool";
167:
168: /** The form definition. */
169: private SAXEventBuffer form;
170:
171: /** The invocation context. */
172: private ToolAgentContext context = null;
173:
174: /* (non-Javadoc)
175: * @see de.danet.an.workflow.spis.aii.ContextRequester#setToolAgentContext(de.danet.an.workflow.spis.aii.ToolAgentContext)
176: */
177: public void setToolAgentContext(ToolAgentContext context) {
178: this .context = context;
179: }
180:
181: /**
182: * Set the value of form.
183: * @param newForm value to assign to form.
184: * @see #getForm
185: */
186: public void setForm(SAXEventBuffer newForm) {
187: this .form = newForm;
188: if (logger.isDebugEnabled()) {
189: logger.debug("Form set to:\n" + form.toString());
190: }
191: }
192:
193: /**
194: * Executes the given activity.
195: *
196: * @param activity the activity to be executed. The supplied object
197: * must be serializable in order to support applications running as
198: * servers.
199: * @param formalParameters the formal parameter list as specified in the
200: * process definition.
201: * @param actualParameters the actual parameters of the application
202: * invocation. The map and the objects contained in the map
203: * must be serializable in order to support applications running as
204: * servers.
205: * @throws CannotExecuteException if execution is not possible.
206: * @throws RemoteException if a temporary problem occurs and the
207: * workflow engine should retry the tool invocation. (Usually
208: * thrown when a deadlock situation occurs while accessing the
209: * activity.)
210: */
211: public void invoke(Activity activity,
212: FormalParameter[] formalParameters, Map actualParameters)
213: throws CannotExecuteException, RemoteException {
214: if (logger.isDebugEnabled()) {
215: logger.debug("Called for " + activity);
216: }
217:
218: // Verify that we have an assignee (else this won't show up)
219: Collection actAssgnmts = activity.assignments();
220: if (actAssgnmts == null || actAssgnmts.size() == 0) {
221: throw new CannotExecuteException(activity.toString()
222: + " has no assignee.");
223: }
224:
225: Object[] data = new Object[] { context.applicationId(), form,
226: formalParameters, actualParameters };
227: applicationDirectory().registerInstance(APPLICATION_NAME,
228: activity, data, true);
229: }
230:
231: /* (non-Javadoc)
232: * @see de.danet.an.workflow.spis.aii.XMLArgumentTypeProvider#requestedXMLArgumentType()
233: */
234: public int requestedXMLArgumentType() {
235: return XMLArgumentTypeProvider.XML_AS_SAX;
236: }
237: }
|