01: package org.syrup.functions;
02:
03: import org.syrup.Context;
04: import org.syrup.Data;
05: import org.syrup.Function;
06: import org.syrup.Result;
07: import org.syrup.helpers.DataImpl;
08: import org.syrup.helpers.NetworkImpl;
09: import org.syrup.helpers.NetworkParser;
10: import org.syrup.helpers.ResultImpl;
11: import org.syrup.helpers.Utils;
12: import org.syrup.helpers.WorkflowImpl;
13:
14: import java.io.ByteArrayOutputStream;
15: import java.io.PrintStream;
16: import java.util.logging.Logger;
17:
18: /**
19: * Takes a XML Workflow description and returns a WorkFlow.
20: *
21: * @author Robbert van Dalen
22: */
23: public class Launch implements Function {
24: static final String COPYRIGHT = "Copyright 2005 Robbert van Dalen."
25: + "At your option, you may copy, distribute, or make derivative works under "
26: + "the terms of The Artistic License. This License may be found at "
27: + "http://www.opensource.org/licenses/artistic-license.php. "
28: + "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK.";
29:
30: private final static Logger logger = Logger
31: .getLogger("org.syrup.functions.Launch");
32:
33: /**
34: */
35: public Result execute(Context context) {
36: try {
37: if (Utils.isFull(context.in_1_link())) {
38: Data d = context.in_1_link().content();
39: // Parses first input.
40: NetworkImpl i = new NetworkParser().parse(d.bytes());
41: ResultImpl r = new ResultImpl(context, true, false,
42: null, null);
43: // Returns the Workflow.
44: WorkflowImpl impl = new WorkflowImpl(r, i);
45: Utils.validate(impl);
46: return impl;
47: } else {
48: throw new Exception("first input is mandatory");
49: }
50: } catch (Throwable e) {
51: return new ResultImpl(context, true, true, null,
52: org.syrup.helpers.Utils.manageError(logger, e,
53: "Launch error"));
54: }
55: }
56: }
|