org.liquidsite.core.data
Class ContentPeer

java.lang.Object
  extended byorg.liquidsite.core.data.AbstractPeer
      extended byorg.liquidsite.core.data.ContentPeer

public class ContentPeer
extends AbstractPeer

A content database peer. This class contains static methods that handles all accesses to the LS_CONTENT table.


Field Summary
static int LATEST_STATUS
          The latest content status flag.
static int PUBLISHED_STATUS
          The published content status flag.
 
Method Summary
static int doCountByQuery(DataSource src, ContentQuery query)
          Returns the number of content objects matching the specified query.
static void doDelete(DataSource src, ContentData data)
          Deletes a content object from the data source.
static void doDeleteDomain(DataSource src, java.lang.String domain)
          Deletes all content objects in a domain from the data source.
static void doDeleteRevision(DataSource src, int id, int revision)
          Deletes a content object revision from the data source.
static void doInsert(DataSource src, ContentData data)
          Inserts a new content object into the data source.
static java.util.ArrayList doSelectById(DataSource src, int id)
          Returns a list of all content object revisions with the specified id.
static ContentData doSelectByMaxRevision(DataSource src, int id, boolean maxIsZero)
          Returns the content object with the specified id and highest revision.
static ContentData doSelectByName(DataSource src, java.lang.String domain, int parent, java.lang.String name, boolean maxIsZero)
          Returns the content object with the specified parent and name.
static java.util.ArrayList doSelectByQuery(DataSource src, ContentQuery query)
          Returns a list of content objects matching the specified query.
static ContentData doSelectByRevision(DataSource src, int id, int revision)
          Returns the content object with the specified id and revision.
static void doStatusUpdate(DataSource src, int id)
          Updates the status flags for all content object revisions.
static void doUpdate(DataSource src, ContentData data)
          Updates a content object in the data source.
protected  AbstractData getDataObject()
          Returns a new instance of the data object.
 
Methods inherited from class org.liquidsite.core.data.AbstractPeer
count, delete, insert, select, selectList, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LATEST_STATUS

public static final int LATEST_STATUS
The latest content status flag. This flag is set on content objects that are the latest revision, including unpublished or working revisions.

See Also:
Constant Field Values

PUBLISHED_STATUS

public static final int PUBLISHED_STATUS
The published content status flag. This flag is set on content objects that are the latest published revision, not including working revisions.

See Also:
Constant Field Values
Method Detail

doCountByQuery

public static int doCountByQuery(DataSource src,
                                 ContentQuery query)
                          throws DataObjectException
Returns the number of content objects matching the specified query.

Parameters:
src - the data source to use
query - the content query to use
Returns:
the number of matching content objects
Throws:
DataObjectException - if the data source couldn't be accessed properly

doSelectById

public static java.util.ArrayList doSelectById(DataSource src,
                                               int id)
                                        throws DataObjectException
Returns a list of all content object revisions with the specified id.

Parameters:
src - the data source to use
id - the content id
Returns:
the list of content objects found
Throws:
DataObjectException - if the data source couldn't be accessed properly

doSelectByRevision

public static ContentData doSelectByRevision(DataSource src,
                                             int id,
                                             int revision)
                                      throws DataObjectException
Returns the content object with the specified id and revision.

Parameters:
src - the data source to use
id - the content id
revision - the content revision
Returns:
the content found, or null if no matching content existed
Throws:
DataObjectException - if the data source couldn't be accessed properly

doSelectByMaxRevision

public static ContentData doSelectByMaxRevision(DataSource src,
                                                int id,
                                                boolean maxIsZero)
                                         throws DataObjectException
Returns the content object with the specified id and highest revision. A flag can be set to regard the revision number zero (0) as the highest one.

Parameters:
src - the data source to use
id - the content id
maxIsZero - the revision zero is max flag
Returns:
the content found, or null if no matching content existed
Throws:
DataObjectException - if the data source couldn't be accessed properly

doSelectByName

public static ContentData doSelectByName(DataSource src,
                                         java.lang.String domain,
                                         int parent,
                                         java.lang.String name,
                                         boolean maxIsZero)
                                  throws DataObjectException
Returns the content object with the specified parent and name. If multiple objects should match, any one of them can be returned. Matches of old revisions of content objects will be discarded, and only the highest revision of a matching object is returned. A flag can be set to regard the revision number zero (0) as the highest one.

Parameters:
src - the data source to use
domain - the domain name
parent - the parent content id
name - the content name
maxIsZero - the revision zero is max flag
Returns:
the content found, or null if no matching content existed
Throws:
DataObjectException - if the data source couldn't be accessed properly

doSelectByQuery

public static java.util.ArrayList doSelectByQuery(DataSource src,
                                                  ContentQuery query)
                                           throws DataObjectException
Returns a list of content objects matching the specified query.

Parameters:
src - the data source to use
query - the content query to use
Returns:
a list of all matching content objects
Throws:
DataObjectException - if the data source couldn't be accessed properly

doInsert

public static void doInsert(DataSource src,
                            ContentData data)
                     throws DataObjectException
Inserts a new content object into the data source. This method will assign a new content id if it is set to zero (0).

Parameters:
src - the data source to use
data - the content data object
Throws:
DataObjectException - if the data source couldn't be accessed properly
See Also:
doStatusUpdate(org.liquidsite.core.data.DataSource, int)

doUpdate

public static void doUpdate(DataSource src,
                            ContentData data)
                     throws DataObjectException
Updates a content object in the data source.

Parameters:
src - the data source to use
data - the content data object
Throws:
DataObjectException - if the data source couldn't be accessed properly
See Also:
doStatusUpdate(org.liquidsite.core.data.DataSource, int)

doDelete

public static void doDelete(DataSource src,
                            ContentData data)
                     throws DataObjectException
Deletes a content object from the data source. This method will delete all revisions, as well as related attributes, permissions and locks. Note, however, that it will NOT delete referenced child objects.

Parameters:
src - the data source to use
data - the content data object
Throws:
DataObjectException - if the data source couldn't be accessed properly

doDeleteDomain

public static void doDeleteDomain(DataSource src,
                                  java.lang.String domain)
                           throws DataObjectException
Deletes all content objects in a domain from the data source. This method also deletes all attributes, permissions and locks in the domain.

Parameters:
src - the data source to use
domain - the domain name
Throws:
DataObjectException - if the data source couldn't be accessed properly

doDeleteRevision

public static void doDeleteRevision(DataSource src,
                                    int id,
                                    int revision)
                             throws DataObjectException
Deletes a content object revision from the data source. This method also deletes all related attributes.

Parameters:
src - the data source to use
id - the content identifier
revision - the content revision
Throws:
DataObjectException - if the data source couldn't be accessed properly
See Also:
doStatusUpdate(org.liquidsite.core.data.DataSource, int)

doStatusUpdate

public static void doStatusUpdate(DataSource src,
                                  int id)
                           throws DataObjectException
Updates the status flags for all content object revisions. This method will read the data source to extract the latest revisions, clear any previous status flags, and then set the new flags. This method also updates the status flags in related attributes. When finished inserting, updating or deleting in the content and attribute tables, this method should always be called.

Parameters:
src - the data source to use
id - the content identifier
Throws:
DataObjectException - if the data source couldn't be accessed properly

getDataObject

protected AbstractData getDataObject()
Returns a new instance of the data object.

Specified by:
getDataObject in class AbstractPeer
Returns:
a new instance of the data object