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_catalogsManagerThe catalogs managerprotected Map<String,Set<String>>_contentsChildrenMap to link contents to its children at the end of the processprotected Map<String,Integer>_importedContentsList of imported contentsprotected JSONUtils_jsonUtilsThe JSON utilsprotected Map<String,Map<String,List<String>>>_mappingByContentTypeMapping between metadata and columnsprotected String_odfLangDefault language configured for ODFprotected Set<String>_searchFieldsSearch fields to displayprotected Set<String>_synchronizedContentsList of synchronized contents having differencesprotected Set<String>_updatedRelationContentsList 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 voidconfigureDataSource(Configuration configuration)Configure the data source parameters.protected voidconfigureSearchModel()Configure the search model used by SCCSearchTool.protected StringgetBaseUrl()Get the Pegase base URLprotected StringgetCatalog()Get the catalog for import.protected StringgetIdColumn()Get the identifier JSON field.StringgetIdField()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 StringgetStructureCode()Get the structure code from Pegaseprotected StringgetToken(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 theSynchronizingContentOperatorif 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.voidservice(ServiceManager manager)voidsynchronizeContent(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:
servicein interfaceServiceable- Overrides:
servicein classAbstractSimpleSynchronizableContentsCollection- Throws:
ServiceException
-
getIdField
public String getIdField()
Description copied from interface:SynchronizableContentsCollectionGet 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:SynchronizableContentsCollectionGet 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:AbstractSimpleSynchronizableContentsCollectionSet search parameters for the ID value.- Specified by:
putIdParameterin 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:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result without any treatment.- Specified by:
internalSearchin 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:SynchronizableContentsCollectionImport a content from remote values.- Specified by:
importContentin interfaceSynchronizableContentsCollection- Overrides:
importContentin 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:SynchronizableContentsCollectionSynchronize a content with remove values.- Specified by:
synchronizeContentin interfaceSynchronizableContentsCollection- Overrides:
synchronizeContentin 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:AbstractSimpleSynchronizableContentsCollectionImport or synchronize several contents from search params.- Overrides:
_importOrSynchronizeContentsin classAbstractSimpleSynchronizableContentsCollection- Parameters:
searchParams- Search parametersforceImport- To force import and ignoring the synchronize existing contents only optionlogger- The logger- Returns:
- The
Listof 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:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result organized by attributes- Specified by:
getRemoteValuesin 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:AbstractStaticSynchronizableContentsCollectionConfigure the data source parameters.- Specified by:
configureDataSourcein classAbstractStaticSynchronizableContentsCollection- Parameters:
configuration- Configuration to read- Throws:
ConfigurationException- If an error occurs
-
configureSearchModel
protected void configureSearchModel()
Description copied from class:AbstractStaticSynchronizableContentsCollectionConfigure the search model used by SCCSearchTool.- Specified by:
configureSearchModelin 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-trueto 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:AbstractSimpleSynchronizableContentsCollectionImports or synchronizes a content for a given language- Overrides:
_importOrSynchronizeContentin 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:AbstractSimpleSynchronizableContentsCollectionSynchronize a content with remove values.- Overrides:
_synchronizeContentin 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:AbstractSimpleSynchronizableContentsCollectionFill the content with remote values.- Overrides:
_fillContentin classAbstractSimpleSynchronizableContentsCollection- Parameters:
remoteValues- The remote valuescontent- The content to synchronizeadditionalParameters- Additional parameterscreate-trueif content is creating, false if it is updatedlogger- The logger- Returns:
trueif the content has been modified,falseotherwise- Throws:
Exception- if an error occurs
-
getLanguages
public List<String> getLanguages()
Description copied from interface:SynchronizableContentsCollectionGet the languages handled by this collection- Specified by:
getLanguagesin interfaceSynchronizableContentsCollection- Overrides:
getLanguagesin classAbstractStaticSynchronizableContentsCollection- Returns:
- the list of language
-
_getExpressionsList
protected List<Expression> _getExpressionsList(String lang, String idValue, String contentType)
Description copied from class:AbstractSynchronizableContentsCollectionConstruct the query to retrieve the content.- Overrides:
_getExpressionsListin classAbstractSynchronizableContentsCollection- Parameters:
lang- LangidValue- Synchronization valuecontentType- Content type- Returns:
- The
ListofExpression
-
getTransformedRemoteValues
protected Map<String,Map<String,List<Object>>> getTransformedRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result organized by attributes and transformed by theSynchronizingContentOperatorif exists.- Overrides:
getTransformedRemoteValuesin 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:AbstractStaticSynchronizableContentsCollectionTransform the remote values to take each attribute cardinality into account- Overrides:
_transformRemoteValuesCardinalityin classAbstractStaticSynchronizableContentsCollection- Parameters:
remoteValues- the remote valuesobsoleteContentTypeId- the content type ID from which attributes come from- Returns:
- the transformed values
-
-