Class Profile
- java.lang.Object
-
- org.forgerock.opendj.setup.model.Profile
-
- All Implemented Interfaces:
Comparable<Profile>
public final class Profile extends Object implements Comparable<Profile>
Represents a setup profile.Goal of setup profile is to allow a highly customizable setup of a directory server instance.
A setup profile is uniquely identified by its name and its version (e.g am-cts and 6.5). It uses groovy script for collecting parameters (parameters.groovy) and executing actions (profile.groovy. Executed by the setup tool, the profile script provides a domain specific language to allow to easily:
- Create a backend
- Import initial LDIF data in the backend
- Add custom schema into the directory server
- Create indexes
- Rebuild indexes
- Run
dsconfigtool to perform other configuration actions
Setup profile use
parametersto allow using properties in resource files (such as LDIF data), parameter values must be provided using aProfile.ParameterValuesProviderobject passed in argument ofresolveParameterValues(ExecutionContext, SetupConfiguration, ParameterValuesProvider)method. Parameters can then be used in the profile.groovy script with theirvariable names.Setup profile actions are all run in offline mode, if setup tool should start the server, it will be started after the profile.groovy script execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classProfile.DnParameterRepresents a parameter whose value is associated to a bind DN property in server configuration.classProfile.DomainParameterRepresents a parameter whose value is a domain automatically converted into aDN object.static classProfile.EnumConstant<T3>Represents a constant defined in anenumeration parameter.classProfile.EnumParameter<T3>Represents a parameter with an enumeration of allowed constants.static classProfile.ExecutionContextRepresents when a profileruns.classProfile.HostPortParameterRepresents a parameter whose value is a remote server host and port.classProfile.NumberParameter<N extends Number>Represents a parameter whose value is a number.classProfile.Parameter<P extends Profile.Parameter<P,T>,T>Represents parameters that are defined in parameters.groovy and can be used in the profile.groovy script.classProfile.ParameterFactoryFactory class which groups methods used for creating newProfile.Parameter.static classProfile.ParameterValuesProfile.ParameterValuesProviderbase implementation which can be used to pass profile parameter values.static interfaceProfile.ParameterValuesProviderInterface used by the setup model to retrieve profile parameter values.static interfaceProfile.ParameterVisitor<R,P,E extends Exception>A visitor ofparameters, in the style of the visitor design pattern.classProfile.PasswordParameterRepresents a parameter whose value is a password.classProfile.PathParameterRepresents a parameter which contains aPathvalue.static interfaceProfile.SetupConfigurationRepresents the configuration of the setup associated to this profile.classProfile.StringParameterRepresents a parameter whose value is a string.
-
Field Summary
Fields Modifier and Type Field Description static PatternPROFILE_NAME_PATTERNDefines characters allowed in a profile name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SortedSet<Profile>availableProfiles()Returns the setup profiles available within the running binaries path.static SortedMap<String,SortedSet<Profile>>availableProfilesGroupedByFriendlyName()Returns the setup profiles available within the running binaries path, sorted and grouped by user friendly names.intcompareTo(Profile other)static voidcreateProfileVersionFile(Collection<Profile> profiles, Path instancePath)Creates a config/profile.version file in the provided instance path referencing provided profiles.booleanequals(Object obj)StringgetName()Returns this profile name.PathgetPath()Returns this profile path.StringgetUserFriendlyName()Returns this profile user friendly name.com.forgerock.opendj.util.VersiongetVersion()Returns this profile version.inthashCode()booleanhasSameName(Profile profile)Returnstrueif this profile has the same name as the provided profile.Collection<Profile.Parameter<?,?>>loadParameterDefinitions()Returns all parameters associated to this profile.static ProfilenewSetupProfile(String name, Path folder)Creates and returns a new setup profile associated to the provided parameters.static Profile.ParameterValuesparameters()Entry point method to programmatically define profile parameters values.static voidrejectIfContainsDuplicatedProfiles(Collection<Profile> profiles)Ensures that provided profiles collection does not contain one (or more) profile(s) with the same name.voidresolveParameterValues(Profile.ExecutionContext context, Profile.SetupConfiguration setupConfig, Profile.ParameterValuesProvider parameterValuesProvider)Resolves this profile parameter values using the provided value provider.voidrun(Path configFilePath, SetupConsole console)Runs this profile.StringtoString()
-
-
-
Field Detail
-
PROFILE_NAME_PATTERN
public static final Pattern PROFILE_NAME_PATTERN
Defines characters allowed in a profile name.
-
-
Method Detail
-
createProfileVersionFile
public static void createProfileVersionFile(Collection<Profile> profiles, Path instancePath) throws SetupException
Creates a config/profile.version file in the provided instance path referencing provided profiles.- Parameters:
profiles- Collection of profiles to register into the fileinstancePath- Path of the server instance where the file should be created- Throws:
SetupException- If any errors occur while writing the file
-
rejectIfContainsDuplicatedProfiles
public static void rejectIfContainsDuplicatedProfiles(Collection<Profile> profiles) throws com.forgerock.opendj.cli.ArgumentException
Ensures that provided profiles collection does not contain one (or more) profile(s) with the same name.- Parameters:
profiles- Collection ofsetup profilesto test- Throws:
com.forgerock.opendj.cli.ArgumentException- If the provided collection contains profiles with thesame name
-
parameters
public static Profile.ParameterValues parameters()
Entry point method to programmatically define profile parameters values.Profile.ParameterValuesreturned object should be used as follow:final SetupConfiguration = new SetupConfiguration() { ... } amCts.resolveParameterValues( setupConfiguration, parameters().set("parameterVariableName", parameterValue) .set("anotherParameter", "anotherValue");- Returns:
- a
Profile.ParameterValuesobject for programmatically set parameter values
-
availableProfiles
public static SortedSet<Profile> availableProfiles()
Returns the setup profiles available within the running binaries path.Returned profiles are sorted by name first, then by most recent version.
- Returns:
- the setup
profilesavailable within the running binaries path
-
availableProfilesGroupedByFriendlyName
public static SortedMap<String,SortedSet<Profile>> availableProfilesGroupedByFriendlyName()
Returns the setup profiles available within the running binaries path, sorted and grouped by user friendly names.Returned profile map keys (profile name) are sorted alphabetically, associated values (profile sets) are sorted by most recent version.
- Returns:
- the setup
profilesavailable within the running binaries path, sorted and grouped by user friendly names
-
newSetupProfile
public static Profile newSetupProfile(String name, Path folder) throws com.forgerock.opendj.cli.ArgumentException
Creates and returns a new setup profile associated to the provided parameters.- Parameters:
name- A nonnullnor blank string representing the setup profile namefolder- APathrepresenting the setup profile folder. Last folder of this path must represent the profile version (e.g /path/to/profile/6.0.0, /path/to/profile/6-5)- Returns:
- A new
setup profileassociated to the provided parameters - Throws:
com.forgerock.opendj.cli.ArgumentException- If the provided folder parameter does not reference a valid setup profile folder
-
compareTo
public int compareTo(Profile other)
- Specified by:
compareToin interfaceComparable<Profile>
-
hasSameName
public boolean hasSameName(Profile profile)
Returnstrueif this profile has the same name as the provided profile.Note that
equals(Object)method checks for both the name and the version.- Parameters:
profile-Profileto test- Returns:
trueif this profile has the same name as the provided profile,falseotherwise
-
getName
public String getName()
Returns this profile name.- Returns:
- A string representing this
profilename
-
getUserFriendlyName
public String getUserFriendlyName()
Returns this profile user friendly name.User friendly name should be written in a name.txt file in the profile folder or its parent. If user friendly name cannot be retrieved, this method returns the profile ID (name:version)
- Returns:
- A
LocalizableMessagerepresenting the profile user friendly name
-
getVersion
public com.forgerock.opendj.util.Version getVersion()
Returns this profile version.- Returns:
- This
profileversion
-
loadParameterDefinitions
public Collection<Profile.Parameter<?,?>> loadParameterDefinitions() throws SetupException
Returns all parameters associated to this profile.Profile parameters must be declared in the parameters.groovy script which must be located in the profile directory.
This method will run the parameters.groovy script and will load in memory all parameter definitions, regardless whether they are enabled.
This method does not resolve parameter values.- Returns:
- A collection containing all
parametersassociated to this profile - Throws:
SetupException- If an error occurs while running the parameters.groovy script- See Also:
resolveParameterValues(ExecutionContext, SetupConfiguration, ParameterValuesProvider)
-
resolveParameterValues
public void resolveParameterValues(Profile.ExecutionContext context, Profile.SetupConfiguration setupConfig, Profile.ParameterValuesProvider parameterValuesProvider) throws com.forgerock.opendj.cli.ArgumentException, SetupException
Resolves this profile parameter values using the provided value provider.Profile parameters must be declared in the parameters.groovy script which must be located in the profile directory.
This method always try to load parameter definitions before resolving their values (i.e callingloadParameterDefinitions()) before this method is not mandatory.- Parameters:
context- Whether the resolution happens during setup or post setupsetupConfig- All configuration parameter already collected to setup the server.
Each parameter will be added as build-in profile parameterparameterValuesProvider- AProfile.ParameterValuesProviderused for resolving parameter values- Throws:
com.forgerock.opendj.cli.ArgumentException- If an error occurs while resolving this profile parameter valuesSetupException- If an error occurs while running the parameters.groovy script while loading parameters
-
run
public void run(Path configFilePath, SetupConsole console) throws SetupException
Runs this profile.This profile parameter values must have been
resolvedbefore this method is called.- Parameters:
configFilePath- Configuration file path of the server on which the profile should be runconsole- Console to be used by this profile to report logs and errors- Throws:
SetupException- If an error occurs during this profile execution
-
-