Re: Atom Support

2007-07-31 Thread Jim Alateras


Alex/Jerome,

I am also interested in incorporated APP client and server capabilities 
in our application. I have a couple of questions more so for Alex than 
Jerome.


1. From the little I've read on atomojo there seems to be a database 
dependency on the component. Is this still the case?


2. How much of the APP spec does the current version support? say in 
comparison to apache abdera.



cheers
/jima


Alex Milowski wrote:


On 5/3/07, Jerome Louvel [EMAIL PROTECTED] wrote:


Hi Zsolt,

This extension already exists in SVN but needs to be completed. It has no
external dependency beside the Restlet API and is therefore very
lightweight.

Note that this extension only supports the Atom Feed Format (reading and
writing) but not the Atom Publishing Protocol itself. However, it 
should be
quite straightforward to implement a full APP server based on it and 
on the

Restlet framework.


Yes, it is...

That's what I've been doing in my atomojo project:

  http://code.google.com/p/atomojo

I have an API based on restlet that should let you add my
APP implementation to any application.  Of course, it relies
upon the way I choose to implement the feed storage.

If you want to roll your own, it is quite straight forward to do with
the Restlet API.  There are a lot of details in the APP that you need to
consider, but getting something basic running isn't so hard.

--Alex Milowski



Exceptions ignored while creating representation?

2007-07-31 Thread Richard Wallace

Hello,

I'm messing around with using the SaxRepresentation and the XmlWriter to 
create a XHTML representation of my resources similar to how they're 
created in RESTful Web Services.  So, in my resource I have


   @Override
   public Representation getRepresentation (Variant variant) {
   Representation result = null;
   if (variant.getMediaType().equals 
(MediaType.APPLICATION_XHTML_XML)) {
   result = new SaxRepresentation 
(MediaType.APPLICATION_XHTML_XML) {

   public void write (XmlWriter writer) throws IOException {
   // serialize accounts
   try {
   writer.startDocument ();
   writer.startElement (html);
  
   writer.endElement (html);

   writer.endDocument ();
   } catch (SAXException e) {
   throw new IOException (e.getMessage ());
   }
   }
   };
   }
   return result;
   }

I had to catch the SAXException and throw it as an IOException because 
that is all that is allowed by the API for the write() method.  The 
thing is, I tried throwing a SAXException in the middle of the try 
statement, which caused the IOException to be thrown, but Restlet still 
sent a 200 to the client saying that everything was ok.  If I throw the 
SAXException before endDocument() is called, nothing seems to be sent to 
the client but it gets a 200.  I also tried wrapping it in a 
RuntimeException and saw the same behavior.


Shouldn't the caller of the write() method try and catch exceptions and 
send a 500 to the client?  It might even be better to give the write() 
method the ability to do this, since it is the one that is probably best 
suited to deciding what kind of error should be sent to the client.


Rich