Modifier and Type | Method and Description |
---|---|
static String |
addWordBreaks(String htmlString,
int from,
int spacing)
Adds word break tags to the provided html string.
|
static boolean |
areDnsEqual(String dn1,
String dn2)
Returns
true if the the provided strings represent the same DN
and false otherwise. |
static String |
breakHtmlString(CharSequence cs,
int maxll)
Inserts HTML break tags into
d breaking it up so that ideally
no line is longer than maxll assuming no single word is longer
then maxll . |
static boolean |
canUseAsPort(int port)
Returns
true if the provided port is free and we can use it,
false otherwise. |
static void |
checkJavaVersion()
Checks that the java version we are running is compatible with OpenDS.
|
static boolean |
containsHtml(String text)
Tests a text string to see if it contains HTML.
|
static String |
convertHtmlBreakToLineSeparator(String s)
Converts existing HTML break tags to native line separators.
|
static boolean |
createDirectory(File f)
Creates the a directory in the provided path.
|
static boolean |
createDirectory(String path)
Creates the a directory in the provided path.
|
static boolean |
createFile(File f)
Creates a new file attempting to create the parent directories if
necessary.
|
static void |
createFile(File path,
InputStream is)
Creates a file on the specified path with the contents of the provided
stream.
|
static void |
createProtectedFile(String path,
String content)
Creates a file on the specified path with the contents of the provided
String.
|
static InitialLdapContext |
createStartTLSContext(String ldapsURL,
String dn,
String pwd,
int timeout,
Hashtable<String,String> env,
TrustManager trustManager,
HostnameVerifier verifier)
Creates an LDAP+StartTLS connection and returns the corresponding
LdapContext.
|
static boolean |
directoryExistsAndIsNotEmpty(String path)
Returns
true if the the provided path is a directory, exists
and is not empty false otherwise. |
static String |
escapeCommandLineValue(String value)
This method simply takes a value and tries to transform it (with escape or
'"') characters so that it can be used in a command line.
|
static boolean |
fileExists(String path)
Returns
true if the the provided path is a file and exists and
false otherwise. |
static int |
getCommandLineMaxLineWidth()
Returns the max size in character of a line to be displayed in the command
line.
|
static <T> T |
getCustomizedObject(String fieldName,
T defaultValue,
Class<T> valueClass)
Tries to find a customized object in the customization class.
|
static String |
getDataDisplayString(UserData userInstallData)
Returns the localized string describing the DataOptions chosen by the user.
|
static String |
getDefaultServerLocation()
Returns the default server location that will be proposed to the user in
the installation.
|
static List<List<String>> |
getDsConfigReplicationEnableEquivalentCommandLines(UserData userData)
Returns the equivalent dsconfig command-line required to configure the
first replicated server in the topology.
|
static List<List<String>> |
getDsReplicationEquivalentCommandLines(String subcommand,
UserData userData)
Returns the list of equivalent command-lines that must be executed to
enable or initialize replication as the setup does.
|
static org.opends.quicksetup.util.EmptyPrintStream |
getEmptyPrintStream()
Returns a printstream that does not write anything to standard output.
|
static String |
getFileSystemPermissions(File file)
Returns the file system permissions for a file.
|
static String |
getFormattedEquivalentCommandLine(List<String> cmd,
ProgressMessageFormatter formatter)
Returns a String representation of the provided command-line.
|
static String |
getHtml(String text)
Returns the HTML representation for a given text.
|
static String |
getInstallPathFromClasspath()
Returns the path of the installation of the directory server.
|
static String |
getInstancePathFromInstallPath(String installPath)
Returns the path of the installation of the directory server.
|
static LocalizableMessage |
getMessage(TopologyCacheException te)
Gets a localized representation of the provide TopologyCacheException.
|
static LocalizableMessage |
getMessageForException(NamingException ne)
Returns a message object for the given NamingException.
|
static LocalizableMessage |
getMessageFromCollection(Collection<LocalizableMessage> col,
String separator)
This is a helper method that gets a LocalizableMessage representation of
the elements in the Collection of Messages.
|
static int |
getNumberZipEntries()
Returns the number of entries contained in the zip file.
|
static String |
getPath(File f)
Returns the absolute path for the given file.
|
static String |
getPath(String parentPath,
String relativePath)
Returns the absolute path for the given parentPath and relativePath.
|
static String |
getScriptPath(String script)
Returns the String that can be used to launch an script using Runtime.exec.
|
static String |
getSecurityOptionsString(SecurityOptions ops,
boolean html)
Returns a localized String representation of the provided SecurityOptions
object.
|
static long |
getServerClock(InitialLdapContext ctx)
Returns the current time of a server in milliseconds.
|
static List<String> |
getSetupEquivalentCommandLine(UserData userData)
Returns the equivalent setup CLI command-line.
|
static boolean |
hasEnoughSpace(String directoryPath,
long bytes)
Returns
true if there is more disk space in the provided path
than what is specified with the bytes parameter. |
static boolean |
insureParentsExist(File f)
Creates the parent directory if it does not already exist.
|
static boolean |
isCli()
Returns
true if this is executed from command line and
false otherwise. |
static boolean |
isConfigurationDn(String dn)
Returns
true if the the provided string is a configuration DN
and false otherwise. |
static boolean |
isDescendant(File descendant,
File path)
Returns
true if the first provided path is under the second
path in the file system. |
static boolean |
isLocalHost(String host)
Basic method to know if the host is local or not.
|
static boolean |
isPrivilegedPort(int port)
Returns
true if the provided port is a privileged port,
false otherwise. |
static String |
listToString(List<?> list,
String separator,
String prefix,
String suffix)
Creates a string consisting of the string representation of the elements in
the
list separated by separator . |
static boolean |
parentDirectoryExists(String path)
Returns
true if the parent directory for the provided path
exists and false otherwise. |
static void |
setMacOSXMenuBar(LocalizableMessage appName)
Puts Swing menus in the Mac OS menu bar, if using the Aqua look and feel,
and sets the application name that is displayed in the application menu and
in the dock.
|
static int |
setPermissionsUnix(ArrayList<String> paths,
String permissions)
Sets the permissions of the provided paths with the provided permission
String.
|
static int |
setPermissionsUnix(String path,
String permissions)
Sets the permissions of the provided paths with the provided permission
String.
|
static String |
stripHtml(String s)
Strips any potential HTML markup from a given string.
|
static boolean |
supportsOption(String option,
String javaHome,
String installPath)
Tells whether the provided java installation supports a given option or
not.
|
public static boolean canUseAsPort(int port)
true
if the provided port is free and we can use it,
false
otherwise.port
- the port we are analyzing.true
if the provided port is free and we can use it,
false
otherwise.public static boolean isPrivilegedPort(int port)
true
if the provided port is a privileged port,
false
otherwise.port
- the port we are analyzing.true
if the provided port is a privileged port,
false
otherwise.public static boolean supportsOption(String option, String javaHome, String installPath)
javaHome
- the java installation path.option
- the java option that we want to check.installPath
- the install path of the server.true
if the provided java installation supports a
given option and false
otherwise.public static boolean createFile(File f) throws IOException
f
- File to createIOException
- if something goes wrongpublic static String getPath(String parentPath, String relativePath)
parentPath
- the parent path.relativePath
- the relative path.public static String getScriptPath(String script)
script
- the script namepublic static String getPath(File f)
f
- File to get the pathpublic static boolean isDescendant(File descendant, File path)
true
if the first provided path is under the second
path in the file system.descendant
- the descendant candidate path.path
- the path.true
if the first provided path is under the second
path in the file system; false
otherwise or if either
of the files are nullpublic static boolean parentDirectoryExists(String path)
true
if the parent directory for the provided path
exists and false
otherwise.path
- the path that we are analyzing.true
if the parent directory for the provided path
exists and false
otherwise.public static boolean fileExists(String path)
true
if the the provided path is a file and exists and
false
otherwise.path
- the path that we are analyzing.true
if the the provided path is a file and exists and
false
otherwise.public static boolean directoryExistsAndIsNotEmpty(String path)
true
if the the provided path is a directory, exists
and is not empty false
otherwise.path
- the path that we are analyzing.true
if the the provided path is a directory, exists
and is not empty false
otherwise.public static boolean isConfigurationDn(String dn)
true
if the the provided string is a configuration DN
and false
otherwise.dn
- the String we are analyzing.true
if the the provided string is a configuration DN
and false
otherwise.public static boolean areDnsEqual(String dn1, String dn2)
true
if the the provided strings represent the same DN
and false
otherwise.dn1
- the first dn to compare.dn2
- the second dn to compare.true
if the the provided strings represent the same DN
and false
otherwise.public static boolean insureParentsExist(File f)
f
- File for which parentage will be insuredf
has a
parent after this method is invoked.public static boolean createDirectory(String path) throws IOException
path
- the path.true
if the path was created or already existed (and
was a directory) and false
otherwise.IOException
- if something goes wrong.public static boolean createDirectory(File f) throws IOException
f
- the path.true
if the path was created or already existed (and
was a directory) and false
otherwise.IOException
- if something goes wrong.public static void createFile(File path, InputStream is) throws IOException
path
- the path where the file will be created.is
- the InputStream with the contents of the file.IOException
- if something goes wrong.public static void createProtectedFile(String path, String content) throws IOException, InterruptedException
path
- the path where the file will be created.content
- the String with the contents of the file.IOException
- if something goes wrong.InterruptedException
- if there is a problem changing the permissions of the file.public static LocalizableMessage getMessageFromCollection(Collection<LocalizableMessage> col, String separator)
col
- the collection containing the messages.separator
- the separator String to be used.col
is nullpublic static String getDefaultServerLocation()
public static boolean hasEnoughSpace(String directoryPath, long bytes)
true
if there is more disk space in the provided path
than what is specified with the bytes parameter.directoryPath
- the path.bytes
- the disk space.true
if there is more disk space in the provided path
than what is specified with the bytes parameter.public static LocalizableMessage getMessage(TopologyCacheException te)
te
- the exception.public static int setPermissionsUnix(ArrayList<String> paths, String permissions) throws IOException, InterruptedException
paths
- the paths to set permissions on.permissions
- the UNIX-mode file system permission representation (for example
"644" or "755")IOException
- if something goes wrong.InterruptedException
- if the Runtime.exec method is interrupted.public static int setPermissionsUnix(String path, String permissions) throws IOException, InterruptedException
path
- to set permissions on.permissions
- the UNIX-mode file system permission representation (for example
"644" or "755")IOException
- if something goes wrong.InterruptedException
- if the Runtime.exec method is interrupted.public static boolean isCli()
true
if this is executed from command line and
false
otherwise.true
if this is executed from command line and
false
otherwise.public static InitialLdapContext createStartTLSContext(String ldapsURL, String dn, String pwd, int timeout, Hashtable<String,String> env, TrustManager trustManager, HostnameVerifier verifier) throws NamingException
ldapsURL
- the target *LDAPS* URL.dn
- passed as Context.SECURITY_PRINCIPAL if not null.pwd
- passed as Context.SECURITY_CREDENTIALS if not null.timeout
- passed as com.sun.jndi.ldap.connect.timeout if > 0.env
- null or additional environment properties.trustManager
- null or the trust manager to be invoked during SSL. negociation.verifier
- null or the hostname verifier to be setup in the StartTlsResponse.NamingException
- the exception thrown when instantiating InitialLdapContext.Context
,
InitialLdapContext
,
StartTlsRequest
,
StartTlsResponse
,
TrustedSocketFactory
public static LocalizableMessage getMessageForException(NamingException ne)
ne
- the NamingException.public static String getInstallPathFromClasspath()
public static String getInstancePathFromInstallPath(String installPath)
installPath
- The installation pathpublic static int getCommandLineMaxLineWidth()
public static void setMacOSXMenuBar(LocalizableMessage appName)
appName
- application name to display in the menu bar and the dock.public static int getNumberZipEntries()
public static String listToString(List<?> list, String separator, String prefix, String suffix)
list
separated by separator
.list
- the list to printseparator
- to use in separating elementsprefix
- prepended to each individual element in the list before adding to
the returned string.suffix
- appended to each individual element in the list before adding to
the returned string.public static String getFileSystemPermissions(File file)
file
- the file for which we want the file permissions.public static String breakHtmlString(CharSequence cs, int maxll)
d
breaking it up so that ideally
no line is longer than maxll
assuming no single word is longer
then maxll
. If the string already contains HTML tags that
cause a line break (e.g break and closing list item tags) they are
respected by this method when calculating where to place new breaks to
control the maximum line length.cs
- String to breakmaxll
- int maximum line lengthd
with HTML break tags insertedpublic static String convertHtmlBreakToLineSeparator(String s)
s
- string to convertpublic static String stripHtml(String s)
s
- string to strippublic static boolean containsHtml(String text)
text
- String to testpublic static org.opends.quicksetup.util.EmptyPrintStream getEmptyPrintStream()
public static long getServerClock(InitialLdapContext ctx)
ctx
- the connection to the server.public static void checkJavaVersion() throws IncompatibleVersionException
IncompatibleVersionException
- if the java version we are running is not compatible with OpenDS.public static boolean isLocalHost(String host)
host
- the host to analyze.true
if it is the local host and false
otherwise.public static String getHtml(String text)
text
- the source text from which we want to get the HTML
representationpublic static <T> T getCustomizedObject(String fieldName, T defaultValue, Class<T> valueClass)
T
- the type of the customized object.fieldName
- the name of the field representing an object in the customization
class.defaultValue
- the default value.valueClass
- the class of the parametrized value.public static String addWordBreaks(String htmlString, int from, int spacing)
htmlString
- the string.from
- the first index to start the spacing from.spacing
- the minimal spacing between word breaks.public static String getDataDisplayString(UserData userInstallData)
userInstallData
- the DataOptions of the user.public static String getSecurityOptionsString(SecurityOptions ops, boolean html)
ops
- the SecurityOptions object from which we want to obtain the String
representation.html
- whether the resulting String must be in HTML or not.public static String getFormattedEquivalentCommandLine(List<String> cmd, ProgressMessageFormatter formatter)
cmd
- the command-line arguments.formatter
- the formatted to be used to create the String representation.public static String escapeCommandLineValue(String value)
value
- the String to be treated.public static List<String> getSetupEquivalentCommandLine(UserData userData)
userData
- the user data.public static List<List<String>> getDsReplicationEquivalentCommandLines(String subcommand, UserData userData)
subcommand
- either "enable"
or "initialize"
userData
- the user data.public static List<List<String>> getDsConfigReplicationEnableEquivalentCommandLines(UserData userData)
userData
- the user data.Copyright © 2010-2016 ForgeRock AS. All Rights Reserved.