Copyright © 2012 Kaltura Inc.
All Rights Reserved. Designated trademarks and brands are the property of their respective owners.
Use of this web site constitutes acceptance of the Terms of Use and Privacy Policy.
EduVideo.org
When using the v3 API to get a list of moderation flags, the server responds with:
Notice that, under "item", there are two "objectType" elements. That's a problem. There should only be one. I think the first one is okay based on what PlaylistListResponse looks like. The second "objectType" looks like it contains the value of the "ModerationObjectType" enum. So I think the element needs to be renamed from "objectType" to "moderationObjectType" and the schema changed accordingly.
Jeff
Yeah, this creates a problem when the Java client tries to instantiate a result object from the returned XML. I'm working around this by catching the exception that gets thrown when Java tries to parse the first objectType as an integer. It just ignores the exception. When it gets to the second objectType it successfully parses the int and sets the objectType to the appropriate enum.
It would be nice if someone would fix this on the server side and in the schema, but this workaround will be fine until that happens.
Jeff
Hi Jeff,
It is a bug, but maybe we can work around this without catching the exception.
The .NET client is working with the same XML and it's working fine.
Here's how the KalturaModerationFlag object is parsed:
The enum parsing is using the TryParse (ParseInt internally use the TryParse) method so no exceptions are thrown. (At least it is hidden by the framework).
Because Kaltura backend is build on PHP, which is a very dynamic language and as much as we are trying to make sure that all the responses are "strongly typed" in all the scenarios, it is still better to parse the results in a "safe way".
Thanks for the response Roman.
However, I feel this a bit different in Java.. see this @link where it states: "The Java case is more difficult - there is no direct equivalent to 'TryParse'"...
But it also provide a function that identify the type..so maybe it is possible in Java as well.
Jeff - what you think?
In either language, until the bug is fixed, that case block is going to get executed twice, once for the legitimate element and once for the duplicate element. In one case the integer will be parsed successfully and the other it won't. In the case of .NET it sounds like .NET is swallowing the failure. Java throws an exception, but if I catch it and swallow it, that's functionally equivalent to how .NET is behaving, so it seems like the workaround is okay as-is.
Once I've checked in the Java client code we can revisit if needed. Hopefully the bug will be fixed by then so it will be a non-issue.
Jeff
Again... Nice spot!