Package org.ametys.core.user.population
Class UserPopulationDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.user.population.UserPopulationDAO
-
- All Implemented Interfaces:
LogEnabled
,Disposable
,Initializable
,Component
,Serviceable
public class UserPopulationDAO extends AbstractLogEnabled implements Component, Serviceable, Initializable, Disposable
DAO for accessingUserPopulation
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADMIN_POPULATION_ID
The id of the "admin" populationstatic String
ROLE
Avalon Rolestatic UserIdentity
SYSTEM_USER_IDENTITY
The id of the "user system" populationstatic String
SYSTEM_USER_LOGIN
The id of the "user system" login
-
Constructor Summary
Constructors Constructor Description UserPopulationDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
add(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
Adds a new populationMap<String,Object>
canRemove(String populationId)
Determines if a population can be removedvoid
dispose()
Map<String,Object>
edit(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
Edits the given population.Map<String,Object>
enable(String populationId, boolean enabled)
Enables/Disables the given populationUserPopulation
getAdminPopulation()
Gets the "admin" populationFile
getConfigurationFile()
Return the configuration file.Map<String,Object>
getEditionConfiguration()
Gets the configuration for creating/editing a user population.List<UserPopulation>
getEnabledUserPopulations(boolean withAdmin)
Gets all the enabled populations of this applicationSet<String>
getIgnoredPopulations()
Returns the id of population which have a fatal invalid configuration.Set<String>
getMisconfiguredPopulations()
Returns the id of population which have at least one user directory or one credential provider misconfigured These populations can be used by application.Map<String,Object>
getPopulationParameterValues(String id)
Gets the values of the parameters of the given populationUserPopulation
getUserPopulation(String id)
Gets a population with its id.Map<String,Object>
getUserPopulationAsJson(UserPopulation userPopulation)
Gets a population to JSON formatList<UserPopulation>
getUserPopulations(boolean includeAdminPopulation)
Gets all the populations of this applicationList<Object>
getUserPopulationsAsJson(boolean withAdmin)
Gets all the populations to JSON formatList<String>
getUserPopulationsIds()
Gets the list of the ids of all the population of the applicationvoid
initialize()
Map<String,Object>
isEnabled(String populationId)
Returns the enabled state of the given populationboolean
isValid(String populationId)
Determines if a population has a valid configurationMap<String,Object>
remove(String id)
Removes the given population.Map<String,Object>
remove(String id, boolean forceDeletion)
Removes the given population.void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
ADMIN_POPULATION_ID
public static final String ADMIN_POPULATION_ID
The id of the "admin" population- See Also:
- Constant Field Values
-
SYSTEM_USER_LOGIN
public static final String SYSTEM_USER_LOGIN
The id of the "user system" login- See Also:
- Constant Field Values
-
SYSTEM_USER_IDENTITY
public static final UserIdentity SYSTEM_USER_IDENTITY
The id of the "user system" population
-
-
Constructor Detail
-
UserPopulationDAO
public UserPopulationDAO()
-
-
Method Detail
-
initialize
public void initialize()
- Specified by:
initialize
in interfaceInitializable
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getUserPopulationsAsJson
public List<Object> getUserPopulationsAsJson(boolean withAdmin)
Gets all the populations to JSON format- Parameters:
withAdmin
- True to include the "admin" population- Returns:
- A list of object representing the
UserPopulation
s
-
getUserPopulationAsJson
public Map<String,Object> getUserPopulationAsJson(UserPopulation userPopulation)
Gets a population to JSON format- Parameters:
userPopulation
- The user population to get- Returns:
- An object representing a
UserPopulation
-
getUserPopulations
public List<UserPopulation> getUserPopulations(boolean includeAdminPopulation)
Gets all the populations of this application- Parameters:
includeAdminPopulation
- True to include the "admin" population- Returns:
- A list of
UserPopulation
-
getEnabledUserPopulations
public List<UserPopulation> getEnabledUserPopulations(boolean withAdmin)
Gets all the enabled populations of this application- Parameters:
withAdmin
- True to include the "admin" population- Returns:
- A list of enabled
UserPopulation
-
getUserPopulation
public UserPopulation getUserPopulation(String id)
Gets a population with its id.- Parameters:
id
- The id of the population- Returns:
- The
UserPopulation
, or null if not found
-
getUserPopulationsIds
public List<String> getUserPopulationsIds()
Gets the list of the ids of all the population of the application- Returns:
- The list of the ids of all the populations
-
getIgnoredPopulations
public Set<String> getIgnoredPopulations()
Returns the id of population which have a fatal invalid configuration. These populations can NOT be used by application.- Returns:
- The ignored populations
-
getMisconfiguredPopulations
public Set<String> getMisconfiguredPopulations()
Returns the id of population which have at least one user directory or one credential provider misconfigured These populations can be used by application.- Returns:
- The misconfigured populations.
-
getConfigurationFile
public File getConfigurationFile()
Return the configuration file.- Returns:
- the configuration file.
-
getEditionConfiguration
public Map<String,Object> getEditionConfiguration() throws Exception
Gets the configuration for creating/editing a user population.- Returns:
- A map containing information about what is needed to create/edit a user population
- Throws:
Exception
- If an error occurs.
-
getPopulationParameterValues
public Map<String,Object> getPopulationParameterValues(String id)
Gets the values of the parameters of the given population- Parameters:
id
- The id of the population- Returns:
- The values of the parameters
-
getAdminPopulation
public UserPopulation getAdminPopulation()
Gets the "admin" population- Returns:
- The "admin" population
-
add
public Map<String,Object> add(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
Adds a new population- Parameters:
id
- The unique id of the populationlabel
- The label of the populationuserDirectories
- A list of user directory parameterscredentialProviders
- A list of credential provider parameters- Returns:
- A map containing the id of the created population, or the kind of error that occured
-
edit
public Map<String,Object> edit(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
Edits the given population.- Parameters:
id
- The id of the population to editlabel
- The label of the populationuserDirectories
- A list of user directory parameterscredentialProviders
- A list of credential provider parameters- Returns:
- A map containing the id of the edited population, or the kind of error that occured
-
remove
public Map<String,Object> remove(String id)
Removes the given population.- Parameters:
id
- The id of the population to remove- Returns:
- A map containing the id of the removed population
-
remove
public Map<String,Object> remove(String id, boolean forceDeletion)
Removes the given population.- Parameters:
id
- The id of the population to removeforceDeletion
- Delete the population even if it is still in use- Returns:
- A map containing the id of the removed population
-
enable
public Map<String,Object> enable(String populationId, boolean enabled)
Enables/Disables the given population- Parameters:
populationId
- The id of the population to enable/disableenabled
- True to enable the population, false to disable it.- Returns:
- A map containing the id of the enabled/disabled population, or with an error.
-
isValid
public boolean isValid(String populationId)
Determines if a population has a valid configuration- Parameters:
populationId
- The id of the population to retrieve state- Returns:
- A map, with the response as a boolean, or an error.
-
isEnabled
public Map<String,Object> isEnabled(String populationId)
Returns the enabled state of the given population- Parameters:
populationId
- The id of the population to retrieve state- Returns:
- A map, with the response as a booolean, or an error.
-
canRemove
public Map<String,Object> canRemove(String populationId)
Determines if a population can be removed- Parameters:
populationId
- The id of the population- Returns:
- A map, with the response as a boolean, or an error.
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
-