public interface ContentFragment extends Adaptable, Versionable
Implementations of this interface allow to access content fragments through a stable API, independently from the actual content structure.
Content fragments consist of one or more elements, which in turn may contain variations of their content - for example, a short variation for publishing the fragment on Twitter or maybe an on-the-fly variation when the fragment is reused on a different page than the original one.
One element (the "main" or "master" element) is considered to define the content fragment. This means, it has a special position within the content element and usually contains the "most important" or "most distinctive" content.
Each variation can be synchronized with the original element content, which in the simplest way means that the current content of the element is copied to the variation. Depending on the implementation, there might be more sophisticated ways that change the original content in some way.
Additionally, each content fragment has a collection of associated content, which may contain references to assets, collections or other content fragments.
Each content fragment has a set of meta data, which can be used for determining associated content.
Usage pattern: To obtain a ContentFragment, simply adapt a Resource
to
ContentFragment.class
. This means that each implementing module has to
provide a AdapterFactory
that adapts Resources
to
ContentFragment
.
Transactional behavior: The caller is responsible for committing the respective
ResourceResolver
after calling one or more
methods that change a content fragment unless specified otherwise.
Modifier and Type | Method and Description |
---|---|
void |
addAssociatedContent(Resource content)
Adds the provided
Resource as associated content. |
ContentElement |
createElement(ElementTemplate template)
Creates a new element from the specified template.
|
VariationTemplate |
createVariation(java.lang.String name,
java.lang.String title,
java.lang.String description)
Creates a new variation.
|
java.util.Iterator<Resource> |
getAssociatedContent()
Gets an iterator on associated content.
|
java.lang.String |
getDescription()
Gets the description of the content element.
|
ContentElement |
getElement(java.lang.String elementName)
Gets the content element of the specified name.
|
java.util.Iterator<ContentElement> |
getElements()
Gets an iterator on the templates of predefined content elements of the fragment.
|
java.util.Map<java.lang.String,java.lang.Object> |
getMetaData()
Gets a map of the fragment's meta data.
|
java.lang.String |
getName()
Gets the (technical) name of the content fragment.
|
FragmentTemplate |
getTemplate()
Gets the fragment template assigned to this content element.
|
java.lang.String |
getTitle()
Gets the (human-readable) title of the content fragment.
|
boolean |
hasElement(java.lang.String elementName)
Determines if the content fragment has an element of the specified name.
|
java.util.Iterator<VariationDef> |
listAllVariations()
Gets an iterator on all available variations that are available for the entire
fragment.
|
void |
removeAssociatedContent(Resource content)
Removes the provided
Resource as associated content. |
void |
removeVariation(java.lang.String name)
Removes the specified global variation from the fragment.
|
void |
setDescription(java.lang.String description)
Sets the description of the content fragment.
|
void |
setMetaData(java.lang.String name,
java.lang.Object value)
Sets a single meta data property.
|
void |
setTitle(java.lang.String title)
Sets the (human-readable) title of the content fragment.
|
createVersion, getVersionedContent, listVersions
java.util.Iterator<ContentElement> getElements()
boolean hasElement(java.lang.String elementName)
elementName
- The name of the element to checkContentElement createElement(ElementTemplate template) throws ContentFragmentException
template
- The element templateContentFragmentException
- if the change could not be persistedContentElement getElement(java.lang.String elementName)
elementName
- The name of the element; null
or empty string
for the "main" or "master" elementnull
java.lang.String getName()
java.lang.String getTitle()
void setTitle(java.lang.String title) throws ContentFragmentException
title
- The new titleContentFragmentException
- if the change could not be persistedjava.lang.String getDescription()
void setDescription(java.lang.String description) throws ContentFragmentException
description
- The new descriptionContentFragmentException
- if the change could not be persistedjava.util.Map<java.lang.String,java.lang.Object> getMetaData()
void setMetaData(java.lang.String name, java.lang.Object value) throws ContentFragmentException
As meta data is not limited to the meta data provided through the template, this method is generic.
name
- Name of the meta data propertyvalue
- Value of the meta data propertyContentFragmentException
- if the property could not be set/persistedjava.util.Iterator<VariationDef> listAllVariations()
This is used to get a "plain view" on variations, as not all elements may have all variations.
The list does not include the "master" or base variation!
FragmentTemplate getTemplate()
VariationTemplate createVariation(java.lang.String name, java.lang.String title, java.lang.String description) throws ContentFragmentException
The variation is added to all elements of the fragment.
The content of each fragment must be initialized with a copy of the element content.
name
- The (technical) name of the variation to be createdtitle
- The (human-readable) title of the variation to be createddescription
- The description of the variationContentFragmentException
- if the change could not be persistedvoid removeVariation(java.lang.String name) throws ContentFragmentException
Removes the specified global variation from the fragment.
name
- The name of the global variation to removeContentFragmentException
- if the variation could not be removed properly or
there is no such variation availablejava.util.Iterator<Resource> getAssociatedContent()
void addAssociatedContent(Resource content) throws ContentFragmentException
Resource
as associated content.content
- The new associated contentContentFragmentException
- if the resource could not be addedvoid removeAssociatedContent(Resource content) throws ContentFragmentException
Resource
as associated content.content
- The associated content to removeContentFragmentException
- if the resource could not be removed"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"