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

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


                "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() ) );
    }
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

   
        LdifReader reader = new LdifReader( new StringReader( ldif ) );
   
        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

        // The revision
        long revision = in.readLong();

        // The forward LDIF
        LdifEntry forwardEntry = new LdifEntry();

        try
        {
            forwardEntry.readExternal( in );
        }
        catch ( ClassNotFoundException cnfe )
        {
            IOException ioe = new IOException( cnfe.getMessage() );
            ioe.initCause( cnfe );
            throw ioe;
        }

        // The reverse LDIFs number
        int nbReverses = in.readInt();

        List<LdifEntry> reverses = new ArrayList<LdifEntry>( nbReverses );

        for ( int i = 0; i < nbReverses; i++ )
        {
            LdifEntry reverseEntry = new LdifEntry();

            try
            {
                reverseEntry.readExternal( in );
            }
            catch ( ClassNotFoundException cnfe )
            {
                IOException ioe = new IOException( cnfe.getMessage() );
                ioe.initCause( cnfe );
View Full Code Here

                ldifReader.close();

                if ( ( ldifEntries != null ) && !ldifEntries.isEmpty() )
                {
                    // 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() );
                    }
View Full Code Here

    {
        try
        {
            LdifReader ldifReader = new LdifReader( in );
            boolean first = true;
            LdifEntry ldifEntry = null;

            try
            {
                while ( ldifReader.hasNext() )
                {
                    if ( first )
                    {
                        ldifEntry = ldifReader.next();
   
                        if ( ldifEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
                        {
                            // No UUID, let's create one
                            UUID entryUuid = UUID.randomUUID();
                            ldifEntry.addAttribute( SchemaConstants.ENTRY_UUID_AT, entryUuid.toString() );
                        }
                        if ( ldifEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
                        {
                            // No CSN, let's create one
                            Csn csn = csnFactory.newInstance();
                            ldifEntry.addAttribute( SchemaConstants.ENTRY_CSN_AT, csn.toString() );
                        }
   
                        first = false;
                    }
                    else
                    {
                        // throw an exception : we should not have more than one entry per schema ldif file
                        String msg = I18n.err( I18n.ERR_08003, source );
                        LOG.error( msg );
                        throw new InvalidObjectException( msg );
                    }
                }
            }
            finally
            {
                ldifReader.close();
            }

            // inject the entry
            Entry entry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
            AddOperationContext addContext = new AddOperationContext( null, entry );
            partition.add( addContext );
        }
        catch ( LdapLdifException ne )
        {
View Full Code Here

        String ref0 = "ldap://fermi:10389/ou=users,ou=system";
        String ref1 = "ldap://hertz:10389/ou=users,dc=example,dc=com";
        String ref2 = "ldap://maxwell:10389/ou=users,ou=system";
        td.rootCtx = getSystemContext( getService() );

        LdifEntry akarasulu = getUserAddLdif();
        getService().getAdminSession().add(
            new DefaultEntry( getService().getSchemaManager(), akarasulu.getEntry() ), true );

        // -------------------------------------------------------------------
        // Adds a referral entry regardless of referral handling settings
        // -------------------------------------------------------------------
View Full Code Here

            "m-obsolete: FALSE\n" +
            "m-description: A ship\n";

        StringReader in = new StringReader( numberOfGunsAttrLdif + "\n\n" + shipOCLdif );
        LdifReader ldifReader = new LdifReader( in );
        LdifEntry numberOfGunsAttrEntry = ldifReader.next();
        LdifEntry shipOCEntry = ldifReader.next();
        assertFalse( ldifReader.hasNext() );
        ldifReader.close();

        // should be fine with unique OID
        getService().getAdminSession().add(
            new DefaultEntry( getService().getSchemaManager(), numberOfGunsAttrEntry.getEntry() ) );

        // should blow chuncks using same OID
        try
        {
            getService().getAdminSession().add(
                new DefaultEntry( getService().getSchemaManager(), shipOCEntry.getEntry() ) );

            fail( "Should not be possible to create two schema entities with the same OID." );
        }
        catch ( LdapOtherException e )
        {
View Full Code Here

            opRevision = revision.incrementAndGet();

            // Store the added entry
            Entry addEntry = addContext.getEntry();

            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.Add );
            ldif.setDn( addContext.getDn() );

            for ( Attribute attribute : addEntry.getAttributes() )
            {
                AttributeType attributeType = attribute.getAttributeType();
                ldif.addAttribute( addEntry.get( attributeType ).clone() );
            }

            log( addContext, opRevision, ldif );
        }
View Full Code Here

        if ( journalEnabled )
        {
            opRevision = revision.incrementAndGet();

            // Store the deleted entry
            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.Delete );
            ldif.setDn( deleteContext.getDn() );

            journal.log( getPrincipal( deleteContext ), opRevision, ldif );
        }

        try
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.