本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.DefaultModification类的典型用法代码示例。如果您正苦于以下问题:Java DefaultModification类的具体用法?Java DefaultModification怎么用?Java DefaultModification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultModification类属于org.apache.directory.api.ldap.model.entry包,在下文中一共展示了DefaultModification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateServerModification
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例2: hashCode
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int hashCode()
{
int hash = 37;
if ( name != null )
{
hash = hash * 17 + name.hashCode();
}
hash = hash * 17 + mods.size();
for ( int i = 0; i < mods.size(); i++ )
{
hash = hash * 17 + ( ( DefaultModification ) mods.get( i ) ).hashCode();
}
hash = hash * 17 + super.hashCode();
return hash;
}
示例3: testCreateServerModification
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例4: testApplyAddModificationToEntry
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例5: testApplyRemoveModificationFromEntryAttributeNotPresent
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例6: testApplyRemoveModificationFromEntryAttributeNotSameValue
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例7: testApplyRemoveModificationFromEntrySameAttributeSameValue
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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() );
}
示例8: testApplyModifyModificationRemoveAttribute
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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" ) );
}
示例9: testNotEqualDiffModCount
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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 ) );
}
示例10: modifyEntry
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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);
}
示例11: modify
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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 );
}
示例12: createContextCsnModList
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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 );
}
示例13: writeBinaryAttribute
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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() );
}
}
示例14: writeStringAttribute
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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() );
}
}
示例15: addAttributeModification
import org.apache.directory.api.ldap.model.entry.DefaultModification; //导入依赖的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);
}
}