use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class XBayaUtil method findEndForEachFor.
/**
* @param node
* @return
*/
public static Node findEndForEachFor(ForEachNode node) {
Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
if (toNodes.size() != 1) {
throw new WorkflowRuntimeException("ForEach output does not contain single out-edge");
}
Node middleNode = toNodes.iterator().next();
List<DataPort> outputPorts = middleNode.getOutputPorts();
for (DataPort dataPort : outputPorts) {
if (dataPort.getToNodes().size() == 1) {
Node possibleEndForEachNode = dataPort.getToNodes().get(0);
if (possibleEndForEachNode instanceof EndForEachNode) {
return possibleEndForEachNode;
}
}
}
throw new WorkflowRuntimeException("EndForEachNode not found");
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class WorkflowHarvester method removeUnnecessaryNodes.
/**
* @param pair
* @param clone
*/
private void removeUnnecessaryNodes(Node node, Port candidatePort, Workflow workflow) {
if (candidatePort.getFromPort().getEdges().size() == 1) {
Node fromNode = candidatePort.getFromNode();
try {
List<DataPort> inputPorts = fromNode.getInputPorts();
for (DataPort dataPort : inputPorts) {
removeUnnecessaryNodes(fromNode, dataPort, workflow);
}
workflow.removeNode(fromNode);
} catch (GraphException e) {
throw new WorkflowRuntimeException(e);
}
}
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class GraphUtil method propagateTypes.
/**
* @param graph
* @throws GraphException
*/
public static void propagateTypes(Graph graph) throws GraphException {
List<WSPort> wsPorts = getPorts(graph, WSPort.class);
for (WSPort wsPort : wsPorts) {
List<DataEdge> edges = wsPort.getEdges();
for (DataEdge edge : edges) {
DataPort fromPort = edge.getFromPort();
DataPort toPort = edge.getToPort();
if (fromPort == wsPort) {
toPort.copyType(wsPort);
} else if (toPort == wsPort) {
fromPort.copyType(wsPort);
} else {
throw new WorkflowRuntimeException();
}
}
}
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class JythonClassLoader method getBaseURL.
private URL getBaseURL(Class klass) {
// /d/e/f.class
String path = klass.getName().replace('.', '/').concat(".class");
URL classURL = this.parent.getResource(path);
String jarURLString;
if ("jar".equals(classURL.getProtocol())) {
// classURL = jar:file/a/b/c.jar!/d/e/f.class
// or jar:http://example.org/a/b/c.jar!/d/e/f.class
String file = classURL.getFile();
// file = file:/a/b/c.jar!d/e/f.class
// or http://example.org/a/b/c.jar!d/e/f.class
logger.debug("file: " + file);
jarURLString = file.substring(0, file.lastIndexOf('!'));
// jarURLString = file:/a/b/c.jar
// or http://example.org/a/b/c.jar
} else {
// file:/a/b/c/d/e/f.class
// /a/b/c/d/e/f.class
String file = classURL.getFile();
int index = file.lastIndexOf(path);
// /a/b/c/
jarURLString = "file:" + file.substring(0, index);
}
try {
URL jarURL = new URL(jarURLString);
return jarURL;
} catch (MalformedURLException e) {
throw new WorkflowRuntimeException(e);
}
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class JythonClassLoader method maybeGetJarFile.
private JarFile maybeGetJarFile(URL url) {
String path;
try {
path = URLDecoder.decode(url.getPath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new WorkflowRuntimeException(e);
}
logger.debug("path: " + path);
if (path.endsWith("/")) {
// It's a local directory
return null;
} else if ("file".equals(url.getProtocol())) {
// Jar file
try {
JarFile jarFile = new JarFile(path);
return jarFile;
} catch (IOException e) {
throw new WorkflowRuntimeException(e);
}
} else {
// A Jar file
try {
if (this.tmpJarDirectory == null) {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HHmmss-S");
String time = format.format(date);
String fileName = ".xbaya-jars-" + time;
String tmpdir = System.getProperty("java.io.tmpdir");
this.tmpJarDirectory = new File(tmpdir, fileName);
this.tmpJarDirectory.mkdir();
}
int i = path.lastIndexOf('/');
File file = new File(this.tmpJarDirectory, path.substring(i + 1));
logger.debug("file: " + file);
InputStream stream = url.openStream();
IOUtil.writeToFile(stream, file);
JarFile jarFile = new JarFile(file);
return jarFile;
} catch (IOException e) {
throw new WorkflowRuntimeException(e);
}
}
}
Aggregations