|
From: Weinan L. <we...@re...> - 2012-10-18 16:50:09
|
Hi Jervis,
I've updated 'try-resteasy' and added two new classes:
GuvnorAtomProcessor
GuvnorDecorators
Please also check EntryResource.createAssetFromAtom6().
I've added @GuvnorDecorators to the method above.
Could you please start up the server and try to run ClientTest? I believe this patch has solved your problem. If there are any issues please let me know.
--
Weinan Li
JBoss, Red Hat
On Wednesday, October 17, 2012 at 11:24 PM, Weinan Li wrote:
> The patch I provided to Jervis has fixed his issues in Guvnor. But during the process I've found some missing things in our AtomProvider:
>
> public class Link extends CommonAttributes {
> …
> protected MediaType type;
>
> }
>
> In our Link class it contains MediaType, but MediaType hasn't been JAXB annotated, so it will cause marshal/unmarshal problems. I'll add this missing part, and sum up with the patch I provided to Jervis to create a monolith fix for this.
>
>
> --
> Weinan Li
> JBoss, Red Hat
>
>
> On Wednesday, October 17, 2012 at 3:09 AM, Weinan Li wrote:
>
> > Hi Jervis,
> >
> > I believe I've fixed bug. Could you please help to verify it? Here's the method:
> >
> > Please update your try-resteasy:
> >
> > git pull origin test-guvnor-jaxb
> >
> > and then try
> >
> > http://127.0.0.1:8080/try-resteasy/resteasy/entry3
> > http://127.0.0.1:8080/try-resteasy/resteasy/entry4
> >
> > Currently getAnyOtherJAXBObject(AtomAssetMetadata.class); works fine on my computer.
> >
> > If it works for you also, you can replace Guvnor's Entry.getAnyOtherJAXBObject() with the contents I've attached in getAnyOtherJAXBObject.java. And I'll create a pull request with this patch to RESTEasy trunk.
> >
> >
> > --
> > Weinan Li
> > JBoss, Red Hat
> >
> >
> > On Tuesday, October 16, 2012 at 12:56 AM, Weinan Li wrote:
> >
> > > 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 (http://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.
> > > > > >
> > > > > >
> > > >
> > >
> > > ------------------------------------------------------------------------------
> > > Don't let slow site performance ruin your business. Deploy New Relic APM
> > > Deploy New Relic app performance management and know exactly
> > > what is happening inside your Ruby, Python, PHP, Java, and .NET app
> > > Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> > > http://p.sf.net/sfu/newrelic-dev2dev
> > >
> > > _______________________________________________
> > > Resteasy-developers mailing list
> > > Res...@li... (mailto:Res...@li...)
> > > https://lists.sourceforge.net/lists/listinfo/resteasy-developers
> > >
> > >
> > >
> >
> >
> > ------------------------------------------------------------------------------
> > Don't let slow site performance ruin your business. Deploy New Relic APM
> > Deploy New Relic app performance management and know exactly
> > what is happening inside your Ruby, Python, PHP, Java, and .NET app
> > Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> > http://p.sf.net/sfu/newrelic-dev2dev
> >
> > _______________________________________________
> > Resteasy-developers mailing list
> > Res...@li... (mailto:Res...@li...)
> > https://lists.sourceforge.net/lists/listinfo/resteasy-developers
> >
> >
> >
> >
> > Attachments:
> > - getAnyOtherJAXBObject.java
> >
> >
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
>
> _______________________________________________
> Resteasy-developers mailing list
> Res...@li... (mailto:Res...@li...)
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>
>
|