/** * Get workflow t2flow input stream from content-uri * * @param wf Workflow * @return t2flow input stream */ public InputStream getMyExperimentWorkflowContentStream(Workflow wf) throws DefaultHttpClientException { try { if (myExperimentSession != null) { if (wf != null) { String contentUri = wf.getMyExperimentContentUri(); if (contentUri != null) { URL url = new URL(wf.getMyExperimentContentUri()); HttpResponse wfResponse = myExpRestClient.executeGet( url, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", myExperimentSession); return wfResponse.getEntity().getContent(); } else { throw new DefaultHttpClientException("Invalid workflow or content uri is empty"); } } else { throw new DefaultHttpClientException("Invalid workflow object!"); } } else { throw new DefaultHttpClientException("MyExperiment-Session is not initialised!"); } } catch (Exception ex) { throw new DefaultHttpClientException(ex.getMessage()); } }
/** * Get workflow xml description from myExperiment * * @return Workflow object */ public Workflow getMyExperimentWorkflow(int wfId) throws DefaultHttpClientException { Workflow wf = new Workflow(); wf.setWfid(wfId); String fileName = wfId + ".t2flow"; wf.setFilename(fileName); // get workflow metadata if (myExperimentSession != null) { HttpResponse response = myExpRestClient.executeGet( "/workflow.xml?id=" + wfId, "application/xml", myExperimentSession); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 404) { throw new DefaultHttpClientException( "Workflow " + wfId + " is not available on myExperiment."); } XmlResponseParser responseParser = new XmlResponseParser(response); if (responseParser == null) { throw new DefaultHttpClientException("Error while initialising response parser"); } responseParser.parseResponse(); if (responseParser.isIsParsed()) { XPathEvaluator xPathEval = new XPathEvaluator(responseParser); wf.setTitle(getXmlDescrWorkflowProperty(xPathEval, "/workflow/title", false)); wf.setDescription(getXmlDescrWorkflowProperty(xPathEval, "/workflow/description", true)); wf.setMyExperimentContentUri( getXmlDescrWorkflowProperty(xPathEval, "/workflow/content-uri", false)); wf.setMyExperimentPreviewUri( getXmlDescrWorkflowProperty(xPathEval, "/workflow/preview", false)); } } else { throw new DefaultHttpClientException("MyExperiment-Session is not initialised!"); } return wf; }