Package org.apache.directory.shared.ldap.exception

Examples of org.apache.directory.shared.ldap.exception.LdapSchemaViolationException


                        // No value : we have to remove the entire attribute
                        // Check that we aren't removing a MUST attribute
                        if ( isRequired( change.getUpId(), objectClass ) )
                        {
                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                        }
                       
                        attr = tmpEntry.get( change.getUpId() );
                        if ( attr != null )
                        {
                            tmpEntry.removeAttributes( change.getUpId() );
                        }
                    }
                    else
                    {
                        // for required attributes we need to check if all values are removed
                        // if so then we have a schema violation that must be thrown
                        if ( isRequired( change.getUpId(), objectClass ) && isCompleteRemoval( change, entry ) )
                        {
                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                        }

                        // Now remove the attribute and all its values
                        EntryAttribute modified = tmpEntry.removeAttributes( change.getId() ).get( 0 );

                        // And inject back the values except the ones to remove
                        for ( Value<?> value : change )
                        {
                            if ( modified.contains( value ) )
                            {
                                modified.remove( value );
                            }
                            else if ( !subSchemaModification )
                            {
                                // We are trying to remove an not existing value : error
                                throw new LdapNoSuchAttributeException( "Value " + value + " does not exist in the " + modified + " AT" );
                            }
                        }

                        // ok, done. Last check : if the attribute does not content any more value;
                        // and if it's a MUST one, we should thow an exception
                        if ( ( modified.size() == 0 ) && isRequired( change.getId(), objectClass ) )
                        {
                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                        }

                        // Put back the attribute in the entry only if it has values left in it
                        if ( modified.size() > 0 )
                        {
View Full Code Here


                        case ABSTRACT :
                            if ( !superior.isAbstract() )
                            {
                                String message = "An ABSTRACT ObjectClass cannot inherit from an objectClass which is not ABSTRACT";
                                LOG.error( message );
                                throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                            }
                           
                            break;
   
                        case AUXILIARY :
                            if ( !superior.isAbstract() && ! superior.isAuxiliary() )
                            {
                                String message = "An AUXILiARY ObjectClass cannot inherit from an objectClass which is not ABSTRACT or AUXILIARY";
                                LOG.error( message );
                                throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                            }
                           
                            break;

                        case STRUCTURAL :
                            break;
                    }
                }
                catch ( NamingException ne )
                {
                    // The superior OC does not exist : this is an error
                    String message = "Cannot have a superior which does not exist";
                    LOG.error( message );
                    throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                }
            }
        }
    }
View Full Code Here

            if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) )
            {
                if ( !allowed.contains( attrOid ) )
                {
                    throw new LdapSchemaViolationException( "Attribute " + attribute.getUpId()
                        + " not declared in objectClasses of entry " + dn.getUpName(),
                        ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                }
            }
        }
View Full Code Here

            must.remove( ( ( ServerAttribute ) attribute ).getAttributeType().getOid() );
        }

        if ( must.size() != 0 )
        {
            throw new LdapSchemaViolationException( "Required attributes " + must + " not found within entry "
                + dn.getUpName(), ResultCodeEnum.OBJECT_CLASS_VIOLATION );
        }
    }
View Full Code Here

        if ( structuralObjectClasses.isEmpty() )
        {
            String message = "Entry " + dn + " does not contain a STRUCTURAL ObjectClass";
            LOG.error( message );
            throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
        }

        // --------------------------------------------------------------------
        // Put all structural object classes into new remaining container and
        // start removing any which are superiors of others in the set.  What
        // is left in the remaining set will be unrelated structural
        /// objectClasses.  If there is more than one then we have a problem.
        // --------------------------------------------------------------------

        Set<ObjectClass> remaining = new HashSet<ObjectClass>( structuralObjectClasses.size() );
        remaining.addAll( structuralObjectClasses );
       
        for ( ObjectClass oc : structuralObjectClasses )
        {
            if ( oc.getSuperClasses() != null )
            {
                for ( ObjectClass superClass : oc.getSuperClasses() )
                {
                    if ( superClass.isStructural() )
                    {
                        remaining.remove( superClass );
                    }
                }
            }
        }

        // Like the highlander there can only be one :).
        if ( remaining.size() > 1 )
        {
            String message = "Entry " + dn + " contains more than one STRUCTURAL ObjectClass: " + remaining;
            LOG.error( message );
            throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
        }
    }
View Full Code Here

        EntryAttribute oc = subentry.get( SchemaConstants.OBJECT_CLASS_AT );

        if ( oc == null )
        {
            throw new LdapSchemaViolationException( "A subentry must have an objectClass attribute",
                ResultCodeEnum.OBJECT_CLASS_VIOLATION );
        }

        if ( oc.contains( SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC ) )
        {
View Full Code Here

        {
            if ( hasAdministrativeDescendant( opContext, name ) )
            {
                String msg = "Will not allow rename operation on entries with administrative descendants.";
                LOG.warn( msg );
                throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOT_ALLOWED_ON_RDN );
            }

            next.rename( opContext );

            // calculate the new DN now for use below to modify subentry operational
View Full Code Here

        {
            if ( hasAdministrativeDescendant( opContext, oriChildName ) )
            {
                String msg = "Will not allow rename operation on entries with administrative descendants.";
                LOG.warn( msg );
                throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOT_ALLOWED_ON_RDN );
            }

            next.moveAndRename( opContext );

            // calculate the new DN now for use below to modify subentry operational
View Full Code Here

        {
            if ( hasAdministrativeDescendant( opContext, oriChildName ) )
            {
                String msg = "Will not allow rename operation on entries with administrative descendants.";
                LOG.warn( msg );
                throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOT_ALLOWED_ON_RDN );
            }

            next.move( opContext );

            // calculate the new DN now for use below to modify subentry operational
View Full Code Here

            else
            {
                // Ok, definitively an error
                String msg = I18n.err( I18n.ERR_387, entry.getDn().getName() );
                LOG.info( msg );
                throw new LdapSchemaViolationException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
            }
        }

        if ( schema.isEnabled() && syntaxChecker.isEnabled() )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.exception.LdapSchemaViolationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.