public class DataSourceClientInteraction extends AbstractLogEnabled implements Component, Serviceable
Modifier and Type | Class and Description |
---|---|
static class |
DataSourceClientInteraction.DataSourceType
Enum for data source types
|
Modifier and Type | Field and Description |
---|---|
private DataSourceConsumerExtensionPoint |
_dataSourceConsumerEP
The extension for data source clients
|
private I18nUtils |
_i18nUtils
Component gathering utility method allowing to handle internationalizable text
|
private LDAPDataSourceManager |
_ldapDataSourceManager
The LDAP data source manager
|
private SQLDataSourceManager |
_sqlDataSourceManager
The SQL data source manager
|
static String |
ROLE
The Avalon role
|
Constructor and Description |
---|
DataSourceClientInteraction() |
Modifier and Type | Method and Description |
---|---|
private Map<String,Object> |
_dataSourceDefinition2Json(String type,
AbstractDataSourceManager.DataSourceDefinition dataSourceDef) |
private boolean |
_isValid(String type,
Map<String,Object> parameters) |
private void |
_setDefaultDataSourceName(Map<String,Object> dataSourceAsJSON) |
Map<String,Object> |
addDataSource(String type,
Map<String,Object> parameters)
Add a data source
|
Map<String,Object> |
editDataSource(String type,
Map<String,Object> parameters)
Edit a data source
|
Map<String,Object> |
getDataSource(String type,
String id)
Get the ldap data source information
|
List<Map<String,Object>> |
getDataSources(boolean includePrivate,
boolean includeInternal,
boolean includeDefault)
Get the existing data sources regardless of their type
|
List<Map<String,Object>> |
getDataSources(DataSourceClientInteraction.DataSourceType dataSourceType,
boolean includePrivate,
boolean includeInternal,
boolean includeDefault,
List<String> allowedTypes)
Get the existing data sources
|
List<Map<String,Object>> |
getDataSources(String dataSourceType,
boolean includePrivate,
boolean includeInternal,
boolean includeDefault,
List<String> allowedTypes)
Get the existing data sources
|
Map<String,Object> |
getLDAPDataSource(String id)
Get the ldap data source information
|
Map<String,Object> |
getSQLDataSource(String id)
Get the sql data source information
|
void |
removeDataSource(String type,
List<String> ids)
Remove one or several data sources
|
void |
service(ServiceManager serviceManager) |
Map<String,Object> |
setDefaultDataSource(String type,
String id)
Set the data source of the given id as the default data source for the given type
|
getLogger, setLogger
private SQLDataSourceManager _sqlDataSourceManager
private LDAPDataSourceManager _ldapDataSourceManager
private DataSourceConsumerExtensionPoint _dataSourceConsumerEP
private I18nUtils _i18nUtils
public DataSourceClientInteraction()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public List<Map<String,Object>> getDataSources(DataSourceClientInteraction.DataSourceType dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) throws Exception
dataSourceType
- the data source type. Can be empty or null to get all data sourcesincludePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sourcesincludeDefault
- true to include the default data sourcesallowedTypes
- The sub-types of datasource allowed. Can be null. For now, this parameter is only used for sql data sources. The types are the type of databases (mysql, oarcle, ...)Exception
- if an error occurredpublic List<Map<String,Object>> getDataSources(String dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) throws Exception
dataSourceType
- the data source type. Can be empty or null to get all data sourcesincludePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sourcesincludeDefault
- true to include the default data sourcesallowedTypes
- The sub-types of datasource allowed. Can be null. For now, this parameter is only used for sql data sources. The types are the type of databases (mysql, oarcle, ...)Exception
- if an error occurredpublic List<Map<String,Object>> getDataSources(boolean includePrivate, boolean includeInternal, boolean includeDefault) throws Exception
includePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sourcesincludeDefault
- true to include default data sourcesException
- if an error occurredpublic Map<String,Object> getDataSource(String type, String id) throws Exception
type
- the data source's typeid
- The id the data sourceException
- if an error occurredpublic Map<String,Object> getLDAPDataSource(String id) throws Exception
id
- The id the data sourceException
- if an error occurredpublic Map<String,Object> getSQLDataSource(String id) throws Exception
id
- The id the data sourceException
- if an error occurredpublic Map<String,Object> addDataSource(String type, Map<String,Object> parameters) throws ProcessingException, ConfigurationException, SAXException, IOException
type
- The type of data sourceparameters
- The parameters of the data source to createIOException
- if an error occurredSAXException
- if an error occurredConfigurationException
- if an error occurredProcessingException
- if an error occurredpublic Map<String,Object> editDataSource(String type, Map<String,Object> parameters) throws ProcessingException, ConfigurationException, SAXException, IOException
type
- The type of data sourceparameters
- The parameters of the data source to editIOException
- if an error occurredSAXException
- if an error occurredConfigurationException
- if an error occurredProcessingException
- if an error occurredpublic void removeDataSource(String type, List<String> ids) throws ConfigurationException, SAXException, IOException, ProcessingException
type
- The type of data sourceids
- the ids of the data sources to removeIOException
- if an error occurred while reading configuration fileSAXException
- if an error occurred while parsing configuration fileConfigurationException
- if an error occurred while parsing configuration reading fileProcessingException
- if an error occurred while saving changespublic Map<String,Object> setDefaultDataSource(String type, String id)
type
- the type of the data sourceid
- the id of the data sourceAbstractDataSourceManager.DataSourceDefinition
of data source set as default in JSONprivate void _setDefaultDataSourceName(Map<String,Object> dataSourceAsJSON)
private Map<String,Object> _dataSourceDefinition2Json(String type, AbstractDataSourceManager.DataSourceDefinition dataSourceDef)