org.apache.directory.server.core.schema
Class SchemaService

java.lang.Object
  extended byorg.apache.directory.server.core.interceptor.BaseInterceptor
      extended byorg.apache.directory.server.core.schema.SchemaService
All Implemented Interfaces:
Interceptor

public class SchemaService
extends BaseInterceptor

An Interceptor that manages and enforces schemas.

Version:
$Rev: 437314 $, $Date: 2006-08-27 09:08:03 +0200 (Sun, 27 Aug 2006) $
Author:
Apache Directory Project

Constructor Summary
SchemaService()
          Creates a schema service interceptor.
 
Method Summary
 void add(NextInterceptor next, LdapDN normName, javax.naming.directory.Attributes attrs)
          Check that all the attributes exist in the schema for this entry.
static void alterObjectClasses(javax.naming.directory.Attribute objectClassAttr, ObjectClassRegistry registry)
          Given the objectClasses for an entry, this method adds missing ancestors in the hierarchy except for top which it removes.
 void destroy()
          Destroy the Schema Service
 void init(DirectoryServiceConfiguration factoryCfg, InterceptorConfiguration cfg)
          Initialize the Schema Service
 boolean isBinary(java.lang.String id)
          Check if an attribute stores binary values.
 javax.naming.NamingEnumeration list(NextInterceptor nextInterceptor, LdapDN base)
          Filters Partition#list(org.apache.directory.shared.ldap.name.LdapDN) call.
 javax.naming.directory.Attributes lookup(NextInterceptor nextInterceptor, LdapDN name)
          Filters Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN) call.
 javax.naming.directory.Attributes lookup(NextInterceptor nextInterceptor, LdapDN name, java.lang.String[] attrIds)
          Filters Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN,String[]) call.
 void modify(NextInterceptor next, LdapDN name, int modOp, javax.naming.directory.Attributes mods)
          Check that the modify operations are allowed, and the conform to the schema.
 void modify(NextInterceptor next, LdapDN name, javax.naming.directory.ModificationItem[] mods)
          Filters Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.ModificationItem[]) call.
 javax.naming.NamingEnumeration search(NextInterceptor nextInterceptor, LdapDN base, java.util.Map env, ExprNode filter, javax.naming.directory.SearchControls searchCtls)
          Filters Partition#search(org.apache.directory.shared.ldap.name.LdapDN,java.util.Map,org.apache.directory.shared.ldap.filter.ExprNode,javax.naming.directory.SearchControls) call.
 
Methods inherited from class org.apache.directory.server.core.interceptor.BaseInterceptor
addContextPartition, bind, compare, delete, getContext, getMatchedName, getPrincipal, getRootDSE, getSuffix, hasEntry, isSuffix, listSuffixes, modifyRn, move, move, removeContextPartition, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaService

public SchemaService()
Creates a schema service interceptor.

Method Detail

init

public void init(DirectoryServiceConfiguration factoryCfg,
                 InterceptorConfiguration cfg)
          throws javax.naming.NamingException
Initialize the Schema Service

Specified by:
init in interface Interceptor
Overrides:
init in class BaseInterceptor
Parameters:
factoryCfg -
cfg -
Throws:
javax.naming.NamingException

isBinary

public boolean isBinary(java.lang.String id)
Check if an attribute stores binary values.

Returns:
Returns true if the attribute is binary.

destroy

public void destroy()
Destroy the Schema Service

Specified by:
destroy in interface Interceptor
Overrides:
destroy in class BaseInterceptor

list

public javax.naming.NamingEnumeration list(NextInterceptor nextInterceptor,
                                           LdapDN base)
                                    throws javax.naming.NamingException
Description copied from interface: Interceptor
Filters Partition#list(org.apache.directory.shared.ldap.name.LdapDN) call.

Specified by:
list in interface Interceptor
Overrides:
list in class BaseInterceptor
Throws:
javax.naming.NamingException

search

public javax.naming.NamingEnumeration search(NextInterceptor nextInterceptor,
                                             LdapDN base,
                                             java.util.Map env,
                                             ExprNode filter,
                                             javax.naming.directory.SearchControls searchCtls)
                                      throws javax.naming.NamingException
Description copied from interface: Interceptor
Filters Partition#search(org.apache.directory.shared.ldap.name.LdapDN,java.util.Map,org.apache.directory.shared.ldap.filter.ExprNode,javax.naming.directory.SearchControls) call.

Specified by:
search in interface Interceptor
Overrides:
search in class BaseInterceptor
Throws:
javax.naming.NamingException

lookup

public javax.naming.directory.Attributes lookup(NextInterceptor nextInterceptor,
                                                LdapDN name)
                                         throws javax.naming.NamingException
Description copied from interface: Interceptor
Filters Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN) call.

Specified by:
lookup in interface Interceptor
Overrides:
lookup in class BaseInterceptor
Throws:
javax.naming.NamingException

lookup

public javax.naming.directory.Attributes lookup(NextInterceptor nextInterceptor,
                                                LdapDN name,
                                                java.lang.String[] attrIds)
                                         throws javax.naming.NamingException
Description copied from interface: Interceptor
Filters Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN,String[]) call.

Specified by:
lookup in interface Interceptor
Overrides:
lookup in class BaseInterceptor
Throws:
javax.naming.NamingException

alterObjectClasses

public static void alterObjectClasses(javax.naming.directory.Attribute objectClassAttr,
                                      ObjectClassRegistry registry)
                               throws javax.naming.NamingException
Given the objectClasses for an entry, this method adds missing ancestors in the hierarchy except for top which it removes. This is used for this solution to DIREVE-276. More information about this solution can be found here.

Parameters:
objectClassAttr - the objectClass attribute to modify
Throws:
javax.naming.NamingException - if there are problems

modify

public void modify(NextInterceptor next,
                   LdapDN name,
                   int modOp,
                   javax.naming.directory.Attributes mods)
            throws javax.naming.NamingException
Check that the modify operations are allowed, and the conform to the schema.

Specified by:
modify in interface Interceptor
Overrides:
modify in class BaseInterceptor
Parameters:
next - The next interceptor to call when we are done with the local operation
name - The DN on which the modification is being done
modOp - The modification. One of : DirContext.ADD_ATTRIBUTE DirContext.REMOVE_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE
mods - The modifications to check. Each operation is atomic, and should be applied to a copy of the entry, in order to check that the schema is not violated at the end. For instance, we can't delete an attribute that does not exist and add it later. The opposite is legal.
Throws:
javax.naming.NamingException - The generic exception we get if an illegal operation occurs
LdapNameNotFoundException - If we don't find the entry, then this exception is thrown.
LdapInvalidAttributeIdentifierException - The modified attribute is not known by the schema, or the Entry is not extensible.
LdapNoSuchAttributeException - The modified Attribute does not exist in the current entry or is not added by a previous modification operation.
LdapSchemaViolationException - Another schema violation occured.

modify

public void modify(NextInterceptor next,
                   LdapDN name,
                   javax.naming.directory.ModificationItem[] mods)
            throws javax.naming.NamingException
Description copied from interface: Interceptor
Filters Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.ModificationItem[]) call.

Specified by:
modify in interface Interceptor
Overrides:
modify in class BaseInterceptor
Throws:
javax.naming.NamingException

add

public void add(NextInterceptor next,
                LdapDN normName,
                javax.naming.directory.Attributes attrs)
         throws javax.naming.NamingException
Check that all the attributes exist in the schema for this entry.

Specified by:
add in interface Interceptor
Overrides:
add in class BaseInterceptor
Throws:
javax.naming.NamingException