/** * Creates an AddRequest implementation to create a new entry. * * @param id * the sequence identifier of the AddRequest message. */ public AddRequestImpl(final int id) { super( id, TYPE ); entry = new DefaultClientEntry(); }
/** * Checks if an entry contains a specific attribute * * @param attributes The Attributes to look for * @return <code>true</code> if the attributes are found within the entry * @throws LdapException If the attribute does not exist */ public boolean contains( String upId ) throws LdapException { String id = getId( upId ); return attributes.containsKey( id ); }
if ( containsAttribute( "objectClass" ) ) EntryAttribute objectClass = get( "objectclass" );
/** * Tells if an entry has a specific ObjectClass value * * @param objectClass The ObjectClass we want to check * @return <code>true</code> if the ObjectClass value is present * in the ObjectClass attribute */ public boolean hasObjectClass( String objectClass ) { return contains( "objectclass", objectClass ); }
EntryAttribute attr = get( attribute );
/** * Checks if an entry contains some specific attributes. * * @param attributes The Attributes to look for. * @return <code>true</code> if the attributes are all found within the entry. */ public boolean containsAttribute( String... attributes ) { for ( String attribute:attributes ) { String id = getId( attribute ); if ( !this.attributes.containsKey( id ) ) { return false; } } return true; }
public List<EntryAttribute> remove( EntryAttribute... attributes ) throws LdapException { List<EntryAttribute> removedAttributes = new ArrayList<EntryAttribute>(); for ( EntryAttribute attribute:attributes ) { if ( contains( attribute.getId() ) ) { this.attributes.remove( attribute.getId() ); removedAttributes.add( attribute ); } } return removedAttributes; }
/** * Creates a new AddRequest object. */ public AddRequestCodec() { super(); entry = new DefaultClientEntry(); }
/** * Checks if an entry contains an attribute with some String values. * * @param id The Attribute we are looking for. * @param values The searched values. * @return <code>true</code> if all the values are found within the attribute, * false if at least one value is not present or if the ID is not valid. */ public boolean contains( String upId, String... values ) { String id = getId( upId ); EntryAttribute attribute = attributes.get( id ); if ( attribute == null ) { return false; } return attribute.contains( values ); }
/** * Add some Attributes to the current Entry. * * @param attributes The attributes to add * @throws LdapException If we can't add any of the attributes */ public void add( EntryAttribute... attributes ) throws LdapException { // Loop on all the added attributes for ( EntryAttribute attribute:attributes ) { // If the attribute already exist, we will add the new values. if ( contains( attribute ) ) { EntryAttribute existingAttr = get( attribute.getId() ); // Loop on all the values, and add them to the existing attribute for ( Value<?> value:attribute ) { existingAttr.add( value ); } } else { // Stores the attribute into the entry this.attributes.put( attribute.getId(), attribute ); } } }
/** * Initialize the Entry. */ public void initEntry() { entry = new DefaultClientEntry(); }
/** * Checks if an entry contains an attribute with some binary values. * * @param id The Attribute we are looking for. * @param values The searched values. * @return <code>true</code> if all the values are found within the attribute, * false if at least one value is not present or if the ID is not valid. */ public boolean contains( String upId, byte[]... values ) { String id = getId( upId ); EntryAttribute attribute = attributes.get( id ); if ( attribute == null ) { return false; } return attribute.contains( values ); }
/** * Creates a new Entry object. */ public LdifEntry() { changeType = ChangeType.Add; // Default LDIF content modificationList = new LinkedList<Modification>(); modificationItems = new HashMap<String, Modification>(); entry = new DefaultClientEntry( null ); control = null; }
/** * Checks if an entry contains an attribute with some values. * * @param id The Attribute we are looking for. * @param values The searched values. * @return <code>true</code> if all the values are found within the attribute, * false if at least one value is not present or if the ID is not valid. */ public boolean contains( String upId, Value<?>... values ) { String id = getId( upId ); EntryAttribute attribute = attributes.get( id ); if ( attribute == null ) { return false; } return attribute.contains( values ); }
public String dnToLdif( String schemaName ) throws NamingException { StringBuilder sb = new StringBuilder(); String dn = "m-oid=" + oid + ", ou=attributeTypes" + ", cn=" + Rdn.escapeValue( schemaName ) + ", ou=schema"; // First dump the DN only Entry entry = new DefaultClientEntry( new LdapDN( dn ) ); sb.append( LdifUtils.convertEntryToLdif( entry ) ); return sb.toString(); } }