Apache Abdera API

org.apache.abdera.protocol.server.adapters.jcr
Class JcrCollectionAdapter

java.lang.Object
  extended by org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
      extended by org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
          extended by org.apache.abdera.protocol.server.adapters.jcr.JcrCollectionAdapter
All Implemented Interfaces:
CollectionAdapter, CollectionInfo, MediaCollectionAdapter, Transactional

public class JcrCollectionAdapter
extends org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>

Adapter implementation that uses a JCR Repository to store Atompub collection entries. The adapter is intended to be used with the DefaultProvider implementation.


Constructor Summary
JcrCollectionAdapter()
           
 
Method Summary
 void deleteEntry(String resourceName, RequestContext request)
           
static void dump(javax.jcr.Node node)
          Recursively outputs the contents of the given node.
 void end(RequestContext request, ResponseContext response)
          Called by the provider after dispatching the request to the adapter
 String getAuthor(RequestContext request)
           
 List<Person> getAuthors(javax.jcr.Node entry, RequestContext request)
           
 ResponseContext getCategories(RequestContext request)
          Get an Atompub Categories document
 Object getContent(javax.jcr.Node entry, RequestContext request)
           
 String getContentType(javax.jcr.Node entry)
           
static Calendar getDateOrNull(javax.jcr.Node node, String propName)
           
 Iterable<javax.jcr.Node> getEntries(RequestContext request)
           
 javax.jcr.Node getEntry(String resourceName, RequestContext request)
           
 String getId(javax.jcr.Node entry)
           
 String getId(RequestContext request)
           
 String getMediaName(javax.jcr.Node entry)
           
 InputStream getMediaStream(javax.jcr.Node entry)
           
 String getName(javax.jcr.Node entry)
           
static String getStringOrNull(javax.jcr.Node node, String propName)
           
 Text getSummary(javax.jcr.Node entry, RequestContext request)
           
 String getTitle(javax.jcr.Node entry)
           
 String getTitle(RequestContext request)
          Get the value of the app:collection element's atom:title element.
 Date getUpdated(javax.jcr.Node entry)
           
static javax.jcr.Value getValueOrNull(javax.jcr.Node node, String propName)
           
 void initialize()
          Logs into the repository and posts a node for the collection if one does not exist.
 boolean isMediaEntry(javax.jcr.Node entry)
           
 javax.jcr.Node postEntry(String title, IRI id, String summary, Date updated, List<Person> authors, Content content, RequestContext request)
           
protected  javax.jcr.Node postEntry(String title, String summary, Date updated, List<Person> authors, Content content, javax.jcr.Session session, javax.jcr.Node collectionNode, String resourceName, int num)
           
 javax.jcr.Node postMedia(javax.activation.MimeType mimeType, String slug, InputStream inputStream, RequestContext request)
           
protected  String postSummaryForEntry(javax.jcr.Node n)
          post a summary for an entry.
 void putEntry(javax.jcr.Node entry, String title, Date updated, List<Person> authors, String summary, Content content, RequestContext request)
           
 void setAuthor(String author)
           
 void setCollectionNodePath(String collectionNodePath)
           
 void setCredentials(javax.jcr.Credentials credentials)
           
 void setMaxActiveSessions(int maxActiveSessions)
           
 void setRepository(javax.jcr.Repository repository)
           
 void setTitle(String title)
           
 void start(RequestContext request)
          Called by the provider before dispatching the request to the adapter
 
Methods inherited from class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter
addContent, addEntryDetails, addFeedDetails, addMediaContent, buildGetMediaResponse, createMediaEntry, createNonMediaEntry, deleteEntry, deleteMedia, deleteMedia, getEntry, getEntryFromCollectionProvider, getFeed, getFeedIriForEntry, getLink, getLink, getMedia, getQueryParameters, headEntry, headMedia, postEntry, postMedia, putEntry, putMedia, putMedia
 
Methods inherited from class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
asCollectionElement, buildCreateEntryResponse, buildGetEntryResponse, buildGetFeedResponse, buildHeadEntryResponse, buildPostMediaEntryResponse, compensate, createErrorResponse, createFeedBase, extensionRequest, getAccepts, getCategoriesInfo, getEntryFromRequest, getHref, getHref, getResourceName, optionsEntry, optionsMedia, setHref
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrCollectionAdapter

public JcrCollectionAdapter()
Method Detail

setCollectionNodePath

public void setCollectionNodePath(String collectionNodePath)

setTitle

public void setTitle(String title)

setAuthor

public void setAuthor(String author)

initialize

public void initialize()
                throws Exception
Logs into the repository and posts a node for the collection if one does not exist. Also, this will set up the session pool.

Throws:
javax.jcr.RepositoryException
Exception

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
Overrides:
start in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Throws:
ResponseContextException

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
Overrides:
end in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter

getContentType

public String getContentType(javax.jcr.Node entry)
Overrides:
getContentType in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>

isMediaEntry

public boolean isMediaEntry(javax.jcr.Node entry)
                     throws ResponseContextException
Overrides:
isMediaEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

postMedia

public javax.jcr.Node postMedia(javax.activation.MimeType mimeType,
                                String slug,
                                InputStream inputStream,
                                RequestContext request)
                         throws ResponseContextException
Overrides:
postMedia in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

postSummaryForEntry

protected String postSummaryForEntry(javax.jcr.Node n)
post a summary for an entry. Used when a media entry is postd so you have the chance to post a meaningful summary for consumers of the feed.

Parameters:
n -
Returns:

postEntry

public javax.jcr.Node postEntry(String title,
                                IRI id,
                                String summary,
                                Date updated,
                                List<Person> authors,
                                Content content,
                                RequestContext request)
                         throws ResponseContextException
Specified by:
postEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

postEntry

protected javax.jcr.Node postEntry(String title,
                                   String summary,
                                   Date updated,
                                   List<Person> authors,
                                   Content content,
                                   javax.jcr.Session session,
                                   javax.jcr.Node collectionNode,
                                   String resourceName,
                                   int num)
                            throws ResponseContextException,
                                   javax.jcr.RepositoryException
Throws:
ResponseContextException
javax.jcr.RepositoryException

deleteEntry

public void deleteEntry(String resourceName,
                        RequestContext request)
                 throws ResponseContextException
Specified by:
deleteEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

dump

public static void dump(javax.jcr.Node node)
                 throws javax.jcr.RepositoryException
Recursively outputs the contents of the given node.

Throws:
javax.jcr.RepositoryException

getAuthor

public String getAuthor(RequestContext request)
                 throws ResponseContextException
Specified by:
getAuthor in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Throws:
ResponseContextException

getAuthors

public List<Person> getAuthors(javax.jcr.Node entry,
                               RequestContext request)
                        throws ResponseContextException
Overrides:
getAuthors in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getContent

public Object getContent(javax.jcr.Node entry,
                         RequestContext request)
                  throws ResponseContextException
Specified by:
getContent in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getEntries

public Iterable<javax.jcr.Node> getEntries(RequestContext request)
                                    throws ResponseContextException
Specified by:
getEntries in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getEntry

public javax.jcr.Node getEntry(String resourceName,
                               RequestContext request)
                        throws ResponseContextException
Specified by:
getEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getId

public String getId(RequestContext request)
Specified by:
getId in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter

getId

public String getId(javax.jcr.Node entry)
             throws ResponseContextException
Specified by:
getId in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getMediaName

public String getMediaName(javax.jcr.Node entry)
                    throws ResponseContextException
Overrides:
getMediaName in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getMediaStream

public InputStream getMediaStream(javax.jcr.Node entry)
                           throws ResponseContextException
Overrides:
getMediaStream in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getName

public String getName(javax.jcr.Node entry)
               throws ResponseContextException
Specified by:
getName in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getSummary

public Text getSummary(javax.jcr.Node entry,
                       RequestContext request)
                throws ResponseContextException
Overrides:
getSummary in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getTitle

public String getTitle(RequestContext request)
Description copied from interface: CollectionInfo
Get the value of the app:collection element's atom:title element. This assumes that the title will be type="text". This must not be null;


getTitle

public String getTitle(javax.jcr.Node entry)
                throws ResponseContextException
Specified by:
getTitle in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getUpdated

public Date getUpdated(javax.jcr.Node entry)
                throws ResponseContextException
Specified by:
getUpdated in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

putEntry

public void putEntry(javax.jcr.Node entry,
                     String title,
                     Date updated,
                     List<Person> authors,
                     String summary,
                     Content content,
                     RequestContext request)
              throws ResponseContextException
Specified by:
putEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<javax.jcr.Node>
Throws:
ResponseContextException

getStringOrNull

public static String getStringOrNull(javax.jcr.Node node,
                                     String propName)
                              throws ResponseContextException
Throws:
ResponseContextException

getCategories

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

Specified by:
getCategories in interface CollectionAdapter
Overrides:
getCategories in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter

getDateOrNull

public static Calendar getDateOrNull(javax.jcr.Node node,
                                     String propName)
                              throws ResponseContextException
Throws:
ResponseContextException

getValueOrNull

public static javax.jcr.Value getValueOrNull(javax.jcr.Node node,
                                             String propName)
                                      throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

setRepository

public void setRepository(javax.jcr.Repository repository)

setCredentials

public void setCredentials(javax.jcr.Credentials credentials)

setMaxActiveSessions

public void setMaxActiveSessions(int maxActiveSessions)

Apache Abdera API

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