You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by "Vijayakumar, Manju" <Ma...@gs.com> on 2008/06/20 16:29:03 UTC

How to add Extension elements to feed?

Hi,

I have a requirement to add custom elements in an entry, so I am trying
to implement that using the abdera ExtensionFactory.

I want an element <mynamespace:priority> to be added to my feed. This is
the code I have written.
...
String namespace = "http://somesite.com/ns/1.0";
QName priorityExtension = new QName(namespace,PRIORITY,"mynamespace");
// StringElement extends ElementWrapper, implements Element
StringElement priorityElem = new
StringElement(entry.addExtension(priorityExtension));
priorityElem.setValue(HIGH);
...
// entry should now have
<mynamespace:priority>HIGH</mynamespace:priority> element
//adding the entry to the feed
Feed.addEntry(entry) 

..

// Post the entry to a URI using abdera client
ClientResponse res = client.post(colUri.toString(), entry, opts);
// Asserting if the return status is HTTP 201
Assert.assertEquals(201, res.getStatus());

..

When I debug, I can see that entry contains the extension element, but
after the feed is posted at a URL,
I cannot see the extension elements (through View->Source in IE)

Is there any kind of registering these extension elements on the server
side?
Or is the browser ignoring the extension elements?
Please let me know what I am missing.

Thanks,
Manju	





Extension elements not reflecting on browser

Posted by "Vijayakumar, Manju" <Ma...@gs.com>.
Hi,

The extensions that are added to the entry are not displayed on the IE.
Is this a browser issue?
Should I include my namespace in the entry or feed element tag to get
over this?

I registered the extension elements by creating a
META-INF/services/org.apache.abdera.factory.CustomExtensionFactory

I do the following to check if the server response contains my custom
extension elements:

// Post the entry to a URI using abdera client
ClientResponse res = client.post(colUri.toString(), entry, opts);
// Asserting if the return status is HTTP 201
Assert.assertEquals(201, res.getStatus());
res.getDocument().writeTo(System.out);

..and I get the following:
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">2008-05-29-10-26-1214504201571-Title</title>
<link href="http://somesite.com/index.html" />
<updated>2008-06-26T18:16:41.792Z</updated>
<author><name>procmon</name></author>
<id>urn:2b560cea-b0ee-4bbf-a7f7-99583e7468a0</id>
<summary type="text">Report Available.1214504201586</summary>
<content type="text">Summary: 50 T2T Bypass, 100 T2S Bypass, 250
Unknown.</content>
<mynamespace:priority
xmlns:ns="http://somesite.com/ns/1.0">HIGH</mynamespace:priority>
<link href="/somesite.com/2008-05-29-10-26-1214504201571-Report"
rel="edit" />
</entry>

So I am able to get the extension elements now. But when I do a
View->Source on IE, I don't see them in the xml.
Any idea as to why? 

Thanks in advance,
Manju

-----Original Message-----
From: Vijayakumar, Manju 
Sent: Friday, June 20, 2008 10:29 AM
To: abdera-user@incubator.apache.org
Subject: How to add Extension elements to feed?


Hi,

I have a requirement to add custom elements in an entry, so I am trying
to implement that using the abdera ExtensionFactory.

I want an element <mynamespace:priority> to be added to my feed. This is
the code I have written.
...
String namespace = "http://somesite.com/ns/1.0";
QName priorityExtension = new QName(namespace,PRIORITY,"mynamespace");
// StringElement extends ElementWrapper, implements Element
StringElement priorityElem = new
StringElement(entry.addExtension(priorityExtension));
priorityElem.setValue(HIGH);
...
// entry should now have
<mynamespace:priority>HIGH</mynamespace:priority> element
//adding the entry to the feed
Feed.addEntry(entry) 

..

// Post the entry to a URI using abdera client
ClientResponse res = client.post(colUri.toString(), entry, opts);
// Asserting if the return status is HTTP 201
Assert.assertEquals(201, res.getStatus());

..

When I debug, I can see that entry contains the extension element, but
after the feed is posted at a URL,
I cannot see the extension elements (through View->Source in IE)

Is there any kind of registering these extension elements on the server
side?
Or is the browser ignoring the extension elements?
Please let me know what I am missing.

Thanks,
Manju