Search in sources :

Example 6 with SyntaxCheckerDescription

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

the class SyntaxCheckerDescriptionSchemaParserTest method testRealByteCodeExample.

@Test
public void testRealByteCodeExample() throws ParseException {
    String simple = "( 1.3.6.1.4.1.18060.0.4.1.0.10002 DESC 'bogus desc' " + "FQCN DummySyntaxChecker BYTECODE yv66vgAAADEAHgoABAAYCQADABkHABoHABsHABwBAANvaWQBABJMam" + "F2YS9sYW5nL1N0cmluZzsBAAY8aW5pdD4BABUoTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51b" + "WJlclRhYmxlAQADKClWAQAMc2V0U3ludGF4T2lkAQAMZ2V0U3ludGF4T2lkAQAUKClMamF2YS9sYW5nL1N0cmlu" + "ZzsBAA1pc1ZhbGlkU3ludGF4AQAVKExqYXZhL2xhbmcvT2JqZWN0OylaAQAMYXNzZXJ0U3ludGF4AQAVKExqYXZ" + "hL2xhbmcvT2JqZWN0OylWAQAKRXhjZXB0aW9ucwcAHQEAClNvdXJjZUZpbGUBABdEdW1teVN5bnRheENoZWNrZX" + "IuamF2YQwACAAMDAAGAAcBABJEdW1teVN5bnRheENoZWNrZXIBABBqYXZhL2xhbmcvT2JqZWN0AQA8b3JnL2FwY" + "WNoZS9kaXJlY3Rvcnkvc2hhcmVkL2xkYXAvc2NoZW1hL3N5bnRheC9TeW50YXhDaGVja2VyAQAcamF2YXgvbmFt" + "aW5nL05hbWluZ0V4Y2VwdGlvbgAhAAMABAABAAUAAQACAAYABwAAAAYAAQAIAAkAAQAKAAAAKgACAAIAAAAKKrc" + "AASortQACsQAAAAEACwAAAA4AAwAAAAsABAAMAAkADQABAAgADAABAAoAAAAhAAEAAQAAAAUqtwABsQAAAAEACw" + "AAAAoAAgAAABEABAASAAEADQAJAAEACgAAACIAAgACAAAABiortQACsQAAAAEACwAAAAoAAgAAABcABQAYAAEAD" + "gAPAAEACgAAAB0AAQABAAAABSq0AAKwAAAAAQALAAAABgABAAAAHQABABAAEQABAAoAAAAaAAEAAgAAAAIErAAA" + "AAEACwAAAAYAAQAAACMAAQASABMAAgAKAAAAGQAAAAIAAAABsQAAAAEACwAAAAYAAQAAACkAFAAAAAQAAQAVAAE" + "AFgAAAAIAFw== X-SCHEMA 'nis' )";
    SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(simple);
    assertNotNull(syntaxCheckerDescription);
    assertEquals("1.3.6.1.4.1.18060.0.4.1.0.10002", syntaxCheckerDescription.getOid());
    assertEquals("DummySyntaxChecker", syntaxCheckerDescription.getFqcn());
    assertNotNull(syntaxCheckerDescription.getBytecode());
    assertEquals("bogus desc", syntaxCheckerDescription.getDescription());
}
Also used : SyntaxCheckerDescription(org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription) Test(org.junit.Test)

Example 7 with SyntaxCheckerDescription

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

the class SyntaxCheckerDescriptionSchemaParserTest method testSyntaxCheckerWithDescAndByteCode.

@Test
public void testSyntaxCheckerWithDescAndByteCode() throws ParseException {
    String simple = "( " + OID + " DESC '" + DESC + "' FQCN " + FQCN + " BYTECODE " + BYTECODE + " )";
    SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(simple);
    assertNotNull(syntaxCheckerDescription);
    assertEquals(OID, syntaxCheckerDescription.getOid());
    assertEquals(FQCN, syntaxCheckerDescription.getFqcn());
    assertEquals(BYTECODE, syntaxCheckerDescription.getBytecode());
    assertEquals(DESC, syntaxCheckerDescription.getDescription());
}
Also used : SyntaxCheckerDescription(org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription) Test(org.junit.Test)

Example 8 with SyntaxCheckerDescription

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

the class DefaultSchemaLoader method loadSyntaxCheckers.

private void loadSyntaxCheckers(Attribute syntaxCheckers) throws LdapException {
    if (syntaxCheckers == null) {
        return;
    }
    for (Value value : syntaxCheckers) {
        String desc = value.getValue();
        try {
            SyntaxCheckerDescription syntaxChecker = SC_DESCR_SCHEMA_PARSER.parseSyntaxCheckerDescription(desc);
            updateSchemas(syntaxChecker);
        } catch (ParseException pe) {
            throw new LdapException(pe);
        }
    }
}
Also used : SyntaxCheckerDescription(org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription) Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 9 with SyntaxCheckerDescription

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

the class DefaultSchemaLoader method loadSyntaxCheckers.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadSyntaxCheckers(Schema... schemas) throws LdapException, IOException {
    List<Entry> syntaxCheckerEntries = new ArrayList<>();
    if (schemas == null) {
        return syntaxCheckerEntries;
    }
    for (Schema schema : schemas) {
        Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
        for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
            SchemaObject schemaObject = schemaObjectWrapper.get();
            if (schemaObject instanceof SyntaxCheckerDescription) {
                SyntaxCheckerDescription syntaxCheckerDescription = (SyntaxCheckerDescription) schemaObject;
                Entry syntaxCheckerEntry = getEntry(syntaxCheckerDescription);
                syntaxCheckerEntries.add(syntaxCheckerEntry);
            }
        }
    }
    return syntaxCheckerEntries;
}
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) SyntaxCheckerDescription(org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription) 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)

Aggregations

SyntaxCheckerDescription (org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription)9 Test (org.junit.Test)7 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