org.liquidsite.core.content
Class ContentTemplate

java.lang.Object
  extended byorg.liquidsite.core.content.PersistentObject
      extended byorg.liquidsite.core.content.Content
          extended byorg.liquidsite.core.content.ContentTemplate

public class ContentTemplate
extends Content

A web page template.


Field Summary
 
Fields inherited from class org.liquidsite.core.content.Content
DOCUMENT_CATEGORY, FILE_CATEGORY, FOLDER_CATEGORY, FORUM_CATEGORY, NAME_CHARS, PAGE_CATEGORY, POST_CATEGORY, SECTION_CATEGORY, SITE_CATEGORY, TEMPLATE_CATEGORY, TOPIC_CATEGORY, TRANSLATOR_CATEGORY
 
Fields inherited from class org.liquidsite.core.content.PersistentObject
BINDERS, LOWER_CASE, NUMBERS, UPPER_CASE
 
Constructor Summary
protected ContentTemplate(ContentManager manager, ContentData data, DataSource src)
          Creates a new template.
  ContentTemplate(ContentManager manager, ContentTemplate parent)
          Creates a new template with default values.
  ContentTemplate(ContentManager manager, Domain domain)
          Creates a new template with default values.
 
Method Summary
protected  void doValidate()
          Validates the object data before writing to the database.
 java.util.List getAllElementNames()
          Returns all page element names in this template and it's parents.
 java.lang.String getElement(java.lang.String name)
          Returns a named page element.
 java.util.List getLocalElementNames()
          Returns all page element names in this template.
 void setElement(java.lang.String name, java.lang.String data)
          Sets the data for a named page element.
 
Methods inherited from class org.liquidsite.core.content.Content
deleteRevision, doDelete, doInsert, doUpdate, equals, equals, getAllRevisions, getAttribute, getAttributeNames, getAuthor, getAuthorName, getCategory, getComment, getDomain, getDomainName, getId, getLock, getMaxRevisionNumber, getModifiedDate, getName, getOfflineDate, getOnlineDate, getParent, getParentId, getPermissions, getRevision, getRevisionNumber, isLatestRevision, isOnline, isPublishedRevision, setAttribute, setAuthorName, setComment, setId, setModifiedDate, setName, setOfflineDate, setOnlineDate, setParent, setParentId, setRevisionNumber, toString
 
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
 

Constructor Detail

ContentTemplate

public ContentTemplate(ContentManager manager,
                       Domain domain)
Creates a new template with default values.

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

ContentTemplate

public ContentTemplate(ContentManager manager,
                       ContentTemplate parent)
                throws ContentException
Creates a new template with default values.

Parameters:
manager - the content manager to use
parent - the parent template
Throws:
ContentException - if the database couldn't be accessed properly

ContentTemplate

protected ContentTemplate(ContentManager manager,
                          ContentData data,
                          DataSource src)
                   throws ContentException
Creates a new template.

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

getAllElementNames

public java.util.List getAllElementNames()
                                  throws ContentException
Returns all page element names in this template and it's parents. The returned collection is guaranteed to not contain any duplicates.

Returns:
a collection of page element names
Throws:
ContentException - if the database couldn't be accessed properly

getLocalElementNames

public java.util.List getLocalElementNames()
Returns all page element names in this template. If a page element is not present in this collection, it may still be present in a parent template and thus returned by getElement().

Returns:
a collection of page element names

getElement

public java.lang.String getElement(java.lang.String name)
                            throws ContentException
Returns a named page element. The element data will be retrieved from this template if possible, or from one of the parent templates. The templates will be searched in the inheritance order, starting from this template.

Parameters:
name - the page element name
Returns:
the page element data, or null if the page element didn't exist
Throws:
ContentException - if the database couldn't be accessed properly

setElement

public void setElement(java.lang.String name,
                       java.lang.String data)
Sets the data for a named page element. The element will be removed from this template if the data value is null. The page element values in the parent templates will NOT be modified.

Parameters:
name - the page element name
data - the page element data, or null

doValidate

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

Overrides:
doValidate in class Content
Throws:
ContentException - if the object data wasn't valid