Search in sources :

Example 1 with NoSuchAttributeException

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);
    }
}
Also used : SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) SQLException(java.sql.SQLException) FileNotFoundException(java.io.FileNotFoundException) ConnectionBrokenException(org.identityconnectors.framework.common.exceptions.ConnectionBrokenException) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) ServiceUnavailableException(javax.naming.ServiceUnavailableException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) SchemaViolationException(javax.naming.directory.SchemaViolationException) UnknownUidException(org.identityconnectors.framework.common.exceptions.UnknownUidException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ConnectException(java.net.ConnectException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) InvalidAttributeValueException(javax.naming.directory.InvalidAttributeValueException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AttributeInUseException(javax.naming.directory.AttributeInUseException) NoSuchAttributeException(javax.naming.directory.NoSuchAttributeException) RemoteWrappedException(org.identityconnectors.framework.impl.api.remote.RemoteWrappedException) ConnectorSecurityException(org.identityconnectors.framework.common.exceptions.ConnectorSecurityException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) FileNotFoundException(java.io.FileNotFoundException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServiceUnavailableException(javax.naming.ServiceUnavailableException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) SchemaViolationException(javax.naming.directory.SchemaViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) NoPermissionException(javax.naming.NoPermissionException) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) UnknownUidException(org.identityconnectors.framework.common.exceptions.UnknownUidException) PermissionDeniedException(org.identityconnectors.framework.common.exceptions.PermissionDeniedException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) SQLException(java.sql.SQLException) AlreadyExistsException(org.identityconnectors.framework.common.exceptions.AlreadyExistsException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) InvalidAttributeValueException(javax.naming.directory.InvalidAttributeValueException) ConnectException(java.net.ConnectException) ConfigurationException(org.identityconnectors.framework.common.exceptions.ConfigurationException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) OperationTimeoutException(org.identityconnectors.framework.common.exceptions.OperationTimeoutException) UnknownHostException(java.net.UnknownHostException) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) RetryableException(org.identityconnectors.framework.common.exceptions.RetryableException) ConnectionBrokenException(org.identityconnectors.framework.common.exceptions.ConnectionBrokenException) NoSuchAttributeException(javax.naming.directory.NoSuchAttributeException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) NoPermissionException(javax.naming.NoPermissionException) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) AttributeInUseException(javax.naming.directory.AttributeInUseException)

Aggregations

EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)1 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 FileNotFoundException (java.io.FileNotFoundException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConnectException (java.net.ConnectException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)1 SQLSyntaxErrorException (java.sql.SQLSyntaxErrorException)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 NoPermissionException (javax.naming.NoPermissionException)1 ServiceUnavailableException (javax.naming.ServiceUnavailableException)1 AttributeInUseException (javax.naming.directory.AttributeInUseException)1 InvalidAttributeValueException (javax.naming.directory.InvalidAttributeValueException)1 NoSuchAttributeException (javax.naming.directory.NoSuchAttributeException)1