/** * Checks if the specified LDAP result code indicates the LDAP server * is unavailable, disconnected or timing out. * * @param code The LDAP result code. Must not be {@code null}. * * @return {@code true} if the LDAP result code indicates the LDAP * server is unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final ResultCode code) { return code.equals(ResultCode.CONNECT_ERROR) || code.equals(ResultCode.SERVER_DOWN) || code.equals(ResultCode.TIMEOUT) || code.equals(ResultCode.UNAVAILABLE); }
/** * Runs the tool with the provided set of command-line arguments. * * @param args The command-line arguments provided to this tool. */ public static void main(final String... args) { final ResultCode resultCode = main(System.out, System.err, args); if (resultCode != ResultCode.SUCCESS) { System.exit(resultCode.intValue()); } }
err("Result Code: ", le.getResultCode().intValue(), " (", le.getResultCode().getName(), ')'); if (le.getMatchedDN() != null) if (! le.getResultCode().isConnectionUsable())
/** * Creates a new LDAP exception with the provided result code. A default * message (based on the result code) will be used. * * @param resultCode The result code for this LDAP exception. */ public LDAPException(final ResultCode resultCode) { super(resultCode.getName()); this.resultCode = resultCode; matchedDN = null; diagnosticMessage = null; referralURLs = NO_REFERRALS; responseControls = NO_CONTROLS; }
switch (result.getResultCode().intValue()) if (! ResultCode.isConnectionUsable(result.getResultCode())) le.getResponseControls())); if (! ResultCode.isConnectionUsable(le.getResultCode()))
/** * Indicates whether the connection on which this result code was received is * likely still usable. Note that this is a best guess, and it may or may not * be correct. It will attempt to be conservative so that a connection is * more likely to be classified as unusable when it may still be valid than to * be classified as usable when that is no longer the case. * * @return {@code true} if it is likely that the connection on which this * result code was received is still usable, or {@code false} if it * may no longer be valid. */ public boolean isConnectionUsable() { return isConnectionUsable(this); }
/** * Retrieves the result code with the specified integer value. If the * provided integer value does not correspond to a predefined * {@code ResultCode} object, then a new {@code ResultCode} object will be * created and returned. Any new result codes created will also be cached * and returned for any subsequent requests with that integer value so the * same object will always be returned for a given integer value. * * @param intValue The integer value for which to retrieve the corresponding * result code. * * @return The result code with the specified integer value, or a new result * code */ public static ResultCode valueOf(final int intValue) { return valueOf(intValue, null); }
/** * Indicates whether this result code is one that should be used for * client-side errors rather than returned by the server. * * @return {@code true} if this result code is a client-side result code, or * {@code false} if it is one that may be returned by the server. */ public boolean isClientSideResultCode() { return isClientSideResultCode(this); }
rc = new ResultCode(intValue); rc = new ResultCode(name, intValue);
if (e.getResultCode().equals(ResultCode.ENTRY_ALREADY_EXISTS)) { return false; if (resultCode.equals(ResultCode.SUCCESS)) { return true; if (resultCode.equals(ResultCode.ENTRY_ALREADY_EXISTS)) { return false; throw new PersistenceException("LDAP add for " + entry.getDN() + " failed: " + resultCode.getName());
/** * Creates a new LDAP exception with the provided result code. A default * message (based on the result code) will be used. * * @param resultCode The result code for this LDAP exception. * @param cause The underlying exception that triggered this exception. */ public LDAPException(final ResultCode resultCode, final Throwable cause) { super(resultCode.getName(), cause); this.resultCode = resultCode; matchedDN = null; diagnosticMessage = null; referralURLs = NO_REFERRALS; responseControls = NO_CONTROLS; }
/** * Retrieves a string representation of the result code for this LDAP * exception. * * @param l The locale for the string representation. * * @return A string representation of the result code for this LDAP * exception. */ public String errorCodeToString(final Locale l) { return ResultCode.valueOf(resultCode).getName(); }
switch (result.getResultCode().intValue()) if (! ResultCode.isConnectionUsable(result.getResultCode())) le.getResponseControls())); if (! ResultCode.isConnectionUsable(le.getResultCode()))
/** * Indicates whether the connection on which this result code was received is * likely still usable. Note that this is a best guess, and it may or may not * be correct. It will attempt to be conservative so that a connection is * more likely to be classified as unusable when it may still be valid than to * be classified as usable when that is no longer the case. * * @return {@code true} if it is likely that the connection on which this * result code was received is still usable, or {@code false} if it * may no longer be valid. */ public boolean isConnectionUsable() { return isConnectionUsable(this); }
/** * Retrieves the result code with the specified integer value. If the * provided integer value does not correspond to a predefined * {@code ResultCode} object, then a new {@code ResultCode} object will be * created and returned. Any new result codes created will also be cached * and returned for any subsequent requests with that integer value so the * same object will always be returned for a given integer value. * * @param intValue The integer value for which to retrieve the corresponding * result code. * * @return The result code with the specified integer value, or a new result * code */ public static ResultCode valueOf(final int intValue) { return valueOf(intValue, null); }
/** * Indicates whether this result code is one that should be used for * client-side errors rather than returned by the server. * * @return {@code true} if this result code is a client-side result code, or * {@code false} if it is one that may be returned by the server. */ public boolean isClientSideResultCode() { return isClientSideResultCode(this); }
rc = new ResultCode(intValue); rc = new ResultCode(name, intValue);