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

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


     * Test for method add( String, byte[]...)
     */
    @Test
    public void testAddStringByteArrayArray() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        entry.add( "userPassword", ( byte[] ) null );
        assertEquals( 1, entry.size() );
        Attribute attributePWD = entry.get( "userPassword" );
        assertEquals( 1, attributePWD.size() );
        assertNotNull( attributePWD.get() );
        assertNull( attributePWD.get().getValue() );

        entry.clear();

        entry.add( "userPassword", BYTES1, BYTES1, BYTES2 );
        assertEquals( 1, entry.size() );
        Attribute attributeJPG = entry.get( "userPassword" );
        assertEquals( 2, attributeJPG.size() );
        assertNotNull( attributeJPG.get() );
        assertTrue( attributeJPG.contains( BYTES1 ) );
        assertTrue( attributeJPG.contains( BYTES2 ) );

        entry.clear();

        try
        {
            // Cannot add an attribute which does not exist
            entry.add( "wrongAT", BYTES1, BYTES2 );
            fail();
        }
        catch ( LdapNoSuchAttributeException nsae )
        {
            assertTrue( true );
        }

        // Cannot add String values into a binary attribute
        entry.add( "userPassword", "test", "test2" );
        assertEquals( 2, entry.get( "userPassword" ).size() );
    }
View Full Code Here


            // First, add 100 entries in the server
            for ( int i = 0; i < 100; i++ )
            {
                String dn = "cn=user" + i + "," + BASE;
                Entry kate = new DefaultEntry( dn );

                kate.add( "objectclass", "top", "person" );
                kate.add( "sn", "Bush" );
                kate.add( "cn", "user" + i );

                asyncCnx.add( kate );
            }

            // Searches for all the entries in ou=system
View Full Code Here

                if ( contextEntry == null )
                {
                    if ( contextEntryFile.exists() )
                    {
                        LdifReader reader = new LdifReader( contextEntryFile );
                        contextEntry = new DefaultEntry( schemaManager, reader.next().getEntry() );
                        reader.close();
                    }
                    else
                    {
                        // No context entry and no LDIF file exists.
                        // Skip initialization of context entry here, it will be added later.
                        return;
                    }
                }

                // Initialization of the context entry
                if ( ( suffixDn != null ) && ( contextEntry != null ) )
                {
                    Dn contextEntryDn = contextEntry.getDn();

                    // Checking if the context entry DN is schema aware
                    if ( !contextEntryDn.isSchemaAware() )
                    {
                        contextEntryDn.apply( schemaManager );
                    }

                    // We're only adding the entry if the two DNs are equal
                    if ( suffixDn.equals( contextEntryDn ) )
                    {
                        // Looking for the current context entry
                        Entry suffixEntry = lookup( new LookupOperationContext( null, suffixDn ) );

                        // We're only adding the context entry if it doesn't already exist
                        if ( suffixEntry == null )
                        {
                            // Checking of the context entry is schema aware
                            if ( !contextEntry.isSchemaAware() )
                            {
                                // Making the context entry schema aware
                                contextEntry = new DefaultEntry( schemaManager, contextEntry );
                            }

                            // Adding the 'entryCsn' attribute
                            if ( contextEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
                            {
View Full Code Here

                {
                    // this ldif will have only one entry
                    LdifEntry ldifEntry = ldifEntries.get( 0 );
                    LOG.debug( "Adding entry {}", ldifEntry );

                    Entry serverEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );

                    if ( !serverEntry.containsAttribute( SchemaConstants.ENTRY_CSN_AT ) )
                    {
                        serverEntry.put( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
                    }

                    if ( !serverEntry.containsAttribute( SchemaConstants.ENTRY_UUID_AT ) )
                    {
                        serverEntry.put( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
                    }

                    // call add on the wrapped partition not on the self
                    AddOperationContext addContext = new AddOperationContext( null, serverEntry );
                    super.add( addContext );
View Full Code Here

   
        while ( reader.hasNext() )
        {
            LdifEntry entry = reader.next();
            getLdapServer().getDirectoryService().getAdminSession().add(
                new DefaultEntry( getLdapServer().getDirectoryService().getSchemaManager(), entry.getEntry() ) );
        }
   
        reader.close();
   
        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
View Full Code Here

        while ( reader.hasNext() )
        {
            LdifEntry entry = reader.next();
            getLdapServer().getDirectoryService().getAdminSession().add(
                new DefaultEntry( getLdapServer().getDirectoryService().getSchemaManager(), entry.getEntry() ) );
        }

        reader.close();
    }
View Full Code Here

        assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid() );
        assertNotNull( evaluator.getNormalizer() );
        assertNotNull( evaluator.getComparator() );

        Dn dn = new Dn( schemaManager, "cn=jane doe,o=good times co." );
        Entry attrs = new DefaultEntry( schemaManager, dn );
        attrs.add( "objectClass", "person" );
        attrs.add( "c-street", "3" );
        attrs.add( "cn", "jane doe" );
        attrs.add( "sn", "doe" );
        attrs.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        attrs.add( "entryUUID", Strings.getUUID( 12L ).toString() );

        AddOperationContext addContext = new AddOperationContext( null, attrs );
        ( ( Partition ) store ).add( addContext );

        indexEntry.setId( Strings.getUUID( 12L ) );
View Full Code Here

        LdapNetworkConnection nc = connections.get( 0 );
       
        for( Rdn rdn : parentDn.getRdns() )
        {
            currentDn = new Dn( rdn.getName() + "," + currentDn.getName() );
            Entry e = new DefaultEntry( currentDn.getName(),
            "objectclass: top",
            "objectclass: organizationalUnit",
            "ou: " + rdn.getAva().getValue().getString() );
            nc.add( e );
        }
View Full Code Here

    {
        try
        {
            String cn = RDN_PREFIX + num;
            Dn personDn = new Dn( "cn=" + cn + "," + REPL_AREA_SUFFIX );
            Entry person = new DefaultEntry(
                personDn.toString(),
                "ObjectClass: top",
                "ObjectClass: person",
                "cn: " + cn,
                "sn: sn_" + cn,
View Full Code Here

            t1.join();
            t2.join();
           
            cc.prepareConnections();

            Entry ctxEntry = new DefaultEntry( "dc=example,dc=com",
                "objectClass: domain",
                "objectClass: top",
                "dc: example" );

            for( LdapConnection lc : cc.connections )
            {
                lc.add( ctxEntry );
            }

            Entry replAreaEntry = new DefaultEntry( REPL_AREA_SUFFIX,
                "objectClass: organizationalunit",
                "ou: replicationarea" );

            cc.injectAndWaitTillReplicates( replAreaEntry );
           
            cc.moveOutOfReplAreaAndCompare();
           
            cc.addAndCompare();
           
            List<Dn> modified = cc.modify();
            Thread.sleep( 15000 );
           
            cc.compareEntries( modified );
           
            Entry groupEntry = new DefaultEntry( "ou=groups," + REPL_AREA_SUFFIX,
                "objectClass: organizationalUnit",
                "objectClass: top",
                "ou: groups" );
           
            cc.injectAndWaitTillReplicates( groupEntry );
           
            cc.moveAndCompare( groupEntry.getDn() );
           
            List<Dn> renamed = cc.renameAndCompare( groupEntry.getDn() );
           
            cc.deleteAndVerify( renamed );
        }
        catch( Exception e )
        {
View Full Code Here

TOP

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

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.