Accessing the installed Feed Samples
Samples for Atom and RSS feeds
The Feed servlet is available at the following default URL:
http://servername:port/contextroot/feed. An example url would look like
http://localhost:9080/SampleFeedApp. Now try the following options to
test the support to read RSS and Atom content, in addition to Atom
content generation support.
- Open a browser window to http://localhost:9080/SampleFeedApp/.
This brings up a single page, to view the samples related Atom and RSS
feeds support
- Alternately, manually enter the following urls in the browser
window to try out the Atom and RSS support samples
- http://localhost:9080/SampleFeedApp/feed?create: Generates a
default feed
- http://localhost:9080/SampleFeedApp/feed?read=http://www.oreillynet.com/pub/feed/1:
Reads an example feed, which can be RSS or Atom
- http://localhost:9080/SampleFeedApp/feed?filter=http://www.oreillynet.com/pub/feed/1:
Prints a summary of an example feed. This works only for Atom at this
time, and not for RSS
- http://localhost:9080/SampleFeedApp/feed?xpath : Uses XPath to process a sample feed
Note: The default port and context root for WebSphere® Application Server Community Edition 2.x is 8080 and fs respectively.
Samples for Atom Publishing Protocol (APP)
The FeedAPPServlet, subclass of the default Abdera Servlet, serves the Atom Publishing Protocol (APP) samples. The AbderaServlet is the entry point to the Abdera server framework. The FeedAPPServlet extends the AbderaServlet and when a request is dispatched to the servlet, it creates a RequestContext object and forwards it on to a custom Provider. The provider in trun is responsible for implementing all the business logic of the server, mapping the Atom Publishing Protocol methods into code that manipulates some back-end persistence layer. This servlet is available at the http://localhost:9080/SampleFeedApp/atom/. The APP samples require HTTP operations to work with the feed entries. For example:
- HTTP POST is used to create an entry in a feed
- HTTP PUT is used to update a specific entry in a feed
- HTTP GET is used to retrieve a specific entry from a feed, or
the entire feed, or the service document related to the Abdera server
- HTTP DELETE is used to delete a specific entry from a feed
There are two options to perform these operations on the feed, and view
the results:
- Use XMLHttpRequest (XHR) object in the browser to perform the
PUT, POST, GET, DELETE operations. The normal form submit operation in
the browser supports only the GET and POST operations. The current
sample application does not use the XHR option to demonstrate
the use of APP
- The other, simpler, approach is to use a tool like cURL
(http://curl.haxx.se/download.html). cURL provides a simple command
line operation to invoke calls on the APP server. This is the current
option to try out the APP samples
The cURL options to work with the APP sample are listed below. To
perform a create (POST) or an update(PUT) entry operation, the entry
content is passed using an
entry.xml
document. The content of this document is as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">Eclipse on the browser</title>
<id>urn:uuid:4C93763032355C1C4B1192649345469</id>
<author>
<name>IBM User 1</name>
</author>
<updated>2007-10-16T18:05:46.469Z</updated>
<link href="feedcolln/feed/eclifox" rel="edit"></link>
<source xml:base="http://www.alphaworks.ibm.com/"
xmlns:xml="http://www.w3.org/XML/1998/namespace">
<title type="text">
IBM alphaWorks Emerging Technologies :
</title>
<link href="http://www.alphaworks.ibm.com/"></link>
<updated>2007-10-16T18:05:46.469Z</updated>
<author>
<name>alphaWorks Author</name>
</author>
<id>http://www.alphaworks.ibm.com/</id>
<category term="technology-updates"></category>
</source>
</entry>
The
entry.xml
contains a new entry definition containing the basic entry title,
author, location link.
Note:
A few points to note, before running curl or viewing the samples in the
browser:
- The server name and port, used in this example is
http://localhost:9080/. Change this to a value that is relevant to your
server.
- The following commands refer to an {entry_id}. The entry_id is
within the id tag: <id>entry_id</id>
For example, the entry_id will look something like this
"urn:uuid:{alphanumeric_number}", when it is generated by Abdera.
- In the case of Internet Explorer, the feed content may not be
rendered correctly. This is due to a defect in AXIOM libraries:
https://issues.apache.org/jira/browse/WSCOMMONS-281
Now, we are ready to execute the curl commands. Alternately, the GET
operations could also be performed by opening the url in a browser.
These are explained for every GET command.
- Retrieve the service document for the Abdera server,
using:
- Retrieve the entire feed, using
- Retrieve a specific feed entry, using
- Create an entry, using POST:
- Update a specific entry, using PUT:
- Remove an entry, using DELETE:
Important: The host name, servlet port and context root are documented as 'localhost', '9080' and 'SampleFeedApp'. This might vary according to the server configuration.
Troubleshooting
PUT and DELETE methods do not work
- The PUT method updates a specific entry, and the DELETE method
discards a specific entry. To work with this specific entry, ensure
that the {entry_id} being used already exists in the feed. Perform a
GET operation prior to the PUT or DELETE operation, verify that the
{entry_id} exists. The entry_id is within the id tag:
<id>entry_id</id>
For example, the entry_id will look something like this
"urn:uuid:{alphanumeric_number}", when it is generated by Abdera.
Performing a POST operation, creating an entry, always generates an
entry_id of this format
- In the case of PUT, ensure that the entry_id being used in the
url is similar to the one being entered into the sample entry.xml file.
- Also, note, that the POST operation always returns with the
details of the created entry, including its entry_id information. In
case of a subsequent update to this entry, use this entry_id
Certain feeds are not being read by the Abdera libraries
- Use FeedValidator, to check the validity of a feed.
FeedValidator is available here: http://feedvalidator.org
- Valid Atom feeds are processed by Abdera.
- RSS processing is still being introduced into Abdera,
therefore some valid RSS feeds may still not be processed by Abdera
- In addition, also use curl to check if the feeds are being
served correctly. curl can be obtained from:
http://curl.haxx.se/download.html.
Try this
curl -X GET http://news.google.com/?output=atom
- The last option is to use this sample JavaTM program to
determine if a feed can be processed.
import java.io.InputStream;
import java.net.URL;
import org.apache.abdera.Abdera;
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Feed;
import org.apache.abdera.parser.Parser;
public class TestFeed {
public static void main(String[] args) throws Exception {
Parser parser = Abdera.getNewParser();
InputStream input;
try {
input = new URL(args[0]).openStream();
Document doc = (Document) parser.parse(input);
Feed feed = (Feed) doc.getRoot();
System.out.println("Feed can be parsed");
System.out.println("Begin feed content -----");
feed.writeTo(System.out);
System.out.println("-------End feed content");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Compile this Java program, and to run it, provide a feed as the
program's argument. A command-line example would be: java TestFeed http://www.alphaworks.ibm.com/news/xml/aw.xml
Current Java 2 Security policy reported a potential violation
of Java 2 Security Permission.
- If you see this error in your SystemOut log, notice that this
is a setting that needs to be applied or changed based on the
recommendations in the IBM WebSphere Application Server's Infocenter.
Specifically, refer to http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/csec_rsecmgr2.html
- In the case that you feel this security setting is not
necessary, you can disable it as detailed below
- Open the IBM® WebSphere Application Server admin console, and
expand the "Security" option. Select "Secure administration,
applications, and infrastructure"
- On this "Secure administration, applications, and
infrastructure" configuration page, de-select the "Use Java 2 security
to restrict application access to local resources" option. Click on
"Apply" button.
- Click Save to the master configuration.
- Restart "server1".
Changing the FeedAPPServlet's url-pattern in web.xml
If you intend to change the url-pattern for FeedAppServlet - the
one that provides Atom Publishing Protocol support - then ensure that
the url-pattern is changed in the
<SOURCE_FOLDER>/com/ibm/ajax/feeds/app/samples/feed_settings.properties
file too. For instance, if the value changes in the web.xml from /atom/*
to /publish/*, then set the value /publish in the properties file. This
is to ensure that the URL for the feeds is correctly resolved by the
Abdera server. Otherwise, this will result in a 404 - File not found
error.