org.apache.abdera.protocol.server.impl
Class AbstractCollectionAdapter

java.lang.Object
  extended by org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
All Implemented Interfaces:
CollectionAdapter, CollectionInfo, MediaCollectionAdapter, Transactional
Direct Known Subclasses:
AbstractEntityCollectionAdapter, AbstractMultipartCollectionAdapter, ManagedCollectionAdapter, SimpleAdapter

public abstract class AbstractCollectionAdapter
extends Object
implements CollectionAdapter, MediaCollectionAdapter, Transactional, CollectionInfo

Base CollectionAdapter implementation that provides a number of helper utility methods for adapter implementations.


Constructor Summary
AbstractCollectionAdapter()
           
 
Method Summary
 Collection asCollectionElement(RequestContext request)
          Converts this to an instance of the FOM Collection interface
protected  ResponseContext buildCreateEntryResponse(String link, Entry entry)
          Creates the ResponseContext for a newly created entry.
protected  ResponseContext buildGetEntryResponse(RequestContext request, Entry entry)
          Creates the ResponseContext for a GET entry request.
protected  ResponseContext buildGetFeedResponse(Feed feed)
          Creates the ResponseContext for a GET feed request.
protected  ResponseContext buildHeadEntryResponse(RequestContext request, String id, Date updated)
          Creates the ResponseContext for a HEAD entry request.
protected  ResponseContext buildPostMediaEntryResponse(String link, Entry entry)
          Creates the ResponseContext for a newly created entry.
 void compensate(RequestContext request, Throwable t)
          Called by the provider when a processing error occurs
protected  ResponseContext createErrorResponse(ResponseContextException e)
          Create a ResponseContext (or take it from the Exception) for an exception that occurred in the application.
protected  Feed createFeedBase(RequestContext request)
          Create the base feed for the requested collection.
 ResponseContext deleteMedia(RequestContext request)
          Delete a media resource from the collection
 void end(RequestContext request, ResponseContext response)
          Called by the provider after dispatching the request to the adapter
 ResponseContext extensionRequest(RequestContext request)
          Any request that is not covered by the postEntry, deleteEntry, etc methods will be passed on to the extensionRequest method.
 String[] getAccepts(RequestContext request)
          Returns an array of MIME media types for the app:collection element's app:accept elements.
abstract  String getAuthor(RequestContext request)
           
 ResponseContext getCategories(RequestContext request)
          Get an Atompub Categories document
 CategoriesInfo[] getCategoriesInfo(RequestContext request)
          Return the collection of CategoriesInfo objects for the app:collection element's app:categories elements.
protected  Entry getEntryFromRequest(RequestContext request)
          Retrieves the FOM Entry object from the request payload.
 String getHref()
           
 String getHref(RequestContext request)
          Get the value of the app:collection element's href attribute.
abstract  String getId(RequestContext request)
           
 ResponseContext getMedia(RequestContext request)
          Get a media resource
protected  String getResourceName(RequestContext request)
          Get's the name of the specific resource requested
 ResponseContext headEntry(RequestContext request)
          Get metadata for an entry from the collection
 ResponseContext headMedia(RequestContext request)
          Get metdata for a media resource
 ResponseContext optionsEntry(RequestContext request)
          Get options for an entry from the collection
 ResponseContext optionsMedia(RequestContext request)
          Get a media resource's options.
 ResponseContext postMedia(RequestContext request)
          Add a new media resource to the collection, resulting in the creation of a new Media Link Entry.
 ResponseContext putMedia(RequestContext request)
          Update a media resource
 void setHref(String href)
           
 void start(RequestContext request)
          Called by the provider before dispatching the request to the adapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.abdera.protocol.server.CollectionAdapter
deleteEntry, getEntry, getFeed, postEntry, putEntry
 
Methods inherited from interface org.apache.abdera.protocol.server.CollectionInfo
getTitle
 

Constructor Detail

AbstractCollectionAdapter

public AbstractCollectionAdapter()
Method Detail

getHref

public String getHref()

setHref

public void setHref(String href)

getHref

public String getHref(RequestContext request)
Description copied from interface: CollectionInfo
Get the value of the app:collection element's href attribute. This must not be null

Specified by:
getHref in interface CollectionInfo

compensate

public void compensate(RequestContext request,
                       Throwable t)
Description copied from interface: Transactional
Called by the provider when a processing error occurs

Specified by:
compensate in interface Transactional

end

public void end(RequestContext request,
                ResponseContext response)
Description copied from interface: Transactional
Called by the provider after dispatching the request to the adapter

Specified by:
end in interface Transactional

start

public void start(RequestContext request)
           throws ResponseContextException
Description copied from interface: Transactional
Called by the provider before dispatching the request to the adapter

Specified by:
start in interface Transactional
Throws:
ResponseContextException

getAccepts

public String[] getAccepts(RequestContext request)
Description copied from interface: CollectionInfo
Returns an array of MIME media types for the app:collection element's app:accept elements. These tell a client which media types the collection will accept on a POST

Specified by:
getAccepts in interface CollectionInfo

getCategoriesInfo

public CategoriesInfo[] getCategoriesInfo(RequestContext request)
Description copied from interface: CollectionInfo
Return the collection of CategoriesInfo objects for the app:collection element's app:categories elements. These tell a client which atom:category elements are defined for use in the collections atom:entries

Specified by:
getCategoriesInfo in interface CollectionInfo

getCategories

public ResponseContext getCategories(RequestContext request)
Description copied from interface: CollectionAdapter
Get an Atompub Categories document

Specified by:
getCategories in interface CollectionAdapter

deleteMedia

public ResponseContext deleteMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Delete a media resource from the collection

Specified by:
deleteMedia in interface MediaCollectionAdapter

getMedia

public ResponseContext getMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Get a media resource

Specified by:
getMedia in interface MediaCollectionAdapter

headMedia

public ResponseContext headMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Get metdata for a media resource

Specified by:
headMedia in interface MediaCollectionAdapter

optionsMedia

public ResponseContext optionsMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Get a media resource's options.

Specified by:
optionsMedia in interface MediaCollectionAdapter

putMedia

public ResponseContext putMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Update a media resource

Specified by:
putMedia in interface MediaCollectionAdapter

postMedia

public ResponseContext postMedia(RequestContext request)
Description copied from interface: MediaCollectionAdapter
Add a new media resource to the collection, resulting in the creation of a new Media Link Entry.

Specified by:
postMedia in interface MediaCollectionAdapter

headEntry

public ResponseContext headEntry(RequestContext request)
Description copied from interface: CollectionAdapter
Get metadata for an entry from the collection

Specified by:
headEntry in interface CollectionAdapter

optionsEntry

public ResponseContext optionsEntry(RequestContext request)
Description copied from interface: CollectionAdapter
Get options for an entry from the collection

Specified by:
optionsEntry in interface CollectionAdapter

getAuthor

public abstract String getAuthor(RequestContext request)
                          throws ResponseContextException
Throws:
ResponseContextException

getId

public abstract String getId(RequestContext request)

buildCreateEntryResponse

protected ResponseContext buildCreateEntryResponse(String link,
                                                   Entry entry)
Creates the ResponseContext for a newly created entry. By default, a BaseResponseContext is returned. The Location, Content-Location, Etag and status are set appropriately.


buildPostMediaEntryResponse

protected ResponseContext buildPostMediaEntryResponse(String link,
                                                      Entry entry)
Creates the ResponseContext for a newly created entry. By default, a BaseResponseContext is returned. The Location, Content-Location, Etag and status are set appropriately.


buildGetEntryResponse

protected ResponseContext buildGetEntryResponse(RequestContext request,
                                                Entry entry)
                                         throws ResponseContextException
Creates the ResponseContext for a GET entry request. By default, a BaseResponseContext is returned. The Entry will contain an appropriate atom:source element and the Etag header will be set.

Throws:
ResponseContextException

buildHeadEntryResponse

protected ResponseContext buildHeadEntryResponse(RequestContext request,
                                                 String id,
                                                 Date updated)
                                          throws ResponseContextException
Creates the ResponseContext for a HEAD entry request. By default, an EmptyResponseContext is returned. The Etag header will be set.

Throws:
ResponseContextException

buildGetFeedResponse

protected ResponseContext buildGetFeedResponse(Feed feed)
Creates the ResponseContext for a GET feed request. By default, a BaseResponseContext is returned. The Etag header will be set.


createErrorResponse

protected ResponseContext createErrorResponse(ResponseContextException e)
Create a ResponseContext (or take it from the Exception) for an exception that occurred in the application.

Parameters:
e -
Returns:

createFeedBase

protected Feed createFeedBase(RequestContext request)
                       throws ResponseContextException
Create the base feed for the requested collection.

Throws:
ResponseContextException

getEntryFromRequest

protected Entry getEntryFromRequest(RequestContext request)
                             throws ResponseContextException
Retrieves the FOM Entry object from the request payload.

Throws:
ResponseContextException

getResourceName

protected String getResourceName(RequestContext request)
Get's the name of the specific resource requested


extensionRequest

public ResponseContext extensionRequest(RequestContext request)
Description copied from interface: CollectionAdapter
Any request that is not covered by the postEntry, deleteEntry, etc methods will be passed on to the extensionRequest method. This provides an Adapter with the ability to support Atompub protocol extensions.

Specified by:
extensionRequest in interface CollectionAdapter

asCollectionElement

public Collection asCollectionElement(RequestContext request)
Description copied from interface: CollectionInfo
Converts this to an instance of the FOM Collection interface

Specified by:
asCollectionElement in interface CollectionInfo


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.