当前位置: 首页>>代码示例>>Java>>正文


Java Modification类代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Modification的典型用法代码示例。如果您正苦于以下问题:Java Modification类的具体用法?Java Modification怎么用?Java Modification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Modification类属于org.apache.directory.api.ldap.model.entry包,在下文中一共展示了Modification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateServerModification

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
    Attribute attribute = new DefaultAttribute( "cn", cnAT );
    attribute.add( "test1", "test2" );

    Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
    Modification clone = mod.clone();

    attribute.remove( "test2" );

    Attribute clonedAttribute = clone.getAttribute();

    assertEquals( 1, mod.getAttribute().size() );
    assertTrue( mod.getAttribute().contains( "TEST1" ) );

    assertEquals( 2, clonedAttribute.size() );
    assertTrue( clone.getAttribute().contains( "test1" ) );
    assertTrue( clone.getAttribute().contains( "test2" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:SchemaAwareModificationSerializationTest.java

示例2: testCreateServerModification

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
    Attribute attribute = new DefaultAttribute( "cn" );
    attribute.add( "test1", "test2" );

    Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
    Modification clone = mod.clone();

    attribute.remove( "test2" );

    Attribute clonedAttribute = clone.getAttribute();

    assertEquals( 1, mod.getAttribute().size() );
    assertTrue( mod.getAttribute().contains( "test1" ) );

    assertEquals( 2, clonedAttribute.size() );
    assertTrue( clone.getAttribute().contains( "test1" ) );
    assertTrue( clone.getAttribute().contains( "test2" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:ModificationTest.java

示例3: testApplyAddModificationToEntry

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test a addModification applied to an entry 
 */
@Test
public void testApplyAddModificationToEntry() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.add( "dc", "apache" );
    assertEquals( 1, entry.size() );

    Attribute attr = new DefaultAttribute( "cn", "test" );
    Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );
    assertNotNull( entry.get( "cn" ) );
    assertEquals( 2, entry.size() );
    assertEquals( attr, entry.get( "cn" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:AttributeUtilsTest.java

示例4: testApplyRemoveModificationFromEntryAttributeNotPresent

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which does not contain the attribute
 */
@Test
public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute dc = new DefaultAttribute( "dc", "apache" );
    entry.put( dc );

    Attribute cn = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, cn );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertNotNull( entry.get( "dc" ) );
    assertEquals( 1, entry.size() );
    assertEquals( dc, entry.get( "dc" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java

示例5: testApplyRemoveModificationFromEntryAttributeNotSameValue

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which contains the attribute
 * but without the value to be deleted
 */
@Test
public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute cn = new DefaultAttribute( "cn", "apache" );
    entry.put( cn );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNotNull( entry.get( "cn" ) );
    assertEquals( 1, entry.size() );
    assertEquals( cn, entry.get( "cn" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java

示例6: testApplyRemoveModificationFromEntrySameAttributeSameValue

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which contains the attribute.
 * 
 * The entry should not contain the attribute after the operation
 */
@Test
public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertEquals( 0, entry.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:AttributeUtilsTest.java

示例7: testApplyModifyModificationRemoveAttribute

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test the removing by modification of an existing attribute in an .
 * 
 * @throws LdapException
 */
@Test
public void testApplyModifyModificationRemoveAttribute() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );
    entry.put( "ou", "apache", "acme corp" );

    Attribute newOu = new DefaultAttribute( "ou" );

    Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );

    AttributeUtils.applyModification( entry, modification );

    assertEquals( 1, entry.size() );

    assertNotNull( entry.get( "cn" ) );
    assertNull( entry.get( "ou" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:AttributeUtilsTest.java

示例8: testNotEqualDiffModCount

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * Test for inequality when only the number of mods are different.
 */
@Test
public void testNotEqualDiffModCount() throws LdapException
{
    ModifyRequestImpl req0 = getRequest();
    Attribute attr = new DefaultAttribute( "attr3" );
    attr.add( "val0" );
    attr.add( "val1" );
    attr.add( "val2" );
    Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
    req0.addModification( item );

    ModifyRequestImpl req1 = getRequest();

    assertFalse( req0.equals( req1 ) );
    assertFalse( req1.equals( req0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:ModifyRequestImplTest.java

示例9: testReaderAttrIdCaseInsensitive

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
private void testReaderAttrIdCaseInsensitive( String ldif ) throws Exception
{
    LdifReader reader = new LdifReader();

    List<LdifEntry> entries = reader.parseLdif( ldif );
    assertNotNull( entries );
    reader.close();

    LdifEntry entry = entries.get( 0 );

    assertTrue( entry.isChangeModify() );

    assertEquals( "dc=example,dc=com", entry.getDn().getName() );

    List<Modification> mods = entry.getModifications();
    assertTrue( mods.size() == 1 );
    Attribute attr = mods.get( 0 ).getAttribute();
    assertTrue( attr.getId().equals( "administrativerole" ) );
    assertEquals( attr.getString(), "accessControlSpecificArea" );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:LdifReaderTest.java

示例10: modify

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void modify( Dn dn, List<Modification> mods, LogChange log ) throws LdapException
{
    if ( mods == null )
    {
        return;
    }

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

    for ( Modification mod : mods )
    {
        serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) );
    }

    ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications );

    modifyContext.setLogChange( log );

    OperationManager operationManager = directoryService.getOperationManager();
    operationManager.modify( modifyContext );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:25,代码来源:DefaultCoreSession.java

示例11: createContextCsnModList

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
private void createContextCsnModList() throws LdapException
{
    Modification contextCsnMod = new DefaultModification();
    contextCsnMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
    DefaultAttribute contextCsnAt = new DefaultAttribute( schemaManager
        .lookupAttributeTypeRegistry( SchemaConstants.CONTEXT_CSN_AT ) );
    contextCsnMod.setAttribute( contextCsnAt );

    mods.add( contextCsnMod );

    Modification timeStampMod = new DefaultModification();
    timeStampMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
    DefaultAttribute timeStampAt = new DefaultAttribute( schemaManager
        .lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ) );
    timeStampMod.setAttribute( timeStampAt );

    mods.add( timeStampMod );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:19,代码来源:DefaultPartitionNexus.java

示例12: convertToServerModification

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
 * 
 * Convert a list of ModificationItemImpl to a list of 
 *
 * @param modificationImpls
 * @param atRegistry
 * @return
 * @throws LdapException
 */
public static List<Modification> convertToServerModification( List<ModificationItem> modificationItems,
    SchemaManager schemaManager ) throws LdapException
{
    if ( modificationItems != null )
    {
        List<Modification> modifications = new ArrayList<Modification>( modificationItems.size() );

        for ( ModificationItem modificationItem : modificationItems )
        {
            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( modificationItem
                .getAttribute().getID() );
            modifications.add( toServerModification( modificationItem, attributeType ) );
        }

        return modifications;
    }
    else
    {
        return null;
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:31,代码来源:ServerEntryUtils.java

示例13: writeBinaryAttribute

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
public void writeBinaryAttribute( final String entryDN, final String attributeName, final byte[][] values, final boolean overwrite )
        throws ChaiUnavailableException, ChaiOperationException
{
    activityPreCheck();
    getInputValidator().writeBinaryAttribute( entryDN, attributeName, values, overwrite );

    try
    {
        final ModifyRequest modifyRequest = new ModifyRequestImpl();
        modifyRequest.setName( new Dn( entryDN ) );
        {
            final Modification modification = new DefaultModification();
            modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE );
            modification.setAttribute( new DefaultAttribute( attributeName, values ) );
            modifyRequest.addModification( modification );
        }
        final ModifyResponse response = connection.modify( modifyRequest );
        processResponse( response );
    }
    catch ( LdapException e )
    {
        throw ChaiOperationException.forErrorMessage( e.getMessage() );
    }
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:25,代码来源:ApacheLdapProviderImpl.java

示例14: writeStringAttribute

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
public void writeStringAttribute( final String entryDN, final String attributeName, final Set<String> values, final boolean overwrite )
        throws ChaiOperationException, ChaiUnavailableException, IllegalStateException
{
    activityPreCheck();
    getInputValidator().writeStringAttribute( entryDN, attributeName, values, overwrite );

    try
    {
        final ModifyRequest modifyRequest = new ModifyRequestImpl();
        modifyRequest.setName( new Dn( entryDN ) );
        {
            final Modification modification = new DefaultModification();
            modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE );
            modification.setAttribute( new DefaultAttribute( attributeName, values.toArray( new String[values.size()] ) ) );
            modifyRequest.addModification( modification );
        }
        final ModifyResponse response = connection.modify( modifyRequest );
        processResponse( response );
    }
    catch ( LdapException e )
    {
        throw ChaiOperationException.forErrorMessage( e.getMessage() );
    }
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:25,代码来源:ApacheLdapProviderImpl.java

示例15: addAttributeModification

import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Override
protected void addAttributeModification(Dn dn, List<Modification> modifications,
		org.apache.directory.api.ldap.model.schema.ObjectClass ldapStructuralObjectClass,
		ObjectClass icfObjectClass, Attribute icfAttr, ModificationOperation modOp) {
	
	if (icfAttr.is(OperationalAttributes.LOCK_OUT_NAME) 
			&& LdapConfiguration.LOCKOUT_STRATEGY_OPENLDAP.equals(getConfiguration().getLockoutStrategy())) {
		List<Object> values = icfAttr.getValue();
		if (values.size() != 1) {
			throw new InvalidAttributeValueException("Unexpected number of values in attribute "+icfAttr);
		}
		Boolean value = (Boolean)values.get(0);
		if (value) {
			throw new UnsupportedOperationException("Locking object is not supported (only unlocking is)");
		}
		modifications.add(
				new DefaultModification(modOp, SchemaConstants.PWD_ACCOUNT_LOCKED_TIME_AT)); // no value
		
	} else {
		super.addAttributeModification(dn, modifications, ldapStructuralObjectClass, icfObjectClass, icfAttr, modOp);
	}
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:23,代码来源:LdapConnector.java


注:本文中的org.apache.directory.api.ldap.model.entry.Modification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。