com.arsdigita.cms
Class ContentBundle

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.ContentBundle
All Implemented Interfaces:
com.arsdigita.auditing.Audited, CustomCopy

public class ContentBundle
extends ContentItem

A bundle of content items of different languages. A bundle ties the various language instances of an item together and provides methods to access them.

Version:
$Id: //cms/dev/src/com/arsdigita/cms/ContentBundle.java#32 $
Author:
Shashin Shinde, Justin Ross <jross@redhat.com>

Field Summary
static String BASE_DATA_OBJECT_TYPE
          The base data object type of a bundle
static String DEFAULT_LANGUAGE
          The default language property
static String INSTANCES
          The primary instances association
static String versionId
           
 
Fields inherited from class com.arsdigita.cms.ContentItem
ANCESTORS, AUDITING, CHILDREN, CONTENT_SECTION, CONTENT_TYPE, DRAFT, DRAFT_VERSION, LANGUAGE, LIVE, NAME, 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
ContentBundle(BigDecimal id)
          Retrieves a bundle.
ContentBundle(ContentItem primary)
          Creates a new bundle.
ContentBundle(com.arsdigita.persistence.DataObject object)
          Retrieves or creates a bundle using the DataObject argument.
ContentBundle(com.arsdigita.persistence.OID oid)
          Retrieves a bundle.
ContentBundle(String type)
          Creates a bundle.
 
Method Summary
 void addInstance(ContentItem instance)
          Adds a language instance to this bundle.
protected  void afterSave()
           
protected  void beforeSave()
          For new content items, sets the associated content type if it has not been already set.
protected  boolean canPublishToFS()
          Method to determine whether this ContentItem should be automatically published to the file system.
 boolean copyProperty(CustomCopy source, com.arsdigita.persistence.metadata.Property property, ItemCopier copier)
          Ignore the INSTANCES property for ItemCopier.VERSION_COPY.
 boolean copyServices(ContentItem source)
          Copy services from the source item.
 String getBaseDataObjectType()
          Returns the data object type for this bundle.
 String getDefaultLanguage()
          Gets the default language of the bundle.
 ContentItem getInstance(String language)
          Returns a language instance for language or null if no such instance exists.
 ItemCollection getInstances()
          Produces a collection containing all language instances in this bundle.
 Collection getLanguages()
          List all languages in which this item is available, i.e.
 Lifecycle getLifecycle()
          Fetches the publication lifecycle.
 ContentItem getPrimaryInstance()
          Gets the primary instance of this bundle.
 boolean hasInstance(ContentItem instance)
          Tells whether instance is present in the bundle.
 boolean hasInstance(String language)
          Utility method to check if this bundle already contains an instance for the given language.
protected  void initialize()
          Called from the base class (DomainObject) constructors.
protected  ContentItem makeCopy()
          Performs the actual mechanics of copying a content item.
 ContentItem negotiate(Enumeration locales)
          Negotiate the right language instance for this bundle and return it.
 ContentItem negotiate(Locale[] locales)
          Negotiate the right language instance for this bundle and return it.
 ContentItem publish(LifecycleDefinition definition, Date start)
          Schedules an item for publication.
protected  void publishToFS()
          Publish this item to the filesystem; can only be called on a live version.
 void removeInstance(ContentItem instance)
          Removes a language instance from the bundle.
 void setDefaultLanguage(String language)
          Sets the default language of the bundle.
 void setLifecycle(Lifecycle lifecycle)
          Apply a lifecycle to this content item.
 
Methods inherited from class com.arsdigita.cms.ContentItem
addCategory, addPendingVersion, assertDraft, assertLive, assertMaster, assertPending, beforeDelete, copy, copy, copyProperty, copyServicesFrom, createLiveVersion, createPendingVersion, get, getCategories, getCategoryCollection, getChildren, getContentSection, getContentType, getCreationDate, getCreationIP, getCreationUser, getDisplayName, getDraftVersion, getLanguage, getLastModifiedDate, getLastModifiedIP, getLastModifiedUser, getLiveVersion, getLocale, getName, getParent, getPath, getPathInfo, getPathInfo, getPathNoJsp, getPendingVersions, getPublicVersion, getVersion, getWorkingVersion, isDraftVersion, isLive, isLiveVersion, isPendingVersion, isPublished, promotePendingVersion, removeCategory, removeLifecycle, removePendingVersion, set, setContentSection, setContentType, setDefaultCategory, setLanguage, setLive, setLiveVersion, setName, setParent, setVersion, setVersionRecursively, unpublish, 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, delete, 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
The base data object type of a bundle

See Also:
Constant Field Values

INSTANCES

public static final String INSTANCES
The primary instances association

See Also:
Constant Field Values

DEFAULT_LANGUAGE

public static final String DEFAULT_LANGUAGE
The default language property

See Also:
Constant Field Values
Constructor Detail

ContentBundle

public ContentBundle(ContentItem primary)
Creates a new bundle.

Parameters:
primary - The primary language instance of this bundle

ContentBundle

public ContentBundle(com.arsdigita.persistence.OID oid)
              throws com.arsdigita.domain.DataObjectNotFoundException
Retrieves a bundle.

Parameters:
oid - the OID of the bundle to retrieve

ContentBundle

public ContentBundle(BigDecimal id)
              throws com.arsdigita.domain.DataObjectNotFoundException
Retrieves a bundle.

Parameters:
id - the BigDecimal id of the bundle to retrieve

ContentBundle

public ContentBundle(com.arsdigita.persistence.DataObject object)
Retrieves or creates a bundle using the DataObject argument.

Parameters:
object - the DataObject to use in creating or retrieving the bundle

ContentBundle

public ContentBundle(String type)
Creates a bundle.

Parameters:
type - the String data object type with which to create a new bundle
Method Detail

getBaseDataObjectType

public String getBaseDataObjectType()
Returns the data object type for this bundle.

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

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

getDefaultLanguage

public final String getDefaultLanguage()
Gets the default language of the bundle.


setDefaultLanguage

public final void setDefaultLanguage(String language)
Sets the default language of the bundle.


addInstance

public void addInstance(ContentItem instance)
Adds a language instance to this bundle. This method will fail if the bundle already contains a different instance for the same language. Note that in order to set the primary instance you must call this method and setDefaultLanguage(String) as well.

Parameters:
instance - the new language instance
See Also:
setDefaultLanguage(String)

removeInstance

public void removeInstance(ContentItem instance)
Removes a language instance from the bundle. This method will fail if instance is the primary instance. Note that the language instance is not deleted by this operation; it is just removed from the Bundle. Users of this method have to take care to properly dispose of this instance!

Parameters:
instance - The language instance to remove

getPrimaryInstance

public final ContentItem getPrimaryInstance()
Gets the primary instance of this bundle.

Returns:
the language instance of this item which is marked as the primary instance
See Also:
addInstance(ContentItem)

getInstances

public final ItemCollection getInstances()
Produces a collection containing all language instances in this bundle.

Returns:
a collection of language instances

getInstance

public final ContentItem getInstance(String language)
Returns a language instance for language or null if no such instance exists. This method does not do language negotiation, it only returns an exact match for the given Locale or null if no such match is found.

Parameters:
language - the language for which to get an instance
Returns:
the instance of this item which exactly matches the language part of the Locale l
See Also:
negotiate(java.util.Locale[])

hasInstance

public final boolean hasInstance(ContentItem instance)
Tells whether instance is present in the bundle.

Parameters:
instance - the language instance to look for
Returns:
true if the instance is in the bundle

hasInstance

public final boolean hasInstance(String language)
Utility method to check if this bundle already contains an instance for the given language.

Parameters:
language - an ISO639 2-letter language code
Returns:
true if this ContentBundle contains an instance for the language given as an argument
See Also:
ContentItem.getLanguage()

getLanguages

public final Collection getLanguages()
List all languages in which this item is available, i.e. the language codes of all instances in this bundle.

Returns:
A Collection of language 2-letter codes in which this item is available

negotiate

public ContentItem negotiate(Locale[] locales)
Negotiate the right language instance for this bundle and return it.

Parameters:
locales - the acceptable locales for the language instance, in decreasing importance
Returns:
the negotiated language instance or null if there is no language instance for any of the locales in locales

negotiate

public ContentItem negotiate(Enumeration locales)
Negotiate the right language instance for this bundle and return it.

Parameters:
locales - the acceptable locales for the language instance, in decreasing importance. This parameter has to be an Enumeration of Locale objects.
Returns:
the negotiated language instance or null if there is no language instance for any of the locales in locales.

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

canPublishToFS

protected boolean canPublishToFS()
Description copied from class: ContentItem
Method to determine whether this ContentItem should be automatically published to the file system.

Overrides:
canPublishToFS in class ContentItem

publishToFS

protected void publishToFS()
Description copied from class: ContentItem
Publish this item to the filesystem; can only be called on a live version.

Overrides:
publishToFS in class ContentItem

publish

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

Overrides:
publish in class ContentItem
Parameters:
definition - The lifecycle definition
start - 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()
Description copied from class: ContentItem
Fetches the publication lifecycle.

Overrides:
getLifecycle in class ContentItem
Returns:
The associated lifecycle, null if there is none

setLifecycle

public void setLifecycle(Lifecycle lifecycle)
Description copied from class: ContentItem
Apply a lifecycle to this content item.

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

copyProperty

public boolean copyProperty(CustomCopy source,
                            com.arsdigita.persistence.metadata.Property property,
                            ItemCopier copier)
Ignore the INSTANCES property for ItemCopier.VERSION_COPY.

Specified by:
copyProperty in interface CustomCopy
Overrides:
copyProperty in class ContentItem
Parameters:
source - the source CustomCopy item
property - the property to copy
copier - a temporary class that is able to copy a child item correctly.
Returns:
true if the property was copied; false to indicate that regular metadata-driven methods should be used to copy the property.

copyServices

public boolean copyServices(ContentItem source)
Description copied from class: ContentItem
Copy services from the source item. This method is the analogue of the ContentItem.copyProperty(com.arsdigita.cms.ContentItem, java.lang.String, com.arsdigita.cms.ItemCopier) method above. The object copier will call this method whenever an item has been successfully published, in order to transfer services such as categorization or permissions to the live version.

This method is requied to return false to signal the object copier to transfer default services from the source item; or true in order to abort further processing of services.

Overrides:
copyServices in class ContentItem
Returns:
true to tell the object copier to stop copying services for this item, false otherwise

initialize

protected void initialize()
Description copied from class: ContentItem
Called from the base class (DomainObject) constructors.

Overrides:
initialize in class ContentItem

afterSave

protected void afterSave()
Overrides:
afterSave in class ContentItem


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