abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Berry <chriswbe...@gmail.com>
Subject GData-style optimistic concurrency
Date Mon, 13 Aug 2007 14:35:25 GMT
Greetings,
I have implemented a GData-style Atom store on top of Abdera.
One of the better features of GData is it's optimistic concurrency  
model.
And it seems that Abdera might benefit from providing an abstraction  
around this concept,
similar to the other error codes (e.g. forbidden(), badrequest(), etc.)

I implemented the following (although it might be better to use a  
<content> element, than simply provide an edit link)
Thanks,
-- Chris 

     /**
      * Return a 409 conflict error
      */
     protected ResponseContext optimisticConcurrencyError( Abdera  
abdera, RequestContext request,
                                                                         
                                     String reason, String editURI ) {
         return returnBase( createOptimisticConcurrencyErrorDocument 
( abdera, reason, editURI ),
                                          409, null);
     }

     protected Document createOptimisticConcurrencyErrorDocument 
( Abdera abdera, String message, String editURI ) {

         Document doc = abdera.getFactory().newDocument();
         ExtensibleElement root = (ExtensibleElement)  
abdera.getFactory().newElement(ERROR, doc);
         root.addSimpleExtension( CODE, "409" );
         root.addSimpleExtension( MESSAGE, (message != null) ?  
message : "" );

         // create an Atom edit link
         Link link = abdera.getFactory().newLink();
         link.setHref( editURI );
         link.setRel( "edit" );

         if ( logger.isDebugEnabled() )
             logger.debug( "^^^^^^^^^^^^^^^^ link = " + link );

         root.addExtension( link );

         return doc;
     }




S'all good  ---   chriswberry@gmail.com




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message