public class ContentHelper extends AbstractLogEnabled implements Component, Serviceable
Content
Modifier and Type | Field and Description |
---|---|
private ContentTypeExtensionPoint |
_contentTypeEP |
private ContentTypesHelper |
_contentTypesHelper |
private CurrentUserProvider |
_currentUserProvider |
private ObservationManager |
_observationManager |
private AmetysObjectResolver |
_resolver |
private UserHelper |
_userHelper |
private WorkflowProvider |
_workflowProvider |
static String |
ROLE
The component role.
|
Constructor and Description |
---|
ContentHelper() |
Modifier and Type | Method and Description |
---|---|
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
|
protected Object |
getBinaryValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a binary metadata value from a composite metadata.
|
protected Object |
getBooleanValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a boolean metadata value from a composite metadata.
|
protected void |
getCompositeMetadataValues(Content currentContent,
CompositeMetadata metaHolder,
MetadataDefinition definition,
String metaName,
String remainingPath,
boolean allowsNullValues,
List<Object> values)
Get the values of a metadata reference in a specified content.
The metadata can be in the content or in another linked content (directly or transitively). |
Map<String,Object> |
getContentEditionInformation(String contentId)
Get content edition information.
|
protected void |
getContentMetadataValues(CompositeMetadata metaHolder,
String metaName,
String remainingPath,
boolean allowsNullValues,
List<Object> values,
MetadataType type)
Get the values of a metadata reference in a specified content.
The metadata can be in the content or in another linked content (directly or transitively). |
protected Object |
getContentReferenceValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a content reference metadata value from a composite metadata.
|
protected Object |
getDateValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a Date metadata value from a composite metadata.
|
protected Object |
getDoubleValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a double metadata value from a composite metadata.
|
protected Map<String,Object> |
getEnumeratedValueMap(Enumerator enumerator,
String value)
Build a map representing an enumerator entry (value and label).
|
protected Object |
getFileValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a file metadata value from a composite metadata.
|
protected Object |
getGeocodeValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a geocode metadata value from a composite metadata.
|
protected Object |
getLongValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a long metadata value from a composite metadata.
|
Object |
getMetadataValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a metadata value from a composite metadata.
|
Object |
getMetadataValue(Content content,
String metadataPath)
Get the value of a metadata on a given content.
|
Map<String,Object> |
getMetadataValues(Content content,
Collection<String> metadataPaths)
Get metadata values by their path
|
protected void |
getMetadataValues(Content currentContent,
CompositeMetadata metaHolder,
MetadataDefinition definition,
String metaName,
String remainingPath,
boolean allowsNullValues,
List<Object> values)
Get the values of a metadata reference in a specified content.
The metadata can be in the content or in another linked content (directly or transitively). |
List<Object> |
getMetadataValues(Content content,
String metadataPath)
Get the values of a metadata on a given content.
|
List<Object> |
getMetadataValues(Content content,
String metadataPath,
boolean allowsNullValues)
Get the values of a metadata on a given content.
|
protected void |
getMetadataValues(Content content,
String fullMetaPath,
boolean allowsNullValues,
List<Object> values)
Get the values of a metadata reference in a specified content.
The metadata can be in the content or in another linked content (directly or transitively). |
Map<String,Object> |
getMetadataValues(String contentId,
Collection<String> metadataPath)
Get metadata values by their path
|
protected Object |
getReferenceValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a reference metadata value from a composite metadata.
|
protected Object |
getResourceFileValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a resource-file metadata value from a composite metadata.
|
protected RichText |
getRichTextValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a string (HTML format) reprensenting the rich text metadata value from a composite metadata.
|
protected Object |
getStringValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a string metadata value from a composite metadata.
|
protected Object |
getSubcontentValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a sub-content metadata value from a composite metadata.
|
protected Object |
getUserValue(CompositeMetadata metaHolder,
String name,
MetadataDefinition definition)
Get a user metadata value from a composite metadata.
|
boolean |
hasIndexingReferences(Content content)
Test if the given content has indexing references, i.e.
|
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 UserHelper _userHelper
public ContentHelper()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
ServiceException
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> getMetadataValues(String contentId, Collection<String> metadataPath)
contentId
- The id of contentmetadataPath
- The path of metadata to retrievepublic Map<String,Object> getMetadataValues(Content content, Collection<String> metadataPaths)
content
- The content.metadataPaths
- The path of metadata to retrieve, slash-separated.public Object getMetadataValue(Content content, String metadataPath)
content
- The content.metadataPath
- The metadata path, slash-separated.
It can represent a property on one or more linked contents, i.e. "composite/linkedContent/secondContent/title".public List<Object> getMetadataValues(Content content, String metadataPath)
content
- The content.metadataPath
- The metadata path, slash-separated.
It can represent a property on one or more linked contents, i.e. "composite/linkedContent/secondContent/title".public List<Object> getMetadataValues(Content content, String metadataPath, boolean allowsNullValues)
content
- The content.metadataPath
- The metadata path, slash-separated.
It can represent a property on one or more linked contents, i.e. "composite/linkedContent/secondContent/title".allowsNullValues
- If true, empty values will be added to the list as "null"protected void getMetadataValues(Content content, String fullMetaPath, boolean allowsNullValues, List<Object> values)
content
- The content.fullMetaPath
- The full metadata path (separated by '/').allowsNullValues
- If true, empty values will be added to the list as "null"values
- The list of values to be filled by this method.protected void getMetadataValues(Content currentContent, CompositeMetadata metaHolder, MetadataDefinition definition, String metaName, String remainingPath, boolean allowsNullValues, List<Object> values)
currentContent
- The content currently being browsed.metaHolder
- The current metadata holder, must in some way possess the "metaName" metadata.definition
- The current metadata definition.metaName
- The metadata name.remainingPath
- The remaining path, can be empty.allowsNullValues
- If true, empty values will be added to the list as "null"values
- The list of values to be filled by this method.protected void getCompositeMetadataValues(Content currentContent, CompositeMetadata metaHolder, MetadataDefinition definition, String metaName, String remainingPath, boolean allowsNullValues, List<Object> values)
currentContent
- The content currently being browsed.metaHolder
- The current metadata holder, must in some way possess the "metaName" metadata.definition
- The current metadata definition.metaName
- The metadata name.remainingPath
- The remaining path, can be empty.allowsNullValues
- If true, empty values will be added to the list as "null"values
- The list of values to be filled by this method.protected void getContentMetadataValues(CompositeMetadata metaHolder, String metaName, String remainingPath, boolean allowsNullValues, List<Object> values, MetadataType type)
metaHolder
- The current metadata holder, must in some way possess the "metaName" metadata.metaName
- The metadata name.remainingPath
- The remaining path, can be empty.allowsNullValues
- If true, empty values will be added to the list as "null"values
- The list of values to be filled by this method.type
- The metadata typepublic 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 Object getMetadataValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name (path forbidden).definition
- the metadata definition.protected Object getStringValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Map<String,Object> getEnumeratedValueMap(Enumerator enumerator, String value)
enumerator
- the metadata enumerator.value
- the value to generate.protected Object getLongValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getDoubleValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getBooleanValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getDateValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getUserValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getBinaryValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getFileValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getResourceFileValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getGeocodeValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected RichText getRichTextValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getReferenceValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getContentReferenceValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.protected Object getSubcontentValue(CompositeMetadata metaHolder, String name, MetadataDefinition definition)
metaHolder
- the composite metadata.name
- the metadata name.definition
- the metadata definition.