| | |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isUnix; |
| | | import static com.forgerock.opendj.cli.Utils.OBFUSCATED_VALUE; |
| | | import static com.forgerock.opendj.cli.Utils.getThrowableMsg; |
| | | |
| | | import java.io.*; |
| | | import java.net.InetAddress; |
| | |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.*; |
| | | import org.opends.quicksetup.installer.AuthenticationData; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | | */ |
| | | public static LocalizableMessage getThrowableMsg(LocalizableMessage message, Throwable t) |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(message); |
| | | LocalizableMessageDescriptor.Arg1<Object> tag; |
| | | if (isOutOfMemory(t)) |
| | | { |
| | | tag = INFO_EXCEPTION_OUT_OF_MEMORY_DETAILS; |
| | | } |
| | | else |
| | | { |
| | | tag = INFO_EXCEPTION_DETAILS; |
| | | } |
| | | String detail = t.toString(); |
| | | if (detail != null) |
| | | { |
| | | mb.append(" ").append(tag.get(detail)); |
| | | } |
| | | return mb.toMessage(); |
| | | } |
| | | |
| | | /** |
| | | * Gets a localized representation of the provide TopologyCacheException. |
| | | * @param te the exception. |
| | | * @return a localized representation of the provide TopologyCacheException. |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | | */ |
| | | private static boolean isOutOfMemory(Throwable t) |
| | | { |
| | | boolean isOutOfMemory = false; |
| | | while (!isOutOfMemory && (t != null)) |
| | | { |
| | | if (t instanceof OutOfMemoryError) |
| | | { |
| | | isOutOfMemory = true; |
| | | } |
| | | else if (t instanceof IOException) |
| | | { |
| | | String msg = t.toString(); |
| | | if (msg != null) |
| | | { |
| | | isOutOfMemory = msg.contains("Not enough space"); |
| | | } |
| | | } |
| | | 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. |
| | |
| | | //Chars that require special treatment when passing them to command-line. |
| | | private final static char[] charsToEscape = {' ', '\t', '\n', '|', ';', '<', |
| | | '>', '(', ')', '$', '`', '\\', '"', '\''}; |
| | | private static final String OBFUSCATED_VALUE = "******"; |
| | | |
| | | /** |
| | | * This method simply takes a value and tries to transform it (with escape or |