001 package org.apache.directory.shared.ldap.schema;
002
003
004 import java.util.Map;
005 import java.util.Set;
006
007 import org.apache.directory.shared.ldap.entry.Entry;
008 import org.apache.directory.shared.ldap.name.DN;
009 import org.apache.directory.shared.ldap.schema.AttributeType;
010 import org.apache.directory.shared.ldap.schema.MatchingRule;
011 import org.apache.directory.shared.ldap.schema.ObjectClass;
012 import org.apache.directory.shared.ldap.schema.registries.Schema;
013
014
015 public interface SchemaDao
016 {
017
018 /**
019 * Gets a Map of Schemas managed by a schema store.
020 *
021 * @return a Map of Schemas using the name of the Schema as the key
022 * @throws Exception if there is some problem accessing the schema data
023 */
024 Map<String, Schema> getSchemas() throws Exception;
025
026
027 Set<String> getSchemaNames() throws Exception;
028
029
030 Schema getSchema( String schemaName ) throws Exception;
031
032
033 boolean hasMatchingRule( String oid ) throws Exception;
034
035
036 boolean hasAttributeType( String oid ) throws Exception;
037
038
039 boolean hasObjectClass( String oid ) throws Exception;
040
041
042 boolean hasSyntax( String oid ) throws Exception;
043
044
045 boolean hasSyntaxChecker( String oid ) throws Exception;
046
047
048 /**
049 * Given the non-normalized name (alias) or the OID for a schema entity. This
050 * method finds the schema under which that entity is located.
051 *
052 * NOTE: this method presumes that all alias names across schemas are unique.
053 * This should be the case for LDAP but this can potentially be violated so
054 * we should make sure this is a unique name.
055 *
056 * @param entityName one of the names of the entity or it's numeric id
057 * @return the name of the schema that contains that entity or null if no entity with
058 * that alias name exists
059 * @throws LdapException if more than one entity has the name, or if there
060 * are underlying data access problems
061 */
062 String findSchema( String entityName ) throws Exception;
063
064
065 DN findDn( String entityName ) throws Exception;
066
067
068 /**
069 * Given the non-normalized name (alias) or the OID for a schema entity. This
070 * method finds the entry of the schema entity.
071 *
072 * NOTE: this method presumes that all alias names across schemas are unique.
073 * This should be the case for LDAP but this can potentially be violated so
074 * we should make sure this is a unique name.
075 *
076 * @param entityName one of the names of the entity or it's numeric id
077 * @return the search result for the entity or null if no such entity exists with
078 * that alias or numeric oid
079 * @throws LdapException if more than one entity has the name, or if there
080 * are underlying data access problems
081 */
082 Entry find( String entityName ) throws Exception;
083
084
085 /**
086 * Enables a schema by removing it's m-disabled attribute if present.
087 *
088 * NOTE:
089 * This is a write operation and great care must be taken to make sure it
090 * is used in a limited capacity. This method is called in two places
091 * currently.
092 *
093 * (1) Within the initialization sequence to enable schemas required
094 * for the correct operation of indices in other partitions.
095 * (2) Within the partition schema loader to auto enable schemas that are
096 * depended on by other schemas which are enabled.
097 *
098 * In both cases, the modifier is effectively the administrator since the
099 * server is performing the operation directly or on behalf of a user. In
100 * case (1) during intialization there is no other user involved so naturally
101 * the modifier is the administrator. In case (2) when a user enables a
102 * schema with a dependency that is not enabled the server enables that
103 * dependency on behalf of the user. Again effectively it is the server that
104 * is modifying the schema entry and hence the admin is the modifier.
105 *
106 * No need to worry about a lack of replication propagation in both cases. In
107 * case (1) all replicas will enable these schemas anyway on startup. In case
108 * (2) the original operation that enabled the schema depending on the on that
109 * enableSchema() is called for itself will be replicated. Hence the same chain
110 * reaction will occur in a replica.
111 *
112 * @param schemaName the name of the schema to enable
113 * @throws LdapException if there is a problem updating the schema entry
114 */
115 void enableSchema( String schemaName ) throws Exception;
116
117
118 /**
119 * Returns the set of matchingRules and attributeTypes which depend on the
120 * provided syntax.
121 *
122 * @param numericOid the numeric identifier for the entity
123 * @return the set of matchingRules and attributeTypes depending on a syntax
124 * @throws LdapException if the dao fails to perform search operations
125 */
126 Set<Entry> listSyntaxDependents( String numericOid ) throws Exception;
127
128
129 Set<Entry> listMatchingRuleDependents( MatchingRule mr ) throws Exception;
130
131
132 Set<Entry> listAttributeTypeDependents( AttributeType at ) throws Exception;
133
134
135 /**
136 * Lists the SearchResults of metaSchema objects that depend on a schema.
137 *
138 * @param schemaName the name of the schema to search for dependees
139 * @return a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
140 * @throws LdapException if there is a problem while searching the schema partition
141 */
142 Set<Entry> listSchemaDependents( String schemaName ) throws Exception;
143
144
145 /**
146 * Lists the SearchResults of metaSchema objects that depend on a schema.
147 *
148 * @param schemaName the name of the schema to search for dependencies
149 * @return a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
150 * @throws LdapException if there is a problem while searching the schema partition
151 */
152 Set<Entry> listEnabledSchemaDependents( String schemaName ) throws Exception;
153
154
155 Set<Entry> listObjectClassDependents( ObjectClass oc ) throws Exception;
156 }