org.rometools.propono.atom.server.impl
Class FileBasedAtomHandler

java.lang.Object
  extended by org.rometools.propono.atom.server.impl.FileBasedAtomHandler
All Implemented Interfaces:
AtomHandler

public class FileBasedAtomHandler
extends Object
implements AtomHandler

File-based com.sun.syndication.propono.atom.server.AtomHandler implementation that stores entries and media-entries to disk. Implemented using com.sun.syndication.propono.atom.server.impl.FileBasedAtomService.


Constructor Summary
FileBasedAtomHandler(javax.servlet.http.HttpServletRequest req)
          Construct handler to handle one request.
FileBasedAtomHandler(javax.servlet.http.HttpServletRequest req, String uploaddir)
          Contruct handler for one request, using specified file storage directory.
 
Method Summary
 String authenticateBASIC(javax.servlet.http.HttpServletRequest request)
          BASIC authentication.
 void deleteEntry(AtomRequest areq)
          Delete entry specified by pathInfo.
 String getAtomProtocolURL()
          Get base URI of Atom protocol implementation.
 AtomService getAtomService(AtomRequest areq)
          Return introspection document
 String getAuthenticatedUsername()
          Get username of authenticated user
 Categories getCategories(AtomRequest areq)
          Returns null because we use in-line categories.
 com.sun.syndication.feed.atom.Feed getCollection(AtomRequest areq)
          Get collection specified by pathinfo.
 com.sun.syndication.feed.atom.Entry getEntry(AtomRequest areq)
          Get entry specified by pathInfo.
 AtomMediaResource getMediaResource(AtomRequest areq)
          Get media resource specified by request.
 boolean isAtomServiceURI(AtomRequest areq)
          Return true if specified pathinfo represents URI of service doc.
 boolean isCategoriesURI(AtomRequest areq)
          Return true if specified pathinfo represents URI of category doc.
 boolean isCollectionURI(AtomRequest areq)
          Return true if specified pathinfo represents URI of a collection.
 boolean isEntryURI(AtomRequest areq)
          Return true if specified pathinfo represents URI of an Atom entry.
 boolean isMediaEditURI(AtomRequest areq)
          Return true if specified pathinfo represents media-edit URI.
 com.sun.syndication.feed.atom.Entry postEntry(AtomRequest areq, com.sun.syndication.feed.atom.Entry entry)
          Create a new entry specified by pathInfo and posted entry.
 com.sun.syndication.feed.atom.Entry postMedia(AtomRequest areq, com.sun.syndication.feed.atom.Entry entry)
          Store media data in collection specified by pathInfo, create an Atom media-link entry to store metadata for the new media file and return that entry to the caller.
 void putEntry(AtomRequest areq, com.sun.syndication.feed.atom.Entry entry)
          Update entry specified by pathInfo and posted entry.
 void putMedia(AtomRequest areq)
          Update the media file part of a media-link entry.
 boolean validateUser(String login, String password)
          Method used for validating user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBasedAtomHandler

public FileBasedAtomHandler(javax.servlet.http.HttpServletRequest req)
Construct handler to handle one request.

Parameters:
req - Request to be handled.

FileBasedAtomHandler

public FileBasedAtomHandler(javax.servlet.http.HttpServletRequest req,
                            String uploaddir)
Contruct handler for one request, using specified file storage directory.

Parameters:
req - Request to be handled.
uploaddir - File storage upload dir.
Method Detail

validateUser

public boolean validateUser(String login,
                            String password)
Method used for validating user. Developers can overwrite this method and use credentials stored in Database or LDAP to confirm if the user is allowed to access this service.

Parameters:
login - user submitted login id
password - user submitted password

getAuthenticatedUsername

public String getAuthenticatedUsername()
Get username of authenticated user

Specified by:
getAuthenticatedUsername in interface AtomHandler
Returns:
User name.

getAtomProtocolURL

public String getAtomProtocolURL()
Get base URI of Atom protocol implementation.

Returns:
Base URI of Atom protocol implemenation.

getAtomService

public AtomService getAtomService(AtomRequest areq)
                           throws AtomException
Return introspection document

Specified by:
getAtomService in interface AtomHandler
Returns:
AtomService object with workspaces and collections.
Throws:
com.sun.syndication.propono.atom.server.AtomException - Unexpected exception.
AtomException

getCategories

public Categories getCategories(AtomRequest areq)
                         throws AtomException
Returns null because we use in-line categories.

Specified by:
getCategories in interface AtomHandler
Returns:
Categories object
Throws:
com.sun.syndication.propono.atom.server.AtomException - Unexpected exception.
AtomException

getCollection

public com.sun.syndication.feed.atom.Feed getCollection(AtomRequest areq)
                                                 throws AtomException
Get collection specified by pathinfo.

Specified by:
getCollection in interface AtomHandler
Parameters:
areq - Details of HTTP request
Returns:
ROME feed representing collection.
Throws:
com.sun.syndication.propono.atom.server.AtomException - Invalid collection or other exception.
AtomException

postEntry

public com.sun.syndication.feed.atom.Entry postEntry(AtomRequest areq,
                                                     com.sun.syndication.feed.atom.Entry entry)
                                              throws AtomException
Create a new entry specified by pathInfo and posted entry. We save the submitted Atom entry verbatim, but we do set the id and reset the update time.

Specified by:
postEntry in interface AtomHandler
Parameters:
entry - Entry to be added to collection.
areq - Details of HTTP request
Returns:
Entry as represented on server.
Throws:
com.sun.syndication.propono.atom.server.AtomException - On invalid collection or other error.
AtomException

getEntry

public com.sun.syndication.feed.atom.Entry getEntry(AtomRequest areq)
                                             throws AtomException
Get entry specified by pathInfo.

Specified by:
getEntry in interface AtomHandler
Parameters:
areq - Details of HTTP request
Returns:
ROME Entry object.
Throws:
com.sun.syndication.propono.atom.server.AtomException - On invalid pathinfo or other error.
AtomException

putEntry

public void putEntry(AtomRequest areq,
                     com.sun.syndication.feed.atom.Entry entry)
              throws AtomException
Update entry specified by pathInfo and posted entry.

Specified by:
putEntry in interface AtomHandler
Parameters:
entry -
areq - Details of HTTP request
Throws:
com.sun.syndication.propono.atom.server.AtomException
AtomException

deleteEntry

public void deleteEntry(AtomRequest areq)
                 throws AtomException
Delete entry specified by pathInfo.

Specified by:
deleteEntry in interface AtomHandler
Parameters:
areq - Details of HTTP request
Throws:
AtomException

postMedia

public com.sun.syndication.feed.atom.Entry postMedia(AtomRequest areq,
                                                     com.sun.syndication.feed.atom.Entry entry)
                                              throws AtomException
Store media data in collection specified by pathInfo, create an Atom media-link entry to store metadata for the new media file and return that entry to the caller.

Specified by:
postMedia in interface AtomHandler
Parameters:
areq - Details of HTTP request
entry - New entry initialzied with only title and content type
Returns:
Location URL of new media entry
Throws:
AtomException

putMedia

public void putMedia(AtomRequest areq)
              throws AtomException
Update the media file part of a media-link entry.

Specified by:
putMedia in interface AtomHandler
Parameters:
areq - Details of HTTP request Assuming pathInfo of form /user-name/resource/name
Throws:
AtomException

getMediaResource

public AtomMediaResource getMediaResource(AtomRequest areq)
                                   throws AtomException
Description copied from interface: AtomHandler
Get media resource specified by request.

Specified by:
getMediaResource in interface AtomHandler
Parameters:
areq - Details of HTTP request
Throws:
AtomException

isAtomServiceURI

public boolean isAtomServiceURI(AtomRequest areq)
Return true if specified pathinfo represents URI of service doc.

Specified by:
isAtomServiceURI in interface AtomHandler
Parameters:
areq - Details of HTTP request

isCategoriesURI

public boolean isCategoriesURI(AtomRequest areq)
Return true if specified pathinfo represents URI of category doc.

Specified by:
isCategoriesURI in interface AtomHandler
Parameters:
areq - Details of HTTP request

isCollectionURI

public boolean isCollectionURI(AtomRequest areq)
Return true if specified pathinfo represents URI of a collection.

Specified by:
isCollectionURI in interface AtomHandler
Parameters:
areq - Details of HTTP request

isEntryURI

public boolean isEntryURI(AtomRequest areq)
Return true if specified pathinfo represents URI of an Atom entry.

Specified by:
isEntryURI in interface AtomHandler
Parameters:
areq - Details of HTTP request

isMediaEditURI

public boolean isMediaEditURI(AtomRequest areq)
Return true if specified pathinfo represents media-edit URI.

Specified by:
isMediaEditURI in interface AtomHandler
Parameters:
areq - Details of HTTP request

authenticateBASIC

public String authenticateBASIC(javax.servlet.http.HttpServletRequest request)
BASIC authentication.



Copyright © 2007-2013 ROME Project. All Rights Reserved.