public class ContentHelper extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Content
Modifier and Type | Field and Description |
---|---|
private ContentTypeExtensionPoint |
_contentTypeEP |
private ContentTypesHelper |
_contentTypesHelper |
private Context |
_context |
private CurrentUserProvider |
_currentUserProvider |
private ObservationManager |
_observationManager |
private AmetysObjectResolver |
_resolver |
private SystemPropertyExtensionPoint |
_systemPropertyExtensionPoint |
private WorkflowProvider |
_workflowProvider |
static String |
ROLE
The component role.
|
Constructor and Description |
---|
ContentHelper() |
Modifier and Type | Method and Description |
---|---|
private Object |
_getBinaryValue(CompositeMetadata metadataHolder,
String metadataName) |
private Object |
_getBooleanValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getCompositeMetadataValue(CompositeMetadata metadataHolder,
MetadataDefinition definition,
Locale locale,
boolean resolveReferences,
boolean returnNullValues,
String[] pathSegments,
String metadataName) |
private Object |
_getContentMetadataValue(CompositeMetadata metadataHolder,
MetadataDefinition definition,
Locale defaultLocale,
boolean resolveReferences,
boolean returnNullValues,
String[] pathSegments,
String metadataName) |
private Object |
_getContentValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition,
boolean resolve) |
private Object |
_getDateValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getDoubleValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getFileValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition,
boolean resolveReference) |
private Object |
_getGeocodeValue(CompositeMetadata metadataHolder,
String metadataName) |
private Object |
_getLongValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getMultilingualStringValue(CompositeMetadata metadataHolder,
String metadataName,
Locale locale,
boolean resolve) |
private Object |
_getReferenceValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getResourceValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition,
boolean resolve) |
private Object |
_getRichTextValue(CompositeMetadata metadataHolder,
String metadataName) |
private Object |
_getStringValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Object |
_getSystemPropertyValue(Content content,
String[] pathSegments,
SystemProperty systemProperty) |
private Object |
_getUserValue(CompositeMetadata metadataHolder,
String metadataName,
MetadataDefinition definition) |
private Map<String,Object> |
_setContentType(String contentId,
String contentTypeId,
int actionId,
boolean remove) |
private Map<String,Object> |
_setMixinType(String contentId,
String mixinId,
int actionId,
boolean remove) |
Map<String,Object> |
addContentType(String contentId,
String contentTypeId,
int actionId)
Add a content type to an existing content
|
Map<String,Object> |
addMixinType(String contentId,
String mixinId,
int actionId)
Add a mixin type to an existing content
|
void |
contextualize(Context context) |
Map<String,Object> |
getContentEditionInformation(String contentId)
Get content edition information.
|
Object |
getMetadataValue(CompositeMetadata metadataHolder,
MetadataDefinition definition,
String metadataPath,
Locale locale,
boolean resolveReferences,
boolean returnNullValues)
Get the typed value(s) at given path.
|
Object |
getMetadataValue(Content content,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences)
Get the typed metadata value(s) of a content at given path.
|
Object |
getMetadataValue(Content content,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences,
boolean returnNullValues)
Get the typed metadata value(s) of a content at given path.
|
List<Object> |
getMetadataValues(Content content,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences,
boolean returnNullValues)
Get the typed values of a content at given path.
|
List<Object> |
getMetadataValues(String contentId,
String metadataPath)
Get the typed values of a content at given path.
|
List<Pair<String,Content>> |
getReferencingContents(Content content)
Returns all Contents referencing the given content with their value path
|
Object |
getSimpleMetadataValue(CompositeMetadata metadataHolder,
MetadataDefinition definition,
String metadataName,
Locale locale,
boolean resolveReferences)
Get the typed value(s) of a simple metadata.
|
Content |
getTargetContent(Content sourceContent,
String fieldPath)
Get the content from which to get the system property.
|
List<Content> |
getTargetContents(Content sourceContent,
String fieldPath)
Get the contents from which to get the system property.
|
String |
getTitle(Content content)
Get the title of a content.<br>
If the content is a multilingual content, the title will be retrieved for the current locale if exists, or for default locale 'en' if exists, or for the first found locale.
|
Map<String,String> |
getTitleVariants(Content content)
Get the title variants of a multilingual content
|
Object |
getValue(Content content,
String fieldPath,
Locale defaultLocale,
boolean resolveReferences)
Get the typed value(s) of a content at given path.
|
Object |
getValue(Content content,
String fieldPath,
Locale defaultLocale,
boolean resolveReferences,
boolean returnNullValues)
Get the typed value(s) of a content at given path.
|
boolean |
hasIndexingReferences(Content content)
Test if the given content has indexing references, i.e.
|
boolean |
hasReferencingContents(Content content,
List<String> ignoreContentTypes,
boolean includeSubTypes)
Determines if the content has referencing contents other than whose type is in content types to ignore.
|
boolean |
isMultilingual(Content content)
Determines if a content is a multilingual content
|
boolean |
isReferenceTable(Content content)
Determines if the content is a reference table content type
|
boolean |
isSimple(Content content)
Determines if the content is a simple content type
|
Map<String,Object> |
removeContentType(String contentId,
String contentTypeId,
int actionId)
Remove a content type to an existing content
|
Map<String,Object> |
removeMixinType(String contentId,
String mixinId,
int actionId)
Remove a mixin type to an existing content
|
void |
service(ServiceManager smanager) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
private AmetysObjectResolver _resolver
private ContentTypesHelper _contentTypesHelper
private ContentTypeExtensionPoint _contentTypeEP
private ObservationManager _observationManager
private WorkflowProvider _workflowProvider
private CurrentUserProvider _currentUserProvider
private SystemPropertyExtensionPoint _systemPropertyExtensionPoint
public ContentHelper()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public Map<String,Object> addContentType(String contentId, String contentTypeId, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
contentId
- The content idcontentTypeId
- The content type to addactionId
- The workflow action idcom.opensymphony.workflow.WorkflowException
- ifAmetysRepositoryException
- if an error occurredpublic Map<String,Object> removeContentType(String contentId, String contentTypeId, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
contentId
- The content idcontentTypeId
- The content type to addactionId
- The workflow action idcom.opensymphony.workflow.WorkflowException
- ifAmetysRepositoryException
- if an error occurredpublic Map<String,Object> addMixinType(String contentId, String mixinId, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
contentId
- The content idmixinId
- The mixin type to addactionId
- The workflow action idcom.opensymphony.workflow.WorkflowException
- ifAmetysRepositoryException
- if an error occurredpublic Map<String,Object> removeMixinType(String contentId, String mixinId, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
contentId
- The content idmixinId
- The mixin type to addactionId
- The workflow action idcom.opensymphony.workflow.WorkflowException
- ifAmetysRepositoryException
- if an error occurredpublic Map<String,Object> getContentEditionInformation(String contentId)
contentId
- the content ID.public boolean hasIndexingReferences(Content content)
content
- the content to test.true
if one of the content types or mixins has indexing references, false
otherwise.private Map<String,Object> _setContentType(String contentId, String contentTypeId, int actionId, boolean remove) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
AmetysRepositoryException
com.opensymphony.workflow.WorkflowException
private Map<String,Object> _setMixinType(String contentId, String mixinId, int actionId, boolean remove) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
AmetysRepositoryException
com.opensymphony.workflow.WorkflowException
public boolean isReferenceTable(Content content)
content
- The contentpublic boolean isMultilingual(Content content)
content
- The contenttrue
if the content is an instance of content typepublic boolean isSimple(Content content)
content
- The contentpublic Object getValue(Content content, String fieldPath, Locale defaultLocale, boolean resolveReferences)
content
- The contentfieldPath
- The field id or the path to the metadata, separated by '/'defaultLocale
- The default locale to resolve localized values if the content's language is null. Can be null.resolveReferences
- true
true to resolve references (such as resource or content)public Object getValue(Content content, String fieldPath, Locale defaultLocale, boolean resolveReferences, boolean returnNullValues)
content
- The contentfieldPath
- The field id or the path to the metadata, separated by '/'defaultLocale
- The default locale to resolve localized values if the content's language is null. Can be null.resolveReferences
- true
true to resolve references (such as resource or content)returnNullValues
- true
true to return null values when the metadata does not exists in a repeater or linked content.private Object _getSystemPropertyValue(Content content, String[] pathSegments, SystemProperty systemProperty)
public Content getTargetContent(Content sourceContent, String fieldPath)
sourceContent
- The source content.fieldPath
- The field pathpublic List<Content> getTargetContents(Content sourceContent, String fieldPath)
sourceContent
- The source content.fieldPath
- The field pathpublic Object getMetadataValue(Content content, String metadataPath, Locale defaultLocale, boolean resolveReferences)
content
- The contentmetadataPath
- The path to the metadata, separated by '/'defaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string.
Only to be valued if initial content's language is null, otherwise set this parameter to null.resolveReferences
- true
true to resolve references (such as resource or content)public Object getMetadataValue(Content content, String metadataPath, Locale defaultLocale, boolean resolveReferences, boolean returnNullValues)
content
- The contentmetadataPath
- The path to the metadata, separated by '/'defaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string.
Only to be valued if initial content's language is null, otherwise set this parameter to null.resolveReferences
- true
true to resolve references (such as resource or content)returnNullValues
- true
true to return null values when the metadata does not exists in a repeater or linked content.public List<Object> getMetadataValues(String contentId, String metadataPath)
contentId
- The ID of the contentmetadataPath
- The Path to the metadata, separated by '/'public List<Object> getMetadataValues(Content content, String metadataPath, Locale defaultLocale, boolean resolveReferences, boolean returnNullValues)
content
- The contentmetadataPath
- The path to the metadata, separated by '/'defaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string.
Only to be valued if initial content's language is null, otherwise set this parameter to null.resolveReferences
- true
true to resolve references (such as resource or content)returnNullValues
- true
true to return null values when the metadata does not exists in a repeater or linked content.public String getTitle(Content content)
content
- The contentpublic Map<String,String> getTitleVariants(Content content)
content
- The multilingual contentIllegalArgumentException
- if the content is not a multilingual contentpublic Object getMetadataValue(CompositeMetadata metadataHolder, MetadataDefinition definition, String metadataPath, Locale locale, boolean resolveReferences, boolean returnNullValues)
metadataHolder
- The parent composite metadatadefinition
- The definition of the first metadata in pathmetadataPath
- The path to the metadata, separated by '/'locale
- The locale to used to resolve localized metadataresolveReferences
- true
true to resolve references (such as resource or content)returnNullValues
- true
true to return null values when metadata does not exists.private Object _getContentMetadataValue(CompositeMetadata metadataHolder, MetadataDefinition definition, Locale defaultLocale, boolean resolveReferences, boolean returnNullValues, String[] pathSegments, String metadataName)
private Object _getCompositeMetadataValue(CompositeMetadata metadataHolder, MetadataDefinition definition, Locale locale, boolean resolveReferences, boolean returnNullValues, String[] pathSegments, String metadataName)
public Object getSimpleMetadataValue(CompositeMetadata metadataHolder, MetadataDefinition definition, String metadataName, Locale locale, boolean resolveReferences)
metadataHolder
- The parent composite metadatadefinition
- The definition of the first metadata in pathmetadataName
- The name of the metadatalocale
- The locale to used to resolve localized metadataresolveReferences
- true
true to resolve references (such as resource or content)private Object _getStringValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getMultilingualStringValue(CompositeMetadata metadataHolder, String metadataName, Locale locale, boolean resolve)
private Object _getContentValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition, boolean resolve)
private Object _getUserValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getDateValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getLongValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getDoubleValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getBooleanValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getRichTextValue(CompositeMetadata metadataHolder, String metadataName)
private Object _getBinaryValue(CompositeMetadata metadataHolder, String metadataName)
private Object _getResourceValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition, boolean resolve)
private Object _getGeocodeValue(CompositeMetadata metadataHolder, String metadataName)
private Object _getReferenceValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition)
private Object _getFileValue(CompositeMetadata metadataHolder, String metadataName, MetadataDefinition definition, boolean resolveReference)
public boolean hasReferencingContents(Content content, List<String> ignoreContentTypes, boolean includeSubTypes)
content
- The content to checkignoreContentTypes
- The content types to ignore for referencing contentsincludeSubTypes
- True if sub content types are take into account in ignore content typestrue
if there is at least one Content referencing the content