Package org.apache.directory.api.ldap.model.entry

Examples of org.apache.directory.api.ldap.model.entry.DefaultModification


            .lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );

        String attribVal = "Walker";
        attrib.add( attribVal );

        Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );

        Entry lookedup = partition.fetch( partition.getEntryId( dn ) );

        partition.modify( dn, add );
        assertTrue( lookedup.get( "sn" ).contains( attribVal ) );

        partition.modify( dn, new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
            schemaManager.getAttributeType( "telephoneNumber" ), "+1974045779" ) );
        lookedup = partition.fetch( partition.getEntryId( dn ) );
        assertTrue( lookedup.get( "telephoneNumber" ).contains( "+1974045779" ) );
    }
View Full Code Here


            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );

        String attribVal = "Johnny";
        attrib.add( attribVal );

        Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );

        Entry lookedup = partition.fetch( partition.getEntryId( dn ) );

        assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing

        lookedup = partition.modify( dn, add );
        assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );

        lookedup = partition.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, SN_AT,
            "JWalker" ) );
        assertEquals( "JWalker", lookedup.get( "sn" ).get().getString() );
    }
View Full Code Here

        Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );

        Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, schemaManager
            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );

        Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );

        Entry lookedup = partition.fetch( partition.getEntryId( dn ) );

        assertNotNull( lookedup.get( "sn" ).get() );

        lookedup = partition.modify( dn, add );
        assertNull( lookedup.get( "sn" ) );

        // add an entry for the sake of testing the remove operation
        lookedup = partition.modify( dn,
            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, SN_AT, "JWalker" ) );
        assertNotNull( lookedup.get( "sn" ) );

        lookedup = partition.modify( dn, new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, SN_AT ) );
        assertNull( lookedup.get( "sn" ) );
    }
View Full Code Here

        Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );

        String attribVal = "Marketing";
        attrib.add( attribVal );

        Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );

        Entry lookedup = partition.fetch( partition.getEntryId( dn ) );

        assertNull( lookedup.get( "ou" ) ); // before replacing
View Full Code Here

    public void testIllegalModification2() throws Exception
    {
        LdapConnection con = getWiredConnection( getLdapServer() );

        // first a valid attribute
        Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "description",
            "The description" );
        // then an invalid one without any value
        Modification mod2 = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "displayName" );

        try
        {
            con.modify( "cn=Kate Bush,ou=system", new Modification[]
                { mod, mod2 } );
View Full Code Here

        Attribute description = new DefaultAttribute( "description", sb.toString() );

        try
        {
            Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, description );
            connection.modify( "cn=the person, ou=system", modification );
            fail();
        }
        catch ( Exception e )
        {
View Full Code Here

        Attribute description = new DefaultAttribute( "description", sb.toString() );

        try
        {
            Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, description );
            connection.modify( "cn=the person, ou=system", modification );
            fail();
        }
        catch ( Exception e )
        {
View Full Code Here

    private void addAdministrativeRole( LdapConnection connection, String role ) throws Exception
    {
        Attribute attribute = new DefaultAttribute( "administrativeRole", role );

        connection.modify( "ou=system", new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute ) );
    }
View Full Code Here

        assertNull( "the c-ou collective attribute should not be present", c_ou );

        // -------------------------------------------------------------------
        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------
        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
            new DefaultAttribute( "collectiveExclusions", "c-ou" ) );
        connection.modify( "ou=services,ou=configuration, ou=system", modification );

        // entry should not show the c-ou collective attribute anymore
        entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // now add more collective subentries - the c-ou should still not show due to exclusions
        Entry subentry2 = getTestSubentry2( "cn=testsubentry2,ou=system" );
        connection.add( subentry2 );

        entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // entries without the collectiveExclusion should still show both values of c-ou
        entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        // request the collective attribute specifically
        entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "c-ou" );
        c_ou = entry.get( "c-ou" );

        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        // unspecify the collective attribute in the returning attribute list
        entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "objectClass" );
        c_ou = entry.get( "c-ou" );

        assertNull( "a collective c-ou attribute should not be present", c_ou );

        // -------------------------------------------------------------------
        // now add the subentry for the c-st collective attribute
        // -------------------------------------------------------------------
        connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) );

        // the new attribute c-st should appear in the node with the c-ou exclusion
        entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
        Attribute c_st = entry.get( "c-st" );

        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // in node without exclusions both values of c-ou should appear with c-st value
        entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        c_st = entry.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // -------------------------------------------------------------------
        // now modify an entry to exclude all collective attributes
        // -------------------------------------------------------------------
        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute(
            "collectiveExclusions", "excludeAllCollectiveAttributes" ) );
        connection.modify( "ou=interceptors,ou=configuration, ou=system", modification );

        // none of the attributes should appear any longer
        entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
View Full Code Here

        assertNull( "the c-ou collective attribute should not be present", c_ou );

        // -------------------------------------------------------------------
        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------
        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
            new DefaultAttribute( "collectiveExclusions", "c-ou" ) );
        connection.modify( "ou=services,ou=configuration, ou=system", modification );

        System.out.println( "----- Checking exclusions" );
        entries = getAllEntries( connection, true );

        // entry should not show the c-ou collective attribute anymore
        entry = entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        System.out.println( "----- Exclusions OK" );

        // now add more collective subentries - the c-ou should still not show due to exclusions
        connection.add( getTestSubentry2( "cn=testsubentry2,ou=system" ) );
        entries = getAllEntries( connection, false );

        entry = entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );

        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // entries without the collectiveExclusion should still show both values of c-ou
        entry = entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        // -------------------------------------------------------------------
        // now add the subentry for the c-st collective attribute
        // -------------------------------------------------------------------

        connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) );
        entries = getAllEntries( connection, false );

        // the new attribute c-st should appear in the node with the c-ou exclusion
        entry = entries.get( "ou=services,ou=configuration,ou=system" );
        Attribute c_st = entry.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // in node without exclusions both values of c-ou should appear with c-st value
        entry = entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = entry.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );
        c_st = entry.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // -------------------------------------------------------------------
        // now modify an entry to exclude all collective attributes
        // -------------------------------------------------------------------
        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute(
            "collectiveExclusions", "excludeAllCollectiveAttributes" ) );
        connection.modify( "ou=interceptors,ou=configuration, ou=system", modification );

        entries = getAllEntries( connection, false );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.DefaultModification

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.