RE: CompositeHelper returns 500 on GAE

2011-12-01 Thread Emanuele Ziglioli
See this thread: 
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4375&dsMessageId=2754354

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2889747


Setting NamespacePrefixMapper for JAXB Marshaller

2011-07-04 Thread Emanuele Ziglioli
Hi,

I need to set custom namespaces for the JAXB marshaller and one way is this:

Marshaller m = new Marshaller(this, this.contextPath, getClassLoader());
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new 
Kml.NameSpaceBeautyfier());
m.marshal(getObject(), writer);

where

final static class NameSpaceBeautyfier extends NamespacePrefixMapper
{
   @Override
public String getPreferredPrefix(String namespaceUri, String 
suggestion, boolean requirePrefix)
{...}
}

Are you aware of any other way for the JAXB extension to support custom 
namespaces?

Thank you,
Emanuele

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2784642


Re: Setting NamespacePrefixMapper for JAXB Marshaller

2011-07-04 Thread Emanuele Ziglioli
Hi again,

in my previous message I made a mistake. I was considering Marshaller from 
org.restlet.ext.jax.internal rather than javax.xml.bind.Marshaller!

I've managed to do what I needed to do, you can find my changes in attachment.

Regards,
Emanuele 
Sirtrack Ltd.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2784854

revision.diff
Description: Binary data


Re: Convertion from XML to Jaxb objects in GAE

2011-05-09 Thread Emanuele Ziglioli
Hi,

here's a solution to the problem I posted in an earlier message (still pending 
approval).

I didn't need to create a JaxbRepresentation, this works:

Representation re = new StringRepresentation( xml );
ConverterHelper decoder = new JaxbConverter();
Kml kmloutput = decoder.toObject( re, Kml.class, null );

Similarly, to handle a Post request containing xml:

@Post
public void doPost( Representation rep ) 
{
ConverterHelper decoder = new JaxbConverter();
Kml kml = decoder.toObject( rep, Kml.class, null );
}

There might be an even more elegant way to automatically invoke the 
JaxbConverter, I don't know

Thanks,
Emanuele

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2733511


Re: Convertion from XML to Jaxb objects in GAE

2011-05-09 Thread Emanuele Ziglioli
Using the ConverterService it's even more elegant, provided the media type is 
correct

@Post("xml")
public void doPost( Kml kml ) 
...

Question: how robust is to use the ConverterService behind the scenes? what 
happens is the document fails validation?

Thank you,
Emanuele

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2733526


Convertion from XML to Jaxb objects in GAE

2011-05-09 Thread Emanuele Ziglioli
Hi, I'm trying to unmarshal some XML using the jaxb extension on GAE (version 
2.1m3)

String xml ="";
Representation re = new StringRepresentation( xml );
Representation xmlRe = new JaxbRepresentation( re, Kml.class );
ConverterHelper decoder = new JaxbConverter();
Kml kmloutput = decoder.toObject( xmlRe, Kml.class, null );

the call JaxbConverter.toObject() calls JaxbRepresentation.getObject() and that 
calls

this.object = (T) u.unmarshal(this.xmlRepresentation
.getReader());

Then WriterRepresentation.getReader() calls BioUtils.getReader():

   @Override
public Reader getReader() throws IOException {
return BioUtils.getReader(this);
}

Finally BioUtils.getReader() returns null:

Reader result = null;
if (Edition.CURRENT != Edition.GAE) {
} else {
Context.getCurrentLogger()
.log(Level.WARNING,
"The GAE edition is unable to return a reader for a 
writer representation.");
}
return result;


I don't know why GAE has got this limitation but isn't there any way to work 
around it?

There's a numer of unmarshal() methods in the Unmarshaller class that could be 
used as an alternative.

If there's another way to unmarshal JaxbRepresentation objects in GAE please 
let me know.

Thank you,
Emanuele

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2733493