Search in sources :

Example 36 with DefaultEntry

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

the class SchemaAwareEntryTest method testSize.

/**
 * Test method for size()
 */
@Test
public void testSize() throws LdapException {
    Entry entry = new DefaultEntry(exampleDn);
    assertEquals(0, entry.size());
    entry.add("ObjectClass", "top", "person");
    entry.add("cn", "test");
    entry.add("sn", "Test");
    assertEquals(3, entry.size());
    entry.clear();
    assertEquals(0, entry.size());
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Test(org.junit.Test)

Example 37 with DefaultEntry

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

the class DefaultSchemaLoader method getEntry.

private Entry getEntry(SyntaxCheckerDescription syntaxCheckerDescription) {
    Entry entry = new DefaultEntry();
    entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC);
    entry.put(MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid());
    entry.put(MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn());
    if (syntaxCheckerDescription.getBytecode() != null) {
        entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(syntaxCheckerDescription.getBytecode().toCharArray()));
    }
    if (syntaxCheckerDescription.getDescription() != null) {
        entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription());
    }
    return entry;
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry)

Example 38 with DefaultEntry

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

the class DefaultSchemaLoader method getEntry.

private Entry getEntry(LdapComparatorDescription comparatorDescription) {
    Entry entry = new DefaultEntry();
    entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC);
    entry.put(MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid());
    entry.put(MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn());
    if (comparatorDescription.getBytecode() != null) {
        entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(comparatorDescription.getBytecode().toCharArray()));
    }
    if (comparatorDescription.getDescription() != null) {
        entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription());
    }
    return entry;
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry)

Example 39 with DefaultEntry

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

the class DefaultSchemaLoader method getEntry.

private Entry getEntry(NormalizerDescription normalizerDescription) {
    Entry entry = new DefaultEntry();
    entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC);
    entry.put(MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid());
    entry.put(MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn());
    if (normalizerDescription.getBytecode() != null) {
        entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(normalizerDescription.getBytecode().toCharArray()));
    }
    if (normalizerDescription.getDescription() != null) {
        entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription());
    }
    return entry;
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry)

Example 40 with DefaultEntry

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

the class LdifUtilsTest method testReverseModifyDNSuperior.

/**
 * Check that the correct reverse LDIF is produced for a modifyDn
 * operation that moves and renames the entry while preserving the
 * old rdn.
 *
 * @throws NamingException on error
 */
@Test
public void testReverseModifyDNSuperior() throws LdapException {
    Dn dn = new Dn("cn=john doe, dc=example, dc=com");
    Dn newSuperior = new Dn("ou=system");
    Entry entry = new DefaultEntry(dn);
    entry.add("objectClass", "person", "uidObject");
    entry.add("cn", "john doe", "jack doe");
    entry.add("sn", "doe");
    entry.add("uid", "jdoe");
    List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename(entry, newSuperior, new Rdn("cn=jack doe"), false);
    assertNotNull(reverseds);
    assertEquals(1, reverseds.size());
    LdifEntry reversed = reverseds.get(0);
    assertEquals("cn=jack doe,ou=system", reversed.getDn().getName());
    assertEquals(ChangeType.ModRdn, reversed.getChangeType());
    assertFalse(reversed.isDeleteOldRdn());
    assertEquals("cn=john doe", reversed.getNewRdn());
    assertEquals("dc=example, dc=com", Strings.trim(reversed.getNewSuperior()));
    assertNull(reversed.getEntry());
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Dn(org.apache.directory.api.ldap.model.name.Dn) Rdn(org.apache.directory.api.ldap.model.name.Rdn) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) Test(org.junit.Test)

Aggregations

DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)128 Entry (org.apache.directory.api.ldap.model.entry.Entry)116 Test (org.junit.Test)55 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)41 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)39 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)23 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)20 Modification (org.apache.directory.api.ldap.model.entry.Modification)16 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)16 Dn (org.apache.directory.api.ldap.model.name.Dn)15 CreateException (org.apache.directory.fortress.core.CreateException)15 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)14 Value (org.apache.directory.api.ldap.model.entry.Value)12 LdifReader (org.apache.directory.api.ldap.model.ldif.LdifReader)12 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)5 IOException (java.io.IOException)4 ObjectInputStream (java.io.ObjectInputStream)4 ObjectOutputStream (java.io.ObjectOutputStream)4