use of javax.naming.directory.NoSuchAttributeException in project midpoint by Evolveum.
the class ConnIdUtil method lookForKnownCause.
private static Exception lookForKnownCause(Throwable ex, Throwable originalException, OperationResult parentResult) {
if (ex instanceof FileNotFoundException) {
//fix MID-2711 consider FileNotFoundException as CommunicationException
Exception newEx = new com.evolveum.midpoint.util.exception.CommunicationException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("File not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NameAlreadyBoundException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new ObjectAlreadyExistsException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object already exists: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof javax.naming.CommunicationException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ServiceUnavailableException) {
// In some cases (e.g. JDK 1.6.0_31) this is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectionBrokenException) {
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectionFailedException) {
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SchemaViolationException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new SchemaException(createMessageFromAllExceptions("Schema violation", ex));
parentResult.recordFatalError("Schema violation: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions("Invalid attribute", ex));
parentResult.recordFatalError("Invalid attribute: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof InvalidAttributeValueException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
InvalidAttributeValueException e = (InvalidAttributeValueException) ex;
Exception newEx = null;
if (e.getExplanation().contains("unique attribute conflict")) {
newEx = new ObjectAlreadyExistsException(createMessageFromAllExceptions("Invalid attribute", ex));
} else {
newEx = new SchemaException(createMessageFromAllExceptions("Invalid attribute", ex));
}
parentResult.recordFatalError("Invalid attribute: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectException) {
// Buried deep in many exceptions, usually connection refused or
// similar errors
// Note: needs to be after javax.naming.CommunicationException as the
// javax.naming exception has more info (e.g. hostname)
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Connect error", ex));
parentResult.recordFatalError("Connect error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SQLSyntaxErrorException) {
// Buried deep in many exceptions, usually DB schema problems of
// DB-based connectors
Exception newEx = new SchemaException(createMessageFromAllExceptions("DB syntax error", ex));
parentResult.recordFatalError("DB syntax error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SQLException) {
// Buried deep in many exceptions, usually DB connection problems
Exception newEx = new GenericFrameworkException(createMessageFromAllExceptions("DB error", ex));
parentResult.recordFatalError("DB error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof UnknownUidException) {
// Object not found
Exception newEx = new ObjectNotFoundException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NoPermissionException) {
Exception newEx = new SecurityViolationException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof AttributeInUseException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Attribute in use: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NoSuchAttributeException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("No such attribute: " + ex.getMessage(), newEx);
return newEx;
}
if (ex.getCause() == null) {
// found nothing
return null;
} else {
// Otherwise go one level deeper ...
return lookForKnownCause(ex.getCause(), originalException, parentResult);
}
}
Aggregations