com.sun.syndication.propono.atom.server.impl
Class FileBasedAtomHandler

java.lang.Object
  extended by com.sun.syndication.propono.atom.server.impl.FileBasedAtomHandler
All Implemented Interfaces:
AtomHandler

public class FileBasedAtomHandler
extends Object
implements AtomHandler

File-based AtomHandler implementation that stores entries and media-entries to disk. Implemented using FileBasedAtomService.


Constructor Summary
FileBasedAtomHandler(HttpServletRequest req)
          Construct handler to handle one request.
FileBasedAtomHandler(HttpServletRequest req, String uploaddir)
          Contruct handler for one request, using specified file storage directory.
 
Method Summary
 String authenticateBASIC(HttpServletRequest request)
          BASIC authentication.
 void deleteEntry(String[] pathInfo)
          Delete entry specified by pathInfo.
 String getAtomProtocolURL()
          Get base URI of Atom protocol implementation.
 String getAuthenticatedUsername()
          Get username of authenticated user
 Feed getCollection(String[] pathInfo)
          Get collection specified by pathinfo.
 Entry getEntry(String[] pathInfo)
          Get entry specified by pathInfo.
 AtomService getIntrospection()
          Return introspection document
 boolean isCollectionURI(String[] pathInfo)
          Return true if specified pathinfo represents URI of a collection.
 boolean isEntryURI(String[] pathInfo)
          Return true if specified pathinfo represents URI of an Atom entry.
 boolean isIntrospectionURI(String[] pathInfo)
          Return true if specified pathinfo represents URI of introspection doc.
 boolean isMediaEditURI(String[] pathInfo)
          Return true if specified pathinfo represents media-edit URI.
 Entry postEntry(String[] pathInfo, Entry entry)
          Create a new entry specified by pathInfo and posted entry.
 Entry postMedia(String[] pathInfo, String title, String slug, String contentType, InputStream is)
          Create a new media-link entry.
 Entry putEntry(String[] pathInfo, Entry entry)
          Update entry specified by pathInfo and posted entry.
 Entry putMedia(String[] pathInfo, String contentType, InputStream is)
          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(HttpServletRequest req)
Construct handler to handle one request.

Parameters:
req - Request to be handled.

FileBasedAtomHandler

public FileBasedAtomHandler(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.

getIntrospection

public AtomService getIntrospection()
                             throws AtomException
Return introspection document

Specified by:
getIntrospection in interface AtomHandler
Returns:
AtomService object with workspaces and collections.
Throws:
AtomException - Unexpected exception.

getCollection

public Feed getCollection(String[] pathInfo)
                   throws AtomException
Get collection specified by pathinfo.

Specified by:
getCollection in interface AtomHandler
Parameters:
pathInfo - Path info from Servlet request.
Returns:
ROME feed representing collection.
Throws:
AtomException - Invalid collection or other exception.

postEntry

public Entry postEntry(String[] pathInfo,
                       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.
pathInfo - Path info from Servlet request.
Returns:
Entry as represented on server.
Throws:
AtomException - On invalid collection or other error.

getEntry

public Entry getEntry(String[] pathInfo)
               throws AtomException
Get entry specified by pathInfo.

Specified by:
getEntry in interface AtomHandler
Parameters:
pathInfo - Path info portion of URL
Returns:
ROME Entry object.
Throws:
AtomException - On invalid pathinfo or other error.

putEntry

public Entry putEntry(String[] pathInfo,
                      Entry entry)
               throws AtomException
Update entry specified by pathInfo and posted entry.

Specified by:
putEntry in interface AtomHandler
Parameters:
entry -
pathInfo - Path info portion of URL
Throws:
AtomException

deleteEntry

public void deleteEntry(String[] pathInfo)
                 throws AtomException
Delete entry specified by pathInfo.

Specified by:
deleteEntry in interface AtomHandler
Parameters:
pathInfo - Path info portion of URL
Throws:
AtomException

postMedia

public Entry postMedia(String[] pathInfo,
                       String title,
                       String slug,
                       String contentType,
                       InputStream is)
                throws AtomException
Create a new media-link entry.

Specified by:
postMedia in interface AtomHandler
Parameters:
pathInfo - Path info portion of URL
contentType - MIME type of uploaded content
is - Input Stream of Binary data representing uploaded content
Throws:
AtomException

putMedia

public Entry putMedia(String[] pathInfo,
                      String contentType,
                      InputStream is)
               throws AtomException
Update the media file part of a media-link entry.

Specified by:
putMedia in interface AtomHandler
Parameters:
pathInfo - Path info portion of URL Assuming pathInfo of form /user-name/resource/name
Throws:
AtomException

isIntrospectionURI

public boolean isIntrospectionURI(String[] pathInfo)
Return true if specified pathinfo represents URI of introspection doc.

Specified by:
isIntrospectionURI in interface AtomHandler

isCollectionURI

public boolean isCollectionURI(String[] pathInfo)
Return true if specified pathinfo represents URI of a collection.

Specified by:
isCollectionURI in interface AtomHandler

isEntryURI

public boolean isEntryURI(String[] pathInfo)
Return true if specified pathinfo represents URI of an Atom entry.

Specified by:
isEntryURI in interface AtomHandler

isMediaEditURI

public boolean isMediaEditURI(String[] pathInfo)
Return true if specified pathinfo represents media-edit URI.

Specified by:
isMediaEditURI in interface AtomHandler

authenticateBASIC

public String authenticateBASIC(HttpServletRequest request)
BASIC authentication.