taverna-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Akah <larrya...@gmail.com>
Subject Re: GSOC Taverna Mobile: Uploading workflows to the Taverna player
Date Fri, 03 Jul 2015 13:13:38 GMT
So, you are saying the string should look like this?

String post =
{workflow:{document:data:application/octet-stream;base64,"+Base64.encodeToString(sb.toString().getBytes(),
Base64.DEFAULT)+"}}";

I get the error code: 400 and message: 'Bad request'

Might want to have a look at the following code snippet:

                String basicAuth = Base64.encodeToString(new
> String("username:password").getBytes(), Base64.DEFAULT);
>
                URL posturl = new URL(playerurl);
>                 HttpURLConnection connection = (HttpURLConnection)
> posturl.openConnection();
>                 connection.setRequestProperty("Authorization", basicAuth);
>                 connection.setRequestProperty("Content-Type",
> "application/json");
>                 connection.setRequestMethod("POST");
>                 connection.connect(); //send request
>


>                 DataOutputStream dos = new
> DataOutputStream(connection.getOutputStream());
>                 dos.writeBytes(post);//write post data which is a
> formatted json data representing body of workflow
>                 //dos.writeUTF("");
>                 dos.flush();
>                 dos.close();
>
Cheers


2015-07-03 14:04 GMT+01:00 Larry Akah <larryakah@gmail.com>:

> the code is already in my repository
>
> 2015-07-03 14:01 GMT+01:00 Larry Akah <larryakah@gmail.com>:
>
>> Ok, let me try that.
>>
>> Thanks
>>
>> 2015-07-03 13:57 GMT+01:00 Ian Dunlop <Ian.Dunlop@manchester.ac.uk>:
>>
>>> Hello,
>>>
>>> There should be no encoding in the request, there should be no /", it's
>>> just a plain string. I think you are getting confused by the JSON. The
>>> request is not JSON encoded, it is JSON formatted ie. Key value pairs. Look
>>> at the request I included in this thread and use it as a template in your
>>> code.  I guess the http connection will send it across the wire with
>>> whatever encoding is required by http.
>>>
>>> {"workflow" : {  "document"
>>> :"data:application/octet-stream;base64,BASE64 ENCODE WORKFLOW GOES HERE"}}
>>>
>>> PS. Don't forget to sync your code with github as often as you can so we
>>> can help you out with things like this much easier.
>>>
>>> Cheers,
>>>
>>> Ian
>>>
>>> -----Original Message-----
>>> From: Larry Akah [mailto:larryakah@gmail.com]
>>> Sent: 03 July 2015 13:52
>>> To: dev@taverna.incubator.apache.org
>>> Subject: Re: GSOC Taverna Mobile: Uploading workflows to the Taverna
>>> player
>>>
>>> Am no longer using the json. i have simply constructed the body as a
>>> string:
>>>
>>>  String data =
>>>
>>> "{\"document\":\"data:application/octet-stream;base64,"+Base64.encodeToString(sb.toString().getBytes(),
>>> Base64.DEFAULT)+"\"}";
>>>
>>>  String post = "{\"workflow:\""+data+"}";
>>>
>>> then i write the 'post' string to the player url
>>>
>>> Cheers
>>>
>>>
>>> 2015-07-03 13:48 GMT+01:00 Ian Dunlop <Ian.Dunlop@manchester.ac.uk>:
>>>
>>> > Hello,
>>> >
>>> > Maybe the JSONObject postJson or dos.writeBytes(postJson.toString());
>>> > in
>>> > https://github.com/larrytech7/incubator-taverna-mobile/blob/master/app
>>> > /src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/Wor
>>> > kflowdetailFragment.java is not doing what you think it should. Try
>>> > creating the request as a string rather than using the JSONObject. It
>>> > is just a string like in my message below.
>>> >
>>> > Cheers,
>>> >
>>> > Ian
>>> >
>>> > -----Original Message-----
>>> > From: Larry Akah [mailto:larryakah@gmail.com]
>>> > Sent: 03 July 2015 13:47
>>> > To: dev@taverna.incubator.apache.org
>>> > Subject: Re: GSOC Taverna Mobile: Uploading workflows to the Taverna
>>> > player
>>> >
>>> > I did the same thing with a Chrome REST client and it worked ok, but
>>> > from the java request, i don't seem to figure out exactly what could
>>> > be happening behind the scenes.
>>> >
>>> > 2015-07-03 13:39 GMT+01:00 Ian Dunlop <Ian.Dunlop@manchester.ac.uk>:
>>> >
>>> > > Hello,
>>> > >
>>> > > I just tried sending a workflow using curl with the request
>>> > > formatted like below and the player is working ok and sent back the
>>> > > correct
>>> > response.
>>> > >
>>> > > {"workflow" : {  "document" :
>>> > > "data:application/octet-stream;base64,BASE64
>>> > > ENCODE WORKFLOW GOES HERE"}}
>>> > >
>>> > > Where BASE64 ENCODE WORKFLOW GOES HERE is the BASE 64 encoded
>>> > > version of the workflow with no url encoding.
>>> > >
>>> > > Cheers,
>>> > >
>>> > > Ian
>>> > >
>>> > > -----Original Message-----
>>> > > From: Ian Dunlop [mailto:Ian.Dunlop@manchester.ac.uk]
>>> > > Sent: 03 July 2015 13:29
>>> > > To: dev@taverna.incubator.apache.org
>>> > > Subject: RE: GSOC Taverna Mobile: Uploading workflows to the Taverna
>>> > > player
>>> > >
>>> > > Hello,
>>> > >
>>> > > Unfortunately I can't see your request in the logs for some reason
>>> > > (some docker issue that we don't understand). Can you paste the body
>>> > > in an email (remember not to include any username/password stuff).
>>> > >
>>> > > Cheers,
>>> > >
>>> > > Ian
>>> > >
>>> > > -----Original Message-----
>>> > > From: Larry Akah [mailto:larryakah@gmail.com]
>>> > > Sent: 03 July 2015 12:26
>>> > > To: dev@taverna.incubator.apache.org
>>> > > Subject: GSOC Taverna Mobile: Uploading workflows to the Taverna
>>> > > player
>>> > >
>>> > > Hello, now, am posting the body exactly as described without
>>> > > encoding with json and am getting a 400 bad request message.
>>> > > Anything that could be done about that?
>>> > >
>>> > > Cheers
>>> > >
>>> > >
>>> > > 2015-07-02 10:23 GMT+01:00 Ian Dunlop <Ian.Dunlop@manchester.ac.uk>:
>>> > >
>>> > > > Hello,
>>> > > >
>>> > > > That’s good news. Can’t wait to see it working in the app
– let me
>>> > > > know when you have committed the code. By the way, I think the
>>> > > > mailing list removes attachments, probably best to either add
>>> > > > screenshots to JIRA or send links to the screenshots in something
>>> > > > like dropbox or
>>> > > google drive.
>>> > > >
>>> > > > Cheers,
>>> > > >
>>> > > > Ian
>>> > > >
>>> > > > From: Larry Akah [mailto:larryakah@gmail.com]
>>> > > > Sent: 01 July 2015 20:07
>>> > > > To: dev@taverna.incubator.apache.org
>>> > > > Subject: Re: gsoc taverna mobile - creating a run causes 'fatal'
>>> > > > error and app stops.
>>> > > >
>>> > > > Great, i think its working. I have tested it from a REST client
in
>>> > > > chrome and i receieved the 201 status code and the structure of
>>> > > > the workflow. Find here attached a screenshot of the post request.
>>> > > > Next up, i will be incorporating that into the app.
>>> > > >
>>> > > > cheers
>>> > > >
>>> > > > 2015-06-30 6:39 GMT-05:00 Larry Akah <larryakah@gmail.com<mailto:
>>> > > > larryakah@gmail.com>>:
>>> > > > Ok, thanks.
>>> > > > When i try that, i will send my feedback.
>>> > > >
>>> > > > Cheers
>>> > > >
>>> > > > 2015-06-30 6:35 GMT-05:00 Ian Dunlop <ian.dunlop@manchester.ac.uk
>>> > > <mailto:
>>> > > > ian.dunlop@manchester.ac.uk>>:
>>> > > > -----BEGIN PGP SIGNED MESSAGE-----
>>> > > > Hash: SHA1
>>> > > >
>>> > > > Hello,
>>> > > >
>>> > > > I think the workflow can just be sent as it is. The request is
>>> > > > JSON formatted but the things inside the request don't have to
be.
>>> > > > The t2flow/xml can be sent base64 encoded as they are.
>>> > > >
>>> > > > Cheers,
>>> > > >
>>> > > > Ian
>>> > > >
>>> > > > On 30/06/15 12:32, Larry Akah wrote:
>>> > > > > Hello, The workflows we get from myexperiment are formatted
as
>>> > > > > xml or t2flow files. Do these absolutely need to be converted
in
>>> > > > > json before posting or they can be sent as is?
>>> > > > >
>>> > > > > Cheers
>>> > > > >
>>> > > > > 2015-06-30 5:11 GMT-05:00 Ian Dunlop
>>> > > > > <ian.dunlop@manchester.ac.uk<mailto:ian.dunlop@manchester.ac.uk
>>> >>:
>>> > > > >
>>> > > > > Hello,
>>> > > > >
>>> > > > > I've had a chat with the taverna player developer and you
need
>>> > > > > to send a request as follows:
>>> > > > >
>>> > > > > POST to /workflows.json
>>> > > > >
>>> > > > > {"workflow" : {  "document" :
>>> > > > > "data:application/octet-stream;base64,BASE64 ENCODED WORKFLOW
>>> > > > > GOES HERE"}}
>>> > > > >
>>> > > > > using HTTP basic auth with username:password base64 encoded
in
>>> > > > > the Authorization header in the request  e.g. Authorization:
>>> > > > > Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==. You have to specify .json
>>> > > > > because the content type is not being respected for some
reason.
>>> > > > >
>>> > > > >
>>> > > > > Here's an example using curl: curl -u your_username -X POST
-H
>>> > > > > "Content-Type: application/json" -d@wf.json<mailto:-d@wf.json>
>>> > > > > http://taverna-player-server/workflows.json
>>> > > > >
>>> > > > > where wf.json is the workflow file, this would then prompt
for a
>>> > > > > passwor d. Hope this helps, please let us know how you get
on.
>>> > > > >
>>> > > > > Cheers,
>>> > > > >
>>> > > > > Ian
>>> > > > >
>>> > > > > On 29/06/15 19:23, Larry Akah wrote:
>>> > > > >>>> I need some help with uploading a workflow to
the player. The
>>> > > > >>>> API doesn't make it seem possible currently.
How is it done?
>>> > > > >>>>
>>> > > > >>>> cheers
>>> > > > >>>>
>>> > > > >>>> 2015-06-29 16:55 GMT+01:00 Larry Akah <larryakah@gmail.com
>>> > <mailto:
>>> > > > larryakah@gmail.com>>:
>>> > > > >>>>
>>> > > > >>>>> Yes, its not yet ready. i still need to adjust
that because
>>> > > > >>>>> at first , i was using the player to fetch
workflows and
>>> > > > >>>>> derived a run skeleton to use for creating
workflows. There
>>> > > > >>>>> is still some stuff that needs to be fixed
there.
>>> > > > >>>>>
>>> > > > >>>>> Cheers
>>> > > > >>>>>
>>> > > > >>>>> 2015-06-29 16:34 GMT+01:00 Ian Dunlop
>>> > > > >>>>> <Ian.Dunlop@manchester.ac.uk<mailto:Ian.Dunlop@manchester.ac
>>> > > > >>>>> .uk
>>> > >>:
>>> > > > >>>>>
>>> > > > >>>>>> Hello,
>>> > > > >>>>>>
>>> > > > >>>>>> I got a ‘fatal’ error which the emulator
reported when
>>> > > > >>>>>> clicking on ‘create run’:
>>> > > > >>>>>>
>>> > > > >>>>>> 06-29 15:25:39.554
>>> > > > >>>>>> 8216-8216/mobile.taverna.apache.org.tavernamobile
>>> > > > >>>>>> E/AndroidRuntime﹕ FATAL EXCEPTION:
main Process:
>>> > > > >>>>>> mobile.taverna.apache.org.tavernamobile,
PID: 8216
>>> > > > >>>>>> java.lang.NullPointerException: Attempt
to invoke virtual
>>> > > > >>>>>> method 'void android.app.AlertDialog.show()'
on a null
>>> > > > >>>>>> object reference at
>>> > > > >>>>>> org.apache.taverna.mobile.fragments.workflowdetails.Workflo
>>> > > > >>>>>> wd
>>> > > > >>>>>> et
>>> > > > >>>>>> ai
>>> > > > lFr
>>> > > > >
>>> > > > >>>>>>
>>> > > > agment$WorkflowRunTask.onPostExecute(WorkflowdetailFragment.java:4
>>> > > > 07
>>> > > > )
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > > at
>>> > > > >>>>>> org.apache.taverna.mobile.fragments.workflowdetails.Workflo
>>> > > > >>>>>> wd
>>> > > > >>>>>> et
>>> > > > >>>>>> ai
>>> > > > lFr
>>> > > > >
>>> > > > >>>>>>
>>> > > > agment$WorkflowRunTask.onPostExecute(WorkflowdetailFragment.java:2
>>> > > > 89
>>> > > > )
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > > at android.os.AsyncTask.finish(AsyncTask.java:636)
>>> > > > >>>>>> at android.os.AsyncTask.access$500(AsyncTask.java:177)
>>> > > > >>>>>> at
>>> > > > >>>>>>
>>> android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.
>>> > > > >>>>>> ja
>>> > > > >>>>>> va
>>> > > > :65
>>> > > > >
>>> > > > >>>>>>
>>> > > > 3)
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > > at android.os.Handler.dispatchMessage(Handler.java:102)
>>> > > > >>>>>> at android.os.Looper.loop(Looper.java:135)
at
>>> > > > >>>>>> android.app.ActivityThread.main(ActivityThread.java:5257)
>>> > > > >>>>>> at java.lang.reflect.Method.invoke(Native
Method) at
>>> > > > >>>>>> java.lang.reflect.Method.invoke(Method.java:372)
at
>>> > > > >>>>>> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(
>>> > > > >>>>>> Zy
>>> > > > >>>>>> go
>>> > > > >>>>>> te
>>> > > > Ini
>>> > > > >
>>> > > > >>>>>>
>>> > > > t.java:903)
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > > at
>>> > > > >>>>>> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698
>>> > > > >>>>>> )
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > >>>>>>
>>> > > > The device reported that the app had stopped running but in
>>> > > > >>>>>> fact it returned it to the workflows
view but all the
>>> > > > >>>>>> workflows had disappeared from the view.
I guess it’s
>>> > > > >>>>>> probably because this functionality is
not ready yet but I
>>> > > > >>>>>> figured I should report it anyway.
>>> > > > >>>>>>
>>> > > > >>>>>> Cheers,
>>> > > > >>>>>>
>>> > > > >>>>>> Ian
>>> > > > >>>>>>
>>> > > > >>>>>
>>> > > > >>>>>
>>> > > > >>>>>
>>> > > > >>>>> -- *Akah Larry N.H*
>>> > > > >>>>>
>>> > > > >>>>> *Lead Software Engineer @ GiftedMom* *Founder
IceTeck Inc*
>>> > > > >>>>> *www.iceteck.com<http://www.iceteck.com>*
>>> > > > >>>>>
>>> > > > >>>>> Developing technologies for emergence and
sustainable
>>> > > > >>>>> development.
>>> > > > >>>>>
>>> > > > >>>>>
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>
>>> > > > >
>>> > > > >
>>> > > > >
>>> > > > -----BEGIN PGP SIGNATURE-----
>>> > > > Version: GnuPG v1
>>> > > > iQEcBAEBAgAGBQJVkn8TAAoJEPK45GBX+Cy5iC0IAJ9YpVLfGxgdd+LHyo3eOMfY
>>> > > > SO4sL23TS/htyvAU/61BQh85g8TEmUOvo/19tGkc7ExXf97rTtGc9/KMkHeyeqp+
>>> > > > rnz4OCLHujtsuRgy8P2AZeCibjtb3tqxBuIXmk4fcGyF9IiokHMtHksI0FMcERl8
>>> > > > xYJKacZ4j8XGC7m3oskpLwgF936UbuZTtUsP0rE9JkZgjJU39rjbmGh5ibgHGF35
>>> > > > iYuyO2kb7XQMM3evZHqRkelAK8yraFi6/J+qeVadBGrxPk+8QcyCO21833MXYP1X
>>> > > > wZnLkSfribveFAq8bVLZgbZTmdt9Txwa+5sKBaCVG34voPIRFisg6u7lxgm5Wbs=
>>> > > > =RrFl
>>> > > > -----END PGP SIGNATURE-----
>>> > > >
>>> > > >
>>> > > >
>>> > > > --
>>> > > > *Akah Larry N.H*
>>> > > > *Lead Software Engineer @ GiftedMom* *Founder IceTeck Inc*
>>> > > > *www.iceteck.com<http://www.iceteck.com>*
>>> > > >
>>> > > > Developing technologies for emergence and sustainable development.
>>> > > >
>>> > > >
>>> > > >
>>> > > > --
>>> > > > *Akah Larry N.H*
>>> > > > *Lead Software Engineer @ GiftedMom* *Founder IceTeck Inc*
>>> > > > *www.iceteck.com<http://www.iceteck.com>*
>>> > > >
>>> > > > Developing technologies for emergence and sustainable development.
>>> > > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > *Akah Larry N.H*
>>> > >
>>> > > *Lead Software Engineer @ GiftedMom* *Founder IceTeck Inc*
>>> > > *www.iceteck.com*
>>> > >
>>> > > Developing technologies for emergence and sustainable development.
>>> > >
>>> >
>>> >
>>> >
>>> > --
>>> > *Akah Larry N.H*
>>> >
>>> > *Lead Software Engineer @ GiftedMom*
>>> > *Founder IceTeck Inc*
>>> > *www.iceteck.com*
>>> >
>>> > Developing technologies for emergence and sustainable development.
>>> >
>>>
>>>
>>>
>>> --
>>> *Akah Larry N.H*
>>>
>>> *Lead Software Engineer @ GiftedMom*
>>> *Founder IceTeck Inc*
>>> *www.iceteck.com*
>>>
>>> Developing technologies for emergence and sustainable development.
>>>
>>
>>
>>
>> --
>> *Akah Larry N.H*
>>
>> *Lead Software Engineer @ GiftedMom*
>> *Founder IceTeck Inc*
>> *www.iceteck.com*
>>
>> Developing technologies for emergence and sustainable development.
>>
>>
>
>
> --
> *Akah Larry N.H*
>
> *Lead Software Engineer @ GiftedMom*
> *Founder IceTeck Inc*
> *www.iceteck.com*
>
> Developing technologies for emergence and sustainable development.
>
>


-- 
*Akah Larry N.H*

*Lead Software Engineer @ GiftedMom*
*Founder IceTeck Inc*
*www.iceteck.com*

Developing technologies for emergence and sustainable development.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message