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
Nested Classes Modifier and Type Class Description static classDataSourceClientInteraction.DataSourceTypeEnum for data source types 
- 
Constructor Summary
Constructors Constructor Description DataSourceClientInteraction() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>addDataSource(String type, Map<String,Object> parameters)Add a data sourceMap<String,Object>editDataSource(String type, Map<String,Object> parameters)Edit a data sourceMap<String,Object>getDataSource(String type, String id)Get the ldap data source informationList<Map<String,Object>>getDataSources(boolean includePrivate, boolean includeInternal, boolean includeDefault)Get the existing data sources regardless of their typeList<Map<String,Object>>getDataSources(String dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes)Get the existing data sourcesList<Map<String,Object>>getDataSources(DataSourceClientInteraction.DataSourceType dataSourceType, boolean includePrivate, boolean includeInternal, boolean includeDefault, List<String> allowedTypes)Get the existing data sourcesMap<String,Object>getLDAPDataSource(String id)Get the ldap data source informationMap<String,Object>getSQLDataSource(String id)Get the sql data source informationvoidremoveDataSource(String type, List<String> ids)Remove one or several data sourcesvoidservice(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- 
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
DataSourceClientInteraction
public DataSourceClientInteraction()
 
 - 
 
- 
Method Detail
- 
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
 servicein 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
public Map<String,Object> getDataSource(String type, String id) throws Exception
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
public Map<String,Object> getLDAPDataSource(String id) throws Exception
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
public Map<String,Object> getSQLDataSource(String id) throws Exception
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, IOException
Add 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, IOException
Edit 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
public 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- Parameters:
 type- the type of the data sourceid- the id of the data source- Returns:
 - the 
AbstractDataSourceManager.DataSourceDefinitionof data source set as default in JSON 
 
 - 
 
 -