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

java.lang.Object
  extended by com.sun.syndication.propono.atom.common.Collection
      extended by com.sun.syndication.propono.atom.server.impl.FileBasedCollection

public class FileBasedCollection
extends Collection

File based Atom collection implementation. This is the heart of the file-based Atom service implementation. It provides methods for adding, getting updating and deleting Atom entries and media entries.


Constructor Summary
FileBasedCollection(String title, String handle, String collection, String singular, String baseDir, String accept, String appuri)
          Construct by providing title (plain text, no HTML), a workspace handle, a plural collection name (e.g.
 
Method Summary
 Entry addEntry(Entry entry)
          Add entry to collection.
 Entry addMediaEntry(String title, String slug, String contentType, InputStream is)
          Add media entry to collection.
 void deleteEntry(String fileName)
          Delete an entry and any associated media file.
 Entry getEntry(String fileName)
          Get an entry from the collection.
 Feed getFeedDocument()
          Get feed document representing collection.
 Entry updateEntry(Entry entry, String fileName)
          Update an entry in the collection.
 Entry updateMediaEntry(String fileName, String contentType, InputStream is)
          Update media associated with a media-link entry.
 
Methods inherited from class com.sun.syndication.propono.atom.common.Collection
accepts, addCategories, collectionToElement, elementToCollection, getAccept, getCategories, getHref, getTitle, getTitleType, setAccept, setHref, setTitle, setTitleType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBasedCollection

public FileBasedCollection(String title,
                           String handle,
                           String collection,
                           String singular,
                           String baseDir,
                           String accept,
                           String appuri)
Construct by providing title (plain text, no HTML), a workspace handle, a plural collection name (e.g. entries), a singular collection name (e.g. entry), the base directory for file storage, the content-type range accepted by the collection and the root Atom protocol URI for the service.

Parameters:
title - Title of collection (plain text, no HTML)
handle - Workspace handle
collection - Collection handle, plural
singular - Collection handle, singular
baseDir - Base directory for file storage
accept - Content type range accepted by collection
appuri - URI of Atom protocol service
Method Detail

getFeedDocument

public Feed getFeedDocument()
                     throws AtomException
Get feed document representing collection.

Returns:
Atom Feed representing collection.
Throws:
AtomException - On error retrieving feed file.

addEntry

public Entry addEntry(Entry entry)
               throws Exception
Add entry to collection.

Parameters:
entry - Entry to be added to collection. Entry will be saved to disk in a directory under the collection's directory and the path will follow the pattern [collection-plural]/[entryid]/entry.xml. The entry will be added to the collection's feed in [collection-plural]/feed.xml.
Returns:
Entry as it exists on the server.
Throws:
Exception - On error.

addMediaEntry

public Entry addMediaEntry(String title,
                           String slug,
                           String contentType,
                           InputStream is)
                    throws Exception
Add media entry to collection. Accepts a media file to be added to collection. The file will be saved to disk in a directory under the collection's directory and the path will follow the pattern [collection-plural]/[entryid]/media/[entryid]. An Atom entry will be created to store metadata for the entry and it will exist at the path [collection-plural]/[entryid]/entry.xml. The entry will be added to the collection's feed in [collection-plural]/feed.xml.

Parameters:
title - Title of new entry
slug - String to be used in file-name
contentType - Content type of data
is - Source of media data
Returns:
New entry as it exists on the server
Throws:
Exception - On Error

getEntry

public Entry getEntry(String fileName)
               throws Exception
Get an entry from the collection.

Parameters:
fileName - Internal ID of entry to be returned
Returns:
Entry specified by fileName/ID
Throws:
Exception - On error

updateEntry

public Entry updateEntry(Entry entry,
                         String fileName)
                  throws Exception
Update an entry in the collection.

Parameters:
entry - Updated entry to be stored
fileName - Internal ID of entry
Returns:
Updated entry as it exists on server
Throws:
Exception - On error

updateMediaEntry

public Entry updateMediaEntry(String fileName,
                              String contentType,
                              InputStream is)
                       throws Exception
Update media associated with a media-link entry.

Parameters:
fileName - Internal ID of entry being updated
contentType - Content type of data
is - Source of updated data
Returns:
Updated Entry as it exists on server
Throws:
Exception - On error

deleteEntry

public void deleteEntry(String fileName)
                 throws Exception
Delete an entry and any associated media file.

Parameters:
fileName - Internal ID of entry
Throws:
Exception - On error