|
From: Weinan L. <we...@re...> - 2012-10-15 16:56:23
|
Hi Jervis, I've created a test case here: https://github.com/liweinan/try-resteasy/tree/test-guvnor-jaxb Could you please checkout 'try-resteasy' and use branch 'test-guvnor-jaxb' to give it a try? You can run the example like this: git clone git://github.com/liweinan/try-resteasy.git git checkout -b test-guvnor-jaxb origin/test-guvnor-jaxb mvn jetty:run Then you can access these two urls: http://127.0.0.1:8080/try-resteasy/resteasy/entry http://127.0.0.1:8080/try-resteasy/resteasy/entry2 The first one is the XML generated by JAXB The second one is the XML you gave to me Both can be marshalled by RESTEasy correctly. I've only fix one class in Guvnor's code: In "public class Link extends CommonAttributes", I've comment out the @XmlAttribute of MediaType: // @XmlAttribute public MediaType getType() { return type; } Seems the annotation is not used correctly. Please tell me your test result. -- Weinan Li JBoss, Red Hat On Monday, October 15, 2012 at 4:50 PM, Jervis Liu wrote: > On 2012/10/13 18:14, Weinan Li wrote: > > Hi Jervis, > > > > Sorry for the late reply. I've checked the trunk code in RESTEasy and it seems getJAXBObject could handle custom element properly: > > > > CustomerAtom cust = entry.getContent().getJAXBObject(CustomerAtom.class); Assert.assertEquals(cust.getName(), "bill"); > > Could you please check the example code "org.jboss.resteasy.test.providers.atom.ResourceTest" in 'providers/resteasy-atom'? I believe from RESTEasy 2.3.5 Final it could fulfil your requirement properly. > > > No, I am afraid it does not work. Please note, what we are asking for is not to use extension element on Atom Entry's content element. but on Entry itself or Feed and any other elements that are valid to have extension element per spec : http://tools.ietf.org/html/rfc4287#section-6.4. eg., like sth this: > > AtomAssetMetadata assetMetadata = entry.getAnyOtherJAXBObject(AtomAssetMetadata.class); > > I checked the Atom provider code on RESTEasy master branch. It does not work either. > > > Thanks, > Jervis > > > > -- > > Weinan Li > > JBoss, Red Hat > > > > > > On Tuesday, October 9, 2012 at 2:47 AM, Weinan Li wrote: > > > > > > > > > > > -- > > > Weinan Li > > > JBoss, Red Hat > > > > > > > > > On Monday, October 8, 2012 at 10:14 PM, Jervis Liu wrote: > > > > > > > On 2012/9/29 14:06, Weinan Li wrote: > > > > > > > > > > > > > > > -- > > > > > Weinan Li > > > > > JBoss, Red Hat > > > > > > > > > > > > > > > On Saturday, September 29, 2012 at 12:59 PM, Jervis Liu wrote: > > > > > > > > > > > On 2012/9/27 20:29, Weinan Li wrote: > > > > > > > Hi Jervis, > > > > > > > > > > > > > > Seems Guvnor is using its own Atom encapsulation: > > > > > > > > > > > > > > import org.drools.guvnor.server.jaxrs.jaxb.AtomAssetMetadata; > > > > > > > import org.drools.guvnor.server.jaxrs.providers.atom.Entry; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The Atom provider code was copied from RESTEasy. > > > > > > > > > > > > > > > > > > > > > > > > > > > > AtomAssetMetadata is not copied from RESTEasy and implemented by Guvnor itself. > > > > > > > > > > > This is because the RESTEasy version shipped with AS 7 does not have the Atom Provider. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi, sorry for the confusion. The reason why we maintained our own copy of RESTEasy Atom provider is because the code that handles Atom extension is not available until 2.3.4.Final. The feature we are looking for is the capability to create and read Atom Extension element (http://tools.ietf.org/html/rfc4287#section-6.4). For example, below is how we add a custom extension to Atom using Abdera: > > > > > > > > Abdera abdera = new Abdera(); > > > > Entry entry = abdera.newEntry(); > > > > entry.setTitle("testCreatePackageFromAtom1"); > > > > entry.setSummary("desc for testCreatePackageFromAtom"); > > > > ExtensibleElement extension = entry.addExtension(new QName("", > > > > "metadata")); > > > > ExtensibleElement childExtension = extension.addExtension(new > > > > QName("", "categories")); > > > > childExtension.addSimpleExtension(new QName("", "value")), > > > > "AssetPackageResourceTestCategory"); > > > > > > > > Basically we are looking for a similar way to add and read ATOM extension element using RESTEasy. Unfortunately methods likes getAnyOther, getAnyOtherJaxbObject etc were added into RESTEasy after 2.3.4.Final. > > > > > > > > The problem I reported in this email thread is regarding the code that handles extension element does not work properly (I am referring to our own copy of Atom provider code, which was copied from RESTEasy 2.3.4). To be more precisely, the problem is getAnyOtherJAXBObject returns null. I also verified the object returned by getAnyOther, yes, it is not null, but it is a ElementNSImpl object. I dont think you should expect RESTEasy users to retrieve a raw xml object using getAnyOther then marshall the raw xml to object using JAXB by themselves. This does not sound like a correct way to read Atom extension. > > > > > > > > I hope we can have explicit methods to read and create extension element on Entry, Feed and any other elements that are valid to have extension element per spec : http://tools.ietf.org/html/rfc4287#section-6.4. Eg, sth like Entry.addExentionElement(Object o) and Entry.getExtensionElemnt(), this API will be easier to understand than getAnyOther or getAnyOtherJaxbObject. > > > > > > > |