You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by am...@apache.org on 2012/12/25 02:21:01 UTC

svn commit: r1425697 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/api/ airavata-client/src/main/java/org/apache/airavata/client/impl/ integration-tests/src/test/java/org/apache/airavata/integration/ workflow-mo...

Author: amilaj
Date: Tue Dec 25 01:21:00 2012
New Revision: 1425697

URL: http://svn.apache.org/viewvc?rev=1425697&view=rev
Log:
Fixing AIRAVATA-685. Added necessary functionality workflow manager.

Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
    airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
    airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java?rev=1425697&r1=1425696&r2=1425697&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java Tue Dec 25 01:21:00 2012
@@ -21,6 +21,7 @@
 
 package org.apache.airavata.client.api;
 
+import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
@@ -34,22 +35,95 @@ public interface WorkflowManager {
 
     /**
      * Save the workflow under the given user
-     * @param workflowAsString
-     * @param owner
-     * @return
-     * @throws AiravataAPIInvocationException
+     * @param workflowAsString The workflow as a string.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @return  <code>true</code> if successful else <code>false</code>.
+     * @throws AiravataAPIInvocationException If an error occurred while saving the workflow.
+     * @deprecated Use {@see #addOwnerWorkflow(String workflowAsString, String owner)} and
+     *                  {@see #updateOwnerWorkflow(String workflowAsString, String owner)} methods.
      */
+    @Deprecated
 	public boolean saveWorkflow(String workflowAsString, String owner) throws AiravataAPIInvocationException;
 
     /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowAsString The new workflow to add as a string.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     * @throws DescriptorRecordAlreadyExistsException If adding workflow already exists for the given owner.
+     */
+    public void addOwnerWorkflow (String workflowAsString, String owner) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowPath File path of the workflow.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     * @throws DescriptorRecordAlreadyExistsException If adding workflow already exists for the given owner.
+     */
+    public void addOwnerWorkflow (URI workflowPath, String owner) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflow The new workflow to add.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     * @throws DescriptorRecordAlreadyExistsException If adding workflow already exists for the given owner.
+     */
+    public void addOwnerWorkflow (Workflow workflow, String owner) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * @param workflowPath File path of the workflow.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateOwnerWorkflow (URI workflowPath, String owner) throws AiravataAPIInvocationException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * @param workflowAsString The workflow to update as a string. Workflow is uniquely identified by &lt;xgr:id&gt; tag..
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateOwnerWorkflow (String workflowAsString, String owner) throws AiravataAPIInvocationException;
+
+    /**
      * Save the workflow under the given user
-     * @param workflow
-     * @param owner
-     * @return
-     * @throws AiravataAPIInvocationException
+     * @param workflow The workflow as a string.
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @return <code>true</code> if successful else <code>false</code>.
+     * @throws AiravataAPIInvocationException If an error occurred while saving the workflow.
+     * @deprecated Use {@see #addOwnerWorkflow(Workflow workflow, String owner)} and
+     *                  {@see #updateOwnerWorkflow(Workflow workflow, String owner)} methods.
      */
+    @Deprecated
     public boolean saveWorkflow(Workflow workflow, String owner) throws AiravataAPIInvocationException;
 
+
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * @param workflow The workflow to update. Workflow is uniquely identified by &lt;xgr:id&gt; tag..
+     * @param owner Under which user workflow should be added. This is a privileged method and usually
+     *              only admin calls this.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateOwnerWorkflow (Workflow workflow, String owner) throws AiravataAPIInvocationException;
+
     /**
      * Retrieve workflows saved by the given user
      * @param owner
@@ -97,29 +171,125 @@ public interface WorkflowManager {
 
     /**
      * Save the workflow
-     * @param workflowAsString
-     * @return
+     * @param workflowAsString Workflow as a string.
+     * @deprecated Use {@see #addWorkflow(String workflowAsString)} and
+     *          {@see #updateWorkflow(String workflowAsString)} methods.
      * @throws AiravataAPIInvocationException
      */
+    @Deprecated
 	public boolean saveWorkflow(String workflowAsString) throws AiravataAPIInvocationException;
 
     /**
      * Save the workflow as public
-     * @param workflowAsString
-     * @return
+     * @param workflowAsString Workflow as a string.
+     * @deprecated Use {@see #addWorkflowAsPublic(String workflowAsString)} and
+     *          {@see #updateWorkflowAsPublic(String workflowAsString)} methods.
      * @throws AiravataAPIInvocationException
      */
+    @Deprecated
 	public boolean saveWorkflowAsPublic(String workflowAsString) throws AiravataAPIInvocationException;
 
     /**
      * Save the workflow
-     * @param workflow
-     * @return
+     * @param workflow {@see Workflow} object to save.
+     * @deprecated Use {@see #addWorkflow(Workflow workflow)} and
+     *          {@see #updateWorkflow(Workflow workflow)} methods.
      * @throws AiravataAPIInvocationException
      */
+    @Deprecated
     public boolean saveWorkflow(Workflow workflow) throws AiravataAPIInvocationException;
 
     /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowAsString The new workflow to add and its content as a string.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     */
+    public void addWorkflowAsPublic (String workflowAsString) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * @param workflowAsString The workflow to update. Workflow is uniquely identified by &lt;xgr:id&gt; tag.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateWorkflowAsPublic (String workflowAsString) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowUri Where the workflow file (xml file) exists.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     */
+    public void addWorkflowAsPublic (URI workflowUri) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * @param workflowUri Where the workflow file resides. File location is given as a URI.
+     *                    Workflow is uniquely identified by &lt;xgr:id&gt; tag.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateWorkflowAsPublic (URI workflowUri) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowAsString The new workflow to add and its content as a string.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     */
+    public void addWorkflow (String workflowAsString) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * TODO : What exception should we throw if a different user tries to update the workflow ?
+     * @param workflowAsString The workflow to update. Workflow is uniquely identified by &lt;xgr:id&gt; tag..
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateWorkflow (String workflowAsString) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflow The new workflow to add.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     */
+    public void addWorkflow (Workflow workflow) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * TODO : What exception should we throw if a different user tries to update the workflow ?
+     * @param workflow The workflow to update. Workflow is uniquely identified by &lt;xgr:id&gt; tag..
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateWorkflow (Workflow workflow) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new workflow. Workflow is added to users private space. i.e. only user who added the
+     * workflow will be able to retrieve it.
+     * @param workflowUri New workflow file as a URI.
+     * @throws AiravataAPIInvocationException If an error occurred while adding a new workflow.
+     */
+    public void addWorkflow (URI workflowUri) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates a given workflow. Only user who added the workflow will be able to update it.
+     * TODO : What exception should we throw if a different user tries to update the workflow ?
+     * @param workflowUri The workflow to update as a URI.
+     * @throws AiravataAPIInvocationException If an error occurred while updating the workflow.
+     */
+    public void updateWorkflow (URI workflowUri) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
      * Save the workflow as public
      * @param workflow
      * @return
@@ -174,6 +344,16 @@ public interface WorkflowManager {
     public Workflow getWorkflowFromString(String workflowAsString) throws AiravataAPIInvocationException;
 
     /**
+     * Creates a workflow from a given URI. When we want to create a workflow from a file path
+     * we can use this method.
+     * @param workflowPath The workflow file path as a URI.
+     * @return A workflow object created using given workflow XML file.
+     * @throws AiravataAPIInvocationException If an error occurred while parsing the XML file.
+     */
+    public Workflow getWorkflowFromURI(URI workflowPath) throws AiravataAPIInvocationException;
+
+
+    /**
      * Convert workflow in to a string
      * @param workflow
      * @return

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java?rev=1425697&r1=1425696&r2=1425697&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java Tue Dec 25 01:21:00 2012
@@ -21,6 +21,7 @@
 
 package org.apache.airavata.client.impl;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -28,8 +29,12 @@ import java.util.Map;
 
 import org.apache.airavata.client.AiravataClient;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
+import org.apache.airavata.client.api.DescriptorRecordAlreadyExistsException;
 import org.apache.airavata.client.api.WorkflowManager;
+import org.apache.airavata.common.exception.AiravataConfigurationException;
 import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.worker.UserWorkflowAlreadyExistsException;
 import org.apache.airavata.workflow.model.wf.Workflow;
 import org.apache.airavata.workflow.model.wf.WorkflowData;
 import org.apache.airavata.workflow.model.wf.WorkflowInput;
@@ -55,12 +60,105 @@ public class WorkflowManagerImpl impleme
 		return saveWorkflow(getWorkflowFromString(workflowAsString), workflowAsString, owner);
 	}
 
+    @Override
+    public void addOwnerWorkflow (String workflowAsString, String owner)
+            throws AiravataAPIInvocationException, DescriptorRecordAlreadyExistsException {
+         addWorkflow(getWorkflowFromString(workflowAsString), workflowAsString, owner);
+    }
+
+    @Override
+    public void updateOwnerWorkflow (String workflowAsString, String owner)
+            throws AiravataAPIInvocationException {
+        updateWorkflow(getWorkflowFromString(workflowAsString), workflowAsString, owner);
+    }
+
+    @Override
+    public void addOwnerWorkflow (URI workflowPath, String owner)
+            throws AiravataAPIInvocationException, DescriptorRecordAlreadyExistsException {
+        Workflow workflow = getWorkflowFromURI(workflowPath);
+        addWorkflow(workflow, XMLUtil.xmlElementToString(workflow.toXML()), owner);
+    }
+
+    @Override
+    public void updateOwnerWorkflow (URI workflowPath, String owner)
+            throws AiravataAPIInvocationException {
+        Workflow workflow = getWorkflowFromURI(workflowPath);
+        updateWorkflow(workflow, XMLUtil.xmlElementToString(workflow.toXML()), owner);
+    }
+
 	@Override
 	public boolean saveWorkflow(Workflow workflow, String owner)
 			throws AiravataAPIInvocationException {
 		return saveWorkflow(workflow, XMLUtil.xmlElementToString(workflow.toXML()), owner);
 	}
-	
+
+    @Override
+    public void addOwnerWorkflow (Workflow workflow, String owner) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+        addWorkflow(workflow, XMLUtil.xmlElementToString(workflow.toXML()), owner);
+    }
+
+    @Override
+    public void updateOwnerWorkflow (Workflow workflow, String owner) throws AiravataAPIInvocationException {
+        updateWorkflow(workflow, XMLUtil.xmlElementToString(workflow.toXML()), owner);
+    }
+
+    private void addWorkflow(Workflow workflow, String workflowAsString, String owner)
+            throws AiravataAPIInvocationException, DescriptorRecordAlreadyExistsException {
+        try {
+            getClient().getRegistryClient().addWorkflow(workflow.getName(), workflowAsString);
+        } catch (UserWorkflowAlreadyExistsException e) {
+            throw new DescriptorRecordAlreadyExistsException("Workflow " +
+                    workflow.getName()
+                    + " already exists in the system.", e);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
+                    workflow.getName(), e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry client for workflow " +
+                    workflow.getName(), e);
+        }
+
+        if (owner == null) {
+            try {
+                getClient().getRegistryClient().publishWorkflow(workflow.getName());
+            } catch (RegistryException e) {
+                throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
+                        workflow.getName(), e);
+            } catch (AiravataConfigurationException e) {
+                throw new AiravataAPIInvocationException("Error retrieving registry client for workflow " +
+                        workflow.getName(), e);
+            }
+        }
+    }
+
+    private void updateWorkflow(Workflow workflow, String workflowAsString, String owner)
+            throws AiravataAPIInvocationException {
+        try {
+            getClient().getRegistryClient().updateWorkflow(workflow.getName(), workflowAsString);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
+                    workflow.getName(), e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry client for workflow " +
+                    workflow.getName(), e);
+        }
+
+        if (owner == null) {
+            try {
+                getClient().getRegistryClient().publishWorkflow(workflow.getName());
+            } catch (RegistryException e) {
+                throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
+                        workflow.getName(), e);
+            } catch (AiravataConfigurationException e) {
+                throw new AiravataAPIInvocationException("Error retrieving registry client for workflow " +
+                        workflow.getName(), e);
+            }
+        }
+    }
+
+    // Remove once deprecated methods are removed from the API
+    @Deprecated
 	private boolean saveWorkflow(Workflow workflow, String workflowAsString,String owner)
 			throws AiravataAPIInvocationException {
 		try {
@@ -143,18 +241,73 @@ public class WorkflowManagerImpl impleme
 		return saveWorkflow(workflowAsString, getCurrentUser());
 	}
 
+    @Override
+    public void addWorkflow (String workflowAsString) throws DescriptorRecordAlreadyExistsException,
+            AiravataAPIInvocationException {
+        addOwnerWorkflow(workflowAsString, getCurrentUser());
+    }
+
+    @Override
+    public void updateWorkflow (String workflowAsString) throws AiravataAPIInvocationException {
+        updateOwnerWorkflow(workflowAsString, getCurrentUser());
+    }
+
 	@Override
 	public boolean saveWorkflowAsPublic(String workflowAsString)
 			throws AiravataAPIInvocationException {
 		return saveWorkflow(workflowAsString, null);
 	}
 
+    @Override
+    public void addWorkflowAsPublic (String workflowAsString) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+        addOwnerWorkflow (workflowAsString, null);
+    }
+
+    @Override
+    public void updateWorkflowAsPublic (String workflowAsString) throws AiravataAPIInvocationException {
+        updateOwnerWorkflow(workflowAsString, null);
+    }
+
+    @Override
+    public void addWorkflowAsPublic (URI workflowPath) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+        addOwnerWorkflow (getWorkflowFromURI(workflowPath), null);
+    }
+
+    @Override
+    public void updateWorkflowAsPublic (URI workflowPath) throws AiravataAPIInvocationException {
+        updateOwnerWorkflow(getWorkflowFromURI(workflowPath), null);
+    }
+
 	@Override
 	public boolean saveWorkflow(Workflow workflow)
 			throws AiravataAPIInvocationException {
 		return saveWorkflow(workflow, getCurrentUser());
 	}
 
+    @Override
+    public void addWorkflow (Workflow workflow) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException{
+        addOwnerWorkflow(workflow, getCurrentUser());
+    }
+
+    @Override
+    public void updateWorkflow (Workflow workflow) throws AiravataAPIInvocationException {
+        updateOwnerWorkflow(workflow, getCurrentUser());
+    }
+
+    @Override
+    public void addWorkflow (URI workflowPath) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+        addOwnerWorkflow(getWorkflowFromURI(workflowPath), getCurrentUser());
+    }
+
+    @Override
+    public void updateWorkflow (URI workflowPath) throws AiravataAPIInvocationException {
+        updateOwnerWorkflow(getWorkflowFromURI(workflowPath), getCurrentUser());
+    }
+
 	private String getCurrentUser() {
 		return getClient().getCurrentUser();
 	}
@@ -204,7 +357,16 @@ public class WorkflowManagerImpl impleme
 		}
 	}
 
-	@Override
+    @Override
+    public Workflow getWorkflowFromURI(URI workflowPath) throws AiravataAPIInvocationException {
+        try {
+            return new Workflow(workflowPath);
+        } catch (Exception e) {
+            throw new AiravataAPIInvocationException(e);
+        }
+    }
+
+    @Override
 	public String getWorkflowAsString(Workflow workflow)
 			throws AiravataAPIInvocationException {
 		return XMLUtil.xmlElementToString(workflow.toXML());
@@ -297,12 +459,12 @@ public class WorkflowManagerImpl impleme
 	}
 
 	@Override
-	public List<WorkflowInput> getWorkflowInputs(String workflowName) throws AiravataAPIInvocationException, Exception {
+	public List<WorkflowInput> getWorkflowInputs(String workflowName) throws Exception {
 		return getWorkflow(workflowName).getWorkflowInputs();
 	}
 
 	@Override
-	public List<WorkflowInput> getWorkflowInputs(WorkflowData workflowData) throws AiravataAPIInvocationException, Exception {
+	public List<WorkflowInput> getWorkflowInputs(WorkflowData workflowData) throws Exception {
 		if (workflowData.isPublished()){
 			return getWorkflowFromString(getClient().getRegistryClient().getPublishedWorkflowGraphXML(workflowData.getName())).getWorkflowInputs();
 		}else{

Modified: airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java?rev=1425697&r1=1425696&r2=1425697&view=diff
==============================================================================
--- airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java (original)
+++ airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java Tue Dec 25 01:21:00 2012
@@ -256,8 +256,7 @@ public class BaseCaseIT {
 
         log("Saving workflow ...");
         Workflow workflow = new Workflow(getWorkflowComposeContent("src/test/resources/EchoWorkflow.xwf"));
-        airavataAPI.getWorkflowManager().
-                saveWorkflow(workflow);
+        airavataAPI.getWorkflowManager().addWorkflow(workflow);
 
         Assert.assertTrue(airavataAPI.getWorkflowManager().isWorkflowExists(workflow.getName()));
 

Modified: airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java?rev=1425697&r1=1425696&r2=1425697&view=diff
==============================================================================
--- airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java (original)
+++ airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java Tue Dec 25 01:21:00 2012
@@ -24,6 +24,7 @@ package org.apache.airavata.workflow.mod
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -181,6 +182,25 @@ public class Workflow implements Cloneab
     }
 
     /**
+     * Constructs a workflow from a given URI.
+     * @param workflowFilePath The workflow URI path.
+     * @throws GraphException If an error occurred while creating workflow.
+     * @throws ComponentException If an error occurred while parsing the workflow content.
+     */
+    public Workflow(URI workflowFilePath) throws GraphException, ComponentException {
+        this();
+        try {
+            File filePath = new File(workflowFilePath);
+            XmlElement workflowElement = XMLUtil.loadXML(filePath);
+            parse(workflowElement);
+        } catch (RuntimeException e) {
+            throw new GraphException(e);
+        } catch (IOException e) {
+            throw new GraphException(e);
+        }
+    }
+
+    /**
      * Constructs a Workflow.
      * 
      * @param workflowElement