@@ -663,13 +663,41 @@ public String runWorkflow(String wflowname, List<VariableBinding> vbindings, Map
663663 //return null;
664664 }
665665
666- public String fetchDataFromWings (String dataid ) {
667- String getpage = "users/" + getUsername () + "/" + domain + "/data/fetch" ;
668-
669- // Check for data already present on the server
666+ public byte [] fetchDataFromWings (String dataid ) {
667+ String url = this .server + "/users/" + getUsername () + "/" + domain + "/data/fetch" ;
668+ // Download data already present on the server
670669 List <NameValuePair > formdata = new ArrayList <NameValuePair >();
671670 formdata .add (new BasicNameValuePair ("data_id" , dataid ));
672- return this .get (getpage , formdata );
671+ url += "?" + URLEncodedUtils .format (formdata , "UTF-8" );
672+
673+ this .login ();
674+ CloseableHttpClient client = HttpClientBuilder .create ().build ();
675+ byte [] bytes = null ;
676+ try {
677+ HttpGet securedResource = new HttpGet (url );
678+ CloseableHttpResponse httpResponse = client .execute (securedResource );
679+ try {
680+ HttpEntity responseEntity = httpResponse .getEntity ();
681+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
682+ responseEntity .writeTo (baos );
683+ bytes = baos .toByteArray ();
684+ EntityUtils .consume (responseEntity );
685+ httpResponse .close ();
686+ } catch (Exception e ) {
687+ throw e ;
688+ } finally {
689+ httpResponse .close ();
690+ }
691+ } catch (Exception e ) {
692+ e .printStackTrace ();
693+ } finally {
694+ try {
695+ client .close ();
696+ } catch (IOException e ) {
697+ }
698+ }
699+
700+ return bytes ;
673701 }
674702
675703 public String addOrUpdateData (String id , String type , String contents , boolean addServer ) {
@@ -1310,7 +1338,7 @@ public WorkflowRun getRunStatus(String runId) {
13101338 }
13111339
13121340 @ Override
1313- public String fetchData (String dataId ) {
1341+ public byte [] fetchData (String dataId ) {
13141342 return this .fetchDataFromWings (dataId );
13151343 }
13161344
0 commit comments