org.liquidsite.core.content
Class Content

java.lang.Object
  extended byorg.liquidsite.core.content.PersistentObject
      extended byorg.liquidsite.core.content.Content
Direct Known Subclasses:
ContentDocument, ContentFile, ContentFolder, ContentForum, ContentPage, ContentPost, ContentSection, ContentSite, ContentTemplate, ContentTopic, ContentTranslator

public class Content
extends PersistentObject

The base class for all content objects. This class should NOT be instantiated directly unless in a backup/restore scenario. Otherwise the proper subclass should ALWAYS be created.


Field Summary
static int DOCUMENT_CATEGORY
          The document content category.
static int FILE_CATEGORY
          The file content category.
static int FOLDER_CATEGORY
          The folder content category.
static int FORUM_CATEGORY
          The forum content category.
static java.lang.String NAME_CHARS
          The permitted content name characters.
static int PAGE_CATEGORY
          The page content category.
static int POST_CATEGORY
          The post content category.
static int SECTION_CATEGORY
          The section content category.
static int SITE_CATEGORY
          The site content category.
static int TEMPLATE_CATEGORY
          The template content category.
static int TOPIC_CATEGORY
          The topic content category.
static int TRANSLATOR_CATEGORY
          The translator content category.
 
Fields inherited from class org.liquidsite.core.content.PersistentObject
BINDERS, LOWER_CASE, NUMBERS, UPPER_CASE
 
Constructor Summary
protected Content(ContentManager manager, ContentData data, DataSource src)
          Creates a new content object.
  Content(ContentManager manager, Domain domain, int category)
          Creates a new content object with default values.
 
Method Summary
 void deleteRevision(User user)
          Deletes this content revision from the database.
protected  void doDelete(DataSource src, User user)
          Deletes the object data from the database.
protected  void doInsert(DataSource src, User user, boolean restore)
          Inserts the object data into the database.
protected  void doUpdate(DataSource src, User user)
          Updates the object data in the database.
protected  void doValidate()
          Validates the object data before writing to the database.
 boolean equals(Content obj)
          Checks if this content object equals another object.
 boolean equals(java.lang.Object obj)
          Checks if this content object equals another object.
 Content[] getAllRevisions()
          Returns an array of all content object revisions.
 java.lang.String getAttribute(java.lang.String name)
          Returns a content attribute value (BACKUP ONLY).
 java.util.Iterator getAttributeNames()
          Returns an iterator for all the attribute names (BACKUP ONLY).
 User getAuthor()
          Returns the content last modification author.
 java.lang.String getAuthorName()
          Returns the content last modification author.
 int getCategory()
          Returns the content category.
 java.lang.String getComment()
          Returns the content revision comment.
 Domain getDomain()
          Returns the content domain.
 java.lang.String getDomainName()
          Returns the content domain name.
 int getId()
          Returns the content identifier.
 Lock getLock()
          Returns the lock applicable to this content object.
 int getMaxRevisionNumber()
          Returns the highest content object revision number available.
 java.util.Date getModifiedDate()
          Returns the content last modification date.
 java.lang.String getName()
          Returns the content name.
 java.util.Date getOfflineDate()
          Returns the content publishing offline date.
 java.util.Date getOnlineDate()
          Returns the content publishing online date.
 Content getParent()
          Returns the content parent.
 Content getParent(ContentManager manager)
          Returns the content parent.
 int getParentId()
          Returns the content parent identifier.
 PermissionList getPermissions(boolean inherit)
          Returns the permission list applicable to this content object.
 Content getRevision(int revision)
          Returns the specified content object revision.
 int getRevisionNumber()
          Returns the content revision number.
 boolean isLatestRevision()
          Checks if this content object revision is the latest one.
 boolean isOnline()
          Checks if this content object revision is online.
 boolean isPublishedRevision()
          Checks if this content object revision is the published one.
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets a content attribute value (RESTORE ONLY).
 void setAuthorName(java.lang.String author)
          Sets the content last modification author (RESTORE ONLY).
 void setComment(java.lang.String comment)
          Sets the content revision comment.
 void setId(int id)
          Sets the content identifier (RESTORE ONLY).
 void setModifiedDate(java.util.Date modified)
          Sets the content last modification date (RESTORE ONLY).
 void setName(java.lang.String name)
          Sets the content name.
 void setOfflineDate(java.util.Date offline)
          Sets the content publishing offline date.
 void setOnlineDate(java.util.Date online)
          Sets the content publishing online date.
 void setParent(Content parent)
          Sets the content parent.
 void setParentId(int parent)
          Sets the content parent identifier.
 void setRevisionNumber(int revision)
          Sets the content revision number.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.liquidsite.core.content.PersistentObject
decodeMap, delete, delete, encodeMap, getContentManager, hasAdminAccess, hasPublishAccess, hasReadAccess, hasWriteAccess, isPersistent, restore, restore, save, save, validateChars, validateSize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SITE_CATEGORY

public static final int SITE_CATEGORY
The site content category.

See Also:
Constant Field Values

TRANSLATOR_CATEGORY

public static final int TRANSLATOR_CATEGORY
The translator content category.

See Also:
Constant Field Values

FOLDER_CATEGORY

public static final int FOLDER_CATEGORY
The folder content category.

See Also:
Constant Field Values

PAGE_CATEGORY

public static final int PAGE_CATEGORY
The page content category.

See Also:
Constant Field Values

FILE_CATEGORY

public static final int FILE_CATEGORY
The file content category.

See Also:
Constant Field Values

TEMPLATE_CATEGORY

public static final int TEMPLATE_CATEGORY
The template content category.

See Also:
Constant Field Values

SECTION_CATEGORY

public static final int SECTION_CATEGORY
The section content category.

See Also:
Constant Field Values

DOCUMENT_CATEGORY

public static final int DOCUMENT_CATEGORY
The document content category.

See Also:
Constant Field Values

FORUM_CATEGORY

public static final int FORUM_CATEGORY
The forum content category.

See Also:
Constant Field Values

TOPIC_CATEGORY

public static final int TOPIC_CATEGORY
The topic content category.

See Also:
Constant Field Values

POST_CATEGORY

public static final int POST_CATEGORY
The post content category.

See Also:
Constant Field Values

NAME_CHARS

public static final java.lang.String NAME_CHARS
The permitted content name characters.

See Also:
Constant Field Values
Constructor Detail

Content

public Content(ContentManager manager,
               Domain domain,
               int category)
Creates a new content object with default values. The content identifier will be set to the next available one after storing to the database, and the content revision is set to zero (0).

This constructor should NOT BE CALLED directly unless you know what you are doing. It is supposed to be called by the constructors in the subclasses and is public only to simplify the backup and restore operations.

Parameters:
manager - the content manager to use
domain - the domain
category - the category

Content

protected Content(ContentManager manager,
                  ContentData data,
                  DataSource src)
           throws ContentException
Creates a new content object. This constructor will also read all content attributes from the database.

Parameters:
manager - the content manager to use
data - the content data object
src - the data source to use
Throws:
ContentException - if the database couldn't be accessed properly
Method Detail

equals

public boolean equals(java.lang.Object obj)
Checks if this content object equals another object. This method will only return true if the other object is a content object with the same id.

Parameters:
obj - the object to compare with
Returns:
true if the other object is identical, or false otherwise

equals

public boolean equals(Content obj)
Checks if this content object equals another object. This method will only return true if the other object is a content object with the same id.

Parameters:
obj - the object to compare with
Returns:
true if the other object is identical, or false otherwise

toString

public java.lang.String toString()
Returns a string representation of this object.

Returns:
a string representation of this object

isOnline

public boolean isOnline()
Checks if this content object revision is online. Note that this method does NOT take other revisions into account. A later revision may set different online and offline dates, causing the content object to actually be offline.

Returns:
true if the content object revision is online, or false otherwise

isLatestRevision

public boolean isLatestRevision()
Checks if this content object revision is the latest one. The revision is considered the latest if it is a work revision, or if no work revision exists and it is the latest published revision.

Returns:
true if this content revision is the latest one, or false otherwise

isPublishedRevision

public boolean isPublishedRevision()
Checks if this content object revision is the published one. The revision is considered the published one if it is the revision with the highest revision number. Note that working revision always have a revision number of zero.

Returns:
true if this content revision is the published one, or false otherwise

getDomain

public Domain getDomain()
                 throws ContentException
Returns the content domain.

Returns:
the content domain
Throws:
ContentException - if no content manager is available

getDomainName

public java.lang.String getDomainName()
Returns the content domain name.

Returns:
the content domain name

getId

public int getId()
Returns the content identifier.

Returns:
the content identifier

setId

public void setId(int id)
Sets the content identifier (RESTORE ONLY). This method should NOT BE CALLED unless you know what you are doing. Changing the content identifier may cause irrepairable harm to the content database which is why content identfiers are normally assigned automatically. This method only exists to simplify the backup and restore operations.

Parameters:
id - the new content identifier

getRevisionNumber

public int getRevisionNumber()
Returns the content revision number.

Returns:
the content revision number

setRevisionNumber

public void setRevisionNumber(int revision)
Sets the content revision number. Note that the revision zero (0) is treated specially in several ways. First, when moving from revision zero, the old zero revision will be deleted from the database (corresponding to a revision promotion). Also, when storing a non-zero revision, permissions to publish are required by save().

Parameters:
revision - the new content revision number

getCategory

public int getCategory()
Returns the content category.

Returns:
the content category

getName

public java.lang.String getName()
Returns the content name.

Returns:
the content name

setName

public void setName(java.lang.String name)
Sets the content name.

Parameters:
name - the new name

getParent

public Content getParent()
                  throws ContentException
Returns the content parent.

Returns:
the content parent
Throws:
ContentException - if the database couldn't be accessed properly

getParent

public Content getParent(ContentManager manager)
                  throws ContentException
Returns the content parent.

Parameters:
manager - the content manager to use
Returns:
the content parent, or null if the object has no parent
Throws:
ContentException - if the database couldn't be accessed properly

setParent

public void setParent(Content parent)
Sets the content parent.

Parameters:
parent - the new parent, or null for none

getParentId

public int getParentId()
Returns the content parent identifier.

Returns:
the content parent identifier

setParentId

public void setParentId(int parent)
Sets the content parent identifier.

Parameters:
parent - the new parent identifier

getOnlineDate

public java.util.Date getOnlineDate()
Returns the content publishing online date.

Returns:
the content publishing online date

setOnlineDate

public void setOnlineDate(java.util.Date online)
Sets the content publishing online date.

Parameters:
online - the new publishing online date

getOfflineDate

public java.util.Date getOfflineDate()
Returns the content publishing offline date.

Returns:
the content publishing offline date

setOfflineDate

public void setOfflineDate(java.util.Date offline)
Sets the content publishing offline date.

Parameters:
offline - the new publishing offline date

getModifiedDate

public java.util.Date getModifiedDate()
Returns the content last modification date.

Returns:
the content last modification date

setModifiedDate

public void setModifiedDate(java.util.Date modified)
Sets the content last modification date (RESTORE ONLY). This method should NOT BE CALLED unless you know what you are doing. The date set here will always be overwritten by the save method. This method only exists to simplify the backup and restore operations.

Parameters:
modified - the new last modification date

getAuthor

public User getAuthor()
               throws ContentException
Returns the content last modification author. The author name is set automatically by the save method.

Returns:
the content last modification author
Throws:
ContentException - if the database couldn't be accessed properly

getAuthorName

public java.lang.String getAuthorName()
Returns the content last modification author. The author name is set automatically by the save method.

Returns:
the content last modification author

setAuthorName

public void setAuthorName(java.lang.String author)
Sets the content last modification author (RESTORE ONLY). This method should NOT BE CALLED unless you know what you are doing. The author name set here will always be overwritten by the save method. This method only exists to simplify the backup and restore operations.

Parameters:
author - the content last modification author

getComment

public java.lang.String getComment()
Returns the content revision comment.

Returns:
the content revision comment

setComment

public void setComment(java.lang.String comment)
Sets the content revision comment.

Parameters:
comment - the content revision comment

getAttributeNames

public java.util.Iterator getAttributeNames()
Returns an iterator for all the attribute names (BACKUP ONLY). This method should NOT BE CALLED unless you know what you are doing. It provides direct access to the content attributes that should normally be accessed through the various helper methods in each subclass. This method is only public to simplify the backup and restore operations.

Returns:
an iterator for all the attribute names

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns a content attribute value (BACKUP ONLY). This method should NOT BE CALLED unless you know what you are doing. It provides direct access to the content attributes that should normally be accessed through the various helper methods in each subclass. This method is only public to simplify the backup and restore operations.

Parameters:
name - the content attribute name
Returns:
the content attribute value, or null if not found

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Sets a content attribute value (RESTORE ONLY). If the attribute does not exist it will be created. This method should NOT BE CALLED unless you know what you are doing. It provides direct access to the content attributes that should normally be accessed through the various helper methods in each subclass. This method is only public to simplify the backup and restore operations.

Parameters:
name - the content attribute name
value - the content attribute value

getMaxRevisionNumber

public int getMaxRevisionNumber()
                         throws ContentException
Returns the highest content object revision number available. Note that this may not be the most recent revision, as a working revision (zero) may exist.

Returns:
the highest revision number in the database, or -1 if no revisions are in the database
Throws:
ContentException - if the database couldn't be accessed properly

getRevision

public Content getRevision(int revision)
                    throws ContentException
Returns the specified content object revision.

Parameters:
revision - the content revision
Returns:
the content object revision found, or null if no matching content existed
Throws:
ContentException - if the database couldn't be accessed properly

getAllRevisions

public Content[] getAllRevisions()
                          throws ContentException
Returns an array of all content object revisions.

Returns:
an array of the content object revisions found
Throws:
ContentException - if the database couldn't be accessed properly

getLock

public Lock getLock()
             throws ContentException
Returns the lock applicable to this content object. If no lock has been set on this object, null will be returned.

Returns:
the content lock object found, or null if this object is not locked
Throws:
ContentException - if the database couldn't be accessed properly

getPermissions

public PermissionList getPermissions(boolean inherit)
                              throws ContentException
Returns the permission list applicable to this content object. If this object has no permissions either an empty list or the inherited permission list will be returned.

Parameters:
inherit - the search inherited permissions flag
Returns:
the permission list for this object
Throws:
ContentException - if the database couldn't be accessed properly

deleteRevision

public void deleteRevision(User user)
                    throws ContentException,
                           ContentSecurityException
Deletes this content revision from the database.

Parameters:
user - the user performing the operation
Throws:
ContentException - if the database couldn't be accessed properly
ContentSecurityException - if the user specified didn't have write permissions

doValidate

protected void doValidate()
                   throws ContentException
Validates the object data before writing to the database.

Specified by:
doValidate in class PersistentObject
Throws:
ContentException - if the object data wasn't valid

doInsert

protected void doInsert(DataSource src,
                        User user,
                        boolean restore)
                 throws ContentException
Inserts the object data into the database. If the restore flag is set, no automatic changes should be made to the data before writing to the database.

Specified by:
doInsert in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
restore - the restore flag
Throws:
ContentException - if the database couldn't be accessed properly

doUpdate

protected void doUpdate(DataSource src,
                        User user)
                 throws ContentException
Updates the object data in the database.

Specified by:
doUpdate in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
Throws:
ContentException - if the database couldn't be accessed properly

doDelete

protected void doDelete(DataSource src,
                        User user)
                 throws ContentException
Deletes the object data from the database. This method will also delete any child content object recursively.

Specified by:
doDelete in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
Throws:
ContentException - if the database couldn't be accessed properly