Class Profile
- All Implemented Interfaces:
Comparable<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 parameters to allow using properties in resource files (such as LDIF data),
parameter values must be provided using a Profile.ParameterValuesProvider object passed in argument of
resolveParameterValues(ExecutionContext, SetupConfiguration, ParameterValuesProvider) method.
Parameters can then be used in the profile.groovy script with their
variable 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 ClassesModifier and TypeClassDescriptionfinal classRepresents a parameter whose value is associated to a bind DN property in server configuration.final classRepresents a parameter whose value is a domain automatically converted into aDN object.static final classRepresents a constant defined in anenumeration parameter.final classRepresents a parameter with an enumeration of allowed constants.static enumRepresents when a profileruns.final classRepresents a parameter whose value is a remote server host and port.final 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.final classFactory class which groups methods used for creating newProfile.Parameter.static classProfile.ParameterValuesProviderbase implementation which can be used to pass profile parameter values.static interfaceInterface 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.final classRepresents a parameter whose value is a password.final classRepresents a parameter which contains aPathvalue.static interfaceRepresents the configuration of the setup associated to this profile.final classRepresents a parameter whose value is a string. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternDefines characters allowed in a profile name. -
Method Summary
Modifier and TypeMethodDescriptionReturns the setup profiles available within the running binaries path.Returns the setup profiles available within the running binaries path, sorted and grouped by user friendly names.intstatic voidcreateProfileVersionFile(Collection<Profile> profiles, Path instancePath) Creates a config/profile.version file in the provided instance path referencing provided profiles.booleangetName()Returns this profile name.getPath()Returns this profile path.Returns this profile user friendly name.com.forgerock.opendj.util.VersionReturns this profile version.inthashCode()booleanhasSameName(Profile profile) Returnstrueif this profile has the same name as the provided profile.Collection<Profile.Parameter<?,?>> 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.ParameterValuesEntry 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.toString()
-
Field Details
-
PROFILE_NAME_PATTERN
Defines characters allowed in a profile name.
-
-
Method Details
-
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
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
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
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
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Profile>
-
toString
-
hasSameName
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
Returns this profile name.- Returns:
- A string representing this
profilename
-
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
-
getPath
Returns this profile path. -
loadParameterDefinitions
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
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
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
-