public final class Profile extends Object implements 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:
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(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.
Modifier and Type | Class and Description |
---|---|
class |
Profile.EnumParameter<T3>
Represents a parameter with an enumeration of allowed values.
|
class |
Profile.Parameter<T>
Represents parameters that can be used in the profile.groovy script.
|
class |
Profile.ParameterFactory
Factory class which groups methods used for creating new
Profile.Parameter . |
static class |
Profile.ParameterType<T>
Represents a
parameter type. |
static class |
Profile.ParameterValues
Profile.ParameterValuesProvider base implementation which can be used to pass profile parameter values. |
static interface |
Profile.ParameterValuesProvider
Interface used by the setup model to retrieve profile parameter values.
|
static interface |
Profile.SetupConfiguration
Represents the configuration of the setup associated to this profile.
|
Modifier and Type | Field and Description |
---|---|
static Pattern |
PROFILE_NAME_PATTERN
Defines characters allowed in a profile name.
|
static Path |
PROFILE_PARAMETERS_GROOVY_FILE
Relative path of the script file which profile parameters must be defined.
|
Modifier and Type | Method and Description |
---|---|
static Collection<Profile> |
availableProfiles()
Returns the setup profiles available within the running binaries path.
|
static Profile.SetupConfiguration |
buildInParameters(Setup<?> model)
Returns a new setup configuration object built from the provided setup model.
|
int |
compareTo(Profile other) |
boolean |
equals(Object obj) |
String |
getName()
Returns this profile name.
|
Path |
getPath()
Returns this profile path.
|
String |
getUserFriendlyName()
Returns this profile user friendly name.
|
com.forgerock.opendj.util.Version |
getVersion()
Returns this profile version.
|
int |
hashCode() |
Collection<Profile.Parameter<?>> |
loadParameterDefinitions()
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 |
parameters()
Entry point method to programmatically define profile parameters values.
|
void |
resolveParameterValues(Path installPath,
Profile.ParameterValuesProvider parameterValuesProvider)
Resolves this profile parameter values using the provided value provider.
|
void |
resolveParameterValues(Profile.SetupConfiguration setupConfig,
Profile.ParameterValuesProvider parameterValuesProvider)
Resolves this profile parameter values using the provided value provider.
|
String |
toString() |
public static final Pattern PROFILE_NAME_PATTERN
public static final Path PROFILE_PARAMETERS_GROOVY_FILE
public static Profile.ParameterValues parameters()
Profile.ParameterValues
returned object should be used as follow:
final SetupConfiguration = new SetupConfiguration() { ... } amCts.resolveParameterValues( setupConfiguration, parameters().set("parameterVariableName", parameterValue) .set("anotherParameter", "anotherValue");
Profile.ParameterValues
object for programmatically set parameter valuespublic static Profile.SetupConfiguration buildInParameters(Setup<?> model)
model
- A Setup
object representing the model from which the configuration should be retrievedProfile.SetupConfiguration
object built from the provided setup model
.public static Collection<Profile> availableProfiles()
profiles
available within the running binaries pathpublic static Profile newSetupProfile(String name, Path folder) throws com.forgerock.opendj.cli.ArgumentException
name
- A non null
nor blank string representing the setup profile namefolder
- A Path
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)setup profile
associated to the provided parameterscom.forgerock.opendj.cli.ArgumentException
- If the provided folder parameter does not reference a valid setup profile folderpublic int compareTo(Profile other)
compareTo
in interface Comparable<Profile>
public String getName()
profile
namepublic String getUserFriendlyName()
User friendly name should be written in a name.txt file at the profile folder root. If user friendly name cannot be retrieved, this method returns the profile ID (name:version)
LocalizableMessage
representing the profile user friendly namepublic com.forgerock.opendj.util.Version getVersion()
profile
version
public void resolveParameterValues(Path installPath, Profile.ParameterValuesProvider parameterValuesProvider) throws com.forgerock.opendj.cli.ArgumentException, SetupException
Profile parameters must be declared in the parameters.groovy script which must be located in the
profile directory.
Each parameter declaration must end with a call to Profile.Parameter.resolveValue()
. This
method will return the value provided by the parameterValuesProvider or the parameter default value if
no value can be retrieved for the parameter.
installPath
- Installation path of the server to setup which will be added as a build-in profile parameter.parameterValuesProvider
- A Profile.ParameterValuesProvider
used for resolving parameter valuescom.forgerock.opendj.cli.ArgumentException
- If an error occurs while resolving this profile parameter valuesSetupException
- If an error occurs while running the parameters.groovy scriptresolveParameterValues(SetupConfiguration, ParameterValuesProvider)
public Collection<Profile.Parameter<?>> loadParameterDefinitions() throws SetupException
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.
parameters
associated to this profileSetupException
- If an error occurs while running the parameters.groovy scriptresolveParameterValues(Path, ParameterValuesProvider)
,
resolveParameterValues(SetupConfiguration, ParameterValuesProvider)
public void resolveParameterValues(Profile.SetupConfiguration setupConfig, Profile.ParameterValuesProvider parameterValuesProvider) throws com.forgerock.opendj.cli.ArgumentException, SetupException
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 calling loadParameterDefinitions()
) before this method is not mandatory.
setupConfig
- All configuration parameter already collected to setup the server.parameterValuesProvider
- A Profile.ParameterValuesProvider
used for resolving parameter valuescom.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 parametersresolveParameterValues(Path, ParameterValuesProvider)
Copyright 2010-2022 ForgeRock AS.