OODT-909 create improved exceptions
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/11e28571 Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/11e28571 Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/11e28571 Branch: refs/heads/master Commit: 11e28571225a883ecb2afe66f64941e2dc91112f Parents: c364b7b Author: Tom Barber <[email protected]> Authored: Tue Oct 27 20:40:58 2015 +0000 Committer: Tom Barber <[email protected]> Committed: Tue Oct 27 20:40:58 2015 +0000 ---------------------------------------------------------------------- .../processor/WorkflowProcessorHelper.java | 16 +- .../workflow/exceptions/WorkflowException.java | 11 + ...SourceWorkflowInstanceRepositoryFactory.java | 14 +- .../WorkflowInstanceMetadataReader.java | 19 +- .../lifecycle/WorkflowLifecyclesReader.java | 19 +- .../DataSourceWorkflowRepositoryFactory.java | 9 +- .../repository/PackagedWorkflowRepository.java | 44 ++- .../apache/oodt/cas/workflow/structs/Graph.java | 17 +- .../workflow/system/XmlRpcWorkflowManager.java | 10 +- .../system/XmlRpcWorkflowManagerClient.java | 357 +++++-------------- .../cas/workflow/tools/InstanceRepoCleaner.java | 23 +- .../cas/workflow/util/CygwinScriptFile.java | 6 +- .../oodt/cas/workflow/util/ScriptFile.java | 15 +- .../cas/workflow/util/XmlStructFactory.java | 32 +- 14 files changed, 230 insertions(+), 362 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessorHelper.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessorHelper.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessorHelper.java index 2955d27..29a6743 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessorHelper.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessorHelper.java @@ -17,24 +17,24 @@ package org.apache.oodt.cas.workflow.engine.processor; //OODT imports -import org.apache.oodt.commons.exec.ExecHelper; +import org.apache.commons.lang.StringUtils; import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycle; +import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager; import org.apache.oodt.cas.workflow.structs.Graph; +import org.apache.oodt.cas.workflow.structs.ParentChildWorkflow; import org.apache.oodt.cas.workflow.structs.Priority; import org.apache.oodt.cas.workflow.structs.WorkflowCondition; -import org.apache.oodt.cas.workflow.structs.ParentChildWorkflow; import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance; -import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycle; -import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager; +import org.apache.oodt.commons.exec.ExecHelper; -//JDK imports import java.net.InetAddress; import java.util.List; import java.util.Map; import java.util.Vector; +//JDK imports //APACHE imports -import org.apache.commons.lang.StringUtils; /** * @@ -131,7 +131,7 @@ public class WorkflowProcessorHelper { public WorkflowProcessor buildProcessor(String instanceId, ParentChildWorkflow workflow, Map<String, Class<? extends WorkflowProcessor>> modelToProcessorMap, - boolean preCond) throws Exception { + boolean preCond) throws InstantiationException, IllegalAccessException, ClassNotFoundException { List<WorkflowProcessor> subProcessors = new Vector<WorkflowProcessor>(); List<WorkflowCondition> conditions = preCond ? workflow.getPreConditions() : workflow.getPostConditions(); @@ -151,7 +151,7 @@ public class WorkflowProcessorHelper { public WorkflowProcessor buildProcessor(String instanceId, ParentChildWorkflow model, boolean isCondition, Map<String, Class<? extends WorkflowProcessor>> modelToProcessorMap) - throws Exception { + throws IllegalAccessException, InstantiationException, ClassNotFoundException { WorkflowProcessor wp = modelToProcessorMap.get( model.getGraph().getExecutionType()).newInstance(); WorkflowLifecycle wLifecycle = getLifecycle(model); http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/exceptions/WorkflowException.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/exceptions/WorkflowException.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/exceptions/WorkflowException.java new file mode 100644 index 0000000..308c5ad --- /dev/null +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/exceptions/WorkflowException.java @@ -0,0 +1,11 @@ +package org.apache.oodt.cas.workflow.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class WorkflowException extends Exception { + + public WorkflowException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java index f814922..caf68ad 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java @@ -19,20 +19,20 @@ package org.apache.oodt.cas.workflow.instrepo; //OODT imports -import org.apache.oodt.cas.metadata.util.PathUtils; -import org.apache.oodt.cas.workflow.instrepo.WorkflowInstanceRepository; -import org.apache.oodt.cas.workflow.instrepo.WorkflowInstanceRepositoryFactory; -//APACHE imports import org.apache.commons.dbcp.ConnectionFactory; import org.apache.commons.dbcp.DriverManagerConnectionFactory; import org.apache.commons.dbcp.PoolableConnectionFactory; import org.apache.commons.dbcp.PoolingDataSource; import org.apache.commons.pool.impl.GenericObjectPool; +import org.apache.oodt.cas.metadata.util.PathUtils; +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; -//JDK imports import javax.sql.DataSource; +//APACHE imports +//JDK imports + /** * @author mattmann * @version $Revision$ @@ -60,7 +60,7 @@ public class DataSourceWorkflowInstanceRepositoryFactory implements * Default constructor * </p> */ - public DataSourceWorkflowInstanceRepositoryFactory() throws Exception { + public DataSourceWorkflowInstanceRepositoryFactory() throws WorkflowException { String jdbcUrl, user, pass, driver; jdbcUrl = PathUtils @@ -79,7 +79,7 @@ public class DataSourceWorkflowInstanceRepositoryFactory implements try { Class.forName(driver); } catch (ClassNotFoundException e) { - throw new Exception("Cannot load driver: " + driver); + throw new WorkflowException("Cannot load driver: " + driver); } GenericObjectPool connectionPool = new GenericObjectPool(null); http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/WorkflowInstanceMetadataReader.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/WorkflowInstanceMetadataReader.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/WorkflowInstanceMetadataReader.java index 8f1efe5..406846b 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/WorkflowInstanceMetadataReader.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/WorkflowInstanceMetadataReader.java @@ -19,9 +19,15 @@ package org.apache.oodt.cas.workflow.instrepo; //OODT imports + +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; +import org.apache.oodt.commons.exceptions.CommonsException; import org.apache.oodt.commons.xml.DOMUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; -//JDK imports import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -29,12 +35,11 @@ import java.util.List; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; + +//JDK imports /** * @author mattmann @@ -56,7 +61,7 @@ public final class WorkflowInstanceMetadataReader implements } public static WorkflowInstanceMetMap parseMetMapFile(String mapFilePath) - throws Exception { + throws CommonsException, WorkflowException { Document doc = getDocumentRoot(mapFilePath); Element rootElem = doc.getDocumentElement(); WorkflowInstanceMetMap map = new WorkflowInstanceMetMap(); @@ -66,7 +71,7 @@ public final class WorkflowInstanceMetadataReader implements DEFAULT_WORKFLOW_MAP); if (defaultElem == null) { - throw new Exception("file: [" + mapFilePath + throw new WorkflowException("file: [" + mapFilePath + "] must specify a default workflow to field map!"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java index 22fc39a..b42b8d8 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java @@ -19,10 +19,16 @@ package org.apache.oodt.cas.workflow.lifecycle; //OODT imports + +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; +import org.apache.oodt.commons.exceptions.CommonsException; import org.apache.oodt.commons.xml.DOMUtil; import org.apache.oodt.commons.xml.XMLUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; -//JDK imports import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -30,12 +36,11 @@ import java.util.List; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; + +//JDK imports /** * @author mattmann @@ -56,7 +61,7 @@ public final class WorkflowLifecyclesReader implements WorkflowLifecycleMetKeys } public static List parseLifecyclesFile(String lifecyclesFilePath) - throws Exception { + throws CommonsException, WorkflowException { Document doc = getDocumentRoot(lifecyclesFilePath); Element rootElem = doc.getDocumentElement(); List lifecycles = new Vector(); @@ -66,7 +71,7 @@ public final class WorkflowLifecyclesReader implements WorkflowLifecycleMetKeys DEFAULT_LIFECYCLE); if (defaultElem == null) { - throw new Exception("file: [" + lifecyclesFilePath + throw new WorkflowException("file: [" + lifecyclesFilePath + "] must specify a default workflow lifecycle!"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepositoryFactory.java index dea7dda..d622aee 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepositoryFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepositoryFactory.java @@ -19,15 +19,18 @@ package org.apache.oodt.cas.workflow.repository; //APACHE imports + import org.apache.commons.dbcp.ConnectionFactory; import org.apache.commons.dbcp.DriverManagerConnectionFactory; import org.apache.commons.dbcp.PoolableConnectionFactory; import org.apache.commons.dbcp.PoolingDataSource; import org.apache.commons.pool.impl.GenericObjectPool; +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; -//JDK imports import javax.sql.DataSource; +//JDK imports + /** * @author mattmann * @version $Revision$ @@ -49,7 +52,7 @@ public class DataSourceWorkflowRepositoryFactory implements * Default Constructor * </p>. */ - public DataSourceWorkflowRepositoryFactory() throws Exception { + public DataSourceWorkflowRepositoryFactory() throws WorkflowException { String jdbcUrl, user, pass, driver; jdbcUrl = System @@ -64,7 +67,7 @@ public class DataSourceWorkflowRepositoryFactory implements try { Class.forName(driver); } catch (ClassNotFoundException e) { - throw new Exception("Cannot load driver: " + driver); + throw new WorkflowException("Cannot load driver: " + driver); } GenericObjectPool connectionPool = new GenericObjectPool(null); http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java index 50ed8b5..f24f785 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java @@ -17,17 +17,38 @@ package org.apache.oodt.cas.workflow.repository; //OODT imports + import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.CasMetadataException; import org.apache.oodt.cas.workflow.examples.BranchRedirector; import org.apache.oodt.cas.workflow.examples.NoOpTask; -import org.apache.oodt.cas.workflow.structs.*; +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; +import org.apache.oodt.cas.workflow.structs.Graph; +import org.apache.oodt.cas.workflow.structs.ParentChildWorkflow; +import org.apache.oodt.cas.workflow.structs.Workflow; +import org.apache.oodt.cas.workflow.structs.WorkflowCondition; +import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration; +import org.apache.oodt.cas.workflow.structs.WorkflowTask; +import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration; import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException; import org.apache.oodt.cas.workflow.util.XmlStructFactory; +import org.apache.oodt.commons.exceptions.CommonsException; import org.apache.oodt.commons.xml.XMLUtils; -import org.w3c.dom.*; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import java.io.File; -import java.util.*; +import java.text.ParseException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; @@ -398,7 +419,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository { } } - private void computeEvents() throws Exception { + private void computeEvents() throws WorkflowException { List<ParentChildWorkflow> workflows = new Vector<ParentChildWorkflow>(); for (ParentChildWorkflow w : this.workflows.values()) { workflows.add(w); @@ -441,13 +462,14 @@ public class PackagedWorkflowRepository implements WorkflowRepository { } } } else - throw new Exception("Unsupported execution type: [" + throw new WorkflowException("Unsupported execution type: [" + workflow.getGraph().getExecutionType() + "]"); } } private void loadTaskAndConditionDefinitions(List<Element> rootElements, - Element rootElem, Metadata staticMetadata) throws Exception { + Element rootElem, Metadata staticMetadata) + throws CommonsException, CasMetadataException, WorkflowException, ParseException { List<Element> conditionBlocks = this.getChildrenByTagName(rootElem, "condition"); @@ -474,7 +496,8 @@ public class PackagedWorkflowRepository implements WorkflowRepository { } private void loadGraphs(List<Element> rootElements, Element graphElem, - Graph parent, Metadata staticMetadata) throws Exception { + Graph parent, Metadata staticMetadata) + throws CommonsException, CasMetadataException, WorkflowException, ParseException { LOG.log(Level.FINEST, "Visiting node: [" + graphElem.getNodeName() + "]"); loadConfiguration(rootElements, graphElem, staticMetadata); @@ -520,7 +543,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository { } private void loadConfiguration(List<Element> rootElements, Node workflowNode, - Metadata staticMetadata) throws Exception { + Metadata staticMetadata) throws ParseException, CommonsException, CasMetadataException, WorkflowException { NodeList children = workflowNode.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node curChild = children.item(i); @@ -562,7 +585,8 @@ public class PackagedWorkflowRepository implements WorkflowRepository { } private Metadata loadConfGroup(List<Element> rootElements, String group, - Map<String, Metadata> globalConfGroups) throws Exception { + Map<String, Metadata> globalConfGroups) + throws ParseException, CommonsException, CasMetadataException, WorkflowException { for (final Element rootElement : rootElements) { NodeList nodes = rootElement.getElementsByTagName("configuration"); for (int i = 0; i < nodes.getLength(); i++) { @@ -572,7 +596,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository { return XmlStructFactory.getConfigurationAsMetadata(node); } } - throw new Exception("Configuration group '" + group + "' not defined!"); + throw new WorkflowException("Configuration group '" + group + "' not defined!"); } private void expandWorkflowTasksAndConditions(Graph graph, http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java index bf2a074..e8015c7 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java @@ -18,16 +18,19 @@ package org.apache.oodt.cas.workflow.structs; //JDK imports + +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; + import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.Vector; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; //OODT imports -import org.apache.oodt.cas.metadata.Metadata; /** * @@ -73,7 +76,7 @@ public class Graph { public static final List<String> processorIds = Arrays.asList(new String[] { "sequential", "parallel", "condition", "task" }); - public Graph(Element graphElem, Metadata staticMetadata) throws Exception { + public Graph(Element graphElem, Metadata staticMetadata) throws WorkflowException { this(); this.modelId = graphElem.getAttribute("id"); this.modelName = graphElem.getAttribute("name"); @@ -100,14 +103,14 @@ public class Graph { if ((graphElem.getNodeName().equals("workflow") || graphElem.getNodeName() .equals("conditions")) && this.executionType == null) { - throw new Exception("workflow model '" + graphElem.getNodeName() + throw new WorkflowException("workflow model '" + graphElem.getNodeName() + "' missing execution type"); } else { this.executionType = graphElem.getNodeName(); } if (!processorIds.contains(this.executionType)) - throw new Exception("Unsupported execution type id '" + throw new WorkflowException("Unsupported execution type id '" + this.executionType + "'"); if (!checkValue(this.modelId) && !checkValue(this.modelIdRef)) { http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java index 4e191a5..33bb5b5 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java @@ -581,21 +581,17 @@ public class XmlRpcWorkflowManager { } public synchronized boolean updateWorkflowInstanceStatus( - String workflowInstanceId, String status) throws Exception { + String workflowInstanceId, String status) throws InstanceRepositoryException { WorkflowInstance wInst; - try { wInst = engine.getInstanceRepository().getWorkflowInstanceById( workflowInstanceId); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } + wInst.setStatus(status); return doUpdateWorkflowInstance(wInst); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws IOException { int portNum = -1; String usage = "XmlRpcWorkflowManager --portNum <port number for xml rpc service>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java index cfa013f..336d99d 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java @@ -19,26 +19,26 @@ package org.apache.oodt.cas.workflow.system; //APACHE imports +import org.apache.oodt.cas.cli.CmdLineUtility; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.workflow.structs.Workflow; +import org.apache.oodt.cas.workflow.structs.WorkflowCondition; +import org.apache.oodt.cas.workflow.structs.WorkflowInstance; +import org.apache.oodt.cas.workflow.structs.WorkflowInstancePage; +import org.apache.oodt.cas.workflow.structs.WorkflowTask; +import org.apache.oodt.cas.workflow.util.XmlRpcStructFactory; import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; -//JDK imports +import java.io.IOException; import java.net.URL; import java.util.Hashtable; -import java.util.Vector; import java.util.List; +import java.util.Vector; import java.util.logging.Logger; -import java.io.IOException; +//JDK imports //OODT imports -import org.apache.oodt.cas.workflow.structs.WorkflowInstancePage; -import org.apache.oodt.cas.workflow.structs.WorkflowTask; -import org.apache.oodt.cas.workflow.structs.WorkflowCondition; -import org.apache.oodt.cas.workflow.structs.WorkflowInstance; -import org.apache.oodt.cas.workflow.structs.Workflow; -import org.apache.oodt.cas.workflow.util.XmlRpcStructFactory; -import org.apache.oodt.cas.cli.CmdLineUtility; -import org.apache.oodt.cas.metadata.Metadata; /** * @author mattmann @@ -76,20 +76,14 @@ public class XmlRpcWorkflowManagerClient { } public boolean refreshRepository() - throws Exception { - try { + throws XmlRpcException, IOException { return (Boolean) client.execute( "workflowmgr.refreshRepository", new Vector()); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public String executeDynamicWorkflow(List<String> taskIds, Metadata metadata) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); Vector<String> taskIdVector = new Vector<String>(); taskIdVector.addAll(taskIds); @@ -98,67 +92,42 @@ public class XmlRpcWorkflowManagerClient { argList.add(taskIdVector); argList.add(metadata.getHashtable()); - try { instId = (String) client.execute("workflowmgr.executeDynamicWorkflow", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return instId; } - public List getRegisteredEvents() throws Exception { + public List getRegisteredEvents() throws XmlRpcException, IOException { Vector argList = new Vector(); - try { return (List) client.execute("workflowmgr.getRegisteredEvents", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } - public WorkflowInstancePage getFirstPage() throws Exception { + public WorkflowInstancePage getFirstPage() throws XmlRpcException, IOException { Vector argList = new Vector(); Hashtable pageHash; - try { pageHash = (Hashtable) client.execute("workflowmgr.getFirstPage", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } public WorkflowInstancePage getNextPage(WorkflowInstancePage currentPage) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(XmlRpcStructFactory .getXmlRpcWorkflowInstancePage(currentPage)); Hashtable pageHash; - try { pageHash = (Hashtable) client.execute("workflowmgr.getNextPage", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } @@ -183,69 +152,51 @@ public class XmlRpcWorkflowManagerClient { return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } - public WorkflowInstancePage getLastPage() throws Exception { + public WorkflowInstancePage getLastPage() throws XmlRpcException, IOException { Vector argList = new Vector(); Hashtable pageHash; - try { pageHash = (Hashtable) client.execute("workflowmgr.getLastPage", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } public WorkflowInstancePage paginateWorkflowInstances(int pageNum, - String status) throws Exception { + String status) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(pageNum); argList.add(status); Hashtable pageHash; - try { pageHash = (Hashtable) client.execute( "workflowmgr.paginateWorkflowInstances", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } public WorkflowInstancePage paginateWorkflowInstances(int pageNum) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(pageNum); Hashtable pageHash; - try { pageHash = (Hashtable) client.execute( "workflowmgr.paginateWorkflowInstances", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return XmlRpcStructFactory.getWorkflowInstancePageFromXmlRpc(pageHash); } - public List getWorkflowsByEvent(String eventName) throws Exception { + public List getWorkflowsByEvent(String eventName) throws XmlRpcException, IOException { List workflows = new Vector(); Vector workflowVector; Vector argList = new Vector(); argList.add(eventName); - try { + workflowVector = (Vector) client.execute( "workflowmgr.getWorkflowsByEvent", argList); @@ -259,300 +210,193 @@ public class XmlRpcWorkflowManagerClient { } return workflows; - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } - public Metadata getWorkflowInstanceMetadata(String wInstId) throws Exception { + public Metadata getWorkflowInstanceMetadata(String wInstId) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(wInstId); Metadata met; - try { Hashtable instMetHash = (Hashtable) client.execute( "workflowmgr.getWorkflowInstanceMetadata", argList); met = new Metadata(); met.addMetadata(instMetHash); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + return met; } public synchronized boolean setWorkflowInstanceCurrentTaskStartDateTime( - String wInstId, String startDateTimeIsoStr) throws Exception { + String wInstId, String startDateTimeIsoStr) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(wInstId); argList.add(startDateTimeIsoStr); - try { return (Boolean) client.execute( "workflowmgr.setWorkflowInstanceCurrentTaskStartDateTime", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public double getWorkflowCurrentTaskWallClockMinutes(String workflowInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); - try { return (Double) client.execute( "workflowmgr.getWorkflowCurrentTaskWallClockMinutes", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public double getWorkflowWallClockMinutes(String workflowInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); - try { return (Double) client.execute( "workflowmgr.getWorkflowWallClockMinutes", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean stopWorkflowInstance(String workflowInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); - try { return (Boolean) client.execute( "workflowmgr.stopWorkflowInstance", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean pauseWorkflowInstance(String workflowInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); - try { return (Boolean) client.execute( "workflowmgr.pauseWorkflowInstance", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean resumeWorkflowInstance(String workflowInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); - try { return (Boolean) client.execute( "workflowmgr.resumeWorkflowInstance", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean setWorkflowInstanceCurrentTaskEndDateTime( - String wInstId, String endDateTimeIsoStr) throws Exception { + String wInstId, String endDateTimeIsoStr) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(wInstId); argList.add(endDateTimeIsoStr); - try { return (Boolean) client.execute( "workflowmgr.setWorkflowInstanceCurrentTaskEndDateTime", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean updateWorkflowInstanceStatus( - String workflowInstId, String status) throws Exception { + String workflowInstId, String status) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); argList.add(status); - try { return (Boolean) client.execute( "workflowmgr.updateWorkflowInstanceStatus", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean updateWorkflowInstance(WorkflowInstance instance) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(XmlRpcStructFactory.getXmlRpcWorkflowInstance(instance)); - try { - return (Boolean) client.execute( + return (Boolean) client.execute( "workflowmgr.updateWorkflowInstance", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public synchronized boolean updateMetadataForWorkflow( - String workflowInstId, Metadata metadata) throws Exception { + String workflowInstId, Metadata metadata) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowInstId); argList.add(metadata.getHashtable()); - try { return (Boolean) client.execute( "workflowmgr.updateMetadataForWorkflow", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } public boolean sendEvent(String eventName, Metadata metadata) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(eventName); argList.add(metadata.getHashtable()); - try { return (Boolean) client .execute("workflowmgr.handleEvent", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - throw new Exception(e.getMessage()); - } + } - public WorkflowTask getTaskById(String taskId) throws Exception { + public WorkflowTask getTaskById(String taskId) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(taskId); - try { Hashtable t = (Hashtable) client.execute("workflowmgr.getTaskById", argList); return XmlRpcStructFactory.getWorkflowTaskFromXmlRpc(t); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + } public WorkflowCondition getConditionById(String conditionId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(conditionId); - try { Hashtable c = (Hashtable) client.execute( "workflowmgr.getConditionById", argList); return XmlRpcStructFactory.getWorkflowConditionFromXmlRpc(c); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + } public WorkflowInstance getWorkflowInstanceById(String wInstId) - throws Exception { + throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(wInstId); - try { Hashtable workflowInstance = (Hashtable) client.execute( "workflowmgr.getWorkflowInstanceById", argList); return XmlRpcStructFactory .getWorkflowInstanceFromXmlRpc(workflowInstance); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } } - public Workflow getWorkflowById(String workflowId) throws Exception { + public Workflow getWorkflowById(String workflowId) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(workflowId); - try { Hashtable workflow = (Hashtable) client.execute( "workflowmgr.getWorkflowById", argList); return XmlRpcStructFactory.getWorkflowFromXmlRpc(workflow); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + } - public Vector getWorkflows() throws Exception { + public Vector getWorkflows() throws XmlRpcException, IOException { Vector argList = new Vector(); Vector works; Vector workflows; - try { works = (Vector) client .execute("workflowmgr.getWorkflows", argList); @@ -569,60 +413,39 @@ public class XmlRpcWorkflowManagerClient { return workflows; } else return null; - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + } - public int getNumWorkflowInstancesByStatus(String status) throws Exception{ + public int getNumWorkflowInstancesByStatus(String status) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(status); int numInsts; - try { numInsts = (Integer) client.execute( "workflowmgr.getNumWorkflowInstancesByStatus", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + return numInsts; } - public int getNumWorkflowInstances() throws Exception{ + public int getNumWorkflowInstances() throws XmlRpcException, IOException { Vector argList = new Vector(); int numInsts; - try { numInsts = (Integer) client.execute( "workflowmgr.getNumWorkflowInstances", argList); - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + return numInsts; } - public Vector getWorkflowInstancesByStatus(String status) throws Exception { + public Vector getWorkflowInstancesByStatus(String status) throws XmlRpcException, IOException { Vector argList = new Vector(); argList.add(status); Vector insts; Vector instsUnpacked; - try { insts = (Vector) client.execute( "workflowmgr.getWorkflowInstancesByStatus", argList); if (insts != null) { @@ -637,42 +460,28 @@ public class XmlRpcWorkflowManagerClient { } else return null; - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } + } - public Vector getWorkflowInstances() throws Exception { + public Vector getWorkflowInstances() throws XmlRpcException, IOException { Vector argList = new Vector(); Vector insts; Vector instsUnpacked; - try { - insts = (Vector) client.execute("workflowmgr.getWorkflowInstances", - argList); - if (insts != null) { - instsUnpacked = new Vector(insts.size()); - for (Object inst1 : insts) { - Hashtable hWinst = (Hashtable) inst1; - WorkflowInstance inst = XmlRpcStructFactory - .getWorkflowInstanceFromXmlRpc(hWinst); - instsUnpacked.add(inst); - } - return instsUnpacked; - } else - return null; + insts = (Vector) client.execute("workflowmgr.getWorkflowInstances", + argList); + if (insts != null) { + instsUnpacked = new Vector(insts.size()); + for (Object inst1 : insts) { + Hashtable hWinst = (Hashtable) inst1; + WorkflowInstance inst = XmlRpcStructFactory + .getWorkflowInstanceFromXmlRpc(hWinst); + instsUnpacked.add(inst); + } + return instsUnpacked; + } else + return null; - } catch (XmlRpcException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } } public static void main(String[] args) { http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/tools/InstanceRepoCleaner.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/tools/InstanceRepoCleaner.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/tools/InstanceRepoCleaner.java index 83196e9..cf7f021 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/tools/InstanceRepoCleaner.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/tools/InstanceRepoCleaner.java @@ -18,6 +18,17 @@ package org.apache.oodt.cas.workflow.tools; //JDK imports +import org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepository; +import org.apache.oodt.cas.workflow.structs.WorkflowInstance; +import org.apache.oodt.cas.workflow.structs.WorkflowInstancePage; +import org.apache.oodt.cas.workflow.structs.WorkflowStatus; +import org.apache.oodt.cas.workflow.structs.exceptions.InstanceRepositoryException; +import org.apache.oodt.cas.workflow.system.XmlRpcWorkflowManagerClient; +import org.apache.oodt.commons.date.DateUtils; +import org.apache.xmlrpc.XmlRpcException; + +import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.util.Calendar; import java.util.List; @@ -25,12 +36,6 @@ import java.util.logging.Level; import java.util.logging.Logger; //OODT imports -import org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepository; -import org.apache.oodt.cas.workflow.structs.WorkflowInstance; -import org.apache.oodt.cas.workflow.structs.WorkflowInstancePage; -import org.apache.oodt.cas.workflow.structs.WorkflowStatus; -import org.apache.oodt.cas.workflow.system.XmlRpcWorkflowManagerClient; -import org.apache.oodt.commons.date.DateUtils; /** * @@ -61,7 +66,7 @@ public class InstanceRepoCleaner { public InstanceRepoCleaner() { } - public InstanceRepoCleaner(String wmUrlStr) throws Exception { + public InstanceRepoCleaner(String wmUrlStr) throws MalformedURLException { this.wm = new XmlRpcWorkflowManagerClient(new URL(wmUrlStr)); } @@ -69,7 +74,7 @@ public class InstanceRepoCleaner { this.rep = new LuceneWorkflowInstanceRepository(idxPath, 1000); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws IOException, InstanceRepositoryException, XmlRpcException { String usage = "InstanceRepoCleaner [options]\n" + "<workflow manager url>\n" + "--idxPath <path>\n"; if (args.length != 1 && args.length != 2) { @@ -89,7 +94,7 @@ public class InstanceRepoCleaner { clean.cleanRepository(); } - public void cleanRepository() throws Exception { + public void cleanRepository() throws XmlRpcException, IOException, InstanceRepositoryException { WorkflowInstancePage page = wm != null ? wm.getFirstPage() : rep .getFirstPage(); while (page != null && page.getPageWorkflows() != null http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/util/CygwinScriptFile.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/CygwinScriptFile.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/CygwinScriptFile.java index 038a12a..2427401 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/CygwinScriptFile.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/CygwinScriptFile.java @@ -18,6 +18,8 @@ package org.apache.oodt.cas.workflow.util; +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -56,7 +58,7 @@ public class CygwinScriptFile extends ScriptFile { /** * Override writeScriptFile to ensure Windows (cygwin) compatibility for generated scripts */ - public void writeScriptFile(String filePath) throws Exception { + public void writeScriptFile(String filePath) throws WorkflowException { PrintWriter pw = null; try { @@ -65,7 +67,7 @@ public class CygwinScriptFile extends ScriptFile { pw.print(toString()); // Changed println to print for Cygwin compatibility } catch (IOException e) { e.printStackTrace(); - throw new Exception("Error writing script file!: " + e.getMessage()); + throw new WorkflowException("Error writing script file!: " + e.getMessage()); } finally { try { pw.close(); http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/util/ScriptFile.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/ScriptFile.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/ScriptFile.java index 871dc55..e850b6a 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/ScriptFile.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/ScriptFile.java @@ -19,13 +19,16 @@ package org.apache.oodt.cas.workflow.util; //JDK imports -import java.util.List; -import java.util.Vector; + +import org.apache.oodt.cas.workflow.exceptions.WorkflowException; + import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; import java.io.FileOutputStream; +import java.io.IOException; import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.List; +import java.util.Vector; /** * @author mattmann @@ -104,7 +107,7 @@ public class ScriptFile { return rStr; } - public void writeScriptFile(String filePath) throws Exception { + public void writeScriptFile(String filePath) throws WorkflowException { PrintWriter pw = null; try { @@ -113,7 +116,7 @@ public class ScriptFile { pw.println(toString()); } catch (IOException e) { e.printStackTrace(); - throw new Exception("Error writing script file!: " + e.getMessage()); + throw new WorkflowException("Error writing script file!: " + e.getMessage()); } finally { try { pw.close(); http://git-wip-us.apache.org/repos/asf/oodt/blob/11e28571/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java index 90939a7..0305b43 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java @@ -17,26 +17,28 @@ package org.apache.oodt.cas.workflow.util; -//JDK imports -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import java.util.Vector; -import java.util.HashMap; -import java.util.logging.Logger; -import org.w3c.dom.Node; -import org.w3c.dom.Text; -import org.w3c.dom.NodeList; -import org.w3c.dom.Element; - -//OODT imports import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.CasMetadataException; import org.apache.oodt.cas.metadata.util.PathUtils; import org.apache.oodt.cas.workflow.structs.Workflow; +import org.apache.oodt.cas.workflow.structs.WorkflowCondition; import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration; import org.apache.oodt.cas.workflow.structs.WorkflowTask; import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration; -import org.apache.oodt.cas.workflow.structs.WorkflowCondition; +import org.apache.oodt.commons.exceptions.CommonsException; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.text.ParseException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import java.util.Vector; +import java.util.logging.Logger; + /** * * A class for constructing Workflow Manager objects from XML {@link Node}s @@ -231,7 +233,7 @@ public final class XmlStructFactory { } public static Metadata getConfigurationAsMetadata(Node configNode) - throws Exception { + throws ParseException, CommonsException, CasMetadataException { Metadata curMetadata = new Metadata(); NodeList curGrandChildren = configNode.getChildNodes(); for (int k = 0; k < curGrandChildren.getLength(); k++) {
