abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Client code
Date Tue, 08 Aug 2006 22:22:34 GMT
Ok, so I've got the new client code running to a point where we can use
it with basic Atom Publishing servers.  For instance, we can point it at
Queso and things just work...

  Client client = new CommonsClient();

  String uri = "http://abdera.watson.ibm.com:8080/atom/abdera";

  Entry entry = Factory.INSTANCE.newEntry();
  entry.setId(FOMHelper.generateUuid());
  entry.setTitle("this is a test");
  entry.setUpdated(new Date());
  entry.addAuthor("James");
  entry.addLink("http://example.org/foo");
  entry.setContent("this is a test");

  // Create the entry
  Response response = client.post(uri, entry);

  System.out.println(response.getStatus());
  System.out.println(response.getLocation());
  System.out.println(response.getContentLocation());

  uri = response.getLocation();

  // Edit the entry
  Document<Entry> entry_doc = client.get(uri).getDocument();
  entry_doc.getRoot().setTitle("this is the changed title");
  response = client.put(uri, entry_doc.getRoot());
  System.out.println(response.getStatus());

  // Delete the entry
  response = client.delete(uri);
  System.out.println(response.getStatus());

  // Verify that it's gone
  response = client.get(uri);
  System.out.println(response.getStatus());

We still need to fully exercise and debug the caching code, but things
appear to be minimally functional enough to get real stuff done.

- James


Mime
View raw message