Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Migration from Apache Abdera to Apache Wink

Apache Wink is an excellent the perfect solution for consuming and producing Atom, APP and RSS documents. The following section describes how to migrate from Apache Abdera to Apache Wink by providing a set of examples that cover most use cases.

...

This section contains the following topics:

...

Apache Abdera version 0.4 does not support RSS write.

Apache Wink

Same as in #2) a) Producing Atom Documents or #2) 2) b) Producing Atom Documents Using Apache Wink - the JAX-RS Wayway. However the resource method now returns an RssFeed object instead of AtomFeed object.

...

5) Writing Atom Publishing Protocol (APP) Server

In order to write and publish an APP server using Apache Abdera and Apache Wink perform the following steps:

The following scenario explains how to Implement The following steps explain how to implement an APP server as described in the following beautiful article by James Snell: http://www.ibm.com/developerworks/library/x-atompp1/

...

In order to write an Atom Publishing Protocol client refer to the following examples.

Info
titleImportant Note

Make sure that the APP_Server_Abdera.war and the APP_Server_Wink.war provided in the previous example are deployed before running this examplethese examples.

Apache Abdera - Click on link to Download - APP_Client_Abdera.java

       1. Acessing Service Document:

Code Block
Document<Service> introspection = abderaClient.get(SERVICE_URL).getDocument();
Service service = introspection.getRoot();
List<Workspace> workspaces = service.getWorkspaces();
for (Workspace workspace : workspaces) {
    System.out.println("\t" + workspace.getTitle());
    List<Collection> collections = workspace.getCollections();
    for (Collection collection : collections) {
        System.out.println("\t" + collection.getTitle() + "\t:\t" + collection.getHref());
    }
    System.out.print("\n");
}

       2. Getting a Feed

Code Block
RequestOptions opts = new RequestOptions();
opts.setContentType("application/atom+xml;type=feed");
ClientResponse response = abderaClient.get(FEED_URL, opts);
Feed feed = (Feed)response.getDocument().getRoot();

       3. Posting an entry to a Feed

Code Block
RequestOptions opts = new RequestOptions();
opts.setContentType("application/atom+xml;type=entry");
ClientResponse response = abderaClient.post(FEED_URL, newEntry, opts);

       4. Putting a change to an Entry

Code Block
RequestOptions opts = new RequestOptions();
opts.setContentType("application/atom+xml;type=entry");
ClientResponse response = abderaClient.put(ENTRY_URL, changedEntry.getDocument(), opts);

       5. Getting an Entry

Code Block
RequestOptions opts = new RequestOptions();
opts.setContentType("application/atom+xml;type=entry");
ClientResponse response = abderaClient.get(ENTRY_URL, opts);
Entry entry = (Entry)response.getDocument().getRoot();

       6. Deleting an Entry

Code Block
ClientResponse response = abderaClient.delete(ENTRY_URL);

Apache Wink - Click on link to Download - APP_Client_Wink.java

       1. Acessing Service Document:

Code Block
Resource resource = restClient.resource(SERVICE_URL);
AppService service = resource.accept(MediaTypeUtils.ATOM_SERVICE_DOCUMENT).get(AppService.class);
List<AppWorkspace> workspaces = service.getWorkspace();
for (AppWorkspace workspace : workspaces) {
    System.out.println("\t" + workspace.getTitle().getValue());
    List<AppCollection> collections = workspace.getCollection();
    for (AppCollection collection : collections) {
        System.out.println("\t" + collection.getTitle().getValue()
            + "\t:\t"
            + collection.getHref());
    }
    System.out.print("\n");
}

       2. Getting a Feed

Code Block
Resource feedResource = restClient.resource(FEED_URL);
AtomFeed feed = feedResource.accept(MediaType.APPLICATION_ATOM_XML).get(AtomFeed.class);

       3. Posting an entry to a Feed

Code Block
Resource feedResource = restClient.resource(FEED_URL);
ClientResponse response =
    feedResource.contentType(MediaType.APPLICATION_ATOM_XML).post(newEntry);

       4. Putting a change to an Entry

Code Block
Resource feedResource = restClient.resource(ENTRY_URL);
ClientResponse response =
    feedResource.contentType(MediaType.APPLICATION_ATOM_XML).put(changedEntry);

       5. Getting an Entry

Code Block
Resource feedResource = restClient.resource(ENTRY_URL);
AtomEntry atomEntry = feedResource.accept(MediaType.APPLICATION_ATOM_XML).get(AtomEntry.class);

       6. Deleting an Entry

Code Block
Resource feedResource = restClient.resource(ENTRY_URL);
ClientResponse response = feedResource.delete();

...