Package org.ametys.cms.content
Class GetMetadataSetDefAction
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.acting.AbstractAction
-
- org.apache.cocoon.acting.ServiceableAction
-
- org.ametys.cms.content.GetMetadataSetDefAction
-
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
,Serviceable
,Action
- Direct Known Subclasses:
GetMetadataSetDefByContentTypeAction
,GetServerValuesAction
public class GetMetadataSetDefAction extends ServiceableAction implements Initializable
Get metadata set definition as JSON object
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper
_contentHelper
The content helperprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
Content type extension point.protected ContentTypesHelper
_contentTypesHelper
Helper for content typeprotected CurrentUserProvider
_currentUserProvider
The current user providerprotected ExternalizableMetadataProviderExtensionPoint
_externalizableMetaProvider
The component to retrieve externalizable metadata providerprotected HelpManager
_helpManager
The help manager to get url for each propertyprotected org.slf4j.Logger
_logger
The loggerprotected RightManager
_rightManager
Rights manager-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description GetMetadataSetDefAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addMetadataDefRef(AbstractMetadataSetElement metadataSetElement, String metadataName)
protected MetadataDefinition
_getMetadataDefinition(Content content, MetadataDefinition parentMetadataDefinition, String metadataName)
Retrieves a sub metadata definition from a content type or a parent metadata definition.Map
act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
private Map<String,Object>
annotableDefinition2JsonObject(RichTextMetadataDefinition metaDef)
private Map<String,Object>
compositeDefinition2JsonObject(Content content, AbstractMetadataSetElement metadataSetElement, MetadataDefinition metaDef, Set<String> externalAndLocalMetadata, List<String> languages)
protected Map<String,Object>
content2Json(Content content, String metadataSetName, String fallbackMetadataSetName, boolean isEditionMetadataSet, List<String> languages)
Convert content to JSON objectprotected Map<String,Object>
content2Json(Content content, String metadataSetName, String fallbackMetadataSetName, List<String> metadataNames, boolean isEditionMetadataSet, List<String> languages)
Convert content to JSON objectprotected List<String>
getLanguages(Request request)
list all languages requested by the client in the requestvoid
initialize()
protected Map<String,Object>
metadataDefinition2JsonObject(Content content, AbstractMetadataSetElement metadataSetElement, MetadataDefinition metaDef, String metadataPath, Set<String> externalAndLocalMetadata, List<String> languages)
Convert a metadata to JSON objectprotected Map<String,Object>
metadataSetElement2JsonObject(Content content, MetadataDefinition metadataDefinition, AbstractMetadataSetElement metadataSetElement, Set<String> externalAndLocalMetadata, List<String> languages)
ConvertAbstractMetadataSetElement
to JSON objectvoid
service(ServiceManager serviceManager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_logger
protected org.slf4j.Logger _logger
The logger
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
Content type extension point.
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
Helper for content type
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_rightManager
protected RightManager _rightManager
Rights manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_externalizableMetaProvider
protected ExternalizableMetadataProviderExtensionPoint _externalizableMetaProvider
The component to retrieve externalizable metadata provider
-
_helpManager
protected HelpManager _helpManager
The help manager to get url for each property
-
-
Constructor Detail
-
GetMetadataSetDefAction
public GetMetadataSetDefAction()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
-
getLanguages
protected List<String> getLanguages(Request request)
list all languages requested by the client in the request- Parameters:
request
- the request- Returns:
- an ordonned list of all languages requested by the client (or server default locale if none requested by the client)
-
content2Json
protected Map<String,Object> content2Json(Content content, String metadataSetName, String fallbackMetadataSetName, boolean isEditionMetadataSet, List<String> languages) throws ProcessingException
Convert content to JSON object- Parameters:
content
- The contentmetadataSetName
- The metadata set namefallbackMetadataSetName
- The fallback metadata set name (if the first was not found)isEditionMetadataSet
- true if it is metadataset for editionlanguages
- the current languages requested by the client (an ordonned list)- Returns:
- The JSON object representing the content
- Throws:
ProcessingException
- if an error occurred
-
content2Json
protected Map<String,Object> content2Json(Content content, String metadataSetName, String fallbackMetadataSetName, List<String> metadataNames, boolean isEditionMetadataSet, List<String> languages) throws ProcessingException
Convert content to JSON object- Parameters:
content
- The contentmetadataSetName
- The metadata set namefallbackMetadataSetName
- The fallback metadata set name (if the first was not found)metadataNames
- If metadata name is empty, this is the list of metadatadef to get ('/' separated for composites)isEditionMetadataSet
- true if it is metadataset for editionlanguages
- the current languages requested by the client (an ordonned list)- Returns:
- The JSON object representing the content
- Throws:
ProcessingException
- if an error occurred
-
_addMetadataDefRef
private void _addMetadataDefRef(AbstractMetadataSetElement metadataSetElement, String metadataName)
-
metadataSetElement2JsonObject
protected Map<String,Object> metadataSetElement2JsonObject(Content content, MetadataDefinition metadataDefinition, AbstractMetadataSetElement metadataSetElement, Set<String> externalAndLocalMetadata, List<String> languages) throws ProcessingException
ConvertAbstractMetadataSetElement
to JSON object- Parameters:
content
- The contentmetadataDefinition
- The metadata definitionmetadataSetElement
- The metadataset elementexternalAndLocalMetadata
- The paths of externalizable metadata (with local and external value)languages
- the current languages requested by the client (an ordonned list)- Returns:
- The JSON object representing the metadataset element
- Throws:
ProcessingException
- if an error occurred
-
metadataDefinition2JsonObject
protected Map<String,Object> metadataDefinition2JsonObject(Content content, AbstractMetadataSetElement metadataSetElement, MetadataDefinition metaDef, String metadataPath, Set<String> externalAndLocalMetadata, List<String> languages) throws ProcessingException
Convert a metadata to JSON object- Parameters:
content
- The contentmetadataSetElement
- The metadataset elementmetaDef
- The metadata definitionmetadataPath
- The path of metadataexternalAndLocalMetadata
- The path of externalizable metadata (with local and external value)languages
- the current languages requested by the client (an ordonned list)- Returns:
- The JSON object representing the metadata
- Throws:
ProcessingException
- if an error occured
-
compositeDefinition2JsonObject
private Map<String,Object> compositeDefinition2JsonObject(Content content, AbstractMetadataSetElement metadataSetElement, MetadataDefinition metaDef, Set<String> externalAndLocalMetadata, List<String> languages) throws ProcessingException
- Throws:
ProcessingException
-
annotableDefinition2JsonObject
private Map<String,Object> annotableDefinition2JsonObject(RichTextMetadataDefinition metaDef)
-
_getMetadataDefinition
protected MetadataDefinition _getMetadataDefinition(Content content, MetadataDefinition parentMetadataDefinition, String metadataName)
Retrieves a sub metadata definition from a content type or a parent metadata definition.- Parameters:
content
- the content.parentMetadataDefinition
- the parent metadata definition.metadataName
- the metadata name.- Returns:
- the metadata definition found or
null
otherwise.
-
-