001: /*
002: * ====================================================================
003: *
004: * XFLOW - Process Management System
005: * Copyright (C) 2003 Rob Tan
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions, and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions, and the disclaimer that follows
017: * these conditions in the documentation and/or other materials
018: * provided with the distribution.
019: *
020: * 3. The name "XFlow" must not be used to endorse or promote products
021: * derived from this software without prior written permission. For
022: * written permission, please contact rcktan@yahoo.com
023: *
024: * 4. Products derived from this software may not be called "XFlow", nor
025: * may "XFlow" appear in their name, without prior written permission
026: * from the XFlow Project Management (rcktan@yahoo.com)
027: *
028: * In addition, we request (but do not require) that you include in the
029: * end-user documentation provided with the redistribution and/or in the
030: * software itself an acknowledgement equivalent to the following:
031: * "This product includes software developed by the
032: * XFlow Project (http://xflow.sourceforge.net/)."
033: * Alternatively, the acknowledgment may be graphical using the logos
034: * available at http://xflow.sourceforge.net/
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE XFLOW AUTHORS OR THE PROJECT
040: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: *
049: * ====================================================================
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the XFlow Project and was originally
052: * created by Rob Tan (rcktan@yahoo.com)
053: * For more information on the XFlow Project, please see:
054: * <http://xflow.sourceforge.net/>.
055: * ====================================================================
056: */
057:
058: package xflow.webservice;
059:
060: import xflow.common.*;
061: import xflow.security.*;
062: import xflow.client.*;
063: import java.util.*;
064:
065: public class XflowService {
066:
067: public WorkflowId startWorkflow(String workflowName, int version,
068: WorkItem witem, User user) {
069: WorkflowId wfId = null;
070: try {
071: System.out.println("**** workflowName: " + workflowName);
072: System.out.println("**** version: " + version);
073: System.out.println("**** workitem: " + witem);
074: System.out.println("**** user: " + user);
075: if (version == -1) {
076: wfId = WorkflowManager.startWorkflow(workflowName,
077: witem, user);
078: } else {
079: wfId = WorkflowManager.startWorkflow(workflowName,
080: version, witem, user);
081: }
082: System.out.println("Workflow Started");
083: } catch (XflowException e) {
084: // TBD Throw SOAP exception
085: e.printStackTrace();
086: }
087:
088: return wfId;
089: }
090:
091: public void abortWorkflow(int workflowId, User user) {
092:
093: System.out.println("Aborting workflow");
094: try {
095: WorkflowManager.abortWorkflow(new WorkflowId(workflowId),
096: user);
097: System.out.println("Workflow Aborted");
098: } catch (XflowException e) {
099: // TBD Throw SOAP exception
100: e.printStackTrace();
101: }
102: }
103:
104: public WorkflowState getWorkflowState(int workflowId, User user) {
105: try {
106: return WorkflowManager.getWorkflowState(new WorkflowId(
107: workflowId), user);
108: } catch (XflowException e) {
109: // TBD Throw SOAP exception
110: e.printStackTrace();
111: return null;
112: }
113: }
114:
115: public void setVariable(int workflowId, String variableName,
116: Object variableValue, User user) {
117: try {
118: WorkflowManager.setVariable(new WorkflowId(workflowId),
119: variableName, variableValue, user);
120: } catch (XflowException e) {
121: // TBD Throw SOAP exception
122: e.printStackTrace();
123: }
124: }
125:
126: public Object getVariable(int workflowId, String variableName,
127: User user) {
128: try {
129: return WorkflowManager.getVariable(new WorkflowId(
130: workflowId), variableName, user);
131: } catch (XflowException e) {
132: // TBD Throw SOAP exception
133: e.printStackTrace();
134: return "ERROR";
135: }
136: }
137:
138: public Vector getActiveWorkflows(User user) {
139: try {
140: return WorkflowManager.getActiveWorkflows(user);
141: } catch (XflowException e) {
142: // TBD Throw SOAP exception
143: e.printStackTrace();
144: return null;
145: }
146: }
147:
148: public void deployModel(String xml, String type, User user) {
149: try {
150: WorkflowManager.deployModel(xml, type, user);
151: } catch (XflowException e) {
152: // TBD Throw SOAP exception
153: e.printStackTrace();
154: }
155: }
156:
157: public Vector getWorkItems(String wfName, String processName,
158: User user) {
159: Vector v = null;
160: try {
161: WorkflowProcess wfp = new WorkflowProcess(wfName, -1,
162: processName, null, user);
163: v = wfp.getWorkItems();
164: } catch (XflowException e) {
165: // TBD Throw SOAP exception
166: e.printStackTrace();
167: }
168: return v;
169: }
170:
171: public WorkItem getNextWorkItem(String wfName, String processName,
172: User user) {
173: WorkItem wi = null;
174: try {
175: WorkflowProcess wfp = new WorkflowProcess(wfName, -1,
176: processName, null, user);
177: wi = wfp.getNextWorkItem();
178: } catch (XflowException e) {
179: // TBD Throw SOAP exception
180: e.printStackTrace();
181: }
182: return wi;
183: }
184:
185: public WorkItem getWorkItem(String wfName, String processName,
186: int id, User user) {
187: WorkItem wi = null;
188: try {
189: WorkflowProcess wfp = new WorkflowProcess(wfName, -1,
190: processName, null, user);
191: wi = wfp.getWorkItem(new WorkItemId(id));
192: } catch (XflowException e) {
193: // TBD Throw SOAP exception
194: e.printStackTrace();
195: }
196: return wi;
197: }
198:
199: public void completeWorkItem(String wfName, String processName,
200: WorkItem witem, User user) {
201: try {
202: WorkflowProcess wfp = new WorkflowProcess(wfName, -1,
203: processName, null, user);
204: wfp.completeWorkItem(witem);
205: } catch (XflowException e) {
206: // TBD Throw SOAP exception
207: e.printStackTrace();
208: }
209: }
210:
211: public String xxx() {
212: return "XXX";
213: }
214:
215: public Vector yyy() {
216: Vector v = new Vector();
217: v.addElement("aaa");
218: v.addElement("bbb");
219: return v;
220: }
221:
222: }
|