/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2013 ForgeRock AS
*/
/**
* This class provides some static convenience methods of different nature.
*
*/
public class Utils
{
private Utils()
{
}
/**
* The class name that contains the control panel customizations for
* products.
*/
"org.opends.server.util.ReleaseDefinition";
/**
* The service name required by the JNLP downloader.
*/
/**
* Returns <CODE>true</CODE> if the provided port is free and we can use it,
* <CODE>false</CODE> otherwise.
* @param port the port we are analyzing.
* @return <CODE>true</CODE> if the provided port is free and we can use it,
* <CODE>false</CODE> otherwise.
*/
{
}
/**
* Returns <CODE>true</CODE> if the provided port is a priviledged port,
* <CODE>false</CODE> otherwise.
* @param port the port we are analyzing.
* @return <CODE>true</CODE> if the provided port is a priviledged port,
* <CODE>false</CODE> otherwise.
*/
{
}
/**
* Tells whether the provided java installation supports a given option or
* not.
* @param javaHome the java installation path.
* @param option the java option that we want to check.
* @param installPath the install path of the server.
* @return <CODE>true</CODE> if the provided java installation supports a
* given option and <CODE>false</CODE> otherwise.
*/
{
boolean supported = false;
" are supported with java home: "+javaHome);
try
{
{
}
else
{
}
// In windows by default the scripts ask the user to click on enter when
// they fail. Set this environment variable to avoid it.
{
}
boolean errorDetected = false;
{
{
// If we are running windows, the process get blocked waiting for
// user input. Just wait for a certain time to print the output
// in the logger and then kill the process.
{
public void run()
{
try
{
// To see if the process is over, call the exitValue method.
// If it is not over, a IllegalThreadStateException.
}
catch (Throwable t)
{
}
}
});
t.start();
}
errorDetected = true;
}
}
}
catch (Throwable t)
{
}
return supported;
}
/**
* Creates a new file attempting to create the parent directories
* if necessary.
* @param f File to create
* @return boolean indicating whether the file was created; false otherwise
* @throws IOException if something goes wrong
*/
boolean success = false;
if (f != null) {
}
success = f.createNewFile();
}
return success;
}
/**
* Returns the absolute path for the given parentPath and relativePath.
* @param parentPath the parent path.
* @param relativePath the relative path.
* @return the absolute path for the given parentPath and relativePath.
*/
{
}
/**
* Returns the String that can be used to launch an script using Runtime.exec.
* This method is required because in Windows the script that contain a "="
* in their path must be quoted.
* @param script the script name
* @return the absolute path for the given parentPath and relativePath.
*/
{
}
/**
* Returns the absolute path for the given file. It tries to get the
* canonical file path. If it fails it returns the string representation.
* @param f File to get the path
* @return the absolute path for the given file.
*/
{
if (f != null) {
try
{
/*
* Do a best effort to avoid having a relative representation (for
* instance to avoid having ../../../).
*/
f = f.getCanonicalFile();
}
catch (IOException ioe)
{
/* This is a best effort to get the best possible representation of the
* file: reporting the error is not necessary.
*/
}
}
return path;
}
/**
* Returns <CODE>true</CODE> if the first provided path is under the second
* path in the file system.
* @param descendant the descendant candidate path.
* @param path the path.
* @return <CODE>true</CODE> if the first provided path is under the second
* path in the file system; <code>false</code> otherwise or if
* either of the files are null
*/
boolean isDescendant = false;
if (!isDescendant) {
}
}
}
return isDescendant;
}
/**
* Returns <CODE>true</CODE> if we are running under windows and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if we are running under windows and
* <CODE>false</CODE> otherwise.
*/
public static boolean isWindows()
{
return SetupUtils.isWindows();
}
/**
* Returns <CODE>true</CODE> if we are running under Mac OS and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if we are running under Mac OS and
* <CODE>false</CODE> otherwise.
*/
public static boolean isMacOS()
{
return SetupUtils.isMacOS();
}
/**
* Returns <CODE>true</CODE> if we are running under Unix and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if we are running under Unix and
* <CODE>false</CODE> otherwise.
*/
public static boolean isUnix()
{
return SetupUtils.isUnix();
}
/**
* Returns a String representation of the OS we are running.
* @return a String representation of the OS we are running.
*/
{
return SetupUtils.getOSString();
}
/**
* Returns <CODE>true</CODE> if the parent directory for the provided path
* exists and <CODE>false</CODE> otherwise.
* @param path the path that we are analyzing.
* @return <CODE>true</CODE> if the parent directory for the provided path
* exists and <CODE>false</CODE> otherwise.
*/
{
boolean parentExists = false;
if (parentFile != null)
{
}
return parentExists;
}
/**
* Returns <CODE>true</CODE> if the the provided path is a file and exists and
* <CODE>false</CODE> otherwise.
* @param path the path that we are analyzing.
* @return <CODE>true</CODE> if the the provided path is a file and exists and
* <CODE>false</CODE> otherwise.
*/
{
return f.isFile();
}
/**
* Returns <CODE>true</CODE> if the the provided path is a directory, exists
* and is not empty <CODE>false</CODE> otherwise.
* @param path the path that we are analyzing.
* @return <CODE>true</CODE> if the the provided path is a directory, exists
* and is not empty <CODE>false</CODE> otherwise.
*/
{
boolean directoryExistsAndIsNotEmpty = false;
if (f.isDirectory())
{
}
return directoryExistsAndIsNotEmpty;
}
/**
* Returns <CODE>true</CODE> if the the provided string is a DN and
* <CODE>false</CODE> otherwise.
* @param dn the String we are analyzing.
* @return <CODE>true</CODE> if the the provided string is a DN and
* <CODE>false</CODE> otherwise.
*/
{
boolean isDn = true;
try
{
{
isDn = false;
}
return isDn;
}
/**
* Returns <CODE>true</CODE> if the the provided string is a configuration DN
* and <CODE>false</CODE> otherwise.
* @param dn the String we are analyzing.
* @return <CODE>true</CODE> if the the provided string is a configuration DN
* and <CODE>false</CODE> otherwise.
*/
{
boolean isConfigurationDn = false;
{
}
return isConfigurationDn;
}
/**
* Returns <CODE>true</CODE> if the the provided strings represent the same
* DN and <CODE>false</CODE> otherwise.
* @param dn1 the first dn to compare.
* @param dn2 the second dn to compare.
* @return <CODE>true</CODE> if the the provided strings represent the same
* DN and <CODE>false</CODE> otherwise.
*/
{
boolean areDnsEqual = false;
try
{
// do nothing
}
return areDnsEqual;
}
/**
* Creates the parent directory if it does not already exist.
* @param f File for which parentage will be insured
* @return boolean indicating whether or not the input <code>f</code>
* has a parent after this method is invoked.
*/
if (!b) {
}
return b;
}
/**
* Returns <CODE>true</CODE> if we can write on the provided path and
* <CODE>false</CODE> otherwise.
* @param path the path.
* @return <CODE>true</CODE> if we can write on the provided path and
* <CODE>false</CODE> otherwise.
*/
{
boolean canWrite;
{
} else
{
}
return canWrite;
}
/**
* Creates the a directory in the provided path.
* @param path the path.
* @return <CODE>true</CODE> if the path was created or already existed (and
* was a directory) and <CODE>false</CODE> otherwise.
* @throws IOException if something goes wrong.
*/
}
/**
* Creates the a directory in the provided path.
* @param f the path.
* @return <CODE>true</CODE> if the path was created or already existed (and
* was a directory) and <CODE>false</CODE> otherwise.
* @throws IOException if something goes wrong.
*/
{
boolean directoryCreated;
if (!f.exists())
{
directoryCreated = f.mkdirs();
} else
{
directoryCreated = f.isDirectory();
}
return directoryCreated;
}
/**
* Creates a file on the specified path with the contents of the provided
* stream.
* @param path the path where the file will be created.
* @param is the InputStream with the contents of the file.
* @throws IOException if something goes wrong.
*/
{
byte[] data = new byte[BUFFER_SIZE];
int count;
{
}
}
/**
* Creates a file on the specified path with the contents of the provided
* String. The file is protected, so that 'others' have no access to it.
* @param path the path where the file will be created.
* @param content the String with the contents of the file.
* @throws IOException if something goes wrong.
* @throws InterruptedException if there is a problem changing the permissions
* of the file.
*/
throws IOException, InterruptedException
{
if (!isWindows())
{
}
}
/**
* This is a helper method that gets a String representation of the elements
* in the Collection. The String will display the different elements separated
* by the separator String.
*
* @param col
* the collection containing the String.
* @param separator
* the separator String to be used.
* @return the String representation for the collection.
*/
{
{
{
}
}
}
/**
* This is a helper method that gets a Message representation of the elements
* in the Collection of Messages. The Message will display the different
* elements separated by the separator String.
*
* @param col
* the collection containing the messages.
* @param separator
* the separator String to be used.
* @return the message representation for the collection;
* null if <code>col</code> is null
*/
mb = new MessageBuilder(m);
} else {
}
}
}
return message;
}
/**
* Returns the default server location that will be proposed to the user
* in the installation.
* @return the default server location that will be proposed to the user
* in the installation.
*/
{
int i = 1;
while (fileExists(serverLocation)
{
i++;
}
return serverLocation;
}
/**
* Returns <CODE>true</CODE> if there is more disk space in the provided path
* than what is specified with the bytes parameter.
* @param directoryPath the path.
* @param bytes the disk space.
* @return <CODE>true</CODE> if there is more disk space in the provided path
* than what is specified with the bytes parameter.
*/
long bytes)
{
// TODO This does not work with quotas etc. but at least it seems that
// we do not write all data on disk if it fails.
boolean hasEnoughSpace = false;
boolean deleteDirectory = false;
{
}
try
{
hasEnoughSpace = true;
} catch (IOException ex)
{ /* do nothing */
} finally
{
{
try
{
} catch (IOException ex2)
{ /* do nothing */
}
}
{
}
}
if (deleteDirectory)
{
}
return hasEnoughSpace;
}
/**
* Returns a localized message for a given properties key an throwable.
* @param message prefix
* @param t the throwable for which we want to get a message.
*
* @return a localized message for a given properties key and throwable.
*/
{
if (isOutOfMemory(t))
{
}
else
{
}
{
}
}
/**
* Gets a localized representation of the provide TopologyCacheException.
* @param te the exception.
* @return a localized representation of the provide TopologyCacheException.
*/
{
{
}
{
}
{
}
else
{
// This is unexpected.
{
}
else
{
}
}
}
/**
* Sets the permissions of the provided paths with the provided permission
* String.
* @param paths the paths to set permissions on.
* @param permissions the UNIX-mode file system permission representation
* (for example "644" or "755")
* @return the return code of the chmod command.
* @throws IOException if something goes wrong.
* @throws InterruptedException if the Runtime.exec method is interrupted.
*/
{
{
}
return p.waitFor();
}
/**
* Sets the permissions of the provided paths with the provided permission
* String.
* @param path to set permissions on.
* @param permissions the UNIX-mode file system permission representation
* (for example "644" or "755")
* @return the return code of the chmod command.
* @throws IOException if something goes wrong.
* @throws InterruptedException if the Runtime.exec method is interrupted.
*/
{
return p.waitFor();
}
/**
* Returns the String that can be used to represent a given host name in a
* LDAP URL.
* This method must be used when we have IPv6 addresses (the address in the
* LDAP URL must be enclosed with brackets).
* @param host the host name.
* @return the String that can be used to represent a given host name in a
* LDAP URL.
*/
{
}
/**
* Indicates whether we are in a web start installation or not.
*
* @return <CODE>true</CODE> if we are in a web start installation and
* <CODE>false</CODE> if not.
*/
public static boolean isWebStart()
{
return SetupUtils.isWebStart();
}
/**
* Returns <CODE>true</CODE> if this is executed from command line and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if this is executed from command line and
* <CODE>false</CODE> otherwise.
*/
public static boolean isCli()
{
}
/**
* Creates a clear LDAP connection and returns the corresponding LdapContext.
* This methods uses the specified parameters to create a JNDI environment
* hashtable and creates an InitialLdapContext instance.
*
* @param ldapURL
* the target LDAP URL
* @param dn
* passed as Context.SECURITY_PRINCIPAL if not null
* @param pwd
* passed as Context.SECURITY_CREDENTIALS if not null
* @param timeout
* passed as com.sun.jndi.ldap.connect.timeout if > 0
* @param env
* null or additional environment properties
*
* @throws NamingException
* the exception thrown when instantiating InitialLdapContext
*
* @return the created InitialLdapContext.
* @see javax.naming.Context
* @see javax.naming.ldap.InitialLdapContext
*/
throws NamingException
{
}
/**
* Creates an LDAPS connection and returns the corresponding LdapContext.
* This method uses the TrusteSocketFactory class so that the specified
* trust manager gets called during the SSL handshake. If trust manager is
* null, certificates are not verified during SSL handshake.
*
* @param ldapsURL the target *LDAPS* URL.
* @param dn passed as Context.SECURITY_PRINCIPAL if not null.
* @param pwd passed as Context.SECURITY_CREDENTIALS if not null.
* @param timeout passed as com.sun.jndi.ldap.connect.timeout if > 0.
* @param env null or additional environment properties.
* @param trustManager null or the trust manager to be invoked during SSL
* negociation.
*
* @return the established connection with the given parameters.
*
* @throws NamingException the exception thrown when instantiating
* InitialLdapContext.
*
* @see javax.naming.Context
* @see javax.naming.ldap.InitialLdapContext
* @see org.opends.admin.ads.util.TrustedSocketFactory
*/
trustManager, null);
}
/**
* Creates an LDAP+StartTLS connection and returns the corresponding
* LdapContext.
* This method first creates an LdapContext with anonymous bind. Then it
* requests a StartTlsRequest extended operation. The StartTlsResponse is
* setup with the specified hostname verifier. Negotiation is done using a
* TrustSocketFactory so that the specified TrustManager gets called during
* the SSL handshake.
* If trust manager is null, certificates are not checked during SSL
* handshake.
*
* @param ldapsURL the target *LDAPS* URL.
* @param dn passed as Context.SECURITY_PRINCIPAL if not null.
* @param pwd passed as Context.SECURITY_CREDENTIALS if not null.
* @param timeout passed as com.sun.jndi.ldap.connect.timeout if > 0.
* @param env null or additional environment properties.
* @param trustManager null or the trust manager to be invoked during SSL.
* negociation.
* @param verifier null or the hostname verifier to be setup in the
* StartTlsResponse.
*
* @return the established connection with the given parameters.
*
* @throws NamingException the exception thrown when instantiating
* InitialLdapContext.
*
* @see javax.naming.Context
* @see javax.naming.ldap.InitialLdapContext
* @see javax.naming.ldap.StartTlsRequest
* @see javax.naming.ldap.StartTlsResponse
* @see org.opends.admin.ads.util.TrustedSocketFactory
*/
throws NamingException
{
}
/**
* Tells whether the provided Throwable was caused because of a problem with
* a certificate while trying to establish a connection.
* @param t the Throwable to analyze.
* @return <CODE>true</CODE> if the provided Throwable was caused because of a
* problem with a certificate while trying to establish a connection and
* <CODE>false</CODE> otherwise.
*/
{
return ConnectionUtils.isCertificateException(t);
}
/**
* Returns a message object for the given NamingException.
* @param ne the NamingException.
* @param hostPort the hostPort representation of the server we were
* contacting when the NamingException occurred.
* @return a message object for the given NamingException.
*/
{
{
}
{
}
else
{
}
{
}
else if (ne instanceof AuthenticationException)
{
}
else if (ne instanceof NoPermissionException)
{
}
else if (ne instanceof NamingSecurityException)
{
}
else if (ne instanceof CommunicationException)
{
}
else
{
}
return msg;
}
/**
* Returns a message object for the given NamingException. The code assume
* that we are trying to connect to the local server.
* @param ne the NamingException.
* @return a message object for the given NamingException.
*/
{
{
}
else if (ne instanceof AuthenticationException)
{
}
else if (ne instanceof NoPermissionException)
{
}
else if (ne instanceof NamingSecurityException)
{
}
else if (ne instanceof CommunicationException)
{
}
else
{
}
return msg;
}
/**
* Returns the path of the installation of the directory server. Note that
* this method assumes that this code is being run locally.
* @return the path of the installation of the directory server.
*/
{
if (installPath != null)
{
return installPath;
}
/* Get the install path from the Class Path */
/*
* Do a best effort to avoid having a relative representation (for
* instance to avoid having ../../../).
*/
try
{
}
catch (IOException ioe)
{
// Best effort
}
}
return installPath;
}
{
{
{
return classPath;
}
}
return null;
}
/**
* Returns the path of the installation of the directory server. Note that
* this method assumes that this code is being run locally.
* @param installPath The installation path
* @return the path of the installation of the directory server.
*/
{
"_svc-opendj.sh");
// look for /etc/opt/opendj/instance.loc
// look for <installPath>/instance.loc
f = new File(instancePathFileName);
if (!f.exists()) {
return installPath;
}
}
try
{
}
catch (Exception e)
{
return installPath;
}
// Read the first line and close the file.
try
{
if (instanceLoc.isAbsolute())
{
return instanceLoc.getAbsolutePath();
}
else
{
.getAbsolutePath();
}
}
catch (Exception e)
{
return installPath;
}
finally
{
}
}
/**
* Returns the max size in character of a line to be displayed in the command
* line.
* @return the max size in character of a line to be displayed in the command
* line.
*/
public static int getCommandLineMaxLineWidth()
{
return MAX_LINE_WIDTH;
}
/**
* 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.
* @param appName
* application name to display in the menu bar and the dock.
*/
{
}
/**
* Tells whether this throwable has been generated for an out of memory
* error or not.
* @param t the throwable to analyze.
* @return <CODE>true</CODE> if the throwable was generated by an out of
* memory error and false otherwise.
*/
{
boolean isOutOfMemory = false;
while (!isOutOfMemory && (t != null))
{
if (t instanceof OutOfMemoryError)
{
isOutOfMemory = true;
}
else if (t instanceof IOException)
{
{
}
}
t = t.getCause();
}
return isOutOfMemory;
}
/**
* Returns the number of entries contained in the zip file. This is used to
* update properly the progress bar ratio.
* @return the number of entries contained in the zip file.
*/
static public int getNumberZipEntries()
{
// TODO we should get this dynamically during build
return 165;
}
/**
* Creates a string consisting of the string representation of the
* elements in the <code>list</code> separated by <code>separator</code>.
* @param list the list to print
* @param separator to use in separating elements
* @return String representing the list
*/
}
/**
* Creates a string consisting of the string representation of the
* elements in the <code>list</code> separated by <code>separator</code>.
* @param list the list to print
* @param separator to use in separating elements
* @param prefix prepended to each individual element in the list before
* adding to the returned string.
* @param suffix appended to each individual element in the list before
* adding to the returned string.
* @return String representing the list
*/
}
}
}
}
}
/**
* Returns the file system permissions for a file.
* @param file the file for which we want the file permissions.
* @return the file system permissions for the file.
*/
{
perm = "644";
}
else {
perm = "755";
}
perm = "755";
perm = "755";
perm = "755";
} else {
perm = "644";
}
return perm;
}
/**
* Returns the String representation of the first value of an attribute in a
* LDAP entry.
* @param entry the entry.
* @param attrName the attribute name.
* @return the String representation of the first value of an attribute in a
* LDAP entry.
* @throws NamingException if there is an error processing the entry.
*/
throws NamingException
{
}
/**
* Inserts HTML break tags into <code>d</code> breaking it up
* so that ideally no line is longer than <code>maxll</code>
* assuming no single word is longer then <code>maxll</code>.
* 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.
*
* @param cs String to break
* @param maxll int maximum line length
* @return String representing <code>d</code> with HTML break
* tags inserted
*/
if (len <= 0)
return d;
// First see if there are any tags that would cause a
// natural break in the line. If so start line break
// point evaluation from that point.
if (p > 0 && p < len) {
maxll);
}
}
// Now look for spaces in which to insert a break.
// First see if there are any spaces counting backward
// from the max line length. If there aren't any, then
// use the first space encountered after the max line
// length.
if (p <= 0) {
}
if (p > 0 && p < len) {
return d.substring(0, p) +
} else {
return d;
}
} else {
return d;
}
} else {
return null;
}
}
/**
* Converts existing HTML break tags to native line separators.
* @param s string to convert
* @return converted string
*/
}
/**
* Strips any potential HTML markup from a given string.
* @param s string to strip
* @return resulting string
*/
if (s != null) {
// This is not a comprehensive solution but addresses
// the few tags that we have in Resources.properties
// at the moment. Note that the following might strip
// out more than is intended for non-tags like
// '<your name here>' or for funky tags like
// '<tag attr="1 > 0">'. See test class for cases that
// might cause problems.
}
return o;
}
/**
* Tests a text string to see if it contains HTML.
* @param text String to test
* @return true if the string contains HTML
*/
}
/**
* Returns a printstream that does not write anything to standard output.
* @return a printstream that does not write anything to standard output.
*/
{
if (emptyStream == null)
{
emptyStream = new EmptyPrintStream();
}
return emptyStream;
}
/**
* Returns the current time of a server in milliseconds.
* @param ctx the connection to the server.
* @return the current time of a server in milliseconds.
*/
{
long time = -1;
new String[] {
"currentTime"
});
try
{
try
{
{
new SimpleDateFormat("yyyyMMddHHmmss'Z'");
}
}
finally
{
}
}
catch (Throwable t)
{
}
return time;
}
/**
* Checks that the java version we are running is compatible with OpenDS.
* @throws IncompatibleVersionException if the java version we are running
* is not compatible with OpenDS.
*/
{
{
{
// Compare versions.
boolean versionCompatible =
if (!versionCompatible)
{
throw new IncompatibleVersionException(
null);
}
}
}
if (Utils.isWebStart())
{
// Check that the JNLP service exists.
try
{
}
catch (Throwable t)
{
{
}
else
{
}
throw new IncompatibleVersionException(
t);
}
}
}
/**
* Basic method to know if the host is local or not. This is only used to
* know if we can perform a port check or not.
* @param host the host to analyze.
* @return <CODE>true</CODE> if it is the local host and <CODE>false</CODE>
* otherwise.
*/
{
boolean isLocalHost = false;
{
try
{
{
}
}
catch (Throwable t)
{
}
}
else
{
isLocalHost = true;
}
return isLocalHost;
}
/**
* Returns the HTML representation of a plain text string which is obtained
* by converting some special characters (like '<') into its equivalent
* escaped HTML representation.
*
* @param rawString the String from which we want to obtain the HTML
* representation.
* @return the HTML representation of the plain text string.
*/
{
{
switch (c)
{
case '<':
break;
case '>':
break;
case '&':
break;
case '"':
break;
default:
break;
}
}
}
/**
* Returns the HTML representation for a given text. without adding any kind
* of font or style elements. Just escapes the problematic characters
* (like '<') and transform the break lines into '\n' characters.
*
* @param text the source text from which we want to get the HTML
* representation
* @return the HTML representation for the given text.
*/
{
{
if (i != 0)
{
}
}
}
}
/**
* Tries to find a customized object in the customization class. If the
* customization class does not exist or it does not contain the field
* as the specified type of the object, returns the default value.
* @param <T> the type of the customized object.
* @param fieldName the name of the field representing an object in the
* customization class.
* @param defaultValue the default value.
* @param valueClass the class of the parametrized value.
* @return the customized object.
*/
{
T value = defaultValue;
if (!isWebStart())
{
try
{
}
{
// do nothing
}
}
return value;
}
/**
* Adds word break tags to the provided html string.
* @param htmlString the string.
* @param from the first index to start the spacing from.
* @param spacing the minimal spacing between word breaks.
* @return a string containing word breaks.
*/
{
boolean insideTag = false;
int totalAddedChars = 0;
int addedChars = 0;
{
char c = htmlString.charAt(i);
if (c == '<')
{
insideTag = true;
}
else if ((c == '>') && insideTag)
{
insideTag = false;
}
if (!insideTag && (c != '>'))
{
addedChars ++;
totalAddedChars ++;
}
{
addedChars = 0;
}
}
}
/**
* Returns the localized string describing the DataOptions chosen by the user.
* @param userInstallData the DataOptions of the user.
* @return the localized string describing the DataOptions chosen by the user.
*/
{
boolean createSuffix =
if (createSuffix)
{
{
case CREATE_BASE_ENTRY:
break;
case LEAVE_DATABASE_EMPTY:
break;
case IMPORT_FROM_LDIF_FILE:
break;
break;
default:
}
{
}
{
arg2);
}
else
{
arg2);
}
}
else
{
{
{
}
}
}
}
/**
* Returns a localized String representation of the provided SecurityOptions
* object.
* @param ops the SecurityOptions object from which we want to obtain the
* String representation.
* @param html whether the resulting String must be in HTML or not.
* @return a localized String representation of the provided SecurityOptions
* object.
*/
boolean html)
{
if (ops.getCertificateType() ==
{
}
else
{
if (ops.getEnableStartTLS())
{
}
if (ops.getEnableSSL())
{
{
if (html)
{
}
else
{
}
}
}
if (html)
{
}
else
{
}
switch (ops.getCertificateType())
{
case SELF_SIGNED_CERTIFICATE:
break;
case JKS:
break;
case JCEKS:
break;
case PKCS11:
break;
case PKCS12:
break;
default:
throw new IllegalStateException("Unknown certificate options type: "+
}
}
if (html)
{
}
else
{
}
}
/**
* Returns a String representation of the provided command-line.
* @param cmd the command-line arguments.
* @param formatter the formatted to be used to create the String
* representation.
* @return a String representation of the provided command-line.
*/
{
int initialIndex = 1;
{
for (int i=0 ; i < 10 ; i++)
{
}
}
{
if (s.startsWith("-"))
{
}
else
{
escapeCommandLineValue(s))));
}
}
}
//Chars that require special treatment when passing them to command-line.
'>', '(', ')', '$', '`', '\\', '"', '\''};
/**
* 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.
* @param value the String to be treated.
* @return the transformed value.
*/
{
StringBuilder b = new StringBuilder();
{
{
boolean charToEscapeFound = false;
{
charToEscapeFound = c == charsToEscape[j];
}
if (charToEscapeFound)
{
b.append('\\');
}
b.append(c);
}
}
else
{
}
return b.toString();
}
/**
* Returns the equivalent setup CLI command-line. Note that this command-line
* does not cover all the replication part of the GUI install. Note also
* that to avoid problems in the WebStart setup, all the Strings are
* hard-coded in the implementation of this method.
* @param userData the user data.
* @return the equivalent setup command-line.
*/
{
{
}
else
{
}
{
}
{
case CREATE_BASE_ENTRY:
break;
break;
case IMPORT_FROM_LDIF_FILE:
{
}
if (rejectFile != null)
{
}
{
}
break;
}
{
}
{
}
{
}
{
}
{
}
{
case SELF_SIGNED_CERTIFICATE:
break;
case JKS:
{
}
{
}
break;
case JCEKS:
{
}
{
}
break;
case PKCS12:
{
}
{
}
break;
case PKCS11:
{
}
{
}
break;
}
return cmdLine;
}
/**
* Returns the list of equivalent command-lines that must be executed to
* enable replication as the setup does.
* @param userData the user data.
* @return the list of equivalent command-lines that must be executed to
* enable replication as the setup does.
*/
{
{
}
return cmdLines;
}
/**
* Returns the list of equivalent command-lines that must be executed to
* initialize replication as the setup does.
* @param userData the user data.
* @return the list of equivalent command-lines that must be executed to
* initialize replication as the setup does.
*/
{
{
}
return cmdLines;
}
{
{
}
for (ServerDescriptor s :
{
{
if (remoteRepl.useSecureConnection())
{
}
}
}
{
if (replOptions.useSecureReplication())
{
}
}
{
}
return cmdLine;
}
/**
* Returns the full path of the command-line for a given script name.
* @param userData the user data.
* @param scriptBasicName the script basic name (with no extension).
* @return the full path of the command-line for a given script name.
*/
{
if (isWindows())
{
+ scriptBasicName + ".bat";
}
else
{
}
return cmdLineName;
}
/**
* Returns the installation directory.
* @return the installation directory.
*/
{
{
File f;
if (isWebStart())
{
}
else
{
}
try
{
installDir = f.getCanonicalPath();
}
catch (Throwable t)
{
installDir = f.getAbsolutePath();
}
{
}
}
return installDir;
}
{
{
}
return cmdLine;
}
{
boolean createSuffix =
if (createSuffix)
{
}
else
{
{
}
}
return baseDNs;
}
{
{
boolean found = false;
{
if (ldapURL.equalsIgnoreCase(
{
// This is the server we're configuring
found = true;
{
}
break;
}
}
if (!found)
{
{
{
found = true;
break;
}
}
}
if (!found)
{
// We haven't found the server yet, just take the first one
{
}
}
}
return hm;
}
/**
* Returns the equivalent dsconfig command-line required to configure
* the first replicated server in the topology.
* @param userData the user data.
* @return the equivalent dsconfig command-line required to configure
* the first replicated server in the topology.
*/
{
{
}
return cmdLines;
}
}
/**
* This class is used to avoid displaying the error message related to display
* problems that we might have when trying to display the SplashWindow.
*
*/
/**
* Default constructor.
*
*/
public EmptyPrintStream()
{
super(new ByteArrayOutputStream(), true);
}
/**
* {@inheritDoc}
*/
{
}
}