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