@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" ) ); }
public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { entry.put( modAttr ); } else { for ( Value value : modAttr ) { modifiedAttr.add( value ); } } break; case REMOVE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { break; } for ( Value value : modAttr ) { modifiedAttr.remove( value ); } if ( modifiedAttr.size() == 0 ) { entry.removeAttributes( modifiedAttr.getUpId() ); } } break; case REPLACE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { entry.put( modAttr ); } break; default: break; } }
AttributeUtils { public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { entry.put( modAttr ); } else { for ( Value value : modAttr ) { modifiedAttr.add( value ); } } break; case REMOVE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { break; } for ( Value value : modAttr ) { modifiedAttr.remove( value ); } if ( modifiedAttr.size() == 0 ) { entry.removeAttributes( modifiedAttr.getUpId() ); } } break; case REPLACE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { entry.put( modAttr ); } break; default: break; } } }
AttributeUtils { public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { entry.put( modAttr ); } else { for ( Value value : modAttr ) { modifiedAttr.add( value ); } } break; case REMOVE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { break; } for ( Value value : modAttr ) { modifiedAttr.remove( value ); } if ( modifiedAttr.size() == 0 ) { entry.removeAttributes( modifiedAttr.getUpId() ); } } break; case REPLACE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { entry.put( modAttr ); } break; default: break; } } private  AttributeUtils(); }
AttributeUtils { public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { entry.put( modAttr ); } else { for ( Value value : modAttr ) { modifiedAttr.add( value ); } } break; case REMOVE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { break; } for ( Value value : modAttr ) { modifiedAttr.remove( value ); } if ( modifiedAttr.size() == 0 ) { entry.removeAttributes( modifiedAttr.getUpId() ); } } break; case REPLACE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { entry.put( modAttr ); } break; default: break; } } private  AttributeUtils(); static boolean containsValueCaseIgnore( javax.naming.directory.Attribute attr, Object value ); static Attributes toCaseInsensitive( Attributes attributes ); static String parseAttribute( char[] str, Position pos, boolean withOption, boolean relaxed ); static String parseAttribute( byte[] bytes, Position pos, boolean withOption, boolean relaxed ); static void applyModification( Entry entry, Modification modification ); static Entry toEntry( Attributes attributes, Dn dn ); static Attributes toAttributes( Entry entry ); static javax.naming.directory.Attribute toJndiAttribute( Attribute attribute ); static Attribute toApiAttribute( javax.naming.directory.Attribute jndiAttribute ); }
AttributeUtils { public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { entry.put( modAttr ); } else { for ( Value value : modAttr ) { modifiedAttr.add( value ); } } break; case REMOVE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { modifiedAttr = entry.get( modificationId ); if ( modifiedAttr == null ) { break; } for ( Value value : modAttr ) { modifiedAttr.remove( value ); } if ( modifiedAttr.size() == 0 ) { entry.removeAttributes( modifiedAttr.getUpId() ); } } break; case REPLACE_ATTRIBUTE: if ( modAttr.get() == null ) { entry.removeAttributes( modificationId ); } else { entry.put( modAttr ); } break; default: break; } } private  AttributeUtils(); static boolean containsValueCaseIgnore( javax.naming.directory.Attribute attr, Object value ); static Attributes toCaseInsensitive( Attributes attributes ); static String parseAttribute( char[] str, Position pos, boolean withOption, boolean relaxed ); static String parseAttribute( byte[] bytes, Position pos, boolean withOption, boolean relaxed ); static void applyModification( Entry entry, Modification modification ); static Entry toEntry( Attributes attributes, Dn dn ); static Attributes toAttributes( Entry entry ); static javax.naming.directory.Attribute toJndiAttribute( Attribute attribute ); static Attribute toApiAttribute( javax.naming.directory.Attribute jndiAttribute );  }