package org.syrup.functions;
import org.syrup.Context;
import org.syrup.Data;
import org.syrup.Function;
import org.syrup.Result;
import org.syrup.helpers.DataImpl;
import org.syrup.helpers.NetworkImpl;
import org.syrup.helpers.NetworkParser;
import org.syrup.helpers.ResultImpl;
import org.syrup.helpers.Utils;
import org.syrup.helpers.WorkflowImpl;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.logging.Logger;
/**
* Takes a XML Workflow description and returns a WorkFlow.
*
* @author Robbert van Dalen
*/
public class Launch implements Function
{
static final String COPYRIGHT = "Copyright 2005 Robbert van Dalen."
+ "At your option, you may copy, distribute, or make derivative works under "
+ "the terms of The Artistic License. This License may be found at "
+ "http://www.opensource.org/licenses/artistic-license.php. "
+ "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK.";
private final static Logger logger = Logger.getLogger("org.syrup.functions.Launch");
/**
*/
public Result execute(Context context)
{
try
{
if (Utils.isFull(context.in_1_link()))
{
Data d = context.in_1_link().content();
// Parses first input.
NetworkImpl i = new NetworkParser().parse(d.bytes());
ResultImpl r = new ResultImpl(context, true, false, null, null);
// Returns the Workflow.
WorkflowImpl impl = new WorkflowImpl(r, i);
Utils.validate(impl);
return impl;
}
else
{
throw new Exception("first input is mandatory");
}
}
catch (Throwable e)
{
return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e, "Launch error"));
}
}
}