Package org.ametys.core.datasource
Class DataSourceClientInteraction
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.datasource.DataSourceClientInteraction
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class DataSourceClientInteraction
extends AbstractLogEnabled
implements Component, Serviceable
Component gathering manipulation methods for SQL and LDAP data sources
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum for data source types -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDataSource
(String type, Map<String, Object> parameters) Add a data sourceeditDataSource
(String type, Map<String, Object> parameters) Edit a data sourcegetDataSource
(String type, String id) Get the ldap data source informationgetDataSources
(boolean includePrivate, boolean includeInternal, boolean includeDefault) Get the existing data sources regardless of their typegetDataSources
(String dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) Get the existing data sourcesgetDataSources
(DataSourceClientInteraction.DataSourceType dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) Get the existing data sourcesGet the ldap data source informationGet the sql data source informationvoid
removeDataSource
(String type, List<String> ids) Remove one or several data sourcesvoid
service
(ServiceManager serviceManager) setDefaultDataSource
(String type, String id) Set the data source of the given id as the default data source for the given typeMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role
-
-
Constructor Details
-
DataSourceClientInteraction
public DataSourceClientInteraction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getDataSources
public List<Map<String,Object>> getDataSources(DataSourceClientInteraction.DataSourceType dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) throws Exception Get the existing data sources- Parameters:
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, ...)- Returns:
- the existing data sources
- Throws:
Exception
- if an error occurred
-
getDataSources
public List<Map<String,Object>> getDataSources(String dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes) throws Exception Get the existing data sources- Parameters:
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, ...)- Returns:
- the existing data sources
- Throws:
Exception
- if an error occurred
-
getDataSources
public List<Map<String,Object>> getDataSources(boolean includePrivate, boolean includeInternal, boolean includeDefault) throws Exception Get the existing data sources regardless of their type- Parameters:
includePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sourcesincludeDefault
- true to include default data sources- Returns:
- the existing data sources
- Throws:
Exception
- if an error occurred
-
getDataSource
Get the ldap data source information- Parameters:
type
- the data source's typeid
- The id the data source- Returns:
- The data source's information
- Throws:
Exception
- if an error occurred
-
getLDAPDataSource
Get the ldap data source information- Parameters:
id
- The id the data source- Returns:
- The data source's information
- Throws:
Exception
- if an error occurred
-
getSQLDataSource
Get the sql data source information- Parameters:
id
- The id the data source- Returns:
- The data source's information
- Throws:
Exception
- if an error occurred
-
addDataSource
public Map<String,Object> addDataSource(String type, Map<String, Object> parameters) throws ProcessingException, ConfigurationException, SAXException, IOExceptionAdd a data source- Parameters:
type
- The type of data sourceparameters
- The parameters of the data source to create- Returns:
- the created data source as JSON object
- Throws:
IOException
- if an error occurredSAXException
- if an error occurredConfigurationException
- if an error occurredProcessingException
- if an error occurred
-
editDataSource
public Map<String,Object> editDataSource(String type, Map<String, Object> parameters) throws ProcessingException, ConfigurationException, SAXException, IOExceptionEdit a data source- Parameters:
type
- The type of data sourceparameters
- The parameters of the data source to edit- Returns:
- the edited data source as JSON object
- Throws:
IOException
- if an error occurredSAXException
- if an error occurredConfigurationException
- if an error occurredProcessingException
- if an error occurred
-
removeDataSource
public void removeDataSource(String type, List<String> ids) throws ConfigurationException, SAXException, IOException, ProcessingException Remove one or several data sources- Parameters:
type
- The type of data sourceids
- the ids of the data sources to remove- Throws:
IOException
- 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 changes
-
setDefaultDataSource
Set the data source of the given id as the default data source for the given type- Parameters:
type
- the type of the data sourceid
- the id of the data source- Returns:
- the
AbstractDataSourceManager.DataSourceDefinition
of data source set as default in JSON
-