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

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


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

            // Store the modified entry
            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.Modify );
            ldif.setDn( modifyContext.getDn() );

            // Store the modifications
            for ( Modification modification : modifyContext.getModItems() )
            {
                ldif.addModification( modification );
            }

            journal.log( getPrincipal( modifyContext ), opRevision, ldif );
        }
View Full Code Here


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

            // Store the moved entry
            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.ModDn );
            ldif.setDn( moveContext.getDn() );
            ldif.setNewSuperior( moveContext.getNewSuperior().getNormName() );

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

        try
View Full Code Here

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

            // Store the renamed entry
            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.ModDn );
            ldif.setDn( moveAndRenameContext.getDn() );
            ldif.setNewRdn( moveAndRenameContext.getNewRdn().getNormName() );
            ldif.setDeleteOldRdn( moveAndRenameContext.getDeleteOldRdn() );
            ldif.setNewSuperior( moveAndRenameContext.getNewDn().getNormName() );

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

        try
View Full Code Here

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

            // Store the renamed entry
            LdifEntry ldif = new LdifEntry();
            ldif.setChangeType( ChangeType.ModRdn );
            ldif.setDn( renameContext.getDn() );
            ldif.setNewRdn( renameContext.getNewRdn().getNormName() );
            ldif.setDeleteOldRdn( renameContext.getDeleteOldRdn() );

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

        try
View Full Code Here

            if ( entries == null )
            {
                entries = new ArrayList<LdifEntry>();

                // Building the default config root entry 'ou=config'
                LdifEntry configRootEntry = new LdifEntry();
                configRootEntry.setDn( new Dn( SchemaConstants.OU_AT + "=" + "config" ) );
                addObjectClassAttribute( schemaManager, configRootEntry, "organizationalUnit" );
                addAttributeTypeValues( SchemaConstants.OU_AT, "config", configRootEntry );
                entries.add( configRootEntry );

                // Building entries from the directory service beans
                List<AdsBaseBean> directoryServiceBeans = configBean.getDirectoryServiceBeans();
                for ( AdsBaseBean adsBaseBean : directoryServiceBeans )
                {
                    addBean( configRootEntry.getDn(), schemaManager, adsBaseBean, entries );
                }
            }
        }
        catch ( Exception e )
        {
View Full Code Here

        {
            // Getting the class of the bean
            Class<?> beanClass = bean.getClass();

            // Creating the entry to hold the bean and adding it to the list
            LdifEntry entry = new LdifEntry();
            entry.setDn( getDn( rootDn, bean ) );
            addObjectClassAttribute( schemaManager, entry, getObjectClassNameForBean( beanClass ) );
            entries.add( entry );

            // A flag to know when we reached the 'AdsBaseBean' class when
            // looping on the class hierarchy of the bean
            boolean adsBaseBeanClassFound = false;

            // Looping until the 'AdsBaseBean' class has been found
            while ( !adsBaseBeanClassFound )
            {
                // Checking if we reached the 'AdsBaseBean' class
                if ( beanClass == AdsBaseBean.class )
                {
                    adsBaseBeanClassFound = true;
                }

                // Looping on all fields of the bean
                Field[] fields = beanClass.getDeclaredFields();
                for ( Field field : fields )
                {
                    // Making the field accessible (we get an exception if we don't do that)
                    field.setAccessible( true );

                    // Getting the class of the field
                    Class<?> fieldClass = field.getType();
                    Object fieldValue = field.get( bean );

                    // Looking for the @ConfigurationElement annotation
                    ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class );
                    if ( configurationElement != null )
                    {
                        // Getting the annotation's values
                        String attributeType = configurationElement.attributeType();
                        String objectClass = configurationElement.objectClass();
                        String container = configurationElement.container();
                        boolean isOptional = configurationElement.isOptional();
                        String defaultValue = configurationElement.defaultValue();

                        // Checking if we have a value for the attribute type
                        if ( ( attributeType != null ) && ( !"".equals( attributeType ) ) )
                        {
                            // Checking if the field is optional and if the default value matches
                            if ( isOptional )
                            {
                                if ( ( defaultValue != null ) && ( fieldValue != null )
                                    && ( defaultValue.equalsIgnoreCase( fieldValue.toString() ) ) )
                                {
                                    // Skipping the addition of the value
                                    continue;
                                }
                            }

                            // Adding values to the entry
                            addAttributeTypeValues( configurationElement.attributeType(), fieldValue, entry );

                            continue;
                        }
                        // Checking if we have a value for the object class
                        else if ( ( objectClass != null ) && ( !"".equals( objectClass ) ) )
                        {
                            // Checking if we're dealing with a container
                            if ( ( container != null ) && ( !"".equals( container ) ) )
                            {
                                // Creating the entry for the container and adding it to the list
                                LdifEntry containerEntry = new LdifEntry();
                                containerEntry.setDn( entry.getDn().add( new Rdn( SchemaConstants.OU_AT, container ) ) );
                                addObjectClassAttribute( schemaManager, containerEntry,
                                    SchemaConstants.ORGANIZATIONAL_UNIT_OC );
                                addAttributeTypeValues( SchemaConstants.OU_AT, container, containerEntry );
                                entries.add( containerEntry );

                                if ( Collection.class.isAssignableFrom( fieldClass ) )
                                {
                                    // Looping on the Collection's objects
                                    @SuppressWarnings("unchecked")
                                    Collection<Object> collection = ( Collection<Object> ) fieldValue;
                                    if ( collection != null )
                                    {
                                        for ( Object object : collection )
                                        {
                                            if ( object instanceof AdsBaseBean )
                                            {
                                                // Adding the bean
                                                addBean( containerEntry.getDn(), schemaManager, ( AdsBaseBean ) object,
                                                    entries, entry, attributeType );

                                                continue;
                                            }
                                            else
View Full Code Here

        if ( addEntry.get( REV_AT_OID ) != null )
        {
            return;
        }

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

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

        LdifEntry reverse = LdifRevertor.reverseAdd( addContext.getDn() );
        addContext.setChangeLogEvent( changeLog.log( getPrincipal( addContext ), forward, reverse ) );
    }
View Full Code Here

        if ( serverEntry.get( REV_AT_OID ) != null )
        {
            return;
        }

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.Delete );
        forward.setDn( deleteContext.getDn() );

        Entry reverseEntry = new DefaultEntry( serverEntry.getDn() );

        boolean isCollectiveSubentry = serverEntry.hasObjectClass( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC );

        for ( Attribute attribute : serverEntry )
        {
            // filter collective attributes, they can't be added by the revert operation
            AttributeType at = schemaManager.lookupAttributeTypeRegistry( attribute.getId() );

            if ( !at.isCollective() || isCollectiveSubentry )
            {
                reverseEntry.add( attribute.clone() );
            }
        }

        LdifEntry reverse = LdifRevertor.reverseDel( deleteContext.getDn(), reverseEntry );
        deleteContext.setChangeLogEvent( changeLog.log( getPrincipal( deleteContext ), forward, reverse ) );
    }
View Full Code Here

            }

            return;
        }

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.Modify );
        forward.setDn( modifyContext.getDn() );

        List<Modification> mods = new ArrayList<Modification>( clonedMods.size() );

        for ( Modification modItem : clonedMods )
        {
            // TODO: handle correctly http://issues.apache.org/jira/browse/DIRSERVER-1198
            mods.add( modItem );

            forward.addModification( modItem );
        }

        Entry clientEntry = new DefaultEntry( serverEntry.getDn() );

        for ( Attribute attribute : serverEntry )
        {
            clientEntry.add( attribute.clone() );
        }

        LdifEntry reverse = LdifRevertor.reverseModify(
            modifyContext.getDn(),
            mods,
            clientEntry );

        modifyContext.setChangeLogEvent( changeLog.log( getPrincipal( modifyContext ), forward, reverse ) );
View Full Code Here

        if ( !changeLog.isEnabled() )
        {
            return;
        }

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.ModDn );
        forward.setDn( moveContext.getDn() );
        forward.setNewSuperior( moveContext.getNewSuperior().getName() );

        LdifEntry reverse = LdifRevertor.reverseMove( moveContext.getNewSuperior(), moveContext.getDn() );
        moveContext.setChangeLogEvent( changeLog.log( getPrincipal( moveContext ), forward, reverse ) );
    }
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.