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


Java ModificationOperation类代码示例

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


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

示例1: testCreateServerModification

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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.ModificationOperation; //导入依赖的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: modify

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
    if ( entry == null )
    {
        LOG.debug( "received a null entry for modification" );
        throw new IllegalArgumentException( "Entry to be modified cannot be null" );
    }

    ModifyRequest modReq = new ModifyRequestImpl();
    modReq.setName( entry.getDn() );

    Iterator<Attribute> itr = entry.iterator();

    while ( itr.hasNext() )
    {
        modReq.addModification( itr.next(), modOp );
    }

    ModifyResponse modifyResponse = modify( modReq );

    processResponse( modifyResponse );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:LdapNetworkConnection.java

示例10: modifyEntry

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
/**
 * 修改条目(准确是修改条目的属性)。可包括如下操作。
 *   1. ModificationOperation.ADD_ATTRIBUTE:    添加属性  
 *   2. ModificationOperation.REMOVE_ATTRIBUTE: 删除属性
 *   3. ModificationOperation.REPLACE_ATTRIBUTE:替换属性值
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-02-16
 * @version     v1.0
 *
 * @param i_Operation       操作类型
 * @param i_DN              DN标识
 * @param i_AttributeName   属性名称
 * @param i_AttributeValue  属性值(可为多个)
 * @return
 */
private boolean modifyEntry(ModificationOperation i_Operation ,String i_DN ,String i_AttributeName ,String ... i_AttributeValue)
{
    LdapConnection v_Conn     = null;
    ModifyRequest  v_Request  = new ModifyRequestImpl();
    ModifyResponse v_Response = null;
    
    try
    {
        v_Request.setName(new Dn(i_DN));
        v_Request.addModification(new DefaultModification(i_Operation ,i_AttributeName ,i_AttributeValue));
        
        v_Conn = this.getConnection();
        v_Response = v_Conn.modify(v_Request);
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    finally
    {
        this.closeConnection(v_Conn);
    }
    
    return LDAP.isSuccess(v_Response);
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.ldap,代码行数:42,代码来源:LDAP.java

示例11: createContextCsnModList

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的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: updateEntry

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
@Override
public void updateEntry(String entryDn, String attribute, String value) throws LdapException {
	logger.info("Replacing attribute " + attribute + " value " + value);
	LdapConnection connection = null;

	connection = getConnection();
	Entry entry = null;
	try {
		entry = connection.lookup(entryDn);
		if (entry != null) {
			if (entry.get(attribute) != null) {
				Value<?> oldValue = entry.get(attribute).get();
				entry.remove(attribute, oldValue);
			}
			entry.add(attribute, value);
			connection.modify(entry, ModificationOperation.REPLACE_ATTRIBUTE);
		}
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		throw new LdapException(e);
	} finally {
		releaseConnection(connection);
	}
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:25,代码来源:LDAPServiceImpl.java

示例13: updateEntry

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
public void updateEntry(String entryDn, String attribute, String value) throws Exception {
	logger.info("Replacing attribute " + attribute + " value " + value);
	LdapConnection connection = null;

	connection = getConnection();
	Entry entry = null;
	try {
		entry = connection.lookup(entryDn);
		if (entry != null) {
			if (entry.get(attribute) != null) {
				Value<?> oldValue = entry.get(attribute).get();
				entry.remove(attribute, oldValue);
			}
			entry.add(attribute, value);
			connection.modify(entry, ModificationOperation.REPLACE_ATTRIBUTE);
		}
	} finally {
		releaseConnection(connection);
	}
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider-ahenk-installer,代码行数:21,代码来源:LdapUtils.java

示例14: updateEntryRemoveAttribute

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
public void updateEntryRemoveAttribute(String entryDn, String attribute) throws Exception {

		logger.info("Removing attribute: {}", attribute);
		LdapConnection connection = null;

		connection = getConnection();
		Entry entry = null;
		try {
			entry = connection.lookup(entryDn);
			if (entry != null) {

				for (Attribute a : entry.getAttributes()) {

					if (a.getAttributeType().getName().equalsIgnoreCase("owner")) {
						entry.remove(a);
					}
				}

				connection.modify(entry, ModificationOperation.REMOVE_ATTRIBUTE);
			}
		} finally {
			releaseConnection(connection);
		}
	}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider-ahenk-installer,代码行数:25,代码来源:LdapUtils.java

示例15: updateEntryRemoveAttributeWithValue

import org.apache.directory.api.ldap.model.entry.ModificationOperation; //导入依赖的package包/类
public void updateEntryRemoveAttributeWithValue(String entryDn, String attribute, String value) throws Exception {

		logger.info("Removing attribute: {}", attribute);
		LdapConnection connection = null;

		connection = getConnection();
		Entry entry = null;
		try {
			entry = connection.lookup(entryDn);
			if (entry != null) {

				for (Attribute a : entry.getAttributes()) {
					if (a.contains(value)) {
						a.remove(value);
					}
				}

				connection.modify(entry, ModificationOperation.REPLACE_ATTRIBUTE);
			}
		} finally {
			releaseConnection(connection);
		}

	}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider-ahenk-installer,代码行数:25,代码来源:LdapUtils.java


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