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


Java ModificationOperation.REPLACE_ATTRIBUTE属性代码示例

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


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

示例1: testApplyModifyModificationRemoveAttribute

/**
 * 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,代码行数:23,代码来源:AttributeUtilsTest.java

示例2: testSerializationModificationREPLACE

@Test
public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException,
    LdapInvalidAttributeValueException
{
    Attribute attribute = new DefaultAttribute( "cn", cnAT );
    attribute.add( "test1", "test2" );

    DefaultModification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );

    Modification modSer = deserializeValue( serializeValue( mod ) );

    assertEquals( mod, modSer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:13,代码来源:SchemaAwareModificationSerializationTest.java

示例3: testSerializationModificationREPLACE

@Test
public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException, LdapException
{
    Attribute attribute = new DefaultAttribute( "cn" );
    attribute.add( "test1", "test2" );

    DefaultModification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );

    Modification modSer = deserializeValue( serializeValue( mod ) );

    assertEquals( mod, modSer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:12,代码来源:ModificationTest.java

示例4: testApplyModifyModificationFromEmptyEntry

/**
 * test the addition by modification of an attribute in an empty entry.
 * 
 * As we are replacing a non existing attribute, it should be added.
 *
 * @throws LdapException
 */
@Test
public void testApplyModifyModificationFromEmptyEntry() throws LdapException
{
    Entry entry = new DefaultEntry();

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

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

示例5: testApplyModifyEmptyModificationFromEmptyEntry

/**
 * Test the replacement by modification of an attribute in an empty entry.
 * 
 * As we are replacing a non existing attribute, it should not change the entry.
 *
 * @throws LdapException
 */
@Test
public void testApplyModifyEmptyModificationFromEmptyEntry() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute attr = new DefaultAttribute( "cn" );

    Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
    AttributeUtils.applyModification( entry, modification );
    assertNull( entry.get( "cn" ) );
    assertEquals( 0, entry.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:AttributeUtilsTest.java

示例6: testApplyModifyAttributeModification

/**
 * Test the replacement by modification of an attribute in an empty entry.
 * 
 * As we are replacing a non existing attribute, it should not change the entry.
 *
 * @throws LdapException
 */
@Test
public void testApplyModifyAttributeModification() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );
    entry.put( "ou", "apache", "acme corp" );

    Attribute newOu = new DefaultAttribute( "ou", "Big Company", "directory" );

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

    AttributeUtils.applyModification( entry, modification );

    assertEquals( 2, entry.size() );

    assertNotNull( entry.get( "cn" ) );
    assertNotNull( entry.get( "ou" ) );

    Attribute modifiedAttr = entry.get( "ou" );

    assertTrue( modifiedAttr.size() != 0 );

    Set<String> expectedValues = new HashSet<String>();
    expectedValues.add( "Big Company" );
    expectedValues.add( "directory" );

    for ( Value value : modifiedAttr )
    {
        String valueStr = value.getValue();

        assertTrue( expectedValues.contains( valueStr ) );

        expectedValues.remove( valueStr );
    }

    assertEquals( 0, expectedValues.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:44,代码来源:AttributeUtilsTest.java

示例7: toServerModification

/**
 * Convert a ModificationItem to an instance of a ServerModification object
 *
 * @param modificationImpl the modification instance to convert
 * @param attributeType the associated attributeType
 * @return a instance of a ServerModification object
 */
private static Modification toServerModification( ModificationItem modificationImpl, AttributeType attributeType )
    throws LdapException
{
    ModificationOperation operation;

    switch ( modificationImpl.getModificationOp() )
    {
        case DirContext.REMOVE_ATTRIBUTE:
            operation = ModificationOperation.REMOVE_ATTRIBUTE;
            break;

        case DirContext.REPLACE_ATTRIBUTE:
            operation = ModificationOperation.REPLACE_ATTRIBUTE;
            break;

        case DirContext.ADD_ATTRIBUTE:
        default:
            operation = ModificationOperation.ADD_ATTRIBUTE;
            break;

    }

    Modification modification = new DefaultModification(
        operation,
        ServerEntryUtils.toServerAttribute( modificationImpl.getAttribute(), attributeType ) );

    return modification;

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:36,代码来源:ServerEntryUtils.java

示例8: test822ModifyAccountHt

@Test
   public void test822ModifyAccountHt() throws Exception {
	final String TEST_NAME = "test822ModifyAccountHt";
       TestUtil.displayTestTile(this, TEST_NAME);

       // GIVEN
       Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
       OperationResult result = task.getResult();
       
       long tsStart = System.currentTimeMillis();
       
       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       LdapNetworkConnection connection = ldapConnect();
       Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
       connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
	ldapDisconnect(connection);

	waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
       
       // THEN
       TestUtil.displayThen(TEST_NAME);
       result.computeStatus();
       TestUtil.assertSuccess(result);
       
       long tsEnd = System.currentTimeMillis();
       
       PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
       assertNotNull("No user "+ACCOUNT_HT_UID+" created", user);
       assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

       assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:33,代码来源:AbstractLdapSynchronizationTest.java

示例9: doAdditionalRenameModifications

@Override
protected void doAdditionalRenameModifications(LdapNetworkConnection connection) throws LdapException {
	Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, 
			ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID);
	connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod);
	display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + 
			" -> "+ACCOUNT_HTM_UID+": "+mod);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:8,代码来源:AbstractAdLdapTest.java

示例10: test802ModifyAccountHt

@Test
   public void test802ModifyAccountHt() throws Exception {
	final String TEST_NAME = "test802ModifyAccountHt";
       TestUtil.displayTestTitle(this, TEST_NAME);

       // GIVEN
       Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
       OperationResult result = task.getResult();

       long tsStart = System.currentTimeMillis();

       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       LdapNetworkConnection connection = ldapConnect();
       Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
       connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
	ldapDisconnect(connection);

	waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);

       // THEN
       TestUtil.displayThen(TEST_NAME);
       result.computeStatus();
       TestUtil.assertSuccess(result);

       long tsEnd = System.currentTimeMillis();

       PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
       assertNotNull("No user "+ACCOUNT_HT_UID+" created", user);
       assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

       assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd);

}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:34,代码来源:AbstractLdapSynchronizationTest.java

示例11: test822ModifyAccountHt

@Test
   public void test822ModifyAccountHt() throws Exception {
	final String TEST_NAME = "test822ModifyAccountHt";
       TestUtil.displayTestTitle(this, TEST_NAME);

       // GIVEN
       Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
       OperationResult result = task.getResult();

       long tsStart = System.currentTimeMillis();

       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       LdapNetworkConnection connection = ldapConnect();
       Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
       connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
	ldapDisconnect(connection);

	waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);

       // THEN
       TestUtil.displayThen(TEST_NAME);
       result.computeStatus();
       TestUtil.assertSuccess(result);

       long tsEnd = System.currentTimeMillis();

       PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
       assertNotNull("No user "+ACCOUNT_HT_UID+" created", user);
       assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

       assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd);
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:33,代码来源:AbstractLdapSynchronizationTest.java

示例12: doAdditionalRenameModifications

@Override
protected void doAdditionalRenameModifications(LdapNetworkConnection connection) throws LdapException {
	Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE,
			ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID);
	connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod);
	display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME +
			" -> "+ACCOUNT_HTM_UID+": "+mod);
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:8,代码来源:AbstractAdLdapTest.java

示例13: toDsml

/**
 * {@inheritDoc}
 */
@Override
public Element toDsml( Element root )
{
    Element element = super.toDsml( root );

    ModifyRequest request = getDecorated();

    // Dn
    if ( request.getName() != null )
    {
        element.addAttribute( "dn", request.getName().getName() );
    }

    // Modifications
    Collection<Modification> modifications = request.getModifications();

    for ( Modification modification : modifications )
    {
        Element modElement = element.addElement( "modification" );

        if ( modification.getAttribute() != null )
        {
            modElement.addAttribute( "name", modification.getAttribute().getId() );

            for ( Value value : modification.getAttribute() )
            {
                if ( value.getValue() != null )
                {
                    if ( ParserUtils.needsBase64Encoding( value.getValue() ) )
                    {
                        Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
                        Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
                        element.getDocument().getRootElement().add( xsdNamespace );
                        element.getDocument().getRootElement().add( xsiNamespace );

                        Element valueElement = modElement.addElement( "value" ).addText(
                            ParserUtils.base64Encode( value.getValue() ) );
                        valueElement.addAttribute( new QName( "type", xsiNamespace ), "xsd:"
                            + ParserUtils.BASE64BINARY );
                    }
                    else
                    {
                        modElement.addElement( "value" ).setText( value.getValue() );
                    }
                }
            }
        }

        ModificationOperation operation = modification.getOperation();

        if ( operation == ModificationOperation.ADD_ATTRIBUTE )
        {
            modElement.addAttribute( "operation", "add" );
        }
        else if ( operation == ModificationOperation.REPLACE_ATTRIBUTE )
        {
            modElement.addAttribute( "operation", "replace" );
        }
        else if ( operation == ModificationOperation.REMOVE_ATTRIBUTE )
        {
            modElement.addAttribute( "operation", "delete" );
        }
    }

    return element;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:69,代码来源:ModifyRequestDsml.java

示例14: test802ModifyAccountHt

@Test
   public void test802ModifyAccountHt() throws Exception {
	final String TEST_NAME = "test802ModifyAccountHt";
       TestUtil.displayTestTile(this, TEST_NAME);

       // GIVEN
       Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
       OperationResult result = task.getResult();
       
       long tsStart = System.currentTimeMillis();
       
       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       LdapNetworkConnection connection = ldapConnect();
       Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
       connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
	ldapDisconnect(connection);

	waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
       
       // THEN
       TestUtil.displayThen(TEST_NAME);
       result.computeStatus();
       TestUtil.assertSuccess(result);
       
       long tsEnd = System.currentTimeMillis();
       
       PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
       assertNotNull("No user "+ACCOUNT_HT_UID+" created", user);
       assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

       assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd);

}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:34,代码来源:AbstractLdapSynchronizationTest.java


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