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

Examples of org.apache.directory.api.ldap.model.ldif.LdifEntry


        Tuple<Dn, String> t = null;

        if ( reader.hasNext() )
        {
            LdifEntry ldifEntry = reader.next();

            if ( ldifEntry == null )
            {
                throw new IllegalStateException(
                    "Received null entry while parsing, check the LDIF file for possible incorrect/corrupted entries" );
            }

            t = new Tuple<Dn, String>();

            t.setKey( ldifEntry.getDn() );
            t.setValue( ldifEntry.getOffset() + ":" + ldifEntry.getLengthBeforeParsing() );
        }

        return t;
    }
View Full Code Here


                "objectclass: top\n" +
                "ou: test\n" +
                "entryUUID: 8c7b24a6-1687-461c-88ea-4d30fc234f9b\n" +
                "entryCSN: 20100919005926.530000Z#000000#000#000000";

        LdifEntry ldifEntry = reader.parseLdif( contextEntryStr ).get( 0 );

        contextEntry = new ClonedServerEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );

        CacheService cacheService = new CacheService();
        cacheService.initialize( null );
        dnFactory = new DefaultDnFactory( schemaManager, cacheService.getCache( "dnCache" ) );
    }
View Full Code Here

        file.read( entry1Data );

        String ldif = Strings.utf8ToString( entry1Data );

        LdifEntry ldifEntry = reader.parseLdif( ldif ).get( 0 );

        // Remove the EntryDN
        entry1.removeAttributes( "entryDn" );

        assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );

        //"description: desc of entry1\n"

        modOpCtx = new ModifyOperationContext( mockSession );
        modOpCtx.setEntry( new ClonedServerEntry( entry1 ) );
        modOpCtx.setDn( entry1.getDn() );

        modItems = new ArrayList<Modification>();

        attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
        attribute.add( "desc of entry1" ); // reversed "this is description"

        mod = new DefaultModification();
        mod.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
        mod.setAttribute( attribute );

        modItems.add( mod );
        modOpCtx.setModItems( modItems );

        partition.modify( modOpCtx );

        file.seek( ctxEntryLen );

        entry1Len = getEntryLdifLen( entry1 );
        entry1Data = new byte[( int ) entry1Len];

        file.read( entry1Data );

        ldif = Strings.utf8ToString( entry1Data );

        ldifEntry = reader.parseLdif( ldif ).get( 0 );

        // Remove the EntryDN
        entry1.removeAttributes( "entryDn" );

        assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );

        partition = reloadPartition();
        assertExists( partition, contextEntry );
        assertExists( partition, entry1 );
        assertExists( partition, entry2 );
View Full Code Here

    @Test
    public void testLogCheckRevision() throws Exception
    {
        assertEquals( "first revision is always 0", 0, store.getCurrentRevision() );

        LdifEntry forward = new LdifEntry();
        forward.setDn( "ou=system" );
        forward.setChangeType( ChangeType.Add );
        forward.putAttribute( "objectClass", "organizationalUnit" );
        forward.putAttribute( "ou", "system" );

        LdifEntry reverse = LdifRevertor.reverseAdd( forward.getDn() );
        assertEquals( 1, store.log( new LdapPrincipal( schemaManager ), forward, reverse ).getRevision() );
        assertEquals( 1, store.getCurrentRevision() );
    }
View Full Code Here

        systemDn.apply( schemaManager );

        Dn adminDn = new Dn( schemaManager, "uid=admin, ou=system" );
        adminDn.apply( schemaManager );

        LdifEntry forward = new LdifEntry();
        forward.setDn( systemDn );
        forward.setChangeType( ChangeType.Add );
        forward.putAttribute( "objectClass", "organizationalUnit" );
        forward.putAttribute( "ou", "system" );

        Dn reverseDn = forward.getDn();
        reverseDn.apply( schemaManager );

        LdifEntry reverse = LdifRevertor.reverseAdd( reverseDn );

        String zuluTime = DateUtils.getGeneralizedTime();
        long revision = 1L;

        LdapPrincipal principal = new LdapPrincipal( schemaManager, adminDn, AuthenticationLevel.SIMPLE,
View Full Code Here

    {
        for ( LdifEntry testEntry : testEntries )
        {
            try
            {
                LdifEntry ldifEntry = testEntry.clone();
                Entry entry = ldifEntry.getEntry();
                String dn = ldifEntry.getDn().getName();

                try
                {
                    getAdminSession().add( new DefaultEntry( schemaManager, entry ) );
                }
View Full Code Here

                List<LdifEntry> entries = ldifReader.parseLdif( entryStr );

                if ( ( entries != null ) && ( entries.size() > 0 ) )
                {
                    LdifEntry entry = entries.get( 0 );
                    partition.setContextEntry( entry.getEntry() );
                }

                try
                {
                    ldifReader.close();
View Full Code Here

                return;
            }

            // Getting the context entry
            LdifEntry ldifEntry = itr.next();
            Entry contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );

            // Checking the context entry
            if ( suffixDn.equals( contextEntry.getDn() ) )
            {
                addMandatoryOpAt( contextEntry );
View Full Code Here

        while ( reader.hasNext() )
        {
            // FastLdifReader will always return NULL LdifEntry
            // call getDnTuple() after next() to get a DnTuple
            LdifEntry entry = reader.next();
           
            DnTuple dt = reader.getDnTuple();
           
            dt.getDn().apply( schemaManager );
            sortedDnSet.add( dt );
View Full Code Here

    @Override
    protected LdifEntry createLdifEntry()
    {
        Entry entry = new DefaultEntry( schemaManager );
        return new LdifEntry( entry );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.ldif.LdifEntry

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.