com.arsdigita.cms
Class Folder

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.versioning.VersionedACSObject
                  extended bycom.arsdigita.cms.ContentItem
                      extended bycom.arsdigita.cms.Folder
All Implemented Interfaces:
com.arsdigita.auditing.Audited, CustomCopy

public class Folder
extends ContentItem

This class represents folders for which to organize items in a tree hierarchy. Folders will only ever exist as draft or live versions. There should never be any folders that are pending. The pending versions of ordinary content items are stored in the live version of folders. Folders cannot have their own lifecycles. The methods to get or set lifecycles are no-ops. You should never call publish(com.arsdigita.cms.lifecycle.LifecycleDefinition, java.util.Date) or unpublish() on a folder; at present, these methods only log a warning when they are called. In the future, these warnings may be turned into actual errors.

Version:
$Id: //cms/dev/src/com/arsdigita/cms/Folder.java#41 $
Author:
Jack Chung, Michael Pih, David Lutterkort

Nested Class Summary
static class Folder.ItemCollection
          A collection of items that can be filtered to return only folders or only nonfolders.
 
Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String HOME_FOLDER
           
static String HOME_SECTION
           
static String INDEX
           
protected static String ITEMS
           
static String versionId
           
 
Fields inherited from class com.arsdigita.cms.ContentItem
ANCESTORS, AUDITING, CHILDREN, CONTENT_SECTION, CONTENT_TYPE, DRAFT, DRAFT_VERSION, LANGUAGE, LIVE, PARENT, PENDING, VERSION, VERSIONS
 
Fields inherited from class com.arsdigita.versioning.VersionedACSObject
IS_DELETED, MASTER
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE
 
Constructor Summary
Folder()
          Default constructor.
Folder(BigDecimal id)
          Constructor.
Folder(com.arsdigita.persistence.DataObject obj)
           
Folder(com.arsdigita.persistence.OID oid)
          Constructor.
Folder(String type)
           
 
Method Summary
 void addItem(ContentBundle item)
           
protected  void addPendingVersion(ContentItem version)
          Adds a pending version to the item.
protected  void afterSave()
           
 boolean autoPublishIfAssociated()
          Called by VersionCopier to determine whether to publish associated items when an item goes live.
protected  void beforeDelete()
          Remove any Links pointing to this item before deletion.
protected  void beforeSave()
          For new content items, sets the associated content type if it has not been already set.
protected  boolean canPublishToFS()
          Folders aren't explicitly p2fs'd
 boolean containsFolders()
          Returns true if the folder contains at least one folder, false if the folder does not contain any folders, but is either empty or contains only ordinary items.
 void copyItemsToFolder(Iterator items)
           
 boolean copyProperty(CustomCopy srcItem, com.arsdigita.persistence.metadata.Property property, ItemCopier copier)
          Copy the specified property (attribute or association) from the specified source folder.
 void delete()
          Deletes the folder.
 String getBaseDataObjectType()
           
 String getDisplayName()
          Fetch the display name of the content item.
 ContentBundle getIndexItem()
          Get the (special) index item for the folder.
 ContentItem getItem(String name, boolean isFolder)
          Returns a child content item in this folder (which could itself be a folder) with the specified name.
 Folder.ItemCollection getItems()
          Fetches the child items of this folder.
 Folder.ItemCollection getItems(boolean bSort)
          Fetches the child items of this folder.
 String getLabel()
          Fetches the label of the folder.
 Lifecycle getLifecycle()
          Always returns null, as folders do not have lifecycles.
 Folder.ItemCollection getPrimaryInstances()
          Returns collection of primary language instances for bundles in this folder.
static Folder getUserHomeFolder(com.arsdigita.kernel.User user, ContentSection section)
           
 boolean isEmpty()
          Returns true if the folder is empty.
protected  ContentItem makeCopy()
          Performs the actual mechanics of copying a content item.
 ContentItem publish(LifecycleDefinition cycleDef, Date startDate)
          Schedules an item for publication.
 void removeIndexItem()
          Removes the index item.
 void removeLifecycle()
          Does not do anything, as folders do not have lifecycles.
 void removePendingVersion(ContentItem version)
          Removes a pending version from the item.
 void setIndexItem(ContentBundle item)
          Sets the index item.
 void setLabel(String value)
          Set the label of this folder.
 void setLifecycle(Lifecycle cycle)
          Does not do anything, as folders do not have lifecycles.
static void setUserHomeFolder(com.arsdigita.kernel.User user, Folder folder)
           
protected  void setVersion(String version)
          Set the version of the folder.
 void unpublish()
          Unpublishes an item.
 
Methods inherited from class com.arsdigita.cms.ContentItem
addCategory, assertDraft, assertLive, assertMaster, assertPending, copy, copy, copyProperty, copyServices, copyServicesFrom, createLiveVersion, createPendingVersion, get, getCategories, getCategoryCollection, getChildren, getContentSection, getContentType, getCreationDate, getCreationIP, getCreationUser, getDraftVersion, getLanguage, getLastModifiedDate, getLastModifiedIP, getLastModifiedUser, getLiveVersion, getLocale, getName, getParent, getPath, getPathInfo, getPathInfo, getPathNoJsp, getPendingVersions, getPublicVersion, getVersion, getWorkingVersion, initialize, isDraftVersion, isLive, isLiveVersion, isPendingVersion, isPublished, promotePendingVersion, publishToFS, removeCategory, removeLifecycle, set, setContentSection, setContentType, setDefaultCategory, setLanguage, setLive, setLiveVersion, setName, setParent, setVersionRecursively, unpublishFromFS
 
Methods inherited from class com.arsdigita.versioning.VersionedACSObject
applyTag, applyUniqueTag, autoPropagateMaster, getMaster, getRolledBackTo, getTransactions, getTransactions, isMaster, isRolledBack, isSubtype, permanentlyDelete, propagateMaster, recordAttributeChange, rollBackTo, rollBackTo, rollForward, save, setMaster, trackChanges
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, clear, disconnect, equals, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
Constant Field Values

INDEX

public static final String INDEX
See Also:
Constant Field Values

HOME_FOLDER

public static final String HOME_FOLDER
See Also:
Constant Field Values

HOME_SECTION

public static final String HOME_SECTION
See Also:
Constant Field Values

ITEMS

protected static final String ITEMS
See Also:
Constant Field Values
Constructor Detail

Folder

public Folder()
Default constructor. This creates a new folder.


Folder

public Folder(com.arsdigita.persistence.OID oid)
       throws com.arsdigita.domain.DataObjectNotFoundException
Constructor. The contained DataObject is retrieved from the persistent storage mechanism with an OID specified by oid.

Parameters:
oid - The OID for the retrieved DataObject.

Folder

public Folder(BigDecimal id)
       throws com.arsdigita.domain.DataObjectNotFoundException
Constructor. The contained DataObject is retrieved from the persistent storage mechanism with an OID specified by id and Folder.BASE_DATA_OBJECT_TYPE.

Parameters:
id - The id for the retrieved DataObject

Folder

public Folder(com.arsdigita.persistence.DataObject obj)

Folder

public Folder(String type)
Method Detail

makeCopy

protected ContentItem makeCopy()
Description copied from class: ContentItem
Performs the actual mechanics of copying a content item. Non-final so that subtypes can extend copying behavior.

Overrides:
makeCopy in class ContentItem
Returns:
A new copy of the item

copyItemsToFolder

public void copyItemsToFolder(Iterator items)

getBaseDataObjectType

public String getBaseDataObjectType()
Overrides:
getBaseDataObjectType in class ContentItem
Returns:
the base PDL object type for this item. Child classes should override this method to return the correct value

delete

public void delete()
            throws IllegalStateException
Deletes the folder.

Throws:
IllegalStateException - if the folder is not empty.

beforeDelete

protected void beforeDelete()
Description copied from class: ContentItem
Remove any Links pointing to this item before deletion. XXX This should go away when one-way association targets can specify the equivalent of on delete set null

Overrides:
beforeDelete in class ContentItem

beforeSave

protected void beforeSave()
Description copied from class: ContentItem
For new content items, sets the associated content type if it has not been already set.

Overrides:
beforeSave in class ContentItem

afterSave

protected void afterSave()
Overrides:
afterSave in class ContentItem

getItems

public Folder.ItemCollection getItems(boolean bSort)
Fetches the child items of this folder. The returned collection provides methods to filter by various criteria, for example by name or by whether items are folders or not.

Parameters:
bSort - whether to sort the collection by isFolder and ID
Returns:
child items of this folder

getItems

public Folder.ItemCollection getItems()
Fetches the child items of this folder. The returned collection provides methods to filter by various criteria, for example by name or by whether items are folders or not. The items returned by this method are sorted by isFolder and ID

Returns:
child items of this folder, sorted by isFolder and ID

getPrimaryInstances

public Folder.ItemCollection getPrimaryInstances()
Returns collection of primary language instances for bundles in this folder.


getItem

public ContentItem getItem(String name,
                           boolean isFolder)
Returns a child content item in this folder (which could itself be a folder) with the specified name.

Parameters:
name - The name of the item
isFolder - If true, only return a subfolder. Otherwise, return any subitem
Returns:
The item with the given name, or null if no such item exists in the folder

addItem

public void addItem(ContentBundle item)

getDisplayName

public String getDisplayName()
Description copied from class: ContentItem
Fetch the display name of the content item. The display name for a ContentItem is the name property.

Overrides:
getDisplayName in class ContentItem
Returns:
The name of the content item

getLabel

public final String getLabel()
Fetches the label of the folder.


setLabel

public final void setLabel(String value)
Set the label of this folder.


setVersion

protected void setVersion(String version)
Set the version of the folder. An attempt to set the version to pending will result in the folder's version being set to live. We will never have any pending versions of folders, only live or draft. Pending versions of items are stored in the live version of a folder.

Overrides:
setVersion in class ContentItem
Parameters:
version - A version tag, ContentItem.LIVE or ContentItem.DRAFT or ContentItem.PENDING

unpublish

public void unpublish()
Description copied from class: ContentItem
Unpublishes an item. This method removes the item's lifecycle and removes all pending versions. It is intended for use in UI code, and it should not be used for making items go "unlive". Instead, use setLive(null).

Overrides:
unpublish in class ContentItem

publish

public ContentItem publish(LifecycleDefinition cycleDef,
                           Date startDate)
Description copied from class: ContentItem
Schedules an item for publication.

Overrides:
publish in class ContentItem
Parameters:
cycleDef - The lifecycle definition
startDate - The time to schedule the start of the lifecycle. If null, use the current time as the start date.
Returns:
the new pending version

getLifecycle

public Lifecycle getLifecycle()
Always returns null, as folders do not have lifecycles.

Overrides:
getLifecycle in class ContentItem
Returns:
a Lifecycle value

setLifecycle

public void setLifecycle(Lifecycle cycle)
Does not do anything, as folders do not have lifecycles.

Overrides:
setLifecycle in class ContentItem
Parameters:
cycle - The lifecycle

removeLifecycle

public void removeLifecycle()
Does not do anything, as folders do not have lifecycles.


addPendingVersion

protected void addPendingVersion(ContentItem version)
Description copied from class: ContentItem
Adds a pending version to the item.

Overrides:
addPendingVersion in class ContentItem

removePendingVersion

public void removePendingVersion(ContentItem version)
Description copied from class: ContentItem
Removes a pending version from the item.

Overrides:
removePendingVersion in class ContentItem
Parameters:
version - the version to remove

getIndexItem

public ContentBundle getIndexItem()
Get the (special) index item for the folder. The index item is what carries all the user-editable attributes of the folder. The index item is what should be published when a index page for a folder is desired. The index item is an ordinary item in every respect, i.e., it is part of the collection returned by getItems(), you cannot delete a folder if it still has an index item etc.


setIndexItem

public final void setIndexItem(ContentBundle item)
Sets the index item. This also adds the item to the folder.

Parameters:
item - The index item with the folder's user-editable attributes

removeIndexItem

public final void removeIndexItem()
Removes the index item.


isEmpty

public boolean isEmpty()
Returns true if the folder is empty.

Returns:
true if the folder is empty

containsFolders

public boolean containsFolders()
Returns true if the folder contains at least one folder, false if the folder does not contain any folders, but is either empty or contains only ordinary items.

Returns:
true if the folder contains other folders.

copyProperty

public boolean copyProperty(CustomCopy srcItem,
                            com.arsdigita.persistence.metadata.Property property,
                            ItemCopier copier)
Copy the specified property (attribute or association) from the specified source folder. This method almost completely overrides the metadata-driven methods in ObjectCopier. If the property in question is an association to ContentItem(s), this method should only call FooContentItem newChild = copier.copyItem(originalChild). An attempt to call any other method in order to copy the child will most likely have disastrous consequences. If a child class overrides this method, it should return super.copyProperty in order to indicate that it is not interested in handling the property in any special way.

Specified by:
copyProperty in interface CustomCopy
Overrides:
copyProperty in class ContentItem
Parameters:
srcItem - the source item
property - the property to copy
copier - the ItemCopier
Returns:
true if the property was copied, false to indicate that regular metadata-driven methods should be used to copy the property

canPublishToFS

protected boolean canPublishToFS()
Folders aren't explicitly p2fs'd

Overrides:
canPublishToFS in class ContentItem

autoPublishIfAssociated

public boolean autoPublishIfAssociated()
Called by VersionCopier to determine whether to publish associated items when an item goes live. This will only have an effect for non-component associations where the item is not yet published. Override default for Folders since they don't have their own lifecycles and a folder must be published when an item in it goes live.

Returns:
whether to publish this item

setUserHomeFolder

public static void setUserHomeFolder(com.arsdigita.kernel.User user,
                                     Folder folder)

getUserHomeFolder

public static Folder getUserHomeFolder(com.arsdigita.kernel.User user,
                                       ContentSection section)


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC