Package org.ametys.plugins.odfsync.cdmfr
Class CDMFrSynchronizableContentsCollection
- java.lang.Object
-
- org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
-
- org.ametys.plugins.odfsync.cdmfr.AbstractCDMFrSynchronizableContentsCollection
-
- org.ametys.plugins.odfsync.cdmfr.CDMFrSynchronizableContentsCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection,Configurable,Contextualizable,Serviceable
public class CDMFrSynchronizableContentsCollection extends AbstractCDMFrSynchronizableContentsCollection implements Contextualizable
Class for CDMFr import and synchronization
-
-
Field Summary
Fields Modifier and Type Field Description protected static String__PARAM_FOLDERData source parameter : folderprotected File_cdmfrFolderCDM-fr folderprotected Context_cocoonContextThe Cocoon contextprivate static String_COLUMN_FILENAMEprivate static String_COLUMN_LAST_MODIFIEDprivate static String_COLUMN_LENGTHprivate static String_CRITERIA_FILENAMEprivate static String_CRITERIA_LAST_MODIFIED_AFTERprivate static String_CRITERIA_LAST_MODIFIED_BEFOREprivate static Map<String,Comparator<File>>_NAME_TO_COMPARATORprotected String_odfLangDefault language configured for ODFprotected Set<String>_updatedContentsList of synchronized contents (to avoid a treatment twice or more)-
Fields inherited from class org.ametys.plugins.odfsync.cdmfr.AbstractCDMFrSynchronizableContentsCollection
_importCDMFrComponent
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentDAO, _contentTypeEP, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, _resolver, _synchroComponent, SCC_UNIQUE_ID
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentPrefix, _contentType, _id, _initialActionId, _label, _languages, _modelId, _modelParamValues, _removalSync, _reportMails, _restrictedField, _searchModelConfiguration, _synchronizeActionId, _synchronizeExistingContentsOnly, _synchronizingContentOperator, _validateActionId, _validateAfterImport, _workflowName
-
Fields inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
COLLECTION_ID_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description CDMFrSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Content>_getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)Filter the contents to remove.protected Map<String,Object>_handleFile(File cdmfrFile, Map<String,Object> parameters, org.slf4j.Logger logger)Handle the CDM-fr file to import all the programs and its dependencies containing into it.protected List<ModifiableDefaultContent>_internalPopulate(org.slf4j.Logger logger)Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)private File[]_sortFiles(File[] files, List<Object> sortList)voidconfigure(Configuration configuration)protected voidconfigureDataSource(Configuration configuration)Configure the data source parameters.protected voidconfigureSearchModel()Configure the search model used by SCCSearchTool.protected voidconfigureSpecificParameters()Configure the specific parameters of this implementation of CDM-fr import.voidcontextualize(Context context)ModifiableDefaultContentgetContent(String lang, String idValue)Gets the content in the repositoryintgetTotalCount(Map<String,Object> parameters, org.slf4j.Logger logger)Return the total number of results for the search.booleanhandleRightAssignmentContext()Return true if aRightAssignmentContextshould be automatically generated for the contents of this SCCList<ModifiableDefaultContent>importContent(String idValue, Map<String,Object> additionalParameters, org.slf4j.Logger logger)Import a content from remote values.protected File[]internalSearch(Map<String,Object> parameters, org.slf4j.Logger logger)Search values and return the result without any treatment.Map<String,Map<String,Object>>search(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)Search the data to import from parameters.voidsynchronizeContent(ModifiableDefaultContent content, org.slf4j.Logger logger)Synchronize a content with remove values.voidupdateSyncInformations(ModifiableDefaultContent content, String syncCode, org.slf4j.Logger logger)Method to update the synchronisation informations (collection and value of the ID field).-
Methods inherited from class org.ametys.plugins.odfsync.cdmfr.AbstractCDMFrSynchronizableContentsCollection
getExternalOnlyFields, getIdField, getLocalAndExternalFields, service
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_getContentPathQuery, _getExpressionsList, _getMetadataHolder, _isParamNotEmpty, _removeEmptyParameters, _removeMetadataIfExists, _synchronizeMetadata, _updateRelation, _updateRelation, applyChanges, applyChanges, createContentAction, deleteUnexistingContents, populate, sendErrorMail, updateSCCProperty, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, configureStaticParams, getContentPrefix, getContentType, getId, getInitialActionId, getLabel, getLanguages, getParameterValues, getReportMails, getRestrictedField, getSearchModelConfiguration, getSynchronizeActionId, getSynchronizeCollectionModelId, getSynchronizingContentOperator, getValidateActionId, getWorkflowName, removalSync, synchronizeExistingContentsOnly, validateAfterImport
-
-
-
-
Field Detail
-
__PARAM_FOLDER
protected static final String __PARAM_FOLDER
Data source parameter : folder- See Also:
- Constant Field Values
-
_CRITERIA_FILENAME
private static final String _CRITERIA_FILENAME
- See Also:
- Constant Field Values
-
_CRITERIA_LAST_MODIFIED_AFTER
private static final String _CRITERIA_LAST_MODIFIED_AFTER
- See Also:
- Constant Field Values
-
_CRITERIA_LAST_MODIFIED_BEFORE
private static final String _CRITERIA_LAST_MODIFIED_BEFORE
- See Also:
- Constant Field Values
-
_COLUMN_FILENAME
private static final String _COLUMN_FILENAME
- See Also:
- Constant Field Values
-
_COLUMN_LAST_MODIFIED
private static final String _COLUMN_LAST_MODIFIED
- See Also:
- Constant Field Values
-
_COLUMN_LENGTH
private static final String _COLUMN_LENGTH
- See Also:
- Constant Field Values
-
_NAME_TO_COMPARATOR
private static final Map<String,Comparator<File>> _NAME_TO_COMPARATOR
-
_cocoonContext
protected Context _cocoonContext
The Cocoon context
-
_cdmfrFolder
protected File _cdmfrFolder
CDM-fr folder
-
_updatedContents
protected Set<String> _updatedContents
List of synchronized contents (to avoid a treatment twice or more)
-
-
Constructor Detail
-
CDMFrSynchronizableContentsCollection
public CDMFrSynchronizableContentsCollection()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classAbstractStaticSynchronizableContentsCollection- Throws:
ConfigurationException
-
_internalPopulate
protected List<ModifiableDefaultContent> _internalPopulate(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollectionInternal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)- Overrides:
_internalPopulatein classAbstractCDMFrSynchronizableContentsCollection- Parameters:
logger- The logger- Returns:
- The list of created/synchronized contents
-
importContent
public List<ModifiableDefaultContent> importContent(String idValue, Map<String,Object> additionalParameters, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionImport a content from remote values.- Specified by:
importContentin interfaceSynchronizableContentsCollection- Parameters:
idValue- Id (for import/synchronization) of the content to importadditionalParameters- Additional parameterslogger- The logger- Returns:
- A list of created contents
- Throws:
Exception- if an error occurs.
-
_handleFile
protected Map<String,Object> _handleFile(File cdmfrFile, Map<String,Object> parameters, org.slf4j.Logger logger)
Handle the CDM-fr file to import all the programs and its dependencies containing into it.- Parameters:
cdmfrFile- The CDM-fr fileparameters- Parameters used to import the filelogger- The logger- Returns:
- The list of imported/synchronized programs
-
search
public Map<String,Map<String,Object>> search(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionSearch the data to import from parameters.- Specified by:
searchin interfaceSynchronizableContentsCollection- Overrides:
searchin classAbstractCDMFrSynchronizableContentsCollection- Parameters:
parameters- Parameters for the searchoffset- Begin of the searchlimit- Number of resultssort- Sort of results (ignored for LDAP results)logger- The logger- Returns:
- A map of remote values by content
-
getTotalCount
public int getTotalCount(Map<String,Object> parameters, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionReturn the total number of results for the search.- Specified by:
getTotalCountin interfaceSynchronizableContentsCollection- Overrides:
getTotalCountin classAbstractCDMFrSynchronizableContentsCollection- Parameters:
parameters- Parameters for the searchlogger- The logger- Returns:
- The total count
-
_sortFiles
private File[] _sortFiles(File[] files, List<Object> sortList)
-
internalSearch
protected File[] internalSearch(Map<String,Object> parameters, org.slf4j.Logger logger)
Search values and return the result without any treatment.- Parameters:
parameters- Search parameters to restrict the searchlogger- The logger- Returns:
Filetab listing the available CDM-fr files corresponding to the filter.
-
configureDataSource
protected void configureDataSource(Configuration configuration) throws ConfigurationException
Description copied from class:AbstractStaticSynchronizableContentsCollectionConfigure the data source parameters.- Overrides:
configureDataSourcein classAbstractCDMFrSynchronizableContentsCollection- Parameters:
configuration- Configuration to read- Throws:
ConfigurationException- If an error occurs
-
configureSpecificParameters
protected void configureSpecificParameters()
Configure the specific parameters of this implementation of CDM-fr import.
-
configureSearchModel
protected void configureSearchModel()
Description copied from class:AbstractStaticSynchronizableContentsCollectionConfigure the search model used by SCCSearchTool.- Overrides:
configureSearchModelin classAbstractCDMFrSynchronizableContentsCollection
-
updateSyncInformations
public void updateSyncInformations(ModifiableDefaultContent content, String syncCode, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionMethod to update the synchronisation informations (collection and value of the ID field).- Specified by:
updateSyncInformationsin interfaceSynchronizableContentsCollection- Overrides:
updateSyncInformationsin classAbstractCDMFrSynchronizableContentsCollection- Parameters:
content- Content to updatesyncCode- New synchronization codelogger- The logger- Throws:
Exception- if an error occurs.
-
synchronizeContent
public void synchronizeContent(ModifiableDefaultContent content, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionSynchronize a content with remove values.- Specified by:
synchronizeContentin interfaceSynchronizableContentsCollection- Overrides:
synchronizeContentin classAbstractCDMFrSynchronizableContentsCollection- Parameters:
content- The content to synchronizelogger- The logger- Throws:
Exception- if an error occurs.
-
getContent
public ModifiableDefaultContent getContent(String lang, String idValue)
Description copied from interface:SynchronizableContentsCollectionGets the content in the repository- Specified by:
getContentin interfaceSynchronizableContentsCollection- Overrides:
getContentin classAbstractCDMFrSynchronizableContentsCollection- Parameters:
lang- the languageidValue- the content name- Returns:
- the content in the repository, or null if does not exist
-
handleRightAssignmentContext
public boolean handleRightAssignmentContext()
Description copied from interface:SynchronizableContentsCollectionReturn true if aRightAssignmentContextshould be automatically generated for the contents of this SCC- Specified by:
handleRightAssignmentContextin interfaceSynchronizableContentsCollection- Returns:
- true to automatically generate a
RightAssignmentContext. Return false if the rights of contents of this SCC are handle by its ownRightAssignmentContext
-
_getContentsToRemove
protected List<Content> _getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)
Description copied from class:AbstractSynchronizableContentsCollectionFilter the contents to remove.- Overrides:
_getContentsToRemovein classAbstractCDMFrSynchronizableContentsCollection- Parameters:
contents- The list of all the available contents- Returns:
- The
ListofContentto remove.
-
-