Package org.ametys.cms.tag.jcr
Class ImportTagsAction
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
,Action
public class ImportTagsAction extends AbstractNotifierAction
Import subscribers from a CSV or text file.
-
-
Field Summary
Fields Modifier and Type Field Description private static String[]
_ALLOWED_EXTENSIONS
private int
_createdTagsCount
The count of new tagsprivate int
_errorCount
The count of errorprotected JSONUtils
_jsonUtils
The JSon Utils Componentprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected TagProviderExtensionPoint
_tagProviderExtPt
The tag provider extension pointprotected TagTargetTypeExtensionPoint
_targetTypeEP
Target typesprivate int
_updatedTagsCount
The count of updated tags-
Fields inherited from class org.ametys.core.observation.AbstractNotifierAction
_observationManager
-
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 ImportTagsAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
_findUniqueName(String originalName, Map<String,Object> contextualParameters)
private Set<TagProvider<CMSTag>>
_getTagProviders()
private boolean
_hasTag(Set<TagProvider<CMSTag>> providers, String name, Map<String,Object> contextualParameters)
Map
act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
protected I18nizableText
configureDescription(Configuration configuration, String defaultCatalogue)
Configure description from the passed configurationprotected I18nizableText
configureLabel(Configuration configuration, String defaultCatalogue)
Configure label from the passed configurationprotected Map<String,CMSTag>
configureTags(Configuration configuration, CMSTag parent, String defaultCatalogue)
Configure tag from the passed configurationprotected void
createOrUpdateTags(DefaultTraversableAmetysObject<?> parent, Map<String,CMSTag> tags, Map<String,Object> contextualParameters)
Save or update a tagprotected Configuration
initializeTags(String path)
Initialize a configuration tags from the tags file.void
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
_getCurrentUser
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_ALLOWED_EXTENSIONS
private static final String[] _ALLOWED_EXTENSIONS
-
_tagProviderExtPt
protected TagProviderExtensionPoint _tagProviderExtPt
The tag provider extension point
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_targetTypeEP
protected TagTargetTypeExtensionPoint _targetTypeEP
Target types
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSon Utils Component
-
_createdTagsCount
private int _createdTagsCount
The count of new tags
-
_updatedTagsCount
private int _updatedTagsCount
The count of updated tags
-
_errorCount
private int _errorCount
The count of error
-
-
Constructor Detail
-
ImportTagsAction
public ImportTagsAction()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractNotifierAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
- Throws:
Exception
-
createOrUpdateTags
protected void createOrUpdateTags(DefaultTraversableAmetysObject<?> parent, Map<String,CMSTag> tags, Map<String,Object> contextualParameters)
Save or update a tag- Parameters:
parent
- the JCR parent tag or providertags
- the list of tags to add or updatecontextualParameters
- Contextual parameters transmitted by the environment.
-
initializeTags
protected Configuration initializeTags(String path) throws Exception
Initialize a configuration tags from the tags file.- Parameters:
path
- the path of the file to initialize tags.- Returns:
- The configuration
- Throws:
Exception
- if an error occurs.
-
configureTags
protected Map<String,CMSTag> configureTags(Configuration configuration, CMSTag parent, String defaultCatalogue) throws ConfigurationException
Configure tag from the passed configuration- Parameters:
configuration
- The configurationparent
- The parent tag if anydefaultCatalogue
- The default catalogue for i18n- Returns:
- a Set of
CMSTag
- Throws:
ConfigurationException
- If an error occurred
-
configureLabel
protected I18nizableText configureLabel(Configuration configuration, String defaultCatalogue) throws ConfigurationException
Configure label from the passed configuration- Parameters:
configuration
- The configurationdefaultCatalogue
- The default catalogue- Returns:
- The label
- Throws:
ConfigurationException
- If an error occurred
-
configureDescription
protected I18nizableText configureDescription(Configuration configuration, String defaultCatalogue) throws ConfigurationException
Configure description from the passed configuration- Parameters:
configuration
- The configurationdefaultCatalogue
- The default catalogue- Returns:
- The description
- Throws:
ConfigurationException
- If an error occurred
-
_findUniqueName
private String _findUniqueName(String originalName, Map<String,Object> contextualParameters)
-
_hasTag
private boolean _hasTag(Set<TagProvider<CMSTag>> providers, String name, Map<String,Object> contextualParameters)
-
_getTagProviders
private Set<TagProvider<CMSTag>> _getTagProviders()
-
-