org.opends.server.tools
Class LDAPToolUtils

java.lang.Object
  extended by org.opends.server.tools.LDAPToolUtils

public class LDAPToolUtils
extends java.lang.Object

This class provides utility functions for all the client side tools.


Constructor Summary
LDAPToolUtils()
           
 
Method Summary
static LDAPControl getControl(java.lang.String argString, java.io.PrintStream err)
          Parse the specified command line argument to create the appropriate LDAPControl.
static void printErrorMessage(java.io.PrintStream err, Message explanation, int resultCode, Message errorMessage, DN matchedDN)
          Prints a multi-line error message with the provided information to the given print stream.
static byte[] readBytesFromFile(java.lang.String filePath, java.io.PrintStream err)
          Read the data from the specified file and return it in a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPToolUtils

public LDAPToolUtils()
Method Detail

getControl

public static LDAPControl getControl(java.lang.String argString,
                                     java.io.PrintStream err)
Parse the specified command line argument to create the appropriate LDAPControl. The argument string should be in the format controloid[:criticality[:value|::b64value|:<fileurl]]

Parameters:
argString - The argument string containing the encoded control information.
err - A print stream to which error messages should be written if a problem occurs.
Returns:
The control decoded from the provided string, or null if an error occurs while parsing the argument value.

readBytesFromFile

public static byte[] readBytesFromFile(java.lang.String filePath,
                                       java.io.PrintStream err)
                                throws java.io.IOException
Read the data from the specified file and return it in a byte array.

Parameters:
filePath - The path to the file that should be read.
err - A print stream to which error messages should be written if a problem occurs.
Returns:
A byte array containing the contents of the requested file.
Throws:
java.io.IOException - If a problem occurs while trying to read the specified file.

printErrorMessage

public static void printErrorMessage(java.io.PrintStream err,
                                     Message explanation,
                                     int resultCode,
                                     Message errorMessage,
                                     DN matchedDN)
Prints a multi-line error message with the provided information to the given print stream.

Parameters:
err - The print stream to use to write the error message.
explanation - The general explanation to provide to the user, or null if there is none.
resultCode - The result code returned from the server, or -1 if there is none.
errorMessage - The additional information / error message returned from the server, or null if there was none.
matchedDN - The matched DN returned from the server, or null if there was none.