Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.Modification


            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );

        String attribVal = "Marketing";
        attrib.add( attribVal );

        Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
        mods.add( add );

        ServerEntry lookedup = store.lookup( store.getEntryId( dn.getNormName() ) );

        assertNull( lookedup.get( "ou" ) ); // before replacing
View Full Code Here


        AttributeType at;
        try
        {
            at = directoryService.getSchemaManager().lookupAttributeTypeRegistry( key );
            EntryAttribute attr = new DefaultServerAttribute( at );
            Modification mi = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
            addDelta( mi );
        }
        catch ( LdapException e )
        {
            e.printStackTrace();
View Full Code Here

        AttributeType at;
        try
        {
            at = directoryService.getSchemaManager().lookupAttributeTypeRegistry( key );
            EntryAttribute attr = new DefaultServerAttribute( at, value );
            Modification mi = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
            addDelta( mi );
        }
        catch ( LdapException e )
        {
            e.printStackTrace();
View Full Code Here

     *
     */
    public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
    {
        ServerEntry serverEntry = null;
        Modification modification = ServerEntryUtils.getModificationItem( opContext.getModItems(), entryDeleted );
        boolean isDelete = ( modification != null );

        if ( ! isDelete && ( changeLog.isEnabled() && opContext.isFirstOperation() ) )
        {
            // @todo make sure we're not putting in operational attributes that cannot be user modified
            serverEntry = getAttributes( opContext );
        }
       
        // Duplicate modifications so that the reverse does not contain the operational attributes
        List<Modification> clonedMods = new ArrayList<Modification>();

        for ( Modification mod : opContext.getModItems() )
        {
            clonedMods.add( mod.clone() );
        }

        // Call the next interceptor
        next.modify( opContext );

        // @TODO: needs big consideration!!!
        // NOTE: perhaps we need to log this as a system operation that cannot and should not be reapplied?
        if (
            isDelete ||  
            ! changeLog.isEnabled() ||
            ! opContext.isFirstOperation() ||
           
         // if there are no modifications due to stripping out bogus non-
         // existing attributes then we will have no modification items and
         // should ignore not this without registering it with the changelog
        
            opContext.getModItems().size() == 0
        {
            if ( isDelete )
            {
                LOG.debug( "Bypassing changelog on modify of entryDeleted attribute." );
            }
           
            return;
        }

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.Modify );
        forward.setDn( opContext.getDn() );
       
        List<Modification> mods = new ArrayList<Modification>( clonedMods.size() );
       
        for ( Modification modItem : clonedMods )
        {
            Modification mod = ((ServerModification)modItem).toClientModification();
           
            // TODO: handle correctly http://issues.apache.org/jira/browse/DIRSERVER-1198
            mod.getAttribute().setId( modItem.getAttribute().getId() );
            mods.add( mod );
           
            forward.addModificationItem( mod );
        }
       
View Full Code Here

                operation = ModificationOperation.ADD_ATTRIBUTE;
                break;
               
        }
       
        Modification modification = new ServerModification(
            operation,
            ServerEntryUtils.toServerAttribute( modificationImpl.getAttribute(), attributeType ) );
       
        return modification;
       
View Full Code Here

        if ( modification instanceof ServerModification )
        {
            return modification;
        }
       
        Modification serverModification = new ServerModification(
            modification.getOperation(),
            new DefaultServerAttribute( attributeType, modification.getAttribute() ) );
       
        return serverModification;
       
View Full Code Here

     * @param type the attributeType spec of the Attribute to extract
     * @return the extract Attribute or null if no such attribute exists
     */
    public static EntryAttribute getAttribute( List<Modification> mods, AttributeType type )
    {
        Modification mod = getModificationItem( mods, type );
       
        if ( mod != null )
        {
            return mod.getAttribute();
        }
       
        return null;
    }
View Full Code Here

    private void disableSchema( String schemaName ) throws Exception
    {
        LdapDN dn = new LdapDN( SchemaConstants.CN_AT + "=" + schemaName + "," + SchemaConstants.OU_AT + "=schema" );
        dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );

        Modification mod = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultServerAttribute(
            MetaSchemaConstants.M_DISABLED_AT, registries.getAttributeTypeRegistry().lookup(
                MetaSchemaConstants.M_DISABLED_AT ), "TRUE" ) );

        List<Modification> mods = new ArrayList<Modification>();
        mods.add( mod );
View Full Code Here

        ServerAttribute attribute = new DefaultServerAttribute(
            SchemaConstants.MODIFIERS_NAME_AT,
            modifiersNameAt,
            getPrincipal().getName());

        Modification modifiers = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
        //modifiers.setServerModified();
        modItemList.add( modifiers );
       
        AttributeType modifyTimeStampAt = atRegistry.lookup( SchemaConstants.MODIFY_TIMESTAMP_AT );
        attribute = new DefaultServerAttribute(
            SchemaConstants.MODIFY_TIMESTAMP_AT,
            modifyTimeStampAt,
            DateUtils.getGeneralizedTime() );
       
        Modification timestamp = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
        //timestamp.setServerModified();
        modItemList.add( timestamp );

        // -------------------------------------------------------------------
        // Make the modify() call happen
View Full Code Here

    {
        boolean hasModification = SCHEMA_UNCHANGED;
       
        // Check if the entry has a m-disabled attribute
        EntryAttribute disabledInEntry = entry.get( disabledAT );
        Modification disabledModification = ServerEntryUtils.getModificationItem( mods, disabledAT );
       
        if ( disabledModification != null )
        {
            // We are trying to modify the m-disabled attribute.
            hasModification = disable( name,
                     disabledModification.getOperation(),
                     (ServerAttribute)disabledModification.getAttribute(),
                     disabledInEntry );
        }

        // check if the new schema is enabled or disabled
        boolean isEnabled = false;
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.Modification

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.