Usage of the Moderator class in 1.3.1 alpha

23 views
Skip to first unread message

Michel Jonker

unread,
Jun 4, 2011, 5:54:22 PM6/4/11
to google-api-java-client
Hi there,

I am trying to use the google client api's in my GWT-AppEngine
project.
The server part invokes the moderator model, but I am getting 500
error codes back.

In short this is the code:
I tried to use NetHttpTransport() or (after including the 1.3.2 alpha
client extensions jar) the UrlFetchTransport.
Either one is giving the 500 response code.

So here is the code snippet:

HttpTransport transport = new NetHttpTransport();
or
UrlFetchTransport ftrFetchTransport = new UrlFetchTransport();


Moderator moderator = new Moderator("MyModeratorApp",
ftrFetchTransport, new JacksonFactory());
Get get = moderator.submissions.get(570414, 64);
Submission subm = get.execute();

the get.execute() gives the 500 Server Error.

TIA

Michel Jonker

Michel Jonker

unread,
Jun 5, 2011, 4:43:56 AM6/5/11
to google-api-java-client
Ok, I made a mistake "64" is topicId

com.google.api.moderator.v1.Moderator.Topics.Get topicsGet =
moderator.topics.get(570414, 64);
Topic2 topic2 = topicsGet.execute();

This results in a correctly constructed URL:

https://www.googleapis.com/moderator/v1/series/570414/topics/64?alt=json

But when execute this request an error occurs, I have picked it up in
the SimpleRequestProcessor class (in the eclipse debugger)

e ReportableException (id=5651)
cause IllegalArgumentException (id=5649)
cause IllegalArgumentException (id=5649)
detailMessage null
stackTrace null
detailMessage "Server Error: null" (id=5664)
count 18
hash 0
offset 0
value (id=5666)
stackTrace null

Michel Jonker

unread,
Jun 5, 2011, 11:07:55 AM6/5/11
to google-api-java-client
A little more information

I have imported the alpha 1.3.2 source code and found that in the
com.google.api.client.json.JsonParser.java in the method:

private final Object parseValue(JsonToken token, Field field, Class<?
> fieldClass,
Object destination, CustomizeJsonParser customizeParser)

The error occurs after succesfully processing class

com.google.api.moderator.v1.model.Topic2Id

The eror occurs when trying to process class

java.lang.Integer

It is manifested through a java.lang.IllegalArgumentException

So where in the JSON string below is it failing ?

{"data":{"kind":"moderator#topic","id":
{"topicId":"64","seriesId":"570414"},"name":"Vragen","description":"","presenter":"","counters":
{"plusVotes":4,"minusVotes":0,"noneVotes":0,"users":3,"submissions":
2,"videoSubmissions":2}}}

At this point I am wondering why I have to dive so deep into the low-
level api's ....

Michel Jonker

unread,
Jun 5, 2011, 11:31:25 AM6/5/11
to google-api-java-client
This is the stacktrace:

Exception in thread "main" java.lang.IllegalArgumentException
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:
72)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:
450)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:250)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:
409)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:250)
at
com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:
176)
at
com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:
115)
at
com.google.api.client.googleapis.json.JsonCParser.parse(JsonCParser.java:
49)
at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:
261)
at
com.google.api.moderator.v1.RemoteRequest.executeGet(RemoteRequest.java:
60)
at com.google.api.moderator.v1.Moderator$Topics
$Get.execute(Moderator.java:997)

On 5 jun, 17:07, Michel Jonker <michel.jon...@e-office.com> wrote:
> A little more information
>
> I have imported the alpha 1.3.2 source code and found that in the
> com.google.api.client.json.JsonParser.java in the method:
>
>  private final Object parseValue(JsonToken token, Field field, Class<?> fieldClass,
>
>       Object destination, CustomizeJsonParser customizeParser)
>
> The error occurs after succesfully  processing class
>
> com.google.api.moderator.v1.model.Topic2Id
>
> The eror occurs when trying to process class
>
>  java.lang.Integer
>
> It is manifested through a java.lang.IllegalArgumentException
>
> So where in the JSON string below is it failing ?
>
> {"data":{"kind":"moderator#topic","id":
> {"topicId":"64","seriesId":"570414"},"name":"Vragen","description":"","pres enter":"","counters":

Michel Jonker

unread,
Jun 5, 2011, 12:22:28 PM6/5/11
to google-api-java-client
And the debugger variables are this:


this JacksonParser (id=50)
token JsonToken (id=52)
field Field (id=103)
fieldClass Class<T> (java.lang.Integer) (id=108)
destination Topic2Id (id=90)
customizeParser null

Where field token JsonToken (id=52) has value:

VALUE_STRING

And where field Field (id=103) has value:

public java.lang.Integer
com.google.api.moderator.v1.model.Topic2Id.topicId

Does the jsonparson maybe fail to create an Integer from a String ?

Michel

On 5 jun, 17:07, Michel Jonker <michel.jon...@e-office.com> wrote:
> A little more information
>
> I have imported the alpha 1.3.2 source code and found that in the
> com.google.api.client.json.JsonParser.java in the method:
>
>  private final Object parseValue(JsonToken token, Field field, Class<?> fieldClass,
>
>       Object destination, CustomizeJsonParser customizeParser)
>
> The error occurs after succesfully  processing class
>
> com.google.api.moderator.v1.model.Topic2Id
>
> The eror occurs when trying to process class
>
>  java.lang.Integer
>
> It is manifested through a java.lang.IllegalArgumentException
>
> So where in the JSON string below is it failing ?
>
> {"data":{"kind":"moderator#topic","id":
> {"topicId":"64","seriesId":"570414"},"name":"Vragen","description":"","pres enter":"","counters":

Tony Aiuto

unread,
Jun 5, 2011, 10:41:42 PM6/5/11
to google-api-...@googlegroups.com
A 500 would be a resource consumption error.  Are you using authenticated requests
and/or supplying an API key with your requests?

Also, 1.3 is an old library. The current release is 1.4.1.  If you were going to build
from source (like you did), you'ld be better off downloading the dev branch and
getting a few weeks lead time on version 1.5.

Michel Jonker

unread,
Jun 6, 2011, 1:45:06 AM6/6/11
to google-api-java-client
Thanks for the reply Tony.

I started with the 1.3 lbirary since it came with the GPE 2.4
Moderator API.

I will continue my efforts with the 1.4.1 libraries.

The 500 error was a data error, I mixed up topicId and SubmissionId.

The request seems to be correctly build since the errors occur while
parsing the response ?!

To be continued...

Michel

Michel Jonker

unread,
Jun 6, 2011, 2:15:11 PM6/6/11
to google-api-java-client
The 1.4.1 libraries do give a more detailed description:


seriesId: number field formatted as a JSON string must use the
@JsonString annotation: public java.lang.Integer
com.google.api.moderator.v1.model.SeriesId.seriesId

Exception in thread "main" java.lang.IllegalArgumentException:
seriesId: number field formatted as a JSON string must use the
@JsonString annotation: public java.lang.Integer
com.google.api.moderator.v1.model.SeriesId.seriesId
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:
115)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:
520)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:261)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:
474)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:261)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:224)
at
com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:
180)
at
com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:
120)
at
com.google.api.client.googleapis.json.JsonCParser.parse(JsonCParser.java:
49)
at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:
298)
at
com.google.api.moderator.v1.RemoteRequest.executeGet(RemoteRequest.java:
60)
at com.google.api.moderator.v1.Moderator$Series
$Get.execute(Moderator.java:779)
at
nl.eoffice.google.play.GoogleAPI141Client.main(GoogleAPI141Client.java:
35)

Again this is the java code snippet:

HttpTransport transport = new NetHttpTransport();
JsonFactory jsonfactory = new GsonFactory();
Moderator moderator = new Moderator("MyModeratorApp", transport,
jsonfactory);
com.google.api.moderator.v1.Moderator.Series.Get seriesGet =
moderator.series.get(570414);
Series series = seriesGet.execute();

Michel Jonker

unread,
Jun 7, 2011, 3:28:00 PM6/7/11
to google-api-java-client
Since it came down to a bug in the Moderator classes, I continued the
thread here:

http://groups.google.com/group/google-moderator-api/browse_thread/thread/5853195d200517b1

I solved the issues by adjusting the moderator API source code, now I
need to find a way to get it distributed.

any tips ?

Tony Aiuto

unread,
Jun 8, 2011, 11:35:34 AM6/8/11
to google-api-...@googlegroups.com
The moderator API library is generated directly from discovery, so hand fixes won't make their way back into the available downloads.

What we'll be doing in the next few days is changing the way we handle cases like this one to generate an Object rather than String. At that point, you should be able to download the fresh library from here. In the future, we'll be converging towards more precise field data types.

Look for a version number above 1.0.0-beta.    It should be sometime this week, maybe Thursday or Friday.

Tony Aiuto

unread,
Jun 16, 2011, 11:48:19 PM6/16/11
to google-api-...@googlegroups.com
Michel:

Could you give it a try with a newer version of the moderator library.  If you use maven, change
your dependency from version 1.0.0-beta to 1.1.0-beta.  You can also look right into the repo
fore it here


-tony

Michel Jonker

unread,
Jun 17, 2011, 2:38:20 PM6/17/11
to google-api-java-client
Hi Tony,

Thanks for your reply, since I had a working development set I paid
less attention to this issue.
I will try out your tips next week and let you know the outcome

Michel

On 17 jun, 05:48, Tony Aiuto <ai...@google.com> wrote:
> Michel:
>
> Could you give it a try with a newer version of the moderator library.  If
> you use maven, change
> your dependency from version 1.0.0-beta to 1.1.0-beta.  You can also look
> right into the repo
> fore it here
>
> http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/...
>
> -tony

Michel Jonker

unread,
Jun 25, 2011, 3:43:47 PM6/25/11
to google-api-java-client
Hi Tony,

I looked briefly at the source code of the moderator.java file and I
noticed that the list operation for all submissions within a topic is
not there.
I will also check the fixes for the @JSONString fields.

Regards

Michel

On 17 jun, 05:48, Tony Aiuto <ai...@google.com> wrote:
> Michel:
>
> Could you give it a try with a newer version of the moderator library.  If
> you use maven, change
> your dependency from version 1.0.0-beta to 1.1.0-beta.  You can also look
> right into the repo
> fore it here
>
> http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/...
>
> -tony

Tony Aiuto

unread,
Jun 26, 2011, 10:38:15 PM6/26/11
to google-api-...@googlegroups.com


On Saturday, June 25, 2011 3:43:47 PM UTC-4, Michel Jonker wrote:
Hi Tony,

I looked briefly at the source code of the moderator.java file and I
noticed that the list operation for all submissions within a topic is
not there.

I don't understand what you mean. Is a specific item mentioned in
the language independent Moderator documentation not available
in the Java binding?

Michel Jonker

unread,
Jun 30, 2011, 1:34:51 AM6/30/11
to google-api-java-client
Hi Tony,

Yes, this is the functionality that I need:

http://code.google.com/intl/nl-NL/apis/moderator/v1/reference.html#submissions-list

It (seriesId + TopicId) does work in the online API explorer, and I
could recreate it in the (open) source code.
But to me it seems to be missing from the available moderator client
package.

Regards

Michel
Reply all
Reply to author
Forward
0 new messages