Package javax.naming.directory

Examples of javax.naming.directory.ModificationItem


        // -------------------------------------------------------------------
        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------

        ModificationItem[] items = new ModificationItem[]
            { new ModificationItem( DirContext.ADD_ATTRIBUTE,
                new BasicAttribute( "collectiveExclusions", "c-ou" ) ) };
        getSystemContext( service ).modifyAttributes( "ou=services,ou=configuration", items );

        // entry should not show the c-ou collective attribute anymore
        attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
        c_ou = attributes.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
        getSystemContext( service ).createSubcontext( "cn=testsubentry2", getTestSubentry2() );

        attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
        c_ou = attributes.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
        attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );
        c_ou = attributes.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
       
        attributes = getSystemContext( service ).getAttributes(
                "ou=interceptors,ou=configuration", new String[] { "c-ou" } );
        c_ou = attributes.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

        attributes = getSystemContext( service ).getAttributes(
                "ou=interceptors,ou=configuration", new String[] { "objectClass" } );
        c_ou = attributes.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
        // -------------------------------------------------------------------

        getSystemContext( service ).createSubcontext( "cn=testsubentry3", getTestSubentry3() );

        // the new attribute c-st should appear in the node with the c-ou exclusion
        attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
        Attribute c_st = attributes.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
        attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );
        c_ou = attributes.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 = attributes.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
        // -------------------------------------------------------------------

        items = new ModificationItem[]
            { new ModificationItem( DirContext.REPLACE_ATTRIBUTE, new BasicAttribute( "collectiveExclusions",
                "excludeAllCollectiveAttributes" ) ) };
        getSystemContext( service ).modifyAttributes( "ou=interceptors,ou=configuration", items );

        // none of the attributes should appear any longer
        attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );
View Full Code Here


        // -------------------------------------------------------------------
        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------

        ModificationItem[] items = new ModificationItem[]
            { new ModificationItem( DirContext.ADD_ATTRIBUTE,
                new BasicAttribute( "collectiveExclusions", "c-ou" ) ) };
        getSystemContext( service ).modifyAttributes( "ou=services,ou=configuration", items );
        entries = getAllEntries();

        // entry should not show the c-ou collective attribute anymore
        attributes = entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = attributes.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
        getSystemContext( service ).createSubcontext( "cn=testsubentry2", getTestSubentry2() );
        entries = getAllEntries();

        attributes = entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = attributes.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
        attributes = entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = attributes.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
        // -------------------------------------------------------------------

        getSystemContext( service ).createSubcontext( "cn=testsubentry3", getTestSubentry3() );
        entries = getAllEntries();

        // the new attribute c-st should appear in the node with the c-ou exclusion
        attributes = entries.get( "ou=services,ou=configuration,ou=system" );
        Attribute c_st = attributes.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
        attributes = entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = attributes.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 = attributes.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
        // -------------------------------------------------------------------

        items = new ModificationItem[]
            { new ModificationItem( DirContext.REPLACE_ATTRIBUTE, new BasicAttribute( "collectiveExclusions",
                "excludeAllCollectiveAttributes" ) ) };
        getSystemContext( service ).modifyAttributes( "ou=interceptors,ou=configuration", items );
        entries = getAllEntries();

        // none of the attributes should appear any longer
View Full Code Here

    public void testModifyRegularEntryAddingCollectiveAttribute2() throws Exception
    {
        Attributes entry = getTestEntry( "Ersin Er" );
        getSystemContext( service ).createSubcontext( "cn=Ersin Er", entry );
        Attribute change = new BasicAttribute( "c-l", "Turkiye");
        ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, change);
        try
        {
            getSystemContext( service ).modifyAttributes( "cn=Ersin Er", new ModificationItem[] { mod } );
            fail( "Collective attribute addition to non-collectiveAttributeSubentry should have failed." );
        }
View Full Code Here

        DN dn = getComparatorContainer( "apachemeta" );
        dn.add( "m-oid" + "=" + OID );

        ModificationItem[] mods = new ModificationItem[1];
        Attribute attr = new BasicAttribute( "m-fqcn", BooleanComparator.class.getName() );
        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        getSchemaContext( service ).modifyAttributes( dn, mods );

        assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );

        assertEquals( "comparator schema should be set to apachemeta", schemaManager.getComparatorRegistry()
View Full Code Here

    private void enableSchema( String schemaName ) throws Exception
    {
        // now enable the test schema
        ModificationItem[] mods = new ModificationItem[1];
        Attribute attr = new BasicAttribute( "m-disabled", "FALSE" );
        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        getSchemaContext( service ).modifyAttributes( "cn=" + schemaName, mods );
    }
View Full Code Here

        ctx.createSubcontext( rdn, attrs );

        // Add the first value for description
        String description1 = "an American singer-songwriter";
        Attribute firstDescr = new BasicAttribute( "description", description1 );
        ModificationItem modification = new ModificationItem(DirContext.ADD_ATTRIBUTE, firstDescr);
        ctx.modifyAttributes(rdn, new ModificationItem[] { modification });

        // Add a second value to description
        String description2 = "Grammy award winning";
        Attribute otherDescr = new BasicAttribute( "description", description2 );

        modification = new ModificationItem(DirContext.ADD_ATTRIBUTE, otherDescr );
        ctx.modifyAttributes(rdn, new ModificationItem[] { modification } );
     
        // Add a third value to description
        String description3 = "MTV Music Award winning";
        Attribute thirdDescr = new BasicAttribute( "description", description3 );

        modification = new ModificationItem(DirContext.ADD_ATTRIBUTE, thirdDescr );
        ctx.modifyAttributes(rdn, new ModificationItem[] { modification });

        // Search Entry
        SearchControls sctls = new SearchControls();
        sctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
View Full Code Here

        testAddEnabledSchemaNoDeps();
        assertTrue( IntegrationUtils.isEnabled( service, "dummy" ) );
       
        // make the nis schema depend on the dummy schema
        ModificationItem[] mods = new ModificationItem[1];
        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
                new BasicAttribute( "m-dependencies", "dummy" ) );
        schemaRoot.modifyAttributes( "cn=nis", mods );
       
        // attempt to delete it now & it should fail
        try
View Full Code Here

       
        // now try to disable the test schema which should fail
        // since it's dependent, the dummy schema, is enabled
        ModificationItem[] mods = new ModificationItem[1];
        Attribute attr = new BasicAttribute( "m-disabled", "TRUE" );
        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
       
        try
        {
            schemaRoot.modifyAttributes( "cn=nis", mods );
            fail( "attempt to disable schema with enabled dependents should fail" );
View Full Code Here

    {
        LdapContext schemaRoot = getSchemaContext( service );

        ModificationItem[] mods = new ModificationItem[1];
        Attribute attr = new BasicAttribute( "m-dependencies", "bogus" );
        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
       
        try
        {
            schemaRoot.modifyAttributes( "cn=nis", mods );
            fail( "Should not be able to add bogus dependency to schema" );
View Full Code Here

    {
        LdapContext schemaRoot = getSchemaContext( service );
        IntegrationUtils.enableSchema( service, "nis" );
        ModificationItem[] mods = new ModificationItem[1];
        Attribute attr = new BasicAttribute( "m-dependencies", "mozilla" );
        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
       
        try
        {
            schemaRoot.modifyAttributes( "cn=nis", mods );
            fail( "Should not be able to add disabled dependency to schema" );
View Full Code Here

TOP

Related Classes of javax.naming.directory.ModificationItem

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.