Search in sources :

Example 1 with LdapComparatorDescription

use of org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription in project directory-ldap-api by apache.

the class ComparatorDescriptionSchemaParserTest method testBytecode.

@Test
public void testBytecode() throws ParseException {
    String value = null;
    LdapComparatorDescription ldapComparatorDescription = null;
    // FQCN simple p
    value = "( 1.1 FQCN org.apache.directory.SimpleComparator BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789==== )";
    ldapComparatorDescription = parser.parseComparatorDescription(value);
    assertNotNull(ldapComparatorDescription.getBytecode());
    assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", ldapComparatorDescription.getBytecode());
    // FQCN simple, no spaces
    value = "(1.1 FQCNorg.apache.directory.SimpleComparator BYTECODEABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====)";
    ldapComparatorDescription = parser.parseComparatorDescription(value);
    assertNotNull(ldapComparatorDescription.getBytecode());
    assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", ldapComparatorDescription.getBytecode());
    // FQCN simple, tabs
    value = "\t(\t1.1\tFQCN\torg.apache.directory.SimpleComparator\tBYTECODE\tABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====\t)\t";
    ldapComparatorDescription = parser.parseComparatorDescription(value);
    assertNotNull(ldapComparatorDescription.getBytecode());
    assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", ldapComparatorDescription.getBytecode());
}
Also used : LdapComparatorDescription(org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription) Test(org.junit.Test)

Example 2 with LdapComparatorDescription

use of org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription in project directory-ldap-api by apache.

the class ComparatorDescriptionSchemaParserTest method testFqcn.

@Test
public void testFqcn() throws ParseException {
    String value = null;
    LdapComparatorDescription ldapComparatorDescription = null;
    // FQCN simple
    value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
    ldapComparatorDescription = parser.parseComparatorDescription(value);
    assertNotNull(ldapComparatorDescription.getFqcn());
    assertEquals("org.apache.directory.SimpleComparator", ldapComparatorDescription.getFqcn());
}
Also used : LdapComparatorDescription(org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription) Test(org.junit.Test)

Example 3 with LdapComparatorDescription

use of org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription in project directory-ldap-api by apache.

the class DefaultSchemaLoader method loadComparators.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadComparators(Schema... schemas) throws LdapException, IOException {
    List<Entry> comparatorEntries = new ArrayList<>();
    if (schemas == null) {
        return comparatorEntries;
    }
    for (Schema schema : schemas) {
        Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
        for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
            SchemaObject schemaObject = schemaObjectWrapper.get();
            if (schemaObject instanceof LdapComparatorDescription) {
                LdapComparatorDescription ldapComparatorDescription = (LdapComparatorDescription) schemaObject;
                Entry lcEntry = getEntry(ldapComparatorDescription);
                comparatorEntries.add(lcEntry);
            }
        }
    }
    return comparatorEntries;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) SchemaObjectWrapper(org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper) LdapComparatorDescription(org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription)

Example 4 with LdapComparatorDescription

use of org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription in project directory-ldap-api by apache.

the class DefaultSchemaLoader method loadComparators.

private void loadComparators(Attribute comparators) throws LdapException {
    if (comparators == null) {
        return;
    }
    for (Value value : comparators) {
        String desc = value.getValue();
        try {
            LdapComparatorDescription comparator = C_DESCR_SCHEMA_PARSER.parseComparatorDescription(desc);
            updateSchemas(comparator);
        } catch (ParseException pe) {
            throw new LdapException(pe);
        }
    }
}
Also used : Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapComparatorDescription(org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription)

Aggregations

LdapComparatorDescription (org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription)4 Test (org.junit.Test)2 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)1 Entry (org.apache.directory.api.ldap.model.entry.Entry)1 Value (org.apache.directory.api.ldap.model.entry.Value)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)1 SchemaObjectWrapper (org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper)1 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)1 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)1