Class Directory
- java.lang.Object
-
- org.bedework.util.directory.common.Directory
-
- All Implemented Interfaces:
org.bedework.util.logging.Logged
- Direct Known Subclasses:
LdapDirectory,Ldif
public abstract class Directory extends Object implements org.bedework.util.logging.Logged
Provide access to directory services. If the object is provided with a Properties object it will be queried for a number of properties. If they are absent or no Properties object is provided they will default to some value. Properties are defined in javax.naming.Context and are: java.naming.factory.initial java.naming.provider.url Service provider, e.g. ldap://ldap.example.com:389 java.naming.security.authentication e.g. "simple" java.naming.security.principal e.g. cn=dirManager java.naming.security.credentials Usually the password The intention is that this class should be able to represent various forms of directory, even a sequential input stream of records.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()abstract booleancreate(DirRecord rec)abstract voiddestroy(String dn)abstract voidmodify(String dn, ModificationItem[] mods)DirRecordnewRecord(String entryDn)newRecord - Return a record which can have attribute values added.abstract DirRecordnextRecord()abstract voidreInit()If possible, reInit should allow reuse after a closeabstract voidreplace(String dn, String attrName, Object val)Replace an entire attribute with one containing only the given valueabstract voidreplace(String dn, String attrName, Object[] val)Replace an entire attribute with one containing only the given valuesabstract voidreplace(String dn, String attrName, Object oldval, Object newval)Replace a single given attribute value with the given valuebooleansearch(String base, String filter)Carry out a subtree searchabstract booleansearch(String base, String filter, int scope)Carry out a search with specified scope.booleansearchBase(String base, String filter)Carry out a base level search.booleansearchOne(String base, String filter)Carry out a one level search-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogger, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
-
-
-
Field Detail
-
scopeBase
public static final int scopeBase
- See Also:
- Constant Field Values
-
scopeOne
public static final int scopeOne
- See Also:
- Constant Field Values
-
scopeSub
public static final int scopeSub
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Directory
public Directory() throws NamingExceptionAll other constructors just call init- Throws:
NamingException
-
Directory
public Directory(String mngrDN, String pw) throws NamingException
- Throws:
NamingException
-
-
Method Detail
-
reInit
public abstract void reInit() throws NamingExceptionIf possible, reInit should allow reuse after a close- Throws:
NamingException- on fatal error
-
destroy
public abstract void destroy(String dn) throws NamingException
- Parameters:
dn-- Throws:
NamingException- on fatal error
-
search
public boolean search(String base, String filter) throws NamingException
Carry out a subtree search- Parameters:
base- for searchfilter- ldap filter- Returns:
- DirSearchResult
- Throws:
NamingException
-
searchBase
public boolean searchBase(String base, String filter) throws NamingException
Carry out a base level search. This should be the default if the scope is not specified.- Parameters:
base- for searchfilter- ldap filter- Returns:
- DirSearchResult or null
- Throws:
NamingException- on fatal error
-
searchOne
public boolean searchOne(String base, String filter) throws NamingException
Carry out a one level search- Parameters:
base- for searchfilter- ldap filter- Returns:
- DirSearchResult
- Throws:
NamingException- on fatal error
-
search
public abstract boolean search(String base, String filter, int scope) throws NamingException
Carry out a search with specified scope.- Parameters:
base- for searchfilter- ldap filterscope-- Returns:
- false means no record(s) found. true means it's safe to call nextRecord.
- Throws:
NamingException
-
nextRecord
public abstract DirRecord nextRecord() throws NamingException
- Throws:
NamingException
-
newRecord
public DirRecord newRecord(String entryDn) throws NamingException
newRecord - Return a record which can have attribute values added. create should be called to create the directory entry.- Parameters:
entryDn-- Returns:
- DirRecord
- Throws:
NamingException- on fatal error
-
create
public abstract boolean create(DirRecord rec) throws NamingException
- Parameters:
rec- directory record- Returns:
- boolean true if created, false if already exists
- Throws:
NamingException- on fatal error
-
replace
public abstract void replace(String dn, String attrName, Object val) throws NamingException
Replace an entire attribute with one containing only the given value- Parameters:
dn- for recordattrName- name of attributeval- new value- Throws:
NamingException- on fatal error
-
replace
public abstract void replace(String dn, String attrName, Object[] val) throws NamingException
Replace an entire attribute with one containing only the given values- Parameters:
dn- for recordattrName- name of attributeval- new value- Throws:
NamingException- on fatal error
-
replace
public abstract void replace(String dn, String attrName, Object oldval, Object newval) throws NamingException
Replace a single given attribute value with the given value- Parameters:
dn- for recordattrName- name of attributeoldval- current valuenewval- new value- Throws:
NamingException- on fatal error
-
modify
public abstract void modify(String dn, ModificationItem[] mods) throws NamingException
- Parameters:
dn- for recordmods- list of changes- Throws:
NamingException- on fatal error
-
close
public abstract void close()
-
-