1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * https://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.schema.loader; 21 22 23 import org.apache.directory.api.ldap.model.entry.Entry; 24 import org.apache.directory.api.ldap.model.exception.LdapException; 25 import org.apache.directory.api.ldap.model.schema.AttributeType; 26 import org.apache.directory.api.ldap.model.schema.LdapComparator; 27 import org.apache.directory.api.ldap.model.schema.LdapSyntax; 28 import org.apache.directory.api.ldap.model.schema.MatchingRule; 29 import org.apache.directory.api.ldap.model.schema.Normalizer; 30 import org.apache.directory.api.ldap.model.schema.ObjectClass; 31 import org.apache.directory.api.ldap.model.schema.SchemaManager; 32 import org.apache.directory.api.ldap.model.schema.SyntaxChecker; 33 import org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription; 34 import org.apache.directory.api.ldap.model.schema.parsers.NormalizerDescription; 35 import org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription; 36 import org.apache.directory.api.ldap.model.schema.registries.Registries; 37 import org.apache.directory.api.ldap.model.schema.registries.Schema; 38 39 40 /** 41 * An interface to be implemented by classes needed to create Schema elements. The factory 42 * will creates schema elements based on an Entry. 43 * 44 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 45 */ 46 public interface EntityFactory 47 { 48 /** 49 * Return an instance of the Schema associated to the entry 50 * 51 * @param entry The Schema entry 52 * @return An instance of a Schema 53 * @throws LdapException If the instance can't be created 54 */ 55 Schema getSchema( Entry entry ) throws LdapException; 56 57 58 /** 59 * Construct an AttributeType from an entry representing an AttributeType. 60 * 61 * @param schemaManager The Schema Manager 62 * @param entry The entry containing all the informations to build an AttributeType 63 * @param targetRegistries The registries containing all the enabled SchemaObjects 64 * @param schemaName The schema this SchemaObject will be part of 65 * @return An AttributeType SchemaObject 66 * @throws LdapException If the AttributeType is invalid 67 */ 68 AttributeType getAttributeType( SchemaManager schemaManager, Entry entry, Registries targetRegistries, 69 String schemaName ) throws LdapException; 70 71 72 /** 73 * Construct a LdapComparator from a description of a comparator. 74 * 75 * @param schemaManager The Schema Manager 76 * @param comparatorDescription The LdapComparator description object 77 * @param targetRegistries The registries containing all the enabled SchemaObjects 78 * @param schemaName The schema this SchemaObject will be part of 79 * @return A new instance of a LdapComparator 80 * @throws LdapException If the creation has failed 81 */ 82 LdapComparator<?> getLdapComparator( SchemaManager schemaManager, 83 LdapComparatorDescription comparatorDescription, 84 Registries targetRegistries, String schemaName ) throws LdapException; 85 86 87 /** 88 * Retrieve and load a Comparator class from the DIT. 89 * 90 * @param schemaManager The Schema Manager 91 * @param entry The entry containing all the informations to build a LdapComparator 92 * @param targetRegistries The registries containing all the enabled SchemaObjects 93 * @param schemaName The schema this SchemaObject will be part of 94 * @return the loaded Comparator 95 * @throws LdapException if anything fails during loading 96 */ 97 LdapComparator<?> getLdapComparator( SchemaManager schemaManager, Entry entry, 98 Registries targetRegistries, String schemaName ) throws LdapException; 99 100 101 /** 102 * Construct an MatchingRule from an entry get from the Dit 103 * 104 * @param schemaManager The Schema Manager 105 * @param entry The entry containing all the informations to build a MatchingRule 106 * @param targetRegistries The registries containing all the enabled SchemaObjects 107 * @param schemaName The schema this SchemaObject will be part of 108 * @return A MatchingRule SchemaObject 109 * @throws LdapException If the MatchingRule is invalid 110 */ 111 MatchingRule getMatchingRule( SchemaManager schemaManager, Entry entry, Registries targetRegistries, 112 String schemaName ) throws LdapException; 113 114 115 /** 116 * Create a new instance of a Normalizer 117 * 118 * @param schemaManager The Schema Manager 119 * @param normalizerDescription The Normalizer description object 120 * @param targetRegistries The registries containing all the enabled SchemaObjects 121 * @param schemaName The schema this SchemaObject will be part of 122 * @return A new instance of a normalizer 123 * @throws LdapException If the creation has failed 124 */ 125 Normalizer getNormalizer( SchemaManager schemaManager, NormalizerDescription normalizerDescription, 126 Registries targetRegistries, String schemaName ) throws LdapException; 127 128 129 /** 130 * Retrieve and load a Normalizer class from the DIT. 131 * 132 * @param schemaManager The Schema Manager 133 * @param entry The entry containing all the informations to build a Normalizer 134 * @param targetRegistries The registries containing all the enabled SchemaObjects 135 * @param schemaName The schema this SchemaObject will be part of 136 * @return the loaded Normalizer 137 * @throws LdapException if anything fails during loading 138 */ 139 Normalizer getNormalizer( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) 140 throws LdapException; 141 142 143 /** 144 * 145 * @param schemaManager The Schema Manager 146 * @param entry The entry containing all the informations to build an ObjectClass 147 * @param targetRegistries The registries containing all the enabled SchemaObjects 148 * @param schemaName The schema this SchemaObject will be part of 149 * @return The loaded ObjectClass 150 * @throws LdapException if anything fails during loading 151 */ 152 ObjectClass getObjectClass( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) 153 throws LdapException; 154 155 156 /** 157 * 158 * @param schemaManager The Schema Manager 159 * @param entry The entry containing all the informations to build a LdapSyntax 160 * @param targetRegistries The registries containing all the enabled SchemaObjects 161 * @param schemaName The schema this SchemaObject will be part of 162 * @return The loaded Syntax 163 * @throws LdapException if anything fails during loading 164 */ 165 LdapSyntax getSyntax( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName ) 166 throws LdapException; 167 168 169 /** 170 * Retrieve and load a syntaxChecker class from the DIT. 171 * 172 * @param schemaManager The Schema Manager 173 * @param entry The entry containing all the informations to build a SyntaxChecker 174 * @param targetRegistries The registries containing all the enabled SchemaObjects 175 * @param schemaName The schema this SchemaObject will be part of 176 * @return the loaded SyntaxChecker 177 * @throws LdapException if anything fails during loading 178 */ 179 SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, Entry entry, Registries targetRegistries, 180 String schemaName ) throws LdapException; 181 182 183 /** 184 * Create a new instance of a SyntaxChecker 185 * 186 * @param schemaManager The Schema Manager 187 * @param syntaxCheckerDescription The SyntaxChecker description object 188 * @param targetRegistries The registries containing all the enabled SchemaObjects 189 * @param schemaName The schema this SchemaObject will be part of 190 * @return A new instance of a syntaxChecker 191 * @throws LdapException If the creation has failed 192 */ 193 SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, SyntaxCheckerDescription syntaxCheckerDescription, 194 Registries targetRegistries, String schemaName ) throws LdapException; 195 }