abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: GData-style optimistic concurrency
Date Mon, 13 Aug 2007 15:55:01 GMT
The optimistic concurrency model in Gdata works but using Etags/If-Match
is a better solution.  That said, I would not have a problem putting
some GData-specific code in the extensions model, perhaps a
GDataProvider that would extend AbstractProvider?

- James

Chris Berry wrote:
> 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
View raw message