Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.ModificationOperation


        // Now, apply the modifications on the cloned entry before applying it on the
        // real object.
        for ( Modification mod : mods )
        {
            ModificationOperation modOp = mod.getOperation();
            ServerAttribute change = ( ServerAttribute ) mod.getAttribute();

            // TODO/ handle http://issues.apache.org/jira/browse/DIRSERVER-1198
            if ( ( change.getAttributeType() == null ) && !atRegistry.hasAttributeType( change.getUpId() )
                && !objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
View Full Code Here


     */
    @Test
    public void testPreventStructuralClassRemovalOnModifyReplace() throws Exception
    {
        LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
        ServerEntry modifyAttributes = new DefaultServerEntry( registries );
        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
        modifyAttributes.put( new DefaultServerAttribute( atCN ) );

        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
View Full Code Here

     * operations remove RDN attributes.
     */
    @Test
    public void testPreventRdnChangeOnModifyRemove() throws Exception
    {
        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
        LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
        ServerEntry attributes = new DefaultServerEntry( registries, name );
        attributes.put( "cn", "does not matter" );

        // postive test which should pass
View Full Code Here

     * operations replace RDN attributes.
     */
    @Test
    public void testPreventRdnChangeOnModifyReplace() throws Exception
    {
        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
        LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
        ServerEntry attributes = new DefaultServerEntry( registries, name );
        attributes.put( "cn", "does not matter" );

        // postive test which should pass
View Full Code Here

        AttributeType OBJECT_CLASS = registries.getAttributeTypeRegistry().lookup( "objectClass" );
        AttributeType CN_AT = registries.getAttributeTypeRegistry().lookup( "cn" );

        // this should pass
        LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, new DefaultServerAttribute( "cn", CN_AT ) );

        // this should succeed since person is still in replaced set and is structural
        ServerAttribute objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
        objectClassesReplaced.add( "top" );
View Full Code Here

    @Test
    public void testPreventStructuralClassRemovalOnModifyRemoveAttribute() throws Exception
    {
        AttributeTypeRegistry atReg = registries.getAttributeTypeRegistry();
        LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
        AttributeType ocAt = atReg.lookup( "objectClass" );
       
        ServerAttribute entryObjectClasses = new DefaultServerAttribute( "objectClass", ocAt );
        entryObjectClasses.add( "top", "person", "organizationalPerson" );
View Full Code Here

     */
    @Test
    public void testPreventRdnChangeOnModifyRemoveAttribute() throws Exception
    {
        OidRegistry registry = new MockOidRegistry();
        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
        LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
        AttributeType cnAt = registries.getAttributeTypeRegistry().lookup( "cn" );
        AttributeType ouAt = registries.getAttributeTypeRegistry().lookup( "ou" );
        AttributeType snAt = registries.getAttributeTypeRegistry().lookup( "sn" );

View Full Code Here

            // need to remove references to the subentry
            if ( isOldNameSelected && !isNewNameSelected )
            {
                for ( String aSUBENTRY_OPATTRS : SUBENTRY_OPATTRS )
                {
                    ModificationOperation op = ModificationOperation.REPLACE_ATTRIBUTE;
                    EntryAttribute opAttr = entry.get( aSUBENTRY_OPATTRS );

                    if ( opAttr != null )
                    {
                        opAttr = ( ServerAttribute ) opAttr.clone();
                        opAttr.remove( subentryDn );

                        if ( opAttr.size() < 1 )
                        {
                            op = ModificationOperation.REMOVE_ATTRIBUTE;
                        }

                        modList.add( new ServerModification( op, opAttr ) );
                    }
                }
            }
            // need to add references to the subentry
            else if ( isNewNameSelected && !isOldNameSelected )
            {
                for ( String aSUBENTRY_OPATTRS : SUBENTRY_OPATTRS )
                {
                    ModificationOperation op = ModificationOperation.ADD_ATTRIBUTE;
                    ServerAttribute opAttr = new DefaultServerAttribute( aSUBENTRY_OPATTRS, atRegistry
                        .lookup( aSUBENTRY_OPATTRS ) );
                    opAttr.add( subentryDn );
                    modList.add( new ServerModification( op, opAttr ) );
                }
View Full Code Here

    {
        List<Modification> modList = new ArrayList<Modification>();

        for ( AttributeType attributeType : operational.getAttributeTypes() )
        {
            ModificationOperation op = ModificationOperation.REPLACE_ATTRIBUTE;
            EntryAttribute result = new DefaultServerAttribute( attributeType );
            EntryAttribute opAttrAdditions = operational.get( attributeType );
            EntryAttribute opAttrInEntry = entry.get( attributeType );

            for ( Value<?> value : opAttrAdditions )
View Full Code Here

            // need to remove references to the subentry
            if ( isOldEntrySelected && !isNewEntrySelected )
            {
                for ( String aSUBENTRY_OPATTRS : SUBENTRY_OPATTRS )
                {
                    ModificationOperation op = ModificationOperation.REPLACE_ATTRIBUTE;
                    EntryAttribute opAttr = oldEntry.get( aSUBENTRY_OPATTRS );

                    if ( opAttr != null )
                    {
                        opAttr = ( ServerAttribute ) opAttr.clone();
                        opAttr.remove( subentryDn );

                        if ( opAttr.size() < 1 )
                        {
                            op = ModificationOperation.REMOVE_ATTRIBUTE;
                        }

                        modList.add( new ServerModification( op, opAttr ) );
                    }
                }
            }
            // need to add references to the subentry
            else if ( isNewEntrySelected && !isOldEntrySelected )
            {
                for ( String attribute : SUBENTRY_OPATTRS )
                {
                    ModificationOperation op = ModificationOperation.ADD_ATTRIBUTE;
                    AttributeType type = atRegistry.lookup( attribute );
                    ServerAttribute opAttr = new DefaultServerAttribute( attribute, type );
                    opAttr.add( subentryDn );
                    modList.add( new ServerModification( op, opAttr ) );
                }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.ModificationOperation

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.