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_FILE
private ContentTypeExtensionPoint
_contentTypeEP
private Context
_context
private LanguagesManager
_languagesManager
private long
_lastFileReading
private LDAPDataSourceManager
_ldapDataSourceManager
private ServiceManager
_smanager
private SQLDataSourceManager
_sqlDataSourceManager
private SynchronizeContentsCollectionModelExtensionPoint
_syncCollectionModelEP
private Map<String,SynchronizableContentsCollection>
_synchronizableCollections
private SynchronizingContentOperatorExtensionPoint
_synchronizingContentOperatorEP
private UserDirectoryFactory
_userDirectoryFactory
private UserPopulationDAO
_userPopulationDAO
private WorkflowProvider
_workflowProvider
static String
ROLE
Avalon 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:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in 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
null
if 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:
dispose
in interfaceDisposable
-
-