You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ra...@apache.org on 2012/10/29 19:58:12 UTC
svn commit: r1403461 - in
/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client:
AiravataClient.java AiravataClientUtils.java
api/AiravataAPIInvocationException.java api/ExecutionManager.java
impl/ExecutionManagerImpl.java
Author: raminder
Date: Mon Oct 29 18:58:11 2012
New Revision: 1403461
URL: http://svn.apache.org/viewvc?rev=1403461&view=rev
Log:
Code cleanup for airavata client. Improved exception handling etc. AIRAVATA-626
Modified:
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClientUtils.java
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPIInvocationException.java
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java?rev=1403461&r1=1403460&r2=1403461&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java Mon Oct 29 18:58:11 2012
@@ -46,10 +46,10 @@ import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
import javax.xml.stream.XMLStreamException;
import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
import org.apache.airavata.client.api.AiravataManager;
import org.apache.airavata.client.api.ApplicationManager;
import org.apache.airavata.client.api.ExecutionManager;
@@ -62,11 +62,11 @@ import org.apache.airavata.client.impl.E
import org.apache.airavata.client.impl.ProvenanceManagerImpl;
import org.apache.airavata.client.impl.UserManagerImpl;
import org.apache.airavata.client.impl.WorkflowManagerImpl;
-import org.apache.airavata.registry.api.exception.RegistryException;
import org.apache.airavata.common.utils.Version;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.exception.RegistryException;
import org.apache.airavata.registry.api.workflow.ExperimentData;
import org.apache.airavata.workflow.model.component.ComponentException;
import org.apache.airavata.workflow.model.component.registry.JCRComponentRegistry;
@@ -85,12 +85,14 @@ import org.apache.airavata.xbaya.monitor
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
import org.apache.axis2.AxisFault;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AiravataClient implements AiravataAPI {
-// private static final MLogger log = MLogger.getLogger();
+ private static final Logger log = LoggerFactory
+ .getLogger(AiravataClient.class);
public static final String GFAC = "gfac";
- public static final String JCR = "jcr";
public static final String PROXYSERVER = "proxyserver";
public static final String MSGBOX = "msgbox";
public static final String BROKER = "broker";
@@ -98,23 +100,20 @@ public class AiravataClient implements A
public static final String DEFAULT_MYPROXY_SERVER = "myproxy.url";
public static final String DEFAULT_MESSAGE_BOX_URL = "messagebox.url";
public static final String DEFAULT_BROKER_URL = "messagebroker.url";
- public static final String DEFAULT_JCR_URL = "jcr.url";
- public static final String JCR_USERNAME = "jcr.username";
- public static final String JCR_PASSWORD = "jcr.password";
public static final String MYPROXYUSERNAME = "myproxy.username";
public static final String MYPROXYPASS = "myproxy.password";
public static final String WITHLISTENER = "with.Listener";
public static final String WORKFLOWSERVICEURL = "xbaya.service.url";
- public static final String TRUSTED_CERT_LOCATION = "trusted.cert.location";
- private AiravataClientConfiguration clientConfiguration;
- private MonitorConfiguration monitorConfiguration;
+ public static final String TRUSTED_CERT_LOCATION = "trusted.cert.location";
+ private AiravataClientConfiguration clientConfiguration;
+ private MonitorConfiguration monitorConfiguration;
private static String workflow = "";
- private static WorkflowContextHeaderBuilder builder;
- private String currentUser;
-
+ private static WorkflowContextHeaderBuilder builder;
+ private String currentUser;
+
private AiravataRegistry2 registry;
- private Map<String, String> configuration = new HashMap<String, String>();
+ private Map<String, String> configuration = new HashMap<String, String>();
private AiravataManagerImpl airavataManagerImpl;
private ApplicationManagerImpl applicationManagerImpl;
private WorkflowManagerImpl workflowManagerImpl;
@@ -124,106 +123,124 @@ public class AiravataClient implements A
// private NameValue[] configurations = new NameValue[7];
- private static final Version API_VERSION=new Version("Airavata",0,5,null,null,null);
-
- protected AiravataClient(Map<String,String> configuration)
+ private static final Version API_VERSION = new Version("Airavata", 0, 5,
+ null, null, null);
+
+ protected AiravataClient(Map<String, String> configuration)
throws MalformedURLException {
this.configuration = configuration;
initialize();
}
+ // FIXME: Need a constructor to set registry URL
+ protected AiravataClient() {
+ }
+
protected AiravataClient(String fileName) throws RegistryException,
MalformedURLException, IOException {
- URL url = this. getClass().getClassLoader().getResource(fileName);
+ URL url = this.getClass().getClassLoader().getResource(fileName);
if (url == null) {
url = (new File(fileName)).toURL();
}
Properties properties = new Properties();
properties.load(url.openStream());
-
- configuration.put(GFAC,validateAxisService(properties
- .getProperty(DEFAULT_GFAC_URL)));
+ configuration.put(GFAC,
+ validateAxisService(properties.getProperty(DEFAULT_GFAC_URL)));
configuration.put(MSGBOX, validateAxisService(properties
- .getProperty(DEFAULT_MESSAGE_BOX_URL)));
- configuration.put(BROKER,validateAxisService(properties
- .getProperty(DEFAULT_BROKER_URL)));
- configuration.put(WORKFLOWSERVICEURL,validateAxisService(properties
- .getProperty(WORKFLOWSERVICEURL)));
- configuration.put(JCR,properties
- .getProperty(DEFAULT_JCR_URL));
- configuration.put(JCR_USERNAME,properties.getProperty(JCR_USERNAME));
-
- configuration.put(JCR_PASSWORD,properties.getProperty(JCR_PASSWORD));
-
- configuration.put(WITHLISTENER,properties.getProperty(WITHLISTENER));
-
- initialize();
- }
-
- protected AiravataClient(URI registryUrl, String username, String password) throws MalformedURLException, RepositoryException, RegistryException {
- this(createConfig(registryUrl, username, password));
- }
-
- private static HashMap<String, String> createConfig(URI registryUrl, String username, String password) throws RepositoryException, RegistryException {
- HashMap<String, String> config = new HashMap<String,String>();
- config.put(AiravataClient.JCR,registryUrl.toString());
- config.put(AiravataClient.JCR_USERNAME,username);
- config.put(AiravataClient.JCR_PASSWORD,password);
- AiravataRegistry2 registryObject = getRegistryObject(username, password);
- if (registryObject!=null){
- URI uri = registryObject.getEventingServiceURI();
- config.put(AiravataClient.BROKER,uri==null? "http://localhost:8080/axis2/services/EventingService":uri.toString());
- uri = registryObject.getMessageBoxURI();
- config.put(AiravataClient.MSGBOX,uri==null? "http://localhost:8080/axis2/services/MsgBoxService":uri.toString());
- List<URI> URLList = registryObject.getWorkflowInterpreterURIs();
- config.put(AiravataClient.WORKFLOWSERVICEURL,URLList==null || URLList.size()==0? "http://localhost:8080/axis2/services/WorkflowInterpretor?wsdl":URLList.get(0).toString());
- List<URI> urlList = registryObject.getGFacURIs();
- config.put(AiravataClient.GFAC,urlList==null || urlList.size()==0? "http://localhost:8080/axis2/services/GFacService":urlList.get(0).toString());
- config.put(AiravataClient.WITHLISTENER,"true");
- }
- return config;
+ .getProperty(DEFAULT_MESSAGE_BOX_URL)));
+ configuration
+ .put(BROKER, validateAxisService(properties
+ .getProperty(DEFAULT_BROKER_URL)));
+ configuration
+ .put(WORKFLOWSERVICEURL, validateAxisService(properties
+ .getProperty(WORKFLOWSERVICEURL)));
+ configuration.put(WITHLISTENER, properties.getProperty(WITHLISTENER));
+
+ initialize();
}
+
+ // protected AiravataClient(URI registryUrl, String username, String
+ // password) throws MalformedURLException, RepositoryException,
+ // RegistryException {
+ // this(createConfig(registryUrl, username, password));
+ // }
+ //
+ // private static HashMap<String, String> createConfig(URI registryUrl,
+ // String username, String password) throws RepositoryException,
+ // RegistryException {
+ // HashMap<String, String> config = new HashMap<String,String>();
+ // config.put(AiravataClient.JCR,registryUrl.toString());
+ // config.put(AiravataClient.JCR_USERNAME,username);
+ // config.put(AiravataClient.JCR_PASSWORD,password);
+ // AiravataRegistry2 registryObject = getRegistryObject(username, password);
+ // if (registryObject!=null){
+ // URI uri = registryObject.getEventingServiceURI();
+ // config.put(AiravataClient.BROKER,uri==null?
+ // "http://localhost:8080/axis2/services/EventingService":uri.toString());
+ // uri = registryObject.getMessageBoxURI();
+ // config.put(AiravataClient.MSGBOX,uri==null?
+ // "http://localhost:8080/axis2/services/MsgBoxService":uri.toString());
+ // List<URI> URLList = registryObject.getWorkflowInterpreterURIs();
+ // config.put(AiravataClient.WORKFLOWSERVICEURL,URLList==null ||
+ // URLList.size()==0?
+ // "http://localhost:8080/axis2/services/WorkflowInterpretor?wsdl":URLList.get(0).toString());
+ // List<URI> urlList = registryObject.getGFacURIs();
+ // config.put(AiravataClient.GFAC,urlList==null || urlList.size()==0?
+ // "http://localhost:8080/axis2/services/GFacService":urlList.get(0).toString());
+ // config.put(AiravataClient.WITHLISTENER,"true");
+ // }
+ // return config;
+ // }
private void initialize() throws MalformedURLException {
updateClientConfiguration(configuration);
-
- // At this point we do not know the workflowExperimentId
+
+ // At this point we do not know the workflowExperimentId
+ // FIXME: Registry URL is set null as its not used. Set this when we
+ // have rest services
builder = new WorkflowContextHeaderBuilder(configuration.get(BROKER),
- configuration.get(GFAC),configuration.get(JCR),null,null,
- configuration.get(MSGBOX));
-
- //TODO: At some point this should contain the current user the airavata client is
- //logged in to the Airavata system
+ configuration.get(GFAC), null, null, null,
+ configuration.get(MSGBOX));
+
+ // TODO: At some point this should contain the current user the airavata
+ // client is
+ // logged in to the Airavata system
setCurrentUser(getClientConfiguration().getJcrUsername());
}
- private void updateClientConfiguration(Map<String,String> configuration)
+ private void updateClientConfiguration(Map<String, String> configuration)
throws MalformedURLException {
AiravataClientConfiguration clientConfiguration = getClientConfiguration();
- if (configuration.get(GFAC) != null) {
- clientConfiguration
- .setGfacURL(new URL(configuration.get(GFAC)));
- }
- if (configuration.get(MSGBOX)!= null) {
- clientConfiguration.setMessageboxURL(new URL(configuration.get(MSGBOX)));
- }
- if (configuration.get(BROKER)!= null) {
- clientConfiguration.setMessagebrokerURL(new URL(configuration.get(BROKER)));
- }
- if (configuration.get(JCR)!= null) {
- clientConfiguration
- .setJcrURL(new URL(configuration.get(JCR)));
- }
- if (configuration.get(WORKFLOWSERVICEURL)!= null) {
- clientConfiguration.setXbayaServiceURL(new URL(configuration.get(WORKFLOWSERVICEURL)));
- }
- if (configuration.get(MSGBOX)!= null) {
- clientConfiguration.setMessageboxURL(new URL(configuration.get(MSGBOX)));
- }
-
- if (clientConfiguration.getJcrURL()!=null && clientConfiguration.getGfacURL()==null){
+ if (configuration.get(GFAC) != null) {
+ clientConfiguration.setGfacURL(new URL(configuration.get(GFAC)));
+ }
+ if (configuration.get(MSGBOX) != null) {
+ clientConfiguration.setMessageboxURL(new URL(configuration
+ .get(MSGBOX)));
+ }
+ if (configuration.get(BROKER) != null) {
+ clientConfiguration.setMessagebrokerURL(new URL(configuration
+ .get(BROKER)));
+ }
+ // if (configuration.get(JCR)!= null) {
+ // clientConfiguration
+ // .setJcrURL(new URL(configuration.get(JCR)));
+ // }
+ if (configuration.get(WORKFLOWSERVICEURL) != null) {
+ clientConfiguration.setXbayaServiceURL(new URL(configuration
+ .get(WORKFLOWSERVICEURL)));
+ }
+ if (configuration.get(MSGBOX) != null) {
+ clientConfiguration.setMessageboxURL(new URL(configuration
+ .get(MSGBOX)));
+ }
+
+ if (clientConfiguration.getJcrURL() != null
+ && clientConfiguration.getGfacURL() == null) {
try {
- clientConfiguration.setGfacURL(getRegistry().getGFacURIs().get(0).toURL());
- configuration.put(GFAC,clientConfiguration.getGfacURL().toString());
+ clientConfiguration.setGfacURL(getRegistry().getGFacURIs()
+ .get(0).toURL());
+ configuration.put(GFAC, clientConfiguration.getGfacURL()
+ .toString());
} catch (Exception e) {
e.printStackTrace();
}
@@ -260,7 +277,8 @@ public class AiravataClient implements A
this.workflow = workflowAsaString;
}
- public static void updateWorkflowInputValuesFromProperties(List<WorkflowInput> inputs, String fileName) throws IOException{
+ public static void updateWorkflowInputValuesFromProperties(
+ List<WorkflowInput> inputs, String fileName) throws IOException {
URL url = AiravataClient.class.getClassLoader().getResource(fileName);
if (url == null) {
url = (new File(fileName)).toURL();
@@ -268,12 +286,12 @@ public class AiravataClient implements A
Properties properties = new Properties();
properties.load(url.openStream());
for (WorkflowInput workflowInput : inputs) {
- if (properties.containsKey(workflowInput.getName())){
+ if (properties.containsKey(workflowInput.getName())) {
workflowInput.setValue(properties.get(workflowInput.getName()));
}
}
}
-
+
public NameValue[] setInputs(String fileName) throws IOException {
URL url = this.getClass().getClassLoader().getResource(fileName);
if (url == null) {
@@ -339,100 +357,129 @@ public class AiravataClient implements A
return runWorkflow(topic, user, null, topic);
}
- public String runWorkflow(String topic, String user, String metadata, String workflowInstanceName) {
+ public String runWorkflow(String topic, String user, String metadata,
+ String workflowInstanceName) {
return runWorkflow(topic, user, metadata, workflowInstanceName, builder);
}
-
- public String runWorkflow(String topic, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder) {
- String worflowoutput = null;
- try {
- WorkflowInterpretorStub stub = new WorkflowInterpretorStub(
- getClientConfiguration().getXbayaServiceURL().toString());
- OMElement omElement = AXIOMUtil.stringToOM(XMLUtil.xmlElementToString(builder.getXml()));
- stub._getServiceClient().addHeader(omElement);
- worflowoutput = stub.launchWorkflow(workflow, topic,null);
- runPreWorkflowExecutionTasks(worflowoutput, user, metadata, workflowInstanceName);
- } catch (AxisFault e) {
+ public String runWorkflow(String topic, String user, String metadata,
+ String workflowInstanceName, WorkflowContextHeaderBuilder builder) {
+ String worflowoutput = null;
+ try {
+ WorkflowInterpretorStub stub = new WorkflowInterpretorStub(
+ getClientConfiguration().getXbayaServiceURL().toString());
+ OMElement omElement = AXIOMUtil.stringToOM(XMLUtil
+ .xmlElementToString(builder.getXml()));
+ stub._getServiceClient().addHeader(omElement);
+ worflowoutput = stub.launchWorkflow(workflow, topic, null);
+ runPreWorkflowExecutionTasks(worflowoutput, user, metadata,
+ workflowInstanceName);
+
+ } catch (AxisFault e) {
+
} catch (RemoteException e) {
-// log.fine(e.getMessage(), e);
+ // log.fine(e.getMessage(), e);
} catch (RegistryException e) {
-// log.fine(e.getMessage(), e);
+ // log.fine(e.getMessage(), e);
} catch (XMLStreamException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-// log.info("Workflow output : " + worflowoutput);
- return worflowoutput;
+ e.printStackTrace(); // To change body of catch statement use File |
+ // Settings | File Templates.
+ }
+ // log.info("Workflow output : " + worflowoutput);
+ return worflowoutput;
}
public Monitor getWorkflowExecutionMonitor(String topic) {
- return getWorkflowExecutionMonitor(topic, null);
- }
+ return getWorkflowExecutionMonitor(topic, null);
+ }
public Monitor getWorkflowExecutionMonitor(String topic,
- MonitorEventListener listener) {
- final String fTopic = topic;
- try {
- monitorConfiguration = new MonitorConfiguration(new URI(
- configuration.get(BROKER)), fTopic, true, new URI(
- configuration.get(MSGBOX)));
- } catch (URISyntaxException e1) {
- e1.printStackTrace();
- }
- final Monitor monitor = new Monitor(monitorConfiguration);
- monitor.setPrint(true);
- monitor.getEventData().registerEventListener(listener);
- return monitor;
- }
-
- private void runPreWorkflowExecutionTasks(String topic, String user,
- String metadata,String experimentName) throws RegistryException {
+ MonitorEventListener listener) {
+ final String fTopic = topic;
+ try {
+ monitorConfiguration = new MonitorConfiguration(new URI(
+ configuration.get(BROKER)), fTopic, true, new URI(
+ configuration.get(MSGBOX)));
+ } catch (URISyntaxException e1) {
+ e1.printStackTrace();
+ }
+ final Monitor monitor = new Monitor(monitorConfiguration);
+ monitor.setPrint(true);
+ monitor.getEventData().registerEventListener(listener);
+ return monitor;
+ }
+
+ private void runPreWorkflowExecutionTasks(String topic, String user,
+ String metadata, String experimentName) throws RegistryException {
if (user != null) {
getRegistry().updateExperimentExecutionUser(topic, user);
}
if (metadata != null) {
getRegistry().updateExperimentMetadata(topic, metadata);
}
- if (experimentName==null) {
- experimentName=topic;
+ if (experimentName == null) {
+ experimentName = topic;
}
getRegistry().updateExperimentName(topic, experimentName);
}
- public String runWorkflow(String topic, NameValue[] inputs) throws Exception {
+ public String runWorkflow(String topic, NameValue[] inputs)
+ throws Exception {
return runWorkflow(topic, inputs, null);
}
- public String runWorkflow(String topic, NameValue[] inputs, String user) throws Exception {
- return runWorkflow(topic, inputs, user, null,topic);
- }
-
- public String runWorkflow(final String topic, final NameValue[] inputs, final String user,
- final String metadata, final String experimentName) throws Exception{
- return runWorkflow(topic, inputs, user, metadata, experimentName, builder);
- }
- public String runWorkflow(final String topic, final NameValue[] inputs, final String user,
- final String metadata, final String experimentName, final WorkflowContextHeaderBuilder builder) throws Exception{
- return runWorkflow(topic, inputs, user, metadata, experimentName, builder, true);
- }
-
- private static int TIMEOUT_STEP=1000;
- private static int MAX_TIMEOUT=60000;
- public String runWorkflow(final String topic, final NameValue[] inputs, final String user,
- final String metadata, final String experimentName, final WorkflowContextHeaderBuilder builder, boolean launchOnThread) throws Exception{
- runPreWorkflowExecutionTasks(topic, user, metadata,experimentName);
+ public String runWorkflow(String topic, NameValue[] inputs, String user)
+ throws Exception {
+ return runWorkflow(topic, inputs, user, null, topic);
+ }
+
+ public String runWorkflow(final String topic, final NameValue[] inputs,
+ final String user, final String metadata,
+ final String experimentName) throws Exception {
+ return runWorkflow(topic, inputs, user, metadata, experimentName,
+ builder);
+ }
+
+ public String runWorkflow(final String topic, final NameValue[] inputs,
+ final String user, final String metadata,
+ final String experimentName,
+ final WorkflowContextHeaderBuilder builder) throws AiravataAPIInvocationException {
+ return runWorkflow(topic, inputs, user, metadata, experimentName,
+ builder, true);
+ }
+
+ private static int TIMEOUT_STEP = 1000;
+ private static int MAX_TIMEOUT = 60000;
+
+ public String runWorkflow(final String topic, final NameValue[] inputs,
+ final String user, final String metadata,
+ final String experimentName,
+ final WorkflowContextHeaderBuilder builder, boolean launchOnThread)
+ throws AiravataAPIInvocationException {
+ try {
+ runPreWorkflowExecutionTasks(topic, user, metadata, experimentName);
+ } catch (RegistryException e) {
+ throw new AiravataAPIInvocationException(e);
+ }
if (launchOnThread) {
new Thread(new Runnable() {
public void run() {
launchWorkflow(topic, inputs, builder);
}
}).start();
- int timeout=0;
- while(!getRegistry().isExperimentExists(topic) && timeout<MAX_TIMEOUT){
- Thread.sleep(TIMEOUT_STEP);
- timeout+=MAX_TIMEOUT;
+ int timeout = 0;
+ try {
+ while (!getRegistry().isExperimentExists(topic)
+ && timeout < MAX_TIMEOUT) {
+ Thread.sleep(TIMEOUT_STEP);
+ timeout += MAX_TIMEOUT;
+ }
+ } catch (RegistryException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (InterruptedException e) {
+ throw new AiravataAPIInvocationException(e);
}
- }else{
+ } else {
launchWorkflow(topic, inputs, builder);
}
return topic;
@@ -463,19 +510,18 @@ public class AiravataClient implements A
public AiravataRegistry2 getRegistry() throws RegistryException {
if (registry == null) {
- String jcrUsername = getClientConfiguration().getJcrUsername();
- String jcrPassword = getClientConfiguration().getJcrPassword();
- registry = getRegistryObject(jcrUsername, jcrPassword);
- }
+ String jcrUsername = getClientConfiguration().getJcrUsername();
+ String jcrPassword = getClientConfiguration().getJcrPassword();
+ registry = getRegistryObject(jcrUsername, jcrPassword);
+ }
return registry;
}
- private static AiravataRegistry2 getRegistryObject(
- String jcrUsername,
- String jcrPassword)
- throws RegistryException {
- AiravataRegistry2 registry = new JCRComponentRegistry(jcrUsername,jcrPassword).getRegistry();
- return registry;
+ private static AiravataRegistry2 getRegistryObject(String jcrUsername,
+ String jcrPassword) throws RegistryException {
+ AiravataRegistry2 registry = new JCRComponentRegistry(jcrUsername,
+ jcrPassword).getRegistry();
+ return registry;
}
public AiravataClientConfiguration getClientConfiguration() {
@@ -487,7 +533,7 @@ public class AiravataClient implements A
private String validateAxisService(String urlString)
throws RegistryException {
- String originalURL=urlString;
+ String originalURL = urlString;
if (!urlString.endsWith("?wsdl")) {
urlString = urlString + "?wsdl";
}
@@ -538,128 +584,207 @@ public class AiravataClient implements A
}
return workflowList;
}
-
- public String runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs) throws Exception{
- return runWorkflow(workflowTemplateId,inputs,getRegistry().getUser().getUserName(),null,workflowTemplateId+"_"+Calendar.getInstance().getTime().toString());
- }
-
- public String runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs,String workflowInstanceName) throws Exception{
- return runWorkflow(workflowTemplateId,inputs,getRegistry().getUser().getUserName(),null,workflowInstanceName);
+
+ public String runWorkflow(String workflowTemplateId,
+ List<WorkflowInput> inputs) throws Exception {
+ return runWorkflow(workflowTemplateId, inputs, getRegistry().getUser()
+ .getUserName(), null, workflowTemplateId + "_"
+ + Calendar.getInstance().getTime().toString());
+ }
+
+ public String runWorkflow(String workflowTemplateId,
+ List<WorkflowInput> inputs, String workflowInstanceName)
+ throws Exception {
+ return runWorkflow(workflowTemplateId, inputs, getRegistry().getUser()
+ .getUserName(), null, workflowInstanceName);
}
-
- public String runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName) throws Exception{
+
+ public String runWorkflow(String workflowTemplateId,
+ List<WorkflowInput> inputs, String user, String metadata,
+ String workflowInstanceName) throws Exception {
Workflow workflowObj = getWorkflow(workflowTemplateId);
- return runWorkflow(workflowObj, inputs, user, metadata,workflowInstanceName,builder);
+ return runWorkflow(workflowObj, inputs, user, metadata,
+ workflowInstanceName, builder);
}
- public String runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder) throws Exception{
+ public String runWorkflow(String workflowTemplateId,
+ List<WorkflowInput> inputs, String user, String metadata,
+ String workflowInstanceName, WorkflowContextHeaderBuilder builder)
+ throws Exception {
Workflow workflowObj = getWorkflow(workflowTemplateId);
- return runWorkflow(workflowObj, inputs, user, metadata,workflowInstanceName,builder);
+ return runWorkflow(workflowObj, inputs, user, metadata,
+ workflowInstanceName, builder);
}
-
- public String runWorkflow(Workflow workflow,
- List<WorkflowInput> inputs, String workflowInstanceName)
- throws GraphException, ComponentException, Exception {
- return runWorkflow(workflow, inputs, null, null, workflowInstanceName,builder);
+
+ public String runWorkflow(Workflow workflow, List<WorkflowInput> inputs,
+ String workflowInstanceName) throws GraphException,
+ ComponentException, Exception {
+ return runWorkflow(workflow, inputs, null, null, workflowInstanceName,
+ builder);
}
- public String runWorkflow(Workflow workflowObj,
- List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName)
+ public String runWorkflow(Workflow workflowObj, List<WorkflowInput> inputs,
+ String user, String metadata, String workflowInstanceName)
throws GraphException, ComponentException, Exception {
- return runWorkflow(workflowObj, inputs, user, metadata, workflowInstanceName,builder);
+ return runWorkflow(workflowObj, inputs, user, metadata,
+ workflowInstanceName, builder);
}
-
- public String runWorkflow(Workflow workflowObj,
- List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder)
- throws GraphException, ComponentException, Exception {
+
+ public String runWorkflow(Workflow workflowObj, List<WorkflowInput> inputs,
+ String user, String metadata, String workflowInstanceName,
+ WorkflowContextHeaderBuilder builder) throws AiravataAPIInvocationException{
try {
- String workflowString=XMLUtil.xmlElementToString(workflowObj.toXML());
+ String workflowString = XMLUtil.xmlElementToString(workflowObj
+ .toXML());
List<WSComponentPort> ports = getWSComponentPortInputs(workflowObj);
for (WorkflowInput input : inputs) {
- WSComponentPort port = getWSComponentPort(input.getName(), ports);
- if (port!=null){
+ WSComponentPort port = getWSComponentPort(input.getName(),
+ ports);
+ if (port != null) {
port.setValue(input.getValue());
}
}
- List<NameValue> inputValues=new ArrayList<NameValue>();
+ List<NameValue> inputValues = new ArrayList<NameValue>();
for (WSComponentPort port : ports) {
NameValue nameValue = new NameValue();
nameValue.setName(port.getName());
- if (port.getValue()==null){
+ if (port.getValue() == null) {
nameValue.setValue(port.getDefaultValue());
- }else{
+ } else {
nameValue.setValue(port.getValue().toString());
}
inputValues.add(nameValue);
}
- workflow=workflowString;
- String topic=workflowObj.getName()+"_"+UUID.randomUUID();
- getRegistry().setWorkflowInstanceTemplateName(topic, workflowObj.getName());
- return runWorkflow(topic, inputValues.toArray(new NameValue[]{}), user, metadata, workflowInstanceName,builder);
- } catch (PathNotFoundException e) {
- e.printStackTrace();
+ workflow = workflowString;
+ String topic = workflowObj.getName() + "_" + UUID.randomUUID();
+ getRegistry().setWorkflowInstanceTemplateName(topic,
+ workflowObj.getName());
+ return runWorkflow(topic, inputValues.toArray(new NameValue[] {}),
+ user, metadata, workflowInstanceName, builder);
} catch (RegistryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (RepositoryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new AiravataAPIInvocationException(e);
+ } catch (GraphException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (ComponentException e) {
+ throw new AiravataAPIInvocationException(e);
+ }
+ }
+
+ public String runWorkflow(String workflowName, List<WorkflowInput> inputs,
+ String user, String metadata, String workflowInstanceName,
+ String experimentID) throws AiravataAPIInvocationException {
+ try {
+ Workflow workflowObj = getWorkflow(workflowName);
+ String workflowString = XMLUtil.xmlElementToString(workflowObj
+ .toXML());
+ List<WSComponentPort> ports;
+ ports = getWSComponentPortInputs(workflowObj);
+ for (WorkflowInput input : inputs) {
+ WSComponentPort port = getWSComponentPort(input.getName(),
+ ports);
+ if (port != null) {
+ port.setValue(input.getValue());
+ }
+ }
+ List<NameValue> inputValues = new ArrayList<NameValue>();
+ for (WSComponentPort port : ports) {
+ NameValue nameValue = new NameValue();
+ nameValue.setName(port.getName());
+ if (port.getValue() == null) {
+ nameValue.setValue(port.getDefaultValue());
+ } else {
+ nameValue.setValue(port.getValue().toString());
+ }
+ inputValues.add(nameValue);
+ }
+ workflow = workflowString;
+ if (experimentID == null || experimentID.isEmpty()) {
+ experimentID = workflowObj.getName() + "_" + UUID.randomUUID();
+ }
+ getRegistry().setWorkflowInstanceTemplateName(experimentID,
+ workflowObj.getName());
+ return runWorkflow(experimentID,
+ inputValues.toArray(new NameValue[] {}), user, metadata,
+ workflowInstanceName, this.builder);
+ } catch (RegistryException e) {
+ throw new AiravataAPIInvocationException(
+ "Error working with Airavata Registry: "
+ + e.getLocalizedMessage(), e);
+ } catch (GraphException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (ComponentException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (Exception e) {
+ throw new AiravataAPIInvocationException(e);
}
- return null;
}
-
- public List<WorkflowInput> getWorkflowInputs(String workflowTemplateId) throws Exception{
+
+ public List<WorkflowInput> getWorkflowInputs(String workflowTemplateId)
+ throws AiravataAPIInvocationException {
try {
Workflow workflowTemplate = getWorkflow(workflowTemplateId);
- List<WSComponentPort> inputs = getWSComponentPortInputs(workflowTemplate);
- List<InputNode> inputNodes = getInputNodes(workflowTemplate);
- List<WorkflowInput> results=new ArrayList<WorkflowInput>();
+ List<WSComponentPort> inputs = getWSComponentPortInputs(workflowTemplate);
+ List<InputNode> inputNodes = getInputNodes(workflowTemplate);
+ List<WorkflowInput> results = new ArrayList<WorkflowInput>();
for (InputNode port : inputNodes) {
- Object value=null;
- WSComponentPort wsComponentPort = getWSComponentPort(port.getName(), inputs);
- if (wsComponentPort!=null){
- value=wsComponentPort.getValue();
+ Object value = null;
+ WSComponentPort wsComponentPort = getWSComponentPort(
+ port.getName(), inputs);
+ if (wsComponentPort != null) {
+ value = wsComponentPort.getValue();
}
- results.add(new WorkflowInput(port.getName(), port.getParameterType().getLocalPart(), port.getDefaultValue(), value, !port.isVisibility()));
+ results.add(new WorkflowInput(port.getName(), port
+ .getParameterType().getLocalPart(), port
+ .getDefaultValue(), value, !port.isVisibility()));
}
return results;
- } catch (RegistryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (RepositoryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (AiravataAPIInvocationException e) {
+ throw e;
+ }catch (Exception e) {
+ throw new AiravataAPIInvocationException(e);
}
- return null;
}
public String getWorkflowAsString(String workflowTemplateId)
- throws RegistryException, PathNotFoundException,
- RepositoryException {
- Map<String, String> workflows = getRegistry().getWorkflows();
- for (String name : workflows.keySet()) {
- if (name.equals(workflowTemplateId)){
- return workflows.get(name);
+ throws AiravataAPIInvocationException {
+ try {
+ Map<String, String> workflows = getRegistry().getWorkflows();
+ for (String name : workflows.keySet()) {
+ if (name.equals(workflowTemplateId)) {
+ return workflows.get(name);
+ }
}
+ return null;
+ } catch (RegistryException e) {
+ throw new AiravataAPIInvocationException(e);
}
- return null;
+
}
-
private List<WSComponentPort> getWSComponentPortInputs(
- String workflowTemplateId) throws RegistryException,
- PathNotFoundException, RepositoryException, GraphException,
- ComponentException, ValueFormatException {
+ String workflowTemplateId) throws AiravataAPIInvocationException{
Workflow workflow = getWorkflow(workflowTemplateId);
- return getWSComponentPortInputs(workflow);
+ try {
+ return getWSComponentPortInputs(workflow);
+ } catch (GraphException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (ComponentException e) {
+ throw new AiravataAPIInvocationException(e);
+ }
}
private Workflow getWorkflow(String workflowTemplateId)
- throws RegistryException, PathNotFoundException,
- RepositoryException, GraphException, ComponentException,
- ValueFormatException {
- Workflow workflow = new Workflow(getWorkflowAsString(workflowTemplateId));
- return workflow;
+ throws AiravataAPIInvocationException {
+ try {
+ Workflow workflow = new Workflow(
+ getWorkflowAsString(workflowTemplateId));
+ return workflow;
+ } catch (GraphException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (ComponentException e) {
+ throw new AiravataAPIInvocationException(e);
+ }
+
}
private List<WSComponentPort> getWSComponentPortInputs(Workflow workflow)
@@ -668,188 +793,143 @@ public class AiravataClient implements A
List<WSComponentPort> inputs = workflow.getInputs();
return inputs;
}
-
- private List<InputNode> getInputNodes(String workflowTemplateId) throws PathNotFoundException, GraphException, ComponentException, ValueFormatException, RegistryException, RepositoryException{
+
+ private List<InputNode> getInputNodes(String workflowTemplateId)
+ throws AiravataAPIInvocationException {
Workflow workflow = getWorkflow(workflowTemplateId);
return getInputNodes(workflow);
}
-
+
private List<InputNode> getInputNodes(Workflow workflow) {
- List<InputNode> inputNodes = GraphUtil.getInputNodes(workflow.getGraph());
+ List<InputNode> inputNodes = GraphUtil.getInputNodes(workflow
+ .getGraph());
return inputNodes;
}
-
- private WSComponentPort getWSComponentPort(String name,List<WSComponentPort> ports){
+
+ private WSComponentPort getWSComponentPort(String name,
+ List<WSComponentPort> ports) {
for (WSComponentPort port : ports) {
- if (port.getName().equals(name)){
+ if (port.getName().equals(name)) {
return port;
}
}
return null;
}
-
+
public static WorkflowContextHeaderBuilder getBuilder() {
- return builder;
+ return builder;
}
- public static void main(String[] args) throws Exception {
- AiravataAPI api = AiravataClientUtils.getAPI(new URI("http://localhost:8080"), "admin", "admin");
- Workflow w = api.getWorkflowManager().getWorkflow("Workflow1");
- List<WorkflowInput> workflowInputs = w.getWorkflowInputs();
- for (WorkflowInput input : workflowInputs) {
- input.setValue("0");
- }
- System.out.println(api.getExecutionManager().runExperiment(w,workflowInputs));
-// ProvenanceManager pm = api.getProvenanceManager();
-// ExperimentData workflowExperimentData = pm.getWorkflowExperimentData("Workflow1_9341caee-b3fc-4474-9b15-b943756a5839");
-
-// pm.getExperimentIdList(owner)
-// workflowInstanceData = d.getWorkflowInstanceData().get(0).getNodeDataList();
-// d.get
-// pm.setWorkflowInstanceNodeOutput(new WorkflowInstanceNode(new WorkflowInstance("test", "test"), "test_node"), "some_data");
-// pm.setWorkflowInstanceStatus(new WorkflowInstanceStatus(new WorkflowInstance("test", "test"), ExecutionStatus.RUNNING));
-// List<String> experiments = pm.getExperiments();
-// for (String id : experiments) {
-// System.out.println(id);
-// }
-// api.getAiravataManager().getEventingServiceURL();
-// System.out.println(api.getAiravataManager().getEventingServiceURL());
-
-//// AiravataAPI api = AiravataClientUtils.getAPI(new URI("http://gf7.ucs.indiana.edu:8030/jackrabbit/rmi"), "admin", "admin");
-//// System.out.println(api.getAiravataManager().getWorkflowInterpreterServiceURL());
-//// System.exit(0);
-//// WorkflowSchedulingContext workflowSchedulingContext= WorkflowSchedulingContext.Factory.newInstance();
-//// WorkflowContextHeaderBuilder workflowContextHeader = api.getExecutionManager().createWorkflowContextHeader();
-//// workflowContextHeader.setWorkflowSchedulingContext(workflowSchedulingContext);
-//// workflowSchedulingContext.addNewApplicationSchedulingContext();
-//// System.out.println(workflowContextHeader.getWorkflowSchedulingContext());
-//// System.exit(0);
-//
-// HashMap<String, String> map;
-// URI uri;
-//
-// uri=new URI("http://gw56.quarry.iu.teragrid.org:8090/jackrabbit-webapp-2.4.0/rmi");
-//// uri=new URI("http://localhost:8081/rmi");
-// map = new HashMap<String, String>();
-// map.put("org.apache.jackrabbit.repository.uri", uri.toString());
-// AiravataJCRRegistry reg1 = new AiravataJCRRegistry(uri, "org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory", "admin","admin", map);
-//
-// uri=new URI("http://gw26.quarry.iu.teragrid.org:8090/jackrabbit-webapp-2.4.0/rmi");
-//// uri=new URI("http://localhost:8082/rmi");
-// map = new HashMap<String, String>();
-// map.put("org.apache.jackrabbit.repository.uri", uri.toString());
-// AiravataJCRRegistry reg2 = new AiravataJCRRegistry(uri, "org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory", "admin","admin", map);
-//// Session login = reg2.getRepository().login(new SimpleCredentials("admin","admin".toCharArray()));
-//// login.getRootNode().getNode("experiments").remove();
-//// login.getRootNode().getNode("AIRAVATA_CONFIGURATION_DATA").remove();
-//// login.save();
-//// login.logout();
-//// migrateRespositoryData(reg1, reg2);
-// System.exit(0);
- }
-
- private static void addNode(Node parentNode, Node childNode) throws RepositoryException{
+ private static void addNode(Node parentNode, Node childNode)
+ throws RepositoryException {
Node node;
String childNodeName = childNode.getName();
- if (!parentNode.hasNode(childNodeName)){
- node=parentNode.addNode(childNodeName);
- }else{
- node=parentNode.getNode(childNodeName);
+ if (!parentNode.hasNode(childNodeName)) {
+ node = parentNode.addNode(childNodeName);
+ } else {
+ node = parentNode.getNode(childNodeName);
}
System.out.println(node.getPath());
PropertyIterator childProperties = childNode.getProperties();
- while(childProperties.hasNext()){
+ while (childProperties.hasNext()) {
Property childProperty = childProperties.nextProperty();
- if (!(childProperty.getName().startsWith("jcr:") || childProperty.getName().startsWith("rep:"))) {
- if (childProperty.isMultiple()){
+ if (!(childProperty.getName().startsWith("jcr:") || childProperty
+ .getName().startsWith("rep:"))) {
+ if (childProperty.isMultiple()) {
node.setProperty(childProperty.getName(),
childProperty.getValues());
- }else{
+ } else {
node.setProperty(childProperty.getName(),
childProperty.getValue());
}
-
+
}
}
NodeIterator children = childNode.getNodes();
- while(children.hasNext()){
- Node c=children.nextNode();
- addNode(node,c);
- }
- }
-
-// private static void migrateRespositoryData(
-// AiravataJCRRegistry sourceRegistry,
-// AiravataJCRRegistry targetRegistry) throws Exception {
-// Session session1 = null;
-// Session session2 = null;
-// try {
-// session1 = sourceRegistry.getRepository().login(new SimpleCredentials(sourceRegistry.getUsername(), new String(sourceRegistry.getPassword()).toCharArray()));
-// session2 = targetRegistry.getRepository().login(new SimpleCredentials(targetRegistry.getUsername(), new String(targetRegistry.getPassword()).toCharArray()));
-// } catch (Exception e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// throw e;
-// }
-//
-//
-// NodeIterator nodes = session1.getRootNode().getNodes();
-// Node rootNode = session2.getRootNode();
-// List<String> ignoreRoots=Arrays.asList(new String[]{"/AIRAVATA_CONFIGURATION_DATA"});
-// while(nodes.hasNext()){
-// Node nextNode = nodes.nextNode();
-// String path = nextNode.getPath();
-// if (!(path.equals("/jcr:system")||path.equals("/rep:policy") || ignoreRoots.contains(path))) {
-// addNode(rootNode,nextNode);
-// System.out.println();
-// }
-// }
-// System.out.print("Saving session.");
-// session1.logout();
-// System.out.print(".");
-// session2.save();
-// System.out.print(".");
-// session2.logout();
-// System.out.println(".done");
-// }
-
+ while (children.hasNext()) {
+ Node c = children.nextNode();
+ addNode(node, c);
+ }
+ }
+
+ // private static void migrateRespositoryData(
+ // AiravataJCRRegistry sourceRegistry,
+ // AiravataJCRRegistry targetRegistry) throws Exception {
+ // Session session1 = null;
+ // Session session2 = null;
+ // try {
+ // session1 = sourceRegistry.getRepository().login(new
+ // SimpleCredentials(sourceRegistry.getUsername(), new
+ // String(sourceRegistry.getPassword()).toCharArray()));
+ // session2 = targetRegistry.getRepository().login(new
+ // SimpleCredentials(targetRegistry.getUsername(), new
+ // String(targetRegistry.getPassword()).toCharArray()));
+ // } catch (Exception e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // throw e;
+ // }
+ //
+ //
+ // NodeIterator nodes = session1.getRootNode().getNodes();
+ // Node rootNode = session2.getRootNode();
+ // List<String> ignoreRoots=Arrays.asList(new
+ // String[]{"/AIRAVATA_CONFIGURATION_DATA"});
+ // while(nodes.hasNext()){
+ // Node nextNode = nodes.nextNode();
+ // String path = nextNode.getPath();
+ // if (!(path.equals("/jcr:system")||path.equals("/rep:policy") ||
+ // ignoreRoots.contains(path))) {
+ // addNode(rootNode,nextNode);
+ // System.out.println();
+ // }
+ // }
+ // System.out.print("Saving session.");
+ // session1.logout();
+ // System.out.print(".");
+ // session2.save();
+ // System.out.print(".");
+ // session2.logout();
+ // System.out.println(".done");
+ // }
+
public AiravataManager getAiravataManager() {
- if (airavataManagerImpl==null) {
+ if (airavataManagerImpl == null) {
airavataManagerImpl = new AiravataManagerImpl(this);
}
return airavataManagerImpl;
}
public ApplicationManager getApplicationManager() {
- if (applicationManagerImpl==null) {
+ if (applicationManagerImpl == null) {
applicationManagerImpl = new ApplicationManagerImpl(this);
}
return applicationManagerImpl;
}
public WorkflowManager getWorkflowManager() {
- if (workflowManagerImpl==null) {
+ if (workflowManagerImpl == null) {
workflowManagerImpl = new WorkflowManagerImpl(this);
}
return workflowManagerImpl;
}
public ProvenanceManager getProvenanceManager() {
- if (provenanceManagerImpl==null) {
+ if (provenanceManagerImpl == null) {
provenanceManagerImpl = new ProvenanceManagerImpl(this);
}
return provenanceManagerImpl;
}
public UserManager getUserManager() {
- if (userManagerImpl==null) {
+ if (userManagerImpl == null) {
userManagerImpl = new UserManagerImpl(this);
}
return userManagerImpl;
}
public ExecutionManager getExecutionManager() {
- if (executionManagerImpl==null) {
+ if (executionManagerImpl == null) {
executionManagerImpl = new ExecutionManagerImpl(this);
}
return executionManagerImpl;
@@ -859,23 +939,19 @@ public class AiravataClient implements A
return currentUser;
}
+ public List<String> getWorkflowServiceNodeIDs(String templateID) throws AiravataAPIInvocationException {
+ try {
+ Workflow workflow = new Workflow(getWorkflowAsString(templateID));
+ return workflow.getWorkflowServiceNodeIDs();
+ } catch (GraphException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (ComponentException e) {
+ throw new AiravataAPIInvocationException(e);
+ } catch (AiravataAPIInvocationException e) {
+ throw e;
+ }
+ }
- public List<String> getWorkflowServiceNodeIDs(String templateID) {
- try {
- Workflow workflow = new Workflow(getWorkflowAsString(templateID));
- return workflow.getWorkflowServiceNodeIDs();
- } catch (RegistryException e) {
- e.printStackTrace();
- } catch (RepositoryException e) {
- e.printStackTrace();
- } catch (GraphException e) {
- e.printStackTrace();
- } catch (ComponentException e) {
- e.printStackTrace();
- }
- return null;
- }
-
public Version getVersion() {
return API_VERSION;
}
@@ -888,13 +964,12 @@ public class AiravataClient implements A
final WorkflowContextHeaderBuilder builder) {
try {
WorkflowInterpretorStub stub = new WorkflowInterpretorStub(
- getClientConfiguration().getXbayaServiceURL()
- .toString());
+ getClientConfiguration().getXbayaServiceURL().toString());
stub._getServiceClient().addHeader(
- AXIOMUtil.stringToOM(XMLUtil
- .xmlElementToString(builder.getXml())));
+ AXIOMUtil.stringToOM(XMLUtil.xmlElementToString(builder
+ .getXml())));
stub.launchWorkflow(workflow, topic, inputs);
- // log.info("Workflow output : " + worflowoutput);
+ // log.info("Workflow output : " + worflowoutput);
} catch (AxisFault e) {
e.printStackTrace();
} catch (XMLStreamException e) {
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClientUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClientUtils.java?rev=1403461&r1=1403460&r2=1403461&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClientUtils.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClientUtils.java Mon Oct 29 18:58:11 2012
@@ -35,18 +35,18 @@ public class AiravataClientUtils {
public static AiravataAPI getAPI(URI registryURL, String username, String password) throws MalformedURLException, RepositoryException, RegistryException{
return getAPI(registryURL, username, password, username);
}
-
+
public static AiravataAPI getAPI(URI registryURL, String username, String password, String alternateUsername) throws MalformedURLException, RepositoryException, RegistryException{
- AiravataClient apiObj = new AiravataClient(registryURL, username, password);
+ AiravataClient apiObj = new AiravataClient();
apiObj.setCurrentUser(alternateUsername);
return apiObj;
}
-
+
public static AiravataAPI getAPI(Map<String,String> configuration) throws MalformedURLException{
AiravataClient apiObj = new AiravataClient(configuration);
return apiObj;
}
-
+
public static AiravataAPI getAPI(String filename) throws MalformedURLException, RegistryException, IOException{
AiravataClient apiObj = new AiravataClient(filename);
return apiObj;
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPIInvocationException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPIInvocationException.java?rev=1403461&r1=1403460&r2=1403461&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPIInvocationException.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPIInvocationException.java Mon Oct 29 18:58:11 2012
@@ -21,12 +21,26 @@
package org.apache.airavata.client.api;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class AiravataAPIInvocationException extends Exception {
+ private static final Logger log = LoggerFactory.getLogger(AiravataAPIInvocationException.class);
private static final long serialVersionUID = 1L;
-
+
public AiravataAPIInvocationException(Throwable e) {
super("Error invoking API", e);
+ log.error(e.getLocalizedMessage(),e);
+ }
+ public AiravataAPIInvocationException(String message) {
+ super(message, null);
+ log.error(message);
+ }
+
+ public AiravataAPIInvocationException(String message, Throwable e) {
+ super(message, e);
+ log.error(message,e);
}
}
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java?rev=1403461&r1=1403460&r2=1403461&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java Mon Oct 29 18:58:11 2012
@@ -32,7 +32,7 @@ import org.apache.airavata.xbaya.monitor
public interface ExecutionManager {
/**
- * Run an experiment containing single workflow
+ * Run an experiment containing single workflow
* @param workflowTemplateId
* @param inputs
* @return
@@ -62,6 +62,18 @@ public interface ExecutionManager {
public abstract String runExperiment(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName)throws AiravataAPIInvocationException;
/**
+ * Run an experiment containing single workflow
+ * @param workflowTemplateId
+ * @param inputs
+ * @param user
+ * @param metadata
+ * @param workflowInstanceName
+ * @return
+ * @throws AiravataAPIInvocationException
+ */
+ public abstract String runExperiment(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, String experimentName)throws AiravataAPIInvocationException;
+
+ /**
* Run an experiment containing single workflow
* @param workflowTemplateId
* @param inputs
@@ -73,7 +85,7 @@ public interface ExecutionManager {
* @throws AiravataAPIInvocationException
*/
public abstract String runExperiment(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder)throws AiravataAPIInvocationException;
-
+
/**
* Run an experiment containing single workflow
* @param workflow
@@ -101,11 +113,11 @@ public interface ExecutionManager {
* @throws AiravataAPIInvocationException
*/
public Monitor getExperimentMonitor(String experimentId, MonitorEventListener listener) throws AiravataAPIInvocationException;
-
+
/**
* Creates a WorkflowContextHeaderBuilder object that can be used to customize the scheduling of a workflow execution.
- * Once configured this object run the workflow using
- * <code>runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder)</code>
+ * Once configured this object run the workflow using
+ * <code>runWorkflow(String workflowTemplateId,List<WorkflowInput> inputs, String user, String metadata, String workflowInstanceName, WorkflowContextHeaderBuilder builder)</code>
* @return
* @throws AiravataAPIInvocationException
*/
Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java?rev=1403461&r1=1403460&r2=1403461&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java Mon Oct 29 18:58:11 2012
@@ -38,11 +38,11 @@ import org.apache.airavata.xbaya.monitor
public class ExecutionManagerImpl implements ExecutionManager {
private AiravataClient client;
-
+
public ExecutionManagerImpl(AiravataClient client) {
setClient(client);
}
-
+
@Override
public String runExperiment(String workflowTemplateId,
List<WorkflowInput> inputs) throws AiravataAPIInvocationException {
@@ -89,7 +89,7 @@ public class ExecutionManagerImpl implem
throws AiravataAPIInvocationException {
return getClient().getWorkflowExecutionMonitor(experimentId,listener);
}
-
+
public AiravataClient getClient() {
return client;
}
@@ -134,4 +134,16 @@ public class ExecutionManagerImpl implem
return ec;
}
+ @Override
+ public String runExperiment(String workflowName,
+ List<WorkflowInput> inputs, String user, String metadata,
+ String workflowInstanceName, String experimentName)
+ throws AiravataAPIInvocationException {
+ try {
+ return getClient().runWorkflow(workflowName, inputs, user, metadata, workflowInstanceName,experimentName);
+ } catch (Exception e) {
+ throw new AiravataAPIInvocationException(e);
+ }
+ }
+
}