- org.apache.streams.twitter.api.Geo
- org.apache.streams.twitter.api.Friends
- org.apache.streams.twitter.api.Account
- org.apache.streams.twitter.api.Users
- org.apache.streams.twitter.api.Statuses
- org.apache.streams.twitter.api.Favorites
- org.apache.streams.twitter.api.AccountActivity
- org.apache.streams.twitter.api.Twitter
- org.apache.streams.twitter.api.WelcomeMessageRules
- org.apache.streams.twitter.api.Media
- org.apache.streams.twitter.api.WelcomeMessages
Background: Apache Streams contains java interfaces which emulate social network REST APIs and implementations (some using Juneau Rest Proxy) for calling method on those APIs via java and transcribing native requests and responses to and from streams interoperability formats
Objective: Expose those interfaces / implementations via a hosted REST API, supporting an HTML serialization option, allowing a user to discover what methods are available, activate them, and view the results directly in the browser.
Some Relevant classes:
- https://github.com/apache/streams/blob/master/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/api/Account.java
- Defines interface for getting account details of the authenticated token.
- https://github.com/apache/streams/blob/master/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/api/Twitter.java
- Includes implementation of Account via Rest Proxy to api.twitter.com
- https://github.com/apache/incubator-juneau/blob/master/juneau-rest/src/main/java/org/apache/juneau/rest/remoteable/RemoteableServlet.java
- Server side of juneau remoting
- https://github.com/apache/incubator-juneau/blob/master/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
- Client side of juneau remoting
Proof of concept code :
https://gist.github.com/steveblackmon/928396d08b0bde3dfbd601ad3d2200a5
Proof of concept interaction :
- http://localhost:8000/twitter
Probot > Twitter http://localhost:8000/twitter/org.apache.streams.twitter.api.Account
Probot > Twitter - settings
- verifyCredentials
- http://localhost:8000/twitter/org.apache.streams.twitter.api.Account?invokeMethod=settings
Probot > Twitter org.apache.juneau.rest.RestException: Error occurred trying to invoke method: settings
- Proof of concept : Diagnosis
Failure seem to occur in PojoIntrospector.java
Line 131
Method m = p.getBeanContext().createSession().getClassMeta(o.getClass()).getPublicMethods().get(method);
m = null
because o.getClass() = java.util.LinkedHashMap$LinkedKeySet
where-as it seems that it should be org.apache.streams.twitter.api.Account.class
In fact
p.getBeanContext().createSession().getClassMeta(org.apache.streams.twitter.api.Account.class).getPublicMethods().get(method);
finds 'settings' as expected.
1 Comment
James Bognar
I see what's going on.
This URL....
http://localhost:8000/twitter/org.apache.streams.twitter.api.Account?invokeMethod=settings
...is mapping to this GET request that simply returns a list of strings...
So you're trying to invoke the settings() method on a collection of strings.
You don't need the Introspectable converter at all in this case. Just use the method below for method invocations....
e.g.
or this is also possible since you have REST_allowMethodParam set to '*'...