gldapo.entry
Class GldapoEntry

java.lang.Object
  extended by gldapo.entry.GldapoEntry

public abstract class GldapoEntry
extends Object

The API reference for schema classes. Schema classes do not extend this class (i.e. schemaObject instanceof GldapoEntry will return false.)


Constructor Summary
GldapoEntry()
           
 
Method Summary
 boolean authenticate(String password)
          Test if password is this entry's password.
 void create()
          Writes the object in it's entirety to the directory.
 void delete()
          Removes the entry specified by this object's brdn from the directory.
 void deleteRecursively()
          Removes the entry specified by this object's brdn from the directory, and all it's children.
static GldapoEntry find()
          Peform a search (using default options), returning the first object found.
static List<GldapoEntry> find(Closure closure)
          Calls find(Map), with a filter option of closure.
static GldapoEntry find(Map options)
          Peform a search, but returning the first object found.
static List<GldapoEntry> find(Map options, Closure closure)
          Calls find(Map), after setting filter in options to closure
static GldapoEntry findAll()
          Peforms a search using all default options.
static List<GldapoEntry> findAll(Closure closure)
          Calls findAll(Map), with a filter option of closure.
static List<GldapoEntry> findAll(Map options)
          Performs a search returning all of the matching entries.
static List<GldapoEntry> findAll(Map options, Closure closure)
          Calls findAll(Map), after setting filter in options to closure
 DistinguishedName getBrdn()
          The Base Relative Distinguished Name for this entry.
static GldapoEntry getByDn(Object dn)
          Fetches the entry at dn from the the default directory.
static GldapoEntry getByDn(Object dn, Object directory)
          Fetches the entry at dn from directory.
 GldapoDirectory getDirectory()
          The connection to an actual LDAP directory.
 DistinguishedName getDn()
          The absolute location of this entry in it's directory.
 String getNamingAttribute()
          The name of the property that is used to define this entry's name.
 String getNamingValue()
          The value for the naming attribute.
 DistinguishedName getParent()
          The dn for the entry in the directory that contains this entry.
 void move(Object brdn)
          Relocate this object in the directory, after sending any updates.
 void move(Object namingValue, Object parent)
          Relocate this object in the directory, after sending any updates.
 void replace()
          Replaces the entry specified by this objects's brdn with this object.
 void replace(Object brdn)
          Replaces the entry @ brdn with this object.
 void replace(Object namingValue, Object parent)
          Replaces the entry at the location specified by namingValue and parent with this object.
 void save()
          Creates of updates the object depending on whether it is a new object or not.
 void setBrdn(Object brdn)
          Set the location of this entry, with a dn relative to the entry's directory base.
 void setDirectory(Object directory)
          Before an operation (create, update, delete etc.) can be performed on an object, it must have directory to perform the operation against.
 void setNamingValue(String value)
          Sets the value of the naming attribute.
 void setParent(Object parent)
          Defines the location for this entry by defining it's parent container.
 void update()
          Saves any modifications made to this object to the directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GldapoEntry

public GldapoEntry()
Method Detail

getDirectory

public GldapoDirectory getDirectory()
The connection to an actual LDAP directory.

Returns:
The directory for this object, or null if not set yet.

setDirectory

public void setDirectory(Object directory)
                  throws GldapoDirectoryNotFoundException
Before an operation (create, update, delete etc.) can be performed on an object, it must have directory to perform the operation against.

Parameters:
directory - If not an instance of GldapoDirectory, will be toString()'d and treated as a directory name and the corresponding directory will be pulled from the class's gldapo instance.
Throws:
GldapoDirectoryNotFoundException - If directory is used as a name, and no directory is registered with that name.

getBrdn

public DistinguishedName getBrdn()
                          throws GldapoException
The Base Relative Distinguished Name for this entry. The 'brdn' denotes the location of the entry in the directory, relative to the base of the object's directory. It is a combination of the parent, and namingAttribute/namingValue properties.

Returns:
The brdn, or null if not set yet
Throws:
GldapoException - if the naming value for this object is null

setBrdn

public void setBrdn(Object brdn)
             throws GldapoException
Set the location of this entry, with a dn relative to the entry's directory base. The brdn is converted to a string, and then a DistinguishedName. The leading (leftmost) rdn is seperated from the dn and the value passed to setNamingValue(String). Any remaining rdns are passed as a single value to setParent(Object).

Parameters:
brdn - An object whose string representation will be the brdn
Throws:
GldapoException - if the leading rdn of brdn has a different attribute name to the defined naming attribute for this class

getDn

public DistinguishedName getDn()
                        throws GldapoException
The absolute location of this entry in it's directory. The brdn, plus the base of this object's directory.

Throws:
GldapoException - if this object has no directory, or naming value set

getParent

public DistinguishedName getParent()
The dn for the entry in the directory that contains this entry. A dn of "" indicates that the entry's parent is the base of it's directory. If a parent has not been explicitly set, an empty dn will be returned.

Returns:
A dn, never null

setParent

public void setParent(Object parent)
Defines the location for this entry by defining it's parent container.

Parameters:
parent - the string representation of this object will form the parent dn

getNamingValue

public String getNamingValue()
The value for the naming attribute. This defines part of the location/brdn of this entry.

Returns:
the naming value, or null if not yet set

setNamingValue

public void setNamingValue(String value)
                    throws GldapoException
Sets the value of the naming attribute. This value cannot be changed once set. See move(Object,Object) if you need to move an entry (i.e. change it's naming value)

Parameters:
value - the naming value
Throws:
GldapoException - if this object already has a naming value

getNamingAttribute

public String getNamingAttribute()
The name of the property that is used to define this entry's name. The naming attribute is defined by annotating a property with @GldapoNamingAttribute and is mandatory for schema classes.

Returns:
the attribute name, never null

getByDn

public static GldapoEntry getByDn(Object dn,
                                  Object directory)
                           throws GldapoException
Fetches the entry at dn from directory. If directory is null, the default directory will be used.

Parameters:
dn - an object's whose string representation is the dn of the target entry
directory - if not a directory, an objects whose string representation is the name of a registered directory
Returns:
an entry object, or null if there is no entry at dn
Throws:
GldapoException - if dn or directory are invalid, or an LDAP error occurs.

getByDn

public static GldapoEntry getByDn(Object dn)
                           throws GldapoException
Fetches the entry at dn from the the default directory. Calls getByDn(dn,null).

Throws:
GldapoException

create

public void create()
            throws GldapoException
Writes the object in it's entirety to the directory. Before an object can be written, it must have a location and a directory. To have a location, it must at least have a naming value.

Throws:
GldapoException - If the object is in an invalid state for creating, or an LDAP error occurs.

update

public void update()
            throws GldapoException
Saves any modifications made to this object to the directory. This will only send any changes made, so is not suitable for creating new objects. If this object has no modifications, this is a no-op.

Throws:
GldapoException - if the object is not in a suitable state for updating, or an LDAP error occurs.

save

public void save()
          throws GldapoException
Creates of updates the object depending on whether it is a new object or not.

Throws:
GldapoException - if the object is not in a suitable state for saving, or an LDAP error occurs.

move

public void move(Object brdn)
          throws GldapoException
Relocate this object in the directory, after sending any updates.

Parameters:
brdn - the new brdn of the object (the string representation will be used).
Throws:
GldapoException - if brdn is invalid, this is not an existing entry, or an LDAP error occurs.

move

public void move(Object namingValue,
                 Object parent)
          throws GldapoException
Relocate this object in the directory, after sending any updates.

Parameters:
namingValue - the new naming value (the string representation will be used). If null, the existing naming value will be used.
parent - the new parent container (the string representation will be used). If null, the existing parent value will be used. Use "" to specify no parent.
Throws:
GldapoException - if brdn is invalid, this is not an existing entry, or an LDAP error occurs.

replace

public void replace(Object brdn)
             throws GldapoException
Replaces the entry @ brdn with this object.

Parameters:
brdn - the location of the entry to replace (the string representation will be used).
Throws:
GldapoException - if this object has no directory, or and LDAP error occurs.

replace

public void replace(Object namingValue,
                    Object parent)
             throws GldapoException
Replaces the entry at the location specified by namingValue and parent with this object.

Parameters:
namingValue - the replacee's naming value (the string representation will be used). If null, this object's naming value will be used.
parent - the replacee's parent container (the string representation will be used). If null, this object's parent value will be used. Use "" to specify no parent.
Throws:
GldapoException - if this object has no directory, or and LDAP error occurs.

replace

public void replace()
             throws GldapoException
Replaces the entry specified by this objects's brdn with this object.

Throws:
GldapoException - if this object has no directory, no valid brdn, or and LDAP error occurs.

delete

public void delete()
            throws GldapoException
Removes the entry specified by this object's brdn from the directory. This will fail if the entry has children, use deleteRecursively() in that case.

Throws:
GldapoException - if this object has no directory, no valid brdn, or and LDAP error occurs.

deleteRecursively

public void deleteRecursively()
                       throws GldapoException
Removes the entry specified by this object's brdn from the directory, and all it's children.

Throws:
GldapoException - if this object has no directory, no valid brdn, or and LDAP error occurs.

authenticate

public boolean authenticate(String password)
                     throws GldapoException
Test if password is this entry's password.

Throws:
GldapoException - if this object has no location or directory defined, or an LDAP error occurs

findAll

public static List<GldapoEntry> findAll(Map options)
                                 throws GldapoException
Performs a search returning all of the matching entries.

The options map can contain the following items (but requires none):

KeyValue Description
directoryThe directory to use. Either by name or instance. If null, the default directory will be used
filterThe filter used to restrict the search (string value will be used, or passed to filter builder if Closure). Will be anded with the schema filter if present.
baseThe dn (relative to the base of the directory) to start the search at. If null, the directory base will be used.
absoluteBaseThe dn to start the search at, but absolutely, not relative to the directory base.
searchScopeA string indicating the scope of the search (either "object", "onelevel" or "subtree")
pageSizeThe number of entries to return in one page. If null or less than 1, paging will not be used
countLimitThe maximum amount of entries for the server to return. No limit is used if null. (be mindful that some servers set limits server side)
timeLimitThe maximum number of milliseconds to spend searching. No limit is used if null. (be mindful that some servers set limits server side)
derefLinkFlagA boolean to enable/disable link dereferencing during the search.

Values override the default search options defined by the target directory. Where an option is omitted from options, the value from the directory's set options.

If the filter option is a closure, it will be used with FilterBuilder to build the filter string.

Returns:
the found objects, or an empty list if none were found.
Throws:
GldapoException - if the proposed options are invalid in anyway, or an LDAP error occurs.

findAll

public static List<GldapoEntry> findAll(Map options,
                                        Closure closure)
                                 throws GldapoException
Calls findAll(Map), after setting filter in options to closure

Throws:
GldapoException

findAll

public static List<GldapoEntry> findAll(Closure closure)
                                 throws GldapoException
Calls findAll(Map), with a filter option of closure.

Throws:
GldapoException

findAll

public static GldapoEntry findAll()
                           throws GldapoException
Peforms a search using all default options.

Returns:
the found objects, or an empty list if none were found.
Throws:
GldapoException - if the proposed options are invalid in anyway, or an LDAP error occurs.
See Also:
findAll(Map)

find

public static GldapoEntry find(Map options)
                        throws GldapoException
Peform a search, but returning the first object found.

Parameters:
options - the same as findAll(Map)
Returns:
the entry, or null if not found
Throws:
GldapoException - if the proposed options are invalid in anyway, or an LDAP error occurs.

find

public static List<GldapoEntry> find(Map options,
                                     Closure closure)
                              throws GldapoException
Calls find(Map), after setting filter in options to closure

Throws:
GldapoException

find

public static List<GldapoEntry> find(Closure closure)
                              throws GldapoException
Calls find(Map), with a filter option of closure.

Throws:
GldapoException

find

public static GldapoEntry find()
                        throws GldapoException
Peform a search (using default options), returning the first object found.

Returns:
the entry, or null if not found
Throws:
GldapoException - if the proposed options are invalid in anyway, or an LDAP error occurs.


Copyright © 2007-2010 Codehaus. All Rights Reserved.