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


Java ModificationOperation.REMOVE_ATTRIBUTE属性代码示例

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


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

示例1: testApplyRemoveModificationFromEntryAttributeNotPresent

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

示例2: testApplyRemoveModificationFromEntryAttributeNotSameValue

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

示例3: testApplyRemoveModificationFromEntrySameAttributeSameValue

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

示例4: testSerializationModificationREMOVE

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

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

    Modification modSer = deserializeValue( serializeValue( mod ) );

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

示例5: generateModify

/**
 * A helper method to generate the modified attribute after a rename.
 */
private static LdifEntry generateModify( Dn parentDn, Entry entry, Rdn oldRdn, Rdn newRdn )
{
    LdifEntry restored = new LdifEntry();
    restored.setChangeType( ChangeType.Modify );

    // We have to use the parent Dn, the entry has already
    // been renamed
    restored.setDn( parentDn );

    for ( Ava ava : newRdn )
    {
        // No need to add something which has already been added
        // in the previous modification
        if ( !entry.contains( ava.getNormType(), ava.getValue().getValue() )
            && !( ava.getNormType().equals( oldRdn.getNormType() ) && ava.getValue().getValue().equals(
                oldRdn.getValue() ) ) )
        {
            // Create the modification, which is an Remove
            Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
                new DefaultAttribute( ava.getType(), ava.getValue().getValue() ) );

            restored.addModification( modification );
        }
    }

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

示例6: testSerializationModificationREMOVE

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

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

    Modification modSer = deserializeValue( serializeValue( mod ) );

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

示例7: testApplyRemoveModificationFromEmptyEntry

/**
 * Test the deletion of an attribute into an empty entry
 */
@Test
public void testApplyRemoveModificationFromEmptyEntry() throws LdapException
{
    Entry entry = new DefaultEntry();

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

示例8: testApplyRemoveModificationFromEntrySameAttributeValues

/**
 * Test the deletion of an attribute into an entry which contains the attribute
 * with more than one value
 * 
 * The entry should contain the attribute after the operation, but with one less value
 */
@Test
public void testApplyRemoveModificationFromEntrySameAttributeValues() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test", "apache" );

    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() );

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

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

    boolean isFirst = true;

    for ( Value value : modifiedAttr )
    {
        assertTrue( isFirst );

        isFirst = false;
        assertEquals( "apache", value.getValue() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:AttributeUtilsTest.java

示例9: 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

示例10: 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


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