org.ocap.hn.content
Interface ContentContainer

All Superinterfaces:
ContentEntry

public interface ContentContainer
extends ContentEntry

This class represents a container that contains one or more content entries. Can contain children containers.


Field Summary
static String ALBUM_CONTAINER
          Represents the base album container.
static String ALBUM_CONTAINER_MUSIC
          Represents a music album container.
static String ALBUM_CONTAINER_PHOTO
          Represents a photo album container.
static String CONTAINER
          Represents the base container class.
static String GENRE_CONTAINER
          Represents an unordered collection of 'objects' that "belong" to the genre.
static String GENRE_CONTAINER_MOVIE
          Represents a movie genre container.
static String GENRE_CONTAINER_MUSIC
          Represents a music genre container.
static String PERSON_CONTAINER
          Represents an unordered collection of 'objects' that "belong" to the people.
static String PERSON_CONTAINER_MUSIC_ARTIST
          Represents a music artist person container.
static String PLAYLIST_CONTAINER
          Represents a collection of objects.
static String STORAGE_FOLDER_CONTAINER
          Represents all, or a partition of some physical storage unit of a single type.
static String STORAGE_SYSTEM_CONTAINER
          Represents a potentially heterogeneous collection of storage media.
static String STORAGE_VOLUME_CONTAINER
          Represents all, or a partition of, some physical storage unit of a single type.
 
Method Summary
 boolean addContentEntries(ContentEntry[] entries)
          Adds ContentEntry objects to this ContentContainer.
 boolean addContentEntry(ContentEntry entry)
          Adds a ContentEntry to this ContentContainer.
 boolean contains(ContentEntry entry)
          Checks whether the given ContentEntry is in this ContentContainer in local cache only.
 boolean createContentContainer(String name, org.ocap.storage.ExtendedFileAccessPermissions permissions)
          Creates a new ContentContainer as a child of this ContentContainer.
 boolean createContentItem(File content, String name, org.ocap.storage.ExtendedFileAccessPermissions permissions)
          Creates a new ContentItem representing a local file as a child of this ContentContainer.
 boolean delete()
          Deletes this ContentContainer if and only if it is empty.
 boolean deleteContents()
          Deletes all the ContentEntry objects in this container except for ContentContainer entries.
 boolean deleteEntry()
          Deletes this ContentContainer and all of the ContentEntry objects in this container.
 boolean deleteRecursive(boolean recursive)
          If the recursive parameter is true, this method behaves in a manner equivalent to deleteEntry().
 int getComponentCount()
          Gets the number of ContentEntry objects in this ContentContainer.
 String getContainerClass()
          Returns the container class of this container.
 long getContentSize()
          Gets the size of the ContentContainer and all its content including all its contained ContentContainer objects.
 Date getCreationDate()
          Returns the creation date of this ContentContainer.
 Enumeration getEntries()
          Gets an Enumeration over all entries in this ContentContainer, from local cache only; does not cause network activity.
 ContentList getEntries(ContentDatabaseFilter filter, boolean traverse)
          Returns a ContentList which contains the filtered ContentItems of this ContentContainer.
 ContentEntry getEntry(int n)
          Returns the nth ContentEntry in this container, from local cache only; does not cause network activity.
 ContentEntry getEntry(String ID)
          Returns the ContentEntry associated with the given ID in this container, or NULL if no entry is found.
 org.ocap.storage.ExtendedFileAccessPermissions getExtendedFileAccessPermissions()
          Gets the ExtendedFileAccessPermissions of this ContentContainer.
 int getIndex(ContentEntry n)
          Gets the index of the specified ContentEntry, from local cache only; does not cause network activity.
 String getName()
          Gets the name of this ContentContainer.
 boolean isEmpty()
          Returns an empty indication.
 boolean removeContentEntries(ContentEntry[] entries)
          Removes ContentEntry objects from this ContentContainer.
 boolean removeContentEntry(ContentEntry entry)
          Removes a ContentEntry from this ContentContainer.
 ContentEntry[] toArray()
          Returns an array of all ContentEntry in this ContentContainers including other ContentContainers.
 
Methods inherited from interface org.ocap.hn.content.ContentEntry
getEntryParent, getID, getParentID, getRootMetadataNode, getServer, isLocal
 

Field Detail

CONTAINER

static final String CONTAINER
Represents the base container class.

See Also:
Constant Field Values

ALBUM_CONTAINER

static final String ALBUM_CONTAINER
Represents the base album container.

See Also:
Constant Field Values

ALBUM_CONTAINER_PHOTO

static final String ALBUM_CONTAINER_PHOTO
Represents a photo album container. In addition to being an ALBUM_CONTAINER container may be a photo album.

See Also:
Constant Field Values

ALBUM_CONTAINER_MUSIC

static final String ALBUM_CONTAINER_MUSIC
Represents a music album container. In addition to being an ALBUM_CONTAINER container may be a music album.

See Also:
Constant Field Values

GENRE_CONTAINER

static final String GENRE_CONTAINER
Represents an unordered collection of 'objects' that "belong" to the genre.

See Also:
Constant Field Values

GENRE_CONTAINER_MUSIC

static final String GENRE_CONTAINER_MUSIC
Represents a music genre container. In addition to being a GENRE_CONTAINER a container may be a music genre container

See Also:
Constant Field Values

GENRE_CONTAINER_MOVIE

static final String GENRE_CONTAINER_MOVIE
Represents a movie genre container. In addition to being a GENRE_CONTAINER a container may be a movie genre container

See Also:
Constant Field Values

PLAYLIST_CONTAINER

static final String PLAYLIST_CONTAINER
Represents a collection of objects.

See Also:
Constant Field Values

PERSON_CONTAINER

static final String PERSON_CONTAINER
Represents an unordered collection of 'objects' that "belong" to the people.

See Also:
Constant Field Values

PERSON_CONTAINER_MUSIC_ARTIST

static final String PERSON_CONTAINER_MUSIC_ARTIST
Represents a music artist person container. In addition to being a PERSON_CONTAINER a container may be a music artist.

See Also:
Constant Field Values

STORAGE_SYSTEM_CONTAINER

static final String STORAGE_SYSTEM_CONTAINER
Represents a potentially heterogeneous collection of storage media.

See Also:
Constant Field Values

STORAGE_VOLUME_CONTAINER

static final String STORAGE_VOLUME_CONTAINER
Represents all, or a partition of, some physical storage unit of a single type.

See Also:
Constant Field Values

STORAGE_FOLDER_CONTAINER

static final String STORAGE_FOLDER_CONTAINER
Represents all, or a partition of some physical storage unit of a single type.

See Also:
Constant Field Values
Method Detail

getContainerClass

String getContainerClass()
Returns the container class of this container.

Returns:
The content class of this item.
See Also:
ALBUM_CONTAINER, ALBUM_CONTAINER_MUSIC, ALBUM_CONTAINER_PHOTO, GENRE_CONTAINER, GENRE_CONTAINER_MUSIC, GENRE_CONTAINER_MOVIE, PLAYLIST_CONTAINER, PERSON_CONTAINER, PERSON_CONTAINER_MUSIC_ARTIST, STORAGE_SYSTEM_CONTAINER, STORAGE_VOLUME_CONTAINER, STORAGE_FOLDER_CONTAINER

toArray

ContentEntry[] toArray()
Returns an array of all ContentEntry in this ContentContainers including other ContentContainers. Returns ContentEntry objects stored in local cache only; does not cause network activity.

Returns:
array containing all entries of this ContentContainers

contains

boolean contains(ContentEntry entry)
Checks whether the given ContentEntry is in this ContentContainer in local cache only.

Parameters:
entry - To search for in this ContentEntry.
Returns:
True if the ContentEntry is contained in this container, otherwise returns false.

getEntry

ContentEntry getEntry(String ID)
Returns the ContentEntry associated with the given ID in this container, or NULL if no entry is found. This method SHALL recursively search this container and any sub-containers. This method searches local cache only; does not cause network activity.

Parameters:
ID - String ID of the ContentEntry to return
Returns:
the associated ContentEntry.
See Also:
ContentEntry.getID()

getEntry

ContentEntry getEntry(int n)
Returns the nth ContentEntry in this container, from local cache only; does not cause network activity.

Parameters:
n - Index of the entry to get.
Returns:
the nth ContentEntry.
Throws:
ArrayIndexOutOfBoundsException - if the nth value does not exist.

getEntries

Enumeration getEntries()
Gets an Enumeration over all entries in this ContentContainer, from local cache only; does not cause network activity.

Returns:
Enumeration over all entries in this ContentContainers, or null if there are no entries.

getIndex

int getIndex(ContentEntry n)
Gets the index of the specified ContentEntry, from local cache only; does not cause network activity.

Parameters:
n - The index of the ContentEntry to search for.
Returns:
The index of the ContentEntry or -1 if it doesn't exist in this container.

createContentItem

boolean createContentItem(File content,
                          String name,
                          org.ocap.storage.ExtendedFileAccessPermissions permissions)
Creates a new ContentItem representing a local file as a child of this ContentContainer. If this ContentContainer #isLocal method returns false this method will return false. The resulting ContentItem will contain a single ContentResource containing the content parameter passed to this method.

Parameters:
content - The file containing the content to be represented
name - The name of the new ContentItem.
permissions - Access permissions of the new ContentContainer.
Returns:
True if a new ContentContainers has been created, otherwise return false.
Throws:
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

createContentContainer

boolean createContentContainer(String name,
                               org.ocap.storage.ExtendedFileAccessPermissions permissions)
Creates a new ContentContainer as a child of this ContentContainer. If this ContentContainer #isLocal method returns false this method will return false. Can be used to create a directory structure.

Parameters:
name - The name of the new ContentContainer.
permissions - Access permissions of the new ContentContainer.
Returns:
True if a new ContentContainer has been created, otherwise returns false.
Throws:
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

getEntries

ContentList getEntries(ContentDatabaseFilter filter,
                       boolean traverse)
Returns a ContentList which contains the filtered ContentItems of this ContentContainer. If the traverse parameter is true the ContentItems of all its children ContentContainers is included. The list returned is filtered by the filter parameter. If the filter is null all items are returned.

Parameters:
filter - A ContentDatabaseFilter to filter the ContentItems. If the filter is null all entries are returned
traverse - If true entries in the sub-containers are returned, otherwise only entries in this ContentContainer are returned.
Returns:
a ContentList filtered by the ContentDatabaseFilter

getName

String getName()
Gets the name of this ContentContainer.

Returns:
The name of this ContentContainer.
See Also:
ContentEntry.getID()

delete

boolean delete()
               throws IOException
Deletes this ContentContainer if and only if it is empty. This method removes the content container from its parent. This method returns false if this is a root container. This method deletes a local ContentContainer only. If the #isLocal method returns false an exception is thrown.

Returns:
True if this ContentContainer was deleted, otherwise returns false.
Throws:
SecurityException - if the application is denied to perform the action
IOException - if this ContentContainer is not local.

deleteContents

boolean deleteContents()
                       throws IOException
Deletes all the ContentEntry objects in this container except for ContentContainer entries. This method deletes local ContentEntry instances only. If the #isLocal method returns false, an exception is thrown.

Returns:
True if all of the ContentEntry objects required to be deleted are deleted, otherwise returns false (e.g. ContentContainer entries are not required to be deleted)
Throws:
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container or and entries contained in this container (except for ContentContainer entries).
IOException - if this ContentContainer is not local.

deleteEntry

boolean deleteEntry()
                    throws IOException
Deletes this ContentContainer and all of the ContentEntry objects in this container. Calls the ContentEntry.deleteEntry() method on each ContentEntry in a recursive manner. This method deletes local ContentEntry instances only. If the #isLocal method returns false, an exception is thrown. If a SecurityException is thrown due to insufficient write access permissions on any entry contained within this ContentContainer, this method MAY delete a partial subset of the entries contained within.

Specified by:
deleteEntry in interface ContentEntry
Returns:
True if this ContentContainer and all of the ContentEntry objects in this container were deleted, otherwise returns false.
Throws:
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container or any entries contained in this container.
IOException - if this ContentContainer is not local.

deleteRecursive

boolean deleteRecursive(boolean recursive)
                        throws IOException
If the recursive parameter is true, this method behaves in a manner equivalent to deleteEntry(). If the recursive parameter is false, this method behaves in a manner equivalent to deleteContents(). This method deletes local ContentEntry instances only. If the #isLocal method returns false, an exception is thrown. If a SecurityException is thrown due to insufficient write access permissions on any entry contained within this ContentContainer, this method MAY delete a partial subset of the entries contained within.

Parameters:
recursive - if true all entries and their entries are to be deleted.
Returns:
True if all ContentEntry objects that are required to be deleted are deleted, otherwise returns false.
Throws:
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container or any entries contained in this container.
IOException - if this ContentContainer is not local.
See Also:
deleteContents(), delete()

addContentEntry

boolean addContentEntry(ContentEntry entry)
Adds a ContentEntry to this ContentContainer. Can only add local ContentEntry objects to local ContentContainer. If this entry is already has a parent ContentContainer, it will be removed from that container.

Parameters:
entry - the content entry to be added to this container
Returns:
True if the entry was added. Returns false if the isLocal method of this ContentContainer or the parameter ContentEntry returns false.
Throws:
IllegalStateException - if this ContentContainer does not have a parentID property, i.e., this ContentContainer is not added to the CDS.
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

addContentEntries

boolean addContentEntries(ContentEntry[] entries)
Adds ContentEntry objects to this ContentContainer. Can only add local ContentEntry objects to local ContentContainer. If any entry passed to this method already has a parent ContentContainer, it will be removed from that container.

Parameters:
entries - the content entries to be added to this container
Returns:
True if the entries were added. Returns false if the isLocal method of this ContentContainer or the parameter ContentEntry returns false.
Throws:
IllegalStateException - if this ContentContainer does not have a parentID property, i.e., this ContentContainer is not added to the CDS.
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

removeContentEntry

boolean removeContentEntry(ContentEntry entry)
Removes a ContentEntry from this ContentContainer. Can only remove local ContentEntry objects from local ContentContainers. When the ContentEntry parameter is a ContentContainer, all of its ContentEntry objects are removed from the parameter. For entries that are ContentContainer objects, a possible implementation is a recursive traversal where these objects are removed in a bottom-up fashion by calling this method on each one.

Parameters:
entry - the content entry to be removed from this container
Returns:
True if the entry was removed. Returns false if the isLocal method of this ContentContainer or the parameter ContentEntry is not contained in this container.
Throws:
IllegalArgumentException - if the ContentEntry parameter is a NetRecordingEntry which contains one or more RecordingContentItems.
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

removeContentEntries

boolean removeContentEntries(ContentEntry[] entries)
Removes ContentEntry objects from this ContentContainer. Can only remove local ContentEntry objects from local ContentContainer. If any ContentEntry is not contained within this container, this method will return false and no entries will be removed. When the ContentEntry parameter is a ContentContainer, all of its ContentEntry objects are removed from the parameter. For entries that are ContentContainer objects, a possible implementation is a recursive traversal where these objects are removed in a bottom-up fashion by calling removeContentEntry method on each one.

Parameters:
entries - the content entries to be removed from this container
Returns:
True if the entries were removed. Returns false if the isLocal method of this ContentContainer or if any of the ContentEntry objects are not contained in this container.
Throws:
IllegalArgumentException - if the parameter includes a NetRecordingEntry which contains one or more RecordingContentItems.
SecurityException - if the caller does not have HomeNetPermission("contentmanagement"), or if the caller does not have write permission on this container.

getContentSize

long getContentSize()
Gets the size of the ContentContainer and all its content including all its contained ContentContainer objects. Note that the size may have changed during the call to this method.

Specified by:
getContentSize in interface ContentEntry
Returns:
The content size in bytes or -1 if the size is indeterminate.

getCreationDate

Date getCreationDate()
Returns the creation date of this ContentContainer.

Specified by:
getCreationDate in interface ContentEntry
Returns:
The Date the content was created or null if the creation date is indeterminate.

getExtendedFileAccessPermissions

org.ocap.storage.ExtendedFileAccessPermissions getExtendedFileAccessPermissions()
Gets the ExtendedFileAccessPermissions of this ContentContainer.

Specified by:
getExtendedFileAccessPermissions in interface ContentEntry
Returns:
The ExtendedFileAccessPermission.

getComponentCount

int getComponentCount()
Gets the number of ContentEntry objects in this ContentContainer. Does not include component count of entries within ContentContainer objects contained in this ContentContainer.

Returns:
Number of entries.

isEmpty

boolean isEmpty()
Returns an empty indication.

Returns:
True if this ContentContainer does not contain any ContentEntry objects, otherwise returns false.


Copyright © 2011. All Rights Reserved.