Class PegaseSynchronizableContentsCollection
- java.lang.Object
-
- org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
-
- org.ametys.plugins.odfsync.pegase.PegaseSynchronizableContentsCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection
,Configurable
,Serviceable
public class PegaseSynchronizableContentsCollection extends AbstractSimpleSynchronizableContentsCollection
SCC for Pegase (COF).
-
-
Field Summary
Fields Modifier and Type Field Description protected CatalogsManager
_catalogsManager
The catalogs managerprotected Map<String,Set<String>>
_contentsChildren
Map to link contents to its children at the end of the processprotected Map<String,Integer>
_importedContents
List of imported contentsprotected JSONUtils
_jsonUtils
The JSON utilsprotected Map<String,Map<String,List<String>>>
_mappingByContentType
Mapping between metadata and columnsprotected String
_odfLang
Default language configured for ODFprotected Set<String>
_searchFields
Search fields to displayprotected Set<String>
_synchronizedContents
List of synchronized contents having differencesprotected Set<String>
_updatedRelationContents
List of updated contents by relation-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_contentHelper, _synchronizingContentOperatorEP
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentWorkflowHelper, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, SCC_UNIQUE_ID
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentDAO, _contentPrefix, _contentType, _contentTypeEP, _id, _initialActionId, _label, _languages, _modelId, _modelParamValues, _removalSync, _reportMails, _resolver, _restrictedField, _sccHelper, _searchModelConfiguration, _synchronizeActionId, _synchronizeExistingContentsOnly, _synchronizingContentOperator, _validateActionId, _validateAfterImport, _workflowName
-
Fields inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
COLLECTION_ID_DATA_NAME, RESULT_NB_CREATED_CONTENTS, RESULT_NB_DELETED_CONTENTS, RESULT_NB_NOT_CHANGED_CONTENTS, RESULT_NB_SYNCHRONIZED_CONTENTS
-
-
Constructor Summary
Constructors Constructor Description PegaseSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_fillContent(Map<String,List<Object>> remoteValues, ModifiableContent content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)
Fill the content with remote values.protected ModifiableContent
_getContent(String lang, String syncCode, String contentType)
Get the content from the synchronization code, the lang, the catalog and the content type.protected List<Expression>
_getExpressionsList(String lang, String idValue, String contentType)
Construct the query to retrieve the content.protected ModifiableContent
_getOrCreateContent(String lang, String idValue, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Get or create the content defined by the given parameters.protected Optional<ModifiableContent>
_importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Imports or synchronizes a content for a given languageprotected List<ModifiableContent>
_importOrSynchronizeContents(Map<String,Object> searchParams, boolean forceImport, org.slf4j.Logger logger)
Import or synchronize several contents from search params.protected ContentWorkflowDescription
_mapWorkflowDescription(String category)
Get the workflow description for the given category.protected ModifiableContent
_synchronizeContent(ModifiableContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)
Synchronize a content with remove values.protected Map<String,Object>
_transformRemoteValuesCardinality(Map<String,List<Object>> remoteValues, String obsoleteContentTypeId)
Transform the remote values to take each attribute cardinality into accountprotected void
configureDataSource(Configuration configuration)
Configure the data source parameters.protected void
configureSearchModel()
Configure the search model used by SCCSearchTool.protected String
getBaseUrl()
Get the Pegase base URLprotected String
getCatalog()
Get the catalog for import.protected String
getIdColumn()
Get the identifier JSON field.String
getIdField()
Get the path of metadata holding the unique identifierList<String>
getLanguages()
Get the languages handled by this collectionSet<String>
getLocalAndExternalFields(Map<String,Object> additionalParameters)
Get the path of tri-state fields (with local and external values)protected Map<String,Map<String,List<Object>>>
getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Search values and return the result organized by attributesprotected String
getStructureCode()
Get the structure code from Pegaseprotected String
getToken(CloseableHttpClient httpClient)
Get the token to log to Pegase APIprotected Map<String,Map<String,List<Object>>>
getTransformedRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)
Search values and return the result organized by attributes and transformed by theSynchronizingContentOperator
if exists.List<ModifiableContent>
importContent(String idValue, Map<String,Object> importParams, org.slf4j.Logger logger)
Import a content from remote values.protected Map<String,Map<String,Object>>
internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Search values and return the result without any treatment.protected Map<String,Object>
putIdParameter(String idValue)
Set search parameters for the ID value.void
service(ServiceManager manager)
void
synchronizeContent(ModifiableContent content, org.slf4j.Logger logger)
Synchronize a content with remove values.-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_editContent, _getContentsToRemove, _handleContent, _importContent, _importOrSynchronizeContent, _internalPopulate, _isHandled, _transformRemoteValues, configure, createContentAction, getAdditionalAttributeValues, getContent, getNotSynchronizedRelatedContentIds, getTotalCount, populate, search, updateSyncInformations, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_deleteContents, _getAdditionalInputsForContentCreation, _getContentPathQuery, _hasSomethingChanged, _isParamNotEmpty, _logSynchronizationResult, _removeEmptyParameters, createContentAction, deleteUnexistingContents, empty, getSynchronizationResult, sendErrorMail, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, configureStaticParams, getContentPrefix, getContentType, getId, getInitialActionId, getLabel, getParameterValues, getReportMails, getRestrictedField, getSearchModelConfiguration, getSynchronizeActionId, getSynchronizeCollectionModelId, getSynchronizingContentOperator, getValidateActionId, getWorkflowName, removalSync, synchronizeExistingContentsOnly, validateAfterImport
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
additionalCommonOperations, additionalImportOperations, additionalSynchronizeOperations, handleRightAssignmentContext
-
-
-
-
Field Detail
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSON utils
-
_catalogsManager
protected CatalogsManager _catalogsManager
The catalogs manager
-
_mappingByContentType
protected Map<String,Map<String,List<String>>> _mappingByContentType
Mapping between metadata and columns
-
_searchFields
protected Set<String> _searchFields
Search fields to display
-
_importedContents
protected Map<String,Integer> _importedContents
List of imported contents
-
_synchronizedContents
protected Set<String> _synchronizedContents
List of synchronized contents having differences
-
_updatedRelationContents
protected Set<String> _updatedRelationContents
List of updated contents by relation
-
_contentsChildren
protected Map<String,Set<String>> _contentsChildren
Map to link contents to its children at the end of the process
-
-
Constructor Detail
-
PegaseSynchronizableContentsCollection
public PegaseSynchronizableContentsCollection()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractSimpleSynchronizableContentsCollection
- Throws:
ServiceException
-
getIdField
public String getIdField()
Description copied from interface:SynchronizableContentsCollection
Get the path of metadata holding the unique identifier- Returns:
- the path to the metadata. Can be null.
-
getIdColumn
protected String getIdColumn()
Get the identifier JSON field.- Returns:
- the column id
-
getLocalAndExternalFields
public Set<String> getLocalAndExternalFields(Map<String,Object> additionalParameters)
Description copied from interface:SynchronizableContentsCollection
Get the path of tri-state fields (with local and external values)- Parameters:
additionalParameters
- Additional parameters- Returns:
- the synchronized fields
-
putIdParameter
protected Map<String,Object> putIdParameter(String idValue)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Set search parameters for the ID value.- Specified by:
putIdParameter
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- Value to search- Returns:
- Map with the search parameters
-
internalSearch
protected Map<String,Map<String,Object>> internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result without any treatment.- Specified by:
internalSearch
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
parameters
- Search parameters to restrict the searchoffset
- Begin of the searchlimit
- Number of resultssort
- Sort of results (ignored for LDAP results)logger
- The logger- Returns:
- Map of results without any treatment.
-
importContent
public List<ModifiableContent> importContent(String idValue, Map<String,Object> importParams, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollection
Import a content from remote values.- Specified by:
importContent
in interfaceSynchronizableContentsCollection
- Overrides:
importContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- Id (for import/synchronization) of the content to importimportParams
- Additional parameterslogger
- The logger- Returns:
- A list of created contents
- Throws:
Exception
- if an error occurs.
-
synchronizeContent
public void synchronizeContent(ModifiableContent content, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollection
Synchronize a content with remove values.- Specified by:
synchronizeContent
in interfaceSynchronizableContentsCollection
- Overrides:
synchronizeContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
content
- The content to synchronizelogger
- The logger- Throws:
Exception
- if an error occurs.
-
_importOrSynchronizeContents
protected List<ModifiableContent> _importOrSynchronizeContents(Map<String,Object> searchParams, boolean forceImport, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Import or synchronize several contents from search params.- Overrides:
_importOrSynchronizeContents
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
searchParams
- Search parametersforceImport
- To force import and ignoring the synchronize existing contents only optionlogger
- The logger- Returns:
- The
List
of imported or synchronizedModifiableContent
-
_mapWorkflowDescription
protected ContentWorkflowDescription _mapWorkflowDescription(String category)
Get the workflow description for the given category.- Parameters:
category
- The category- Returns:
- the matching workflow description
-
getRemoteValues
protected Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result organized by attributes- Specified by:
getRemoteValues
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
parameters
- Search parameters to restrict the searchlogger
- The logger- Returns:
- Map of results organized by attributes.
-
configureDataSource
protected void configureDataSource(Configuration configuration) throws ConfigurationException
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the data source parameters.- Specified by:
configureDataSource
in classAbstractStaticSynchronizableContentsCollection
- Parameters:
configuration
- Configuration to read- Throws:
ConfigurationException
- If an error occurs
-
configureSearchModel
protected void configureSearchModel()
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the search model used by SCCSearchTool.- Specified by:
configureSearchModel
in classAbstractStaticSynchronizableContentsCollection
-
getCatalog
protected String getCatalog()
Get the catalog for import.- Returns:
- the catalog
-
getBaseUrl
protected String getBaseUrl()
Get the Pegase base URL- Returns:
- the Pegase base URL
-
getStructureCode
protected String getStructureCode()
Get the structure code from Pegase- Returns:
- the structure code
-
getToken
protected String getToken(CloseableHttpClient httpClient) throws IOException
Get the token to log to Pegase API- Parameters:
httpClient
- Http client- Returns:
- a valid token
- Throws:
IOException
- if an error occurs
-
_getOrCreateContent
protected ModifiableContent _getOrCreateContent(String lang, String idValue, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger) throws Exception
Get or create the content defined by the given parameters.- Parameters:
lang
- The content languageidValue
- The synchronization coderemoteValues
- The remote valuesforceImport
-true
to force import (only on single import or unlimited global synchronization)logger
- The logger- Returns:
- the content
- Throws:
Exception
- if an error occurs
-
_getContent
protected ModifiableContent _getContent(String lang, String syncCode, String contentType)
Get the content from the synchronization code, the lang, the catalog and the content type.- Parameters:
lang
- The langsyncCode
- The synchronization codecontentType
- The content type- Returns:
- the retrieved content
-
_importOrSynchronizeContent
protected Optional<ModifiableContent> _importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Imports or synchronizes a content for a given language- Overrides:
_importOrSynchronizeContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- The unique identifier of the contentlang
- The language of content to import or synchronizeremoteValues
- The remote valuesforceImport
- To force import and ignoring the synchronize existing contents only optionlogger
- The logger- Returns:
- The imported or synchronized content
-
_synchronizeContent
protected ModifiableContent _synchronizeContent(ModifiableContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger) throws Exception
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Synchronize a content with remove values.- Overrides:
_synchronizeContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
content
- The content to synchronizeremoteValues
- Values to synchronizelogger
- The logger- Returns:
- The synchronized content
- Throws:
Exception
- if an error occurs
-
_fillContent
protected boolean _fillContent(Map<String,List<Object>> remoteValues, ModifiableContent content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger) throws Exception
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Fill the content with remote values.- Overrides:
_fillContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
remoteValues
- The remote valuescontent
- The content to synchronizeadditionalParameters
- Additional parameterscreate
-true
if content is creating, false if it is updatedlogger
- The logger- Returns:
true
if the content has been modified,false
otherwise- Throws:
Exception
- if an error occurs
-
getLanguages
public List<String> getLanguages()
Description copied from interface:SynchronizableContentsCollection
Get the languages handled by this collection- Specified by:
getLanguages
in interfaceSynchronizableContentsCollection
- Overrides:
getLanguages
in classAbstractStaticSynchronizableContentsCollection
- Returns:
- the list of language
-
_getExpressionsList
protected List<Expression> _getExpressionsList(String lang, String idValue, String contentType)
Description copied from class:AbstractSynchronizableContentsCollection
Construct the query to retrieve the content.- Overrides:
_getExpressionsList
in classAbstractSynchronizableContentsCollection
- Parameters:
lang
- LangidValue
- Synchronization valuecontentType
- Content type- Returns:
- The
List
ofExpression
-
getTransformedRemoteValues
protected Map<String,Map<String,List<Object>>> getTransformedRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result organized by attributes and transformed by theSynchronizingContentOperator
if exists.- Overrides:
getTransformedRemoteValues
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
searchParameters
- Search parameters to restrict the searchlogger
- The logger- Returns:
- Map of results organized by attributes.
-
_transformRemoteValuesCardinality
protected Map<String,Object> _transformRemoteValuesCardinality(Map<String,List<Object>> remoteValues, String obsoleteContentTypeId)
Description copied from class:AbstractStaticSynchronizableContentsCollection
Transform the remote values to take each attribute cardinality into account- Overrides:
_transformRemoteValuesCardinality
in classAbstractStaticSynchronizableContentsCollection
- Parameters:
remoteValues
- the remote valuesobsoleteContentTypeId
- the content type ID from which attributes come from- Returns:
- the transformed values
-
-