Search in sources :

Example 6 with DefaultAttribute

use of org.apache.directory.api.ldap.model.entry.DefaultAttribute in project directory-ldap-api by apache.

the class SchemaElementImpl method nameToLdif.

/**
 * @return the Names as Ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String nameToLdif() throws LdapException {
    if (names.isEmpty()) {
        return "";
    } else {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute("m-name");
        for (String name : names) {
            attribute.add(name);
        }
        entry.put(attribute);
        return LdifUtils.convertAttributesToLdif(entry);
    }
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute)

Example 7 with DefaultAttribute

use of org.apache.directory.api.ldap.model.entry.DefaultAttribute in project directory-ldap-api by apache.

the class SchemaElementImpl method descToLdif.

/**
 * @return The description as a ldif line
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String descToLdif() throws LdapException {
    if (Strings.isEmpty(description)) {
        return "";
    } else {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute("m-description", description);
        entry.put(attribute);
        return LdifUtils.convertAttributesToLdif(entry);
    }
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute)

Example 8 with DefaultAttribute

use of org.apache.directory.api.ldap.model.entry.DefaultAttribute in project directory-ldap-api by apache.

the class SchemaElementImpl method extensionsToLdif.

/**
 * Return the extensions formated as Ldif lines
 *
 * @param id The attributeId : can be m-objectClassExtension or
 * m-attributeTypeExtension
 * @return The extensions formated as ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
protected String extensionsToLdif(String id) throws LdapException {
    StringBuilder sb = new StringBuilder();
    Entry entry = new DefaultEntry();
    Attribute attribute = new DefaultAttribute(id);
    for (String extension : extensions.keySet()) {
        attribute.add(extension);
    }
    sb.append(LdifUtils.convertAttributesToLdif(entry));
    return sb.toString();
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute)

Example 9 with DefaultAttribute

use of org.apache.directory.api.ldap.model.entry.DefaultAttribute in project directory-ldap-api by apache.

the class ModifyRequestDecorator method addAttributeTypeAndValues.

/**
 * Add a new attributeTypeAndValue
 *
 * @param type The attribute's name
 */
public void addAttributeTypeAndValues(String type) {
    currentAttribute = new DefaultAttribute(type);
    Modification modification = new DefaultModification(currentOperation, currentAttribute);
    getDecorated().addModification(modification);
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute)

Example 10 with DefaultAttribute

use of org.apache.directory.api.ldap.model.entry.DefaultAttribute in project directory-ldap-api by apache.

the class SearchResultEntryDecorator method addAttribute.

/**
 * Create a new attribute
 *
 * @param type The attribute's type
 * @throws LdapException If the value is invalid
 */
public void addAttribute(String type) throws LdapException {
    currentAttribute = new DefaultAttribute(type);
    getDecorated().getEntry().put(currentAttribute);
}
Also used : DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute)

Aggregations

DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)159 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)131 Test (org.junit.Test)106 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)41 Modification (org.apache.directory.api.ldap.model.entry.Modification)40 Entry (org.apache.directory.api.ldap.model.entry.Entry)36 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)35 Value (org.apache.directory.api.ldap.model.entry.Value)20 ByteArrayInputStream (java.io.ByteArrayInputStream)13 ObjectInputStream (java.io.ObjectInputStream)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 ObjectOutputStream (java.io.ObjectOutputStream)12 Dn (org.apache.directory.api.ldap.model.name.Dn)12 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)11 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)11 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)8 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)7 ModifyRequestImpl (org.apache.directory.api.ldap.model.message.ModifyRequestImpl)7 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)7 HashSet (java.util.HashSet)6