Package com.netscape.cmscore.dbs
Class DBRegistry
- java.lang.Object
-
- com.netscape.cmscore.dbs.DBRegistry
-
- All Implemented Interfaces:
ISubsystem
,com.netscape.certsrv.dbs.IDBRegistry
public class DBRegistry extends java.lang.Object implements com.netscape.certsrv.dbs.IDBRegistry, ISubsystem
A class represents a registry where all the schema (object classes and attribute) information is stored. Attribute mappers can be registered with this registry. Given the schema information stored, this registry has knowledge to convert a Java object into a LDAPAttributeSet or vice versa.- Version:
- $Revision$, $Date$
- Author:
- thomask
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description DBRegistry()
Constructs registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description netscape.ldap.LDAPAttributeSet
createLDAPAttributeSet(com.netscape.certsrv.dbs.IDBObj obj)
Creates attribute set from object.com.netscape.certsrv.dbs.IDBObj
createObject(netscape.ldap.LDAPAttributeSet attrs)
Creates object from attribute set.IConfigStore
getConfigStore()
Retrieves configuration store.java.lang.String
getFilter(java.lang.String filter)
Creates LDAP-based search filters with help of registered mappers.java.lang.String
getFilter(java.lang.String filter, com.netscape.certsrv.dbs.IFilterConverter c)
Creates LDAP-based search filters with help of registered mappers.java.lang.String
getId()
Retrieves subsystem identifier.java.lang.String[]
getLDAPAttributes(java.lang.String[] attrs)
Retrieves a list of LDAP attributes that are associated with the given attributes.void
init(IConfigStore config)
Initializes the internal registery.boolean
isAttributeRegistered(java.lang.String ufName)
See if an attribute is registered.boolean
isObjectClassRegistered(java.lang.String className)
See if an object class is registered.void
mapObject(com.netscape.certsrv.dbs.IDBObj parent, java.lang.String name, java.lang.Object obj, netscape.ldap.LDAPAttributeSet attrs)
Maps object into LDAP attribute set.void
registerAttribute(java.lang.String ufName, com.netscape.certsrv.dbs.IDBAttrMapper mapper)
Registers attribute mapper.void
registerDynamicMapper(com.netscape.certsrv.dbs.IDBDynAttrMapper mapper)
Registers a dynamic attribute mapper.void
registerObjectClass(java.lang.String className, java.lang.String[] ldapNames)
Registers object class.void
setId(java.lang.String id)
Sets subsystem identifier.void
shutdown()
Shutdowns this subsystem gracefully.void
startup()
Starts up this subsystem.
-
-
-
Method Detail
-
getId
public java.lang.String getId()
Retrieves subsystem identifier.- Specified by:
getId
in interfaceISubsystem
- Returns:
- subsystem identifier
-
setId
public void setId(java.lang.String id) throws EBaseException
Sets subsystem identifier. This is an internal subsystem, and is not loadable.- Specified by:
setId
in interfaceISubsystem
- Parameters:
id
- subsystem identifier- Throws:
EBaseException
- failed to set id
-
init
public void init(IConfigStore config) throws EBaseException
Initializes the internal registery. Connects to the data source, and create a pool of connection of which applications can use. Optionally, check the integrity of the database.- Specified by:
init
in interfaceISubsystem
- Parameters:
config
- configuration store- Throws:
EBaseException
- failed to initialize
-
getConfigStore
public IConfigStore getConfigStore()
Retrieves configuration store.- Specified by:
getConfigStore
in interfaceISubsystem
- Returns:
- configuration store of this subsystem
-
startup
public void startup() throws EBaseException
Starts up this subsystem.- Specified by:
startup
in interfaceISubsystem
- Throws:
EBaseException
- failed to start up
-
shutdown
public void shutdown()
Shutdowns this subsystem gracefully.- Specified by:
shutdown
in interfaceISubsystem
-
registerObjectClass
public void registerObjectClass(java.lang.String className, java.lang.String[] ldapNames) throws com.netscape.certsrv.dbs.EDBException
Registers object class.- Specified by:
registerObjectClass
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
className
- java class to create for the object classesldapNames
- a list of LDAP object classes- Throws:
com.netscape.certsrv.dbs.EDBException
- failed to register
-
isObjectClassRegistered
public boolean isObjectClassRegistered(java.lang.String className)
See if an object class is registered.- Specified by:
isObjectClassRegistered
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
className
- java class to create- Returns:
- true if object class is registered already
-
registerAttribute
public void registerAttribute(java.lang.String ufName, com.netscape.certsrv.dbs.IDBAttrMapper mapper) throws com.netscape.certsrv.dbs.EDBException
Registers attribute mapper.- Specified by:
registerAttribute
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
ufName
- LDAP attribute namemapper
- mapper to invoke for the attribute- Throws:
com.netscape.certsrv.dbs.EDBException
- failed to register
-
isAttributeRegistered
public boolean isAttributeRegistered(java.lang.String ufName)
See if an attribute is registered.- Specified by:
isAttributeRegistered
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
ufName
- attribute name- Returns:
- true if attribute is registered already
-
registerDynamicMapper
public void registerDynamicMapper(com.netscape.certsrv.dbs.IDBDynAttrMapper mapper)
Description copied from interface:com.netscape.certsrv.dbs.IDBRegistry
Registers a dynamic attribute mapper.- Specified by:
registerDynamicMapper
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
mapper
- The dynamic mapper to register
-
getFilter
public java.lang.String getFilter(java.lang.String filter) throws EBaseException
Creates LDAP-based search filters with help of registered mappers. Parses filter from filter string specified in RFC1558.::= '(' ')' ::= | | | ::= '&' ::= '|' ::= '!' ::= | - ::=
| | ::= ::= | | | ::= '=' ::= '~=' ::= '>=' ::= '<=' ::= '=*' ::= '=' ::= NULL | ::= '*' ::= NULL | '*' ::= NULL | - Specified by:
getFilter
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
filter
- CMS-based filter- Returns:
- LDAP-based filter string
- Throws:
EBaseException
- failed to convert filter
-
getFilter
public java.lang.String getFilter(java.lang.String filter, com.netscape.certsrv.dbs.IFilterConverter c) throws EBaseException
Description copied from interface:com.netscape.certsrv.dbs.IDBRegistry
Creates LDAP-based search filters with help of registered mappers.- Specified by:
getFilter
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
filter
- CMS-based filterc
- filter converter- Returns:
- LDAP-based filter string
- Throws:
EBaseException
- failed to convert filter
-
mapObject
public void mapObject(com.netscape.certsrv.dbs.IDBObj parent, java.lang.String name, java.lang.Object obj, netscape.ldap.LDAPAttributeSet attrs) throws EBaseException
Maps object into LDAP attribute set.- Specified by:
mapObject
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
parent
- object's parentname
- name of the objectobj
- object to be mappedattrs
- LDAP attribute set- Throws:
EBaseException
- failed to map object
-
getLDAPAttributes
public java.lang.String[] getLDAPAttributes(java.lang.String[] attrs) throws EBaseException
Retrieves a list of LDAP attributes that are associated with the given attributes. This method is used for searches, to map the database attributes to LDAP attributes.- Specified by:
getLDAPAttributes
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
attrs
- attributes- Returns:
- LDAP-based attributes
- Throws:
EBaseException
- failed to map attributes
-
createLDAPAttributeSet
public netscape.ldap.LDAPAttributeSet createLDAPAttributeSet(com.netscape.certsrv.dbs.IDBObj obj) throws EBaseException
Creates attribute set from object.- Specified by:
createLDAPAttributeSet
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
obj
- database object- Returns:
- LDAP attribute set
- Throws:
EBaseException
- failed to create set
-
createObject
public com.netscape.certsrv.dbs.IDBObj createObject(netscape.ldap.LDAPAttributeSet attrs) throws com.netscape.certsrv.dbs.EDBException
Creates object from attribute set.- Specified by:
createObject
in interfacecom.netscape.certsrv.dbs.IDBRegistry
- Parameters:
attrs
- LDAP attribute set- Returns:
- database object
- Throws:
com.netscape.certsrv.dbs.EDBException
-
-