public abstract class AbstractDataSourceManager extends AbstractLogEnabled implements Component, Initializable, Serviceable, Disposable
Modifier and Type | Class and Description |
---|---|
static class |
AbstractDataSourceManager.DataSourceDefinition
This class represents the definition of a data source
|
Modifier and Type | Field and Description |
---|---|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
private DataSourceConsumerExtensionPoint |
_dataSourceConsumerEP |
protected Map<String,AbstractDataSourceManager.DataSourceDefinition> |
_dataSourcesDef
The data source definitions
|
private long |
_lastUpdate |
protected ObservationManager |
_observationManager
The observation manager
|
static String |
DEFAULT_DATASOURCE_SUFFIX
The suffix of any default data source
|
Constructor and Description |
---|
AbstractDataSourceManager() |
Modifier and Type | Method and Description |
---|---|
AbstractDataSourceManager.DataSourceDefinition |
add(I18nizableText name,
I18nizableText description,
Map<String,Object> parameters,
boolean isPrivate)
Add a data source
|
protected void |
checkDataSources()
Check that the used data sources are indeed available
|
abstract void |
checkParameters(Map<String,Object> parameters)
Checks the parameters of a data source
|
protected abstract void |
createDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
Creates a data source from its configuration
|
void |
delete(Collection<String> dataSourceIds,
boolean forceDeletion)
Delete data sources
|
protected abstract void |
deleteDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
Deletes a data source
|
void |
dispose() |
protected abstract Map<String,AbstractDataSourceManager.DataSourceDefinition> |
doReadConfiguration(File file)
Actually read configuration.
|
AbstractDataSourceManager.DataSourceDefinition |
edit(String id,
I18nizableText name,
I18nizableText description,
Map<String,Object> parameters,
boolean isPrivate)
Edit a data source
|
protected abstract void |
editDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
Edit a data source from its configuration
|
AbstractDataSourceManager.DataSourceDefinition |
getDataSourceDefinition(String id)
Get the data source definition or null if not found
|
Map<String,AbstractDataSourceManager.DataSourceDefinition> |
getDataSourceDefinitions(boolean includePrivate,
boolean includeInternal,
boolean includeDefault)
Get the data source definitions
|
protected abstract String |
getDataSourcePrefixId()
Get the prefix for data source identifier
|
AbstractDataSourceManager.DataSourceDefinition |
getDefaultDataSourceDefinition()
Get the default data source for this type
|
String |
getDefaultDataSourceId()
Get the id of the default data source
|
abstract File |
getFileConfiguration()
Get the file configuration of data sources
|
void |
initialize() |
protected abstract void |
internalSetDefaultDataSource()
Set a default data source internally
|
protected void |
readConfiguration()
Read and update the data sources configuration
|
protected void |
saveConfiguration()
Save the configured data sources
|
protected void |
saxDataSource(ContentHandler handler,
AbstractDataSourceManager.DataSourceDefinition dataSource)
SAX an instance of data source
|
void |
service(ServiceManager serviceManager) |
AbstractDataSourceManager.DataSourceDefinition |
setDefaultDataSource(String id)
Set the data source with the given id as the default data source
|
getLogger, setLogger
public static final String DEFAULT_DATASOURCE_SUFFIX
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected Map<String,AbstractDataSourceManager.DataSourceDefinition> _dataSourcesDef
private long _lastUpdate
private DataSourceConsumerExtensionPoint _dataSourceConsumerEP
public AbstractDataSourceManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize() throws Exception
initialize
in interface Initializable
Exception
public abstract File getFileConfiguration()
protected abstract String getDataSourcePrefixId()
public abstract void checkParameters(Map<String,Object> parameters) throws ItemCheckerTestFailureException
parameters
- the parameters of the data sourceItemCheckerTestFailureException
- if the test failedprotected abstract void createDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
dataSource
- the data source configurationprotected abstract void editDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
dataSource
- the data source configurationprotected abstract void deleteDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
dataSource
- the data source configurationprotected abstract void internalSetDefaultDataSource()
public Map<String,AbstractDataSourceManager.DataSourceDefinition> getDataSourceDefinitions(boolean includePrivate, boolean includeInternal, boolean includeDefault)
includePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sources. Not used by default.includeDefault
- true to include an additional data source definition for each default data sourcepublic AbstractDataSourceManager.DataSourceDefinition getDataSourceDefinition(String id)
id
- the id of data sourcepublic AbstractDataSourceManager.DataSourceDefinition add(I18nizableText name, I18nizableText description, Map<String,Object> parameters, boolean isPrivate)
name
- the namedescription
- the descriptionparameters
- the parametersisPrivate
- true if privatepublic AbstractDataSourceManager.DataSourceDefinition edit(String id, I18nizableText name, I18nizableText description, Map<String,Object> parameters, boolean isPrivate)
id
- the idname
- the namedescription
- the descriptionparameters
- the parametersisPrivate
- true if privatepublic void delete(Collection<String> dataSourceIds, boolean forceDeletion)
dataSourceIds
- the ids of the data sources to deleteforceDeletion
- Force the remove event the datasource seems to be in usepublic AbstractDataSourceManager.DataSourceDefinition setDefaultDataSource(String id)
id
- the id of the data sourceAbstractDataSourceManager.DataSourceDefinition
of the data source set as defaultpublic AbstractDataSourceManager.DataSourceDefinition getDefaultDataSourceDefinition()
public String getDefaultDataSourceId()
protected final void readConfiguration()
protected abstract Map<String,AbstractDataSourceManager.DataSourceDefinition> doReadConfiguration(File file)
file
- the definitions file.protected void saveConfiguration()
protected void saxDataSource(ContentHandler handler, AbstractDataSourceManager.DataSourceDefinition dataSource) throws SAXException
handler
- the content handler to sax intodataSource
- the data sourceSAXException
- if an error occurred while SAXingprotected void checkDataSources()
public void dispose()
dispose
in interface Disposable