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
dsconfig
tool 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
Modifier and TypeClassDescriptionfinal class
Represents a parameter whose value is associated to a bind DN property in server configuration.final class
Represents a parameter whose value is a domain automatically converted into aDN object
.static final class
Represents a constant defined in anenumeration parameter
.final class
Represents a parameter with an enumeration of allowed constants.static enum
Represents when a profileruns
.final class
Represents a parameter whose value is a remote server host and port.final class
Profile.NumberParameter<N extends Number>
Represents a parameter whose value is a number.class
Profile.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 class
Factory class which groups methods used for creating newProfile.Parameter
.static class
Profile.ParameterValuesProvider
base implementation which can be used to pass profile parameter values.static interface
Interface used by the setup model to retrieve profile parameter values.static interface
Profile.ParameterVisitor<R,
P, E extends Exception> A visitor ofparameters
, in the style of the visitor design pattern.final class
Represents a parameter whose value is a password.final class
Represents a parameter which contains aPath
value.static interface
Represents the configuration of the setup associated to this profile.final class
Represents a parameter whose value is a string. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
Defines 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.int
static void
createProfileVersionFile
(Collection<Profile> profiles, Path instancePath) Creates a config/profile.version file in the provided instance path referencing provided profiles.boolean
getName()
Returns this profile name.getPath()
Returns this profile path.Returns this profile user friendly name.com.forgerock.opendj.util.Version
Returns this profile version.int
hashCode()
boolean
hasSameName
(Profile profile) Returnstrue
if this profile has the same name as the provided profile.Collection<Profile.Parameter<?,
?>> Returns all parameters associated to this profile.static Profile
newSetupProfile
(String name, Path folder) Creates and returns a new setup profile associated to the provided parameters.static Profile.ParameterValues
Entry point method to programmatically define profile parameters values.static void
rejectIfContainsDuplicatedProfiles
(Collection<Profile> profiles) Ensures that provided profiles collection does not contain one (or more) profile(s) with the same name.void
resolveParameterValues
(Profile.ExecutionContext context, Profile.SetupConfiguration setupConfig, Profile.ParameterValuesProvider parameterValuesProvider) Resolves this profile parameter values using the provided value provider.void
run
(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 profiles
to 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.ParameterValues
returned object should be used as follow:final SetupConfiguration = new SetupConfiguration() { ... } amCts.resolveParameterValues( setupConfiguration, parameters().set("parameterVariableName", parameterValue) .set("anotherParameter", "anotherValue");
- Returns:
- a
Profile.ParameterValues
object 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
profiles
available 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
profiles
available 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 nonnull
nor blank string representing the setup profile namefolder
- APath
representing 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 profile
associated 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:
compareTo
in interfaceComparable<Profile>
-
toString
-
hasSameName
Returnstrue
if 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
-Profile
to test- Returns:
true
if this profile has the same name as the provided profile,false
otherwise
-
getName
Returns this profile name.- Returns:
- A string representing this
profile
name
-
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
LocalizableMessage
representing the profile user friendly name
-
getVersion
public com.forgerock.opendj.util.Version getVersion()Returns this profile version.- Returns:
- This
profile
version
-
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
parameters
associated 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.ParameterValuesProvider
used 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
resolved
before 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
-