Class SynchronizableContentsCollectionDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollectionDAO
-
- All Implemented Interfaces:
LogEnabled,Disposable,Initializable,Component,Contextualizable,Serviceable
public class SynchronizableContentsCollectionDAO extends AbstractLogEnabled implements Component, Serviceable, Initializable, Contextualizable, Disposable
DAO for accessingSynchronizableContentsCollection
-
-
Field Summary
Fields Modifier and Type Field Description private static File__CONFIGURATION_FILEprivate ContentTypeExtensionPoint_contentTypeEPprivate Context_contextprivate LanguagesManager_languagesManagerprivate long_lastFileReadingprivate LDAPDataSourceManager_ldapDataSourceManagerprivate ServiceManager_smanagerprivate SQLDataSourceManager_sqlDataSourceManagerprivate SynchronizeContentsCollectionModelExtensionPoint_syncCollectionModelEPprivate Map<String,SynchronizableContentsCollection>_synchronizableCollectionsprivate SynchronizingContentOperatorExtensionPoint_synchronizingContentOperatorEPprivate UserDirectoryFactory_userDirectoryFactoryprivate UserPopulationDAO_userPopulationDAOprivate WorkflowProvider_workflowProviderstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description SynchronizableContentsCollectionDAO()
-
Method Summary
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__CONFIGURATION_FILE
private static File __CONFIGURATION_FILE
-
_synchronizableCollections
private Map<String,SynchronizableContentsCollection> _synchronizableCollections
-
_lastFileReading
private long _lastFileReading
-
_syncCollectionModelEP
private SynchronizeContentsCollectionModelExtensionPoint _syncCollectionModelEP
-
_contentTypeEP
private ContentTypeExtensionPoint _contentTypeEP
-
_userPopulationDAO
private UserPopulationDAO _userPopulationDAO
-
_userDirectoryFactory
private UserDirectoryFactory _userDirectoryFactory
-
_workflowProvider
private WorkflowProvider _workflowProvider
-
_synchronizingContentOperatorEP
private SynchronizingContentOperatorExtensionPoint _synchronizingContentOperatorEP
-
_languagesManager
private LanguagesManager _languagesManager
-
_smanager
private ServiceManager _smanager
-
_sqlDataSourceManager
private SQLDataSourceManager _sqlDataSourceManager
-
_ldapDataSourceManager
private LDAPDataSourceManager _ldapDataSourceManager
-
-
Constructor Detail
-
SynchronizableContentsCollectionDAO
public SynchronizableContentsCollectionDAO()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
_getSQLDataSourceManager
private SQLDataSourceManager _getSQLDataSourceManager()
-
_getLDAPDataSourceManager
private LDAPDataSourceManager _getLDAPDataSourceManager()
-
getSynchronizableContentsCollectionAsJson
public Map<String,Object> getSynchronizableContentsCollectionAsJson(String collectionId)
Gets a synchronizable contents collection to JSON format- Parameters:
collectionId- The id of the synchronizable contents collection to get- Returns:
- An object representing a
SynchronizableContentsCollection
-
getSynchronizableContentsCollectionAsJson
public Map<String,Object> getSynchronizableContentsCollectionAsJson(SynchronizableContentsCollection collection)
Gets a synchronizable contents collection to JSON format- Parameters:
collection- The synchronizable contents collection to get- Returns:
- An object representing a
SynchronizableContentsCollection
-
getSynchronizableContentsCollections
public List<SynchronizableContentsCollection> getSynchronizableContentsCollections()
Get the synchronizable contents collections- Returns:
- the synchronizable contents collections
-
getSynchronizableContentsCollection
public SynchronizableContentsCollection getSynchronizableContentsCollection(String collectionId)
Get a synchronizable contents collection by its id- Parameters:
collectionId- The id of collection- Returns:
- the synchronizable contents collection or
nullif not found
-
_readFile
private void _readFile(boolean forceRead)
-
_createFile
private void _createFile(File file) throws IOException, TransformerConfigurationException, SAXException
-
_createSynchronizableCollection
private SynchronizableContentsCollection _createSynchronizableCollection(Configuration collectionConfig) throws ConfigurationException
- Throws:
ConfigurationException
-
getEditionConfiguration
public Map<String,Object> getEditionConfiguration() throws Exception
Gets the configuration for creating/editing a collection of synchronizable contents.- Returns:
- A map containing information about what is needed to create/edit a collection of synchronizable contents
- Throws:
Exception- If an error occurs.
-
_isValidContentType
private boolean _isValidContentType(ContentType cType)
-
getCollectionParameterValues
public Map<String,Object> getCollectionParameterValues(String collectionId)
Gets the values of the parameters of the given collection- Parameters:
collectionId- The id of the collection- Returns:
- The values of the parameters
-
getSupportedUserDirectories
public List<Map<String,Object>> getSupportedUserDirectories(String populationId)
Gets the supported user directories (i.e. user directories based on a datasource) of the population in a json map- Parameters:
populationId- The id of the user population- Returns:
- the supported user directories (i.e. user directories based on a datasource) of the population in a json map
-
_getDatasourceBasedUserDirectories
private List<String> _getDatasourceBasedUserDirectories(List<UserDirectory> userDirectories)
-
_writeFile
private boolean _writeFile()
-
_createBackup
private File _createBackup()
-
_restoreBackup
private void _restoreBackup(File backup, boolean errorOccured)
-
addCollection
public String addCollection(Map<String,Object> values) throws ProcessingException
Add a newSynchronizableContentsCollection- Parameters:
values- The parameters' values- Returns:
- The id of new created collection or null in case of error
- Throws:
ProcessingException- if creation failed
-
editCollection
public Map<String,Object> editCollection(String id, Map<String,Object> values) throws ProcessingException
- Parameters:
id- The id of collection to editvalues- The parameters' values- Returns:
- The id of new created collection or null in case of error
- Throws:
ProcessingException- if edition failed
-
_isValid
private boolean _isValid(SynchronizableContentsCollection collection)
-
_validateParameter
private boolean _validateParameter(Parameter param, SynchronizableContentsCollection collection)
-
_checkDataSource
private boolean _checkDataSource(String dataSourceId)
-
_addCollection
private boolean _addCollection(String id, Map<String,Object> values) throws FileNotFoundException, IOException, TransformerConfigurationException, SAXException
-
_getTransformerHandler
private TransformerHandler _getTransformerHandler(OutputStream os) throws TransformerConfigurationException
-
removeCollection
public Map<String,Object> removeCollection(String id)
Removes the given collection- Parameters:
id- The id of the collection to remove- Returns:
- A map containing the id of the removed collection, or an error
-
_generateUniqueId
private String _generateUniqueId(String label)
-
_toSAX
private void _toSAX(TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxCollection
private void _saxCollection(ContentHandler handler, String id, Map<String,Object> parameters) throws SAXException
- Throws:
SAXException
-
_saxLanguagesValue
private void _saxLanguagesValue(ContentHandler handler, Object languages) throws SAXException
- Throws:
SAXException
-
_saxCollection
private void _saxCollection(ContentHandler handler, SynchronizableContentsCollection collection) throws SAXException
- Throws:
SAXException
-
_saxNonNullValue
private void _saxNonNullValue(ContentHandler handler, String tagName, Object value) throws SAXException
- Throws:
SAXException
-
_saxModel
private void _saxModel(ContentHandler handler, String modelId, Map<String,Object> paramValues, boolean withPrefix) throws SAXException
- Throws:
SAXException
-
dispose
public void dispose()
- Specified by:
disposein interfaceDisposable
-
-