com.ibm.epic.directory
Class EpicDirectory

java.lang.Object
  |
  +--com.ibm.epic.directory.EpicDirectory

public class EpicDirectory
extends java.lang.Object

Classes for accessing the ePIC directory


Field Summary
static int ADD_ATTRIBUTE
          Operations settings for modifying entries
static java.lang.String CN
          Class Name
static java.lang.String copyrightNotice
          Copyright statement
static int DELETE_ATTRIBUTE
           
static int REPLACE_ATTRIBUTE
           
 
Constructor Summary
EpicDirectory()
          Constructs an EpicDirectory object and will create the initial directory using properties file referenced in the MQAOand creates the initial directory context.
EpicDirectory(java.util.Properties environment)
          Constructs an EpicDirectory object using information supplied in 'environment' and creates the initial directory context.
 
Method Summary
 void close()
          Closes the initial directory context
 javax.naming.directory.DirContext create(java.lang.String dn, javax.naming.directory.Attributes attributes)
          Create an entry in the directory
 void delete(java.lang.String dn)
          Delete an entry in the directory.
 javax.naming.directory.Attribute getAttribute(javax.naming.directory.Attributes attributes, java.lang.String attributeId)
          Returns an specific attribute from the attribute list.
 java.lang.String getAttributeId(javax.naming.directory.Attribute attribute)
          Get the attribute id from an attribute
 javax.naming.NamingEnumeration getAttributeList(javax.naming.directory.Attributes attributes)
          Retrieves an enumeration of the attributes in this attribute set
 int getAttributeListSize(javax.naming.directory.Attributes attributes)
          Get the number of attributes in a given directory entry.
 java.lang.Object getAttributeValue(java.lang.String dn, java.lang.String attributeId)
          Retrieves a single attribute value associated with the distinguished name
Assumes the attribute value is a single value, otherwise will return first value
This method should not be used when more than one attribute Id is to be retrieved.
 java.util.Enumeration getAttributeValueList(javax.naming.directory.Attribute attribute)
          Get the attribute value list for a particular attribute.
 int getAttributeValueListSize(javax.naming.directory.Attribute attribute)
          Get the size of the attribute value list for a given attribute.
 java.lang.String getDN(java.lang.String base, java.lang.String filter)
          Returns the dn for the specifed filter.
 javax.naming.directory.Attribute getNextAttribute(javax.naming.NamingEnumeration attributeList)
          Return the next attribute from the attribute list.
 java.lang.Object getNextAttributeValue(java.util.Enumeration attributeValueList)
          Get the next attribute value from an attribute value list.
 javax.naming.directory.Attributes getNextDirectoryEntry(javax.naming.NamingEnumeration results)
          Return the next directory entry from the search results
static java.util.Properties getProperties(java.lang.String fileName)
          Loads the the ePIC Directory properties file
 java.lang.Boolean isLoggingRequired(java.lang.String ePICAppId)
          Determines whether logging is required for an ePIC Application.
 java.lang.Object lookup(java.lang.String dn)
          Retrieves an object given its distinguished name.
 void modify(java.lang.String dn, int modificationOp, javax.naming.directory.Attributes attributes)
          Modify directory attributes according to the modificationOp and Attributes.
 javax.naming.directory.Attributes read(java.lang.String dn)
          Retrieve all attributes associated with the distinguished name.
 javax.naming.directory.Attributes read(java.lang.String dn, java.lang.String[] returnAttrs)
          Retrieves the attributes listed in returnAttrs associated with a distinguished name.
 javax.naming.NamingEnumeration search(java.lang.String base, javax.naming.directory.Attributes matchingAttrs, java.lang.String[] returnAttrs)
          Search the directory using a base and matching attributes, DOES NOT WORK WITH SUN JNDI!!!!
 javax.naming.NamingEnumeration search(java.lang.String base, java.lang.String filter, int scope)
          Search the directory using a base, filter, and scope.
 javax.naming.NamingEnumeration search(java.lang.String base, java.lang.String filter, java.lang.String[] returnAttrs, int scope)
          Search the directory using a base, filter, return attributes and scope.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_ATTRIBUTE

public static final int ADD_ATTRIBUTE
Operations settings for modifying entries

REPLACE_ATTRIBUTE

public static final int REPLACE_ATTRIBUTE

DELETE_ATTRIBUTE

public static final int DELETE_ATTRIBUTE

CN

public static final java.lang.String CN
Class Name

copyrightNotice

public static final java.lang.String copyrightNotice
Copyright statement
Constructor Detail

EpicDirectory

public EpicDirectory()
              throws EpicDirectoryException
Constructs an EpicDirectory object and will create the initial directory using properties file referenced in the MQAOand creates the initial directory context.
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method

EpicDirectory

public EpicDirectory(java.util.Properties environment)
              throws EpicDirectoryException
Constructs an EpicDirectory object using information supplied in 'environment' and creates the initial directory context.
Parameters:
Properties - Contains LDAP server connection parameters
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method
Method Detail

close

public void close()
           throws EpicDirectoryException
Closes the initial directory context
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method

create

public javax.naming.directory.DirContext create(java.lang.String dn,
                                                javax.naming.directory.Attributes attributes)
                                         throws EpicDirectoryException
Create an entry in the directory
Parameters:
String - Distinguished Name representing the directory entry to be created
Attributes - List of attributes to add to the directory entry
Returns:
DirContext - The newly created context
Throws:
EpicDirectoryException - Throws an exception if the Distinguished Name is null and re-throws other exceptions received in this method

delete

public void delete(java.lang.String dn)
            throws EpicDirectoryException
Delete an entry in the directory.
Parameters:
String - Distinguished Name representing the directory entry to be deleted
Throws:
EpicDirectoryException - Throws an exception if the Distinguished Name is null and re-throws other exceptions received in this method

getAttribute

public javax.naming.directory.Attribute getAttribute(javax.naming.directory.Attributes attributes,
                                                     java.lang.String attributeId)
                                              throws EpicDirectoryException
Returns an specific attribute from the attribute list.
Parameters:
Attributes - List of attributes
String - Specific attribute id to retrieve
Returns:
Attribute - Contains the specific attribute (id + values), return null if attribute not found
Throws:
EpicDirectoryException - Throws an exception if Attributes is null and re-throws other exceptions received in this method

getAttributeId

public java.lang.String getAttributeId(javax.naming.directory.Attribute attribute)
                                throws EpicDirectoryException
Get the attribute id from an attribute
Parameters:
Attribute - Contains the attribute id + values
Returns:
String - Returns the attribute id
Throws:
EpicDirectoryException - Throws an exception if Attribute or return String is null and re-throws other exceptions received in this method

getAttributeList

public javax.naming.NamingEnumeration getAttributeList(javax.naming.directory.Attributes attributes)
                                                throws EpicDirectoryException
Retrieves an enumeration of the attributes in this attribute set
Parameters:
Attributes - List of attributes
Returns:
NamingEnumeration - An enumeration of this attributes in this attribute set. Each element of the enumeration is of class Attribute.
Throws:
EpicDirectoryException - Throws an exception if Attributes is null or NamingEnumeration is empty and re-throws other exceptions received in this method

getAttributeListSize

public int getAttributeListSize(javax.naming.directory.Attributes attributes)
                         throws EpicDirectoryException
Get the number of attributes in a given directory entry.
Parameters:
Attributes - Contains the enumeration of attributes
Returns:
int - Number of attributes in the enumeration
Throws:
EpicDirectoryException - Throws an exception if Attributes is null

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String dn,
                                          java.lang.String attributeId)
                                   throws EpicDirectoryException
Retrieves a single attribute value associated with the distinguished name
Assumes the attribute value is a single value, otherwise will return first value
This method should not be used when more than one attribute Id is to be retrieved.
Parameters:
dn - Distinguished name to be read
attributeId - attribute Id to be searched
Returns:
Object - The attribute value to be returned
Throws:
EpicDirectoryException - Re-throws exceptions exceptions received in this method

getAttributeValueList

public java.util.Enumeration getAttributeValueList(javax.naming.directory.Attribute attribute)
                                            throws EpicDirectoryException
Get the attribute value list for a particular attribute.
Parameters:
Attribute - Contains the attribute id and values
Returns:
Enumeration - Contains the list of attribute values
Throws:
EpicDirectoryException - Throws an exception if Attribute is null or the Enumeration is empty and re-throws other exceptions received in this method

getAttributeValueListSize

public int getAttributeValueListSize(javax.naming.directory.Attribute attribute)
                              throws EpicDirectoryException
Get the size of the attribute value list for a given attribute.
Parameters:
Attribute - Contains the attribute id and values
Returns:
int - Number of attribute values in the list
Throws:
EpicDirectoryException - Throws an exception if Attribute is null

getNextAttribute

public javax.naming.directory.Attribute getNextAttribute(javax.naming.NamingEnumeration attributeList)
                                                  throws EpicDirectoryException
Return the next attribute from the attribute list.
Parameters:
NamingEnumeration - The set of attributes
Returns:
Attribute - Contains the next attribute in the attributeList, Attribute will be set to null when no more attributes are present in the attribute list.
Throws:
EpicDirectoryException - Throws an exception if the NamingEnumeration is null and re-throws other exceptions received in this method

getNextAttributeValue

public java.lang.Object getNextAttributeValue(java.util.Enumeration attributeValueList)
                                       throws EpicDirectoryException
Get the next attribute value from an attribute value list.
Parameters:
Enumeration - Contains the list of attribute values
Returns:
Object - Returns an object containing the attribute value. The object will be null when no more attribute values are present in the list
Throws:
EpicDirectoryException - Throws an exception if the Enumeration is is null and re-throws other exceptions received in this method

getNextDirectoryEntry

public javax.naming.directory.Attributes getNextDirectoryEntry(javax.naming.NamingEnumeration results)
                                                        throws EpicDirectoryException
Return the next directory entry from the search results
Parameters:
NamingEnumeration - Contains the set of directory entries from the search
Returns:
Attributes - Returns the next directory entry, returns null when NamingEnumeration is empty
Throws:
EpicDirectoryException - Throws an exception if NamingEnumeration is null and re-throws other exceptions received in this method

getProperties

public static java.util.Properties getProperties(java.lang.String fileName)
                                          throws EpicDirectoryException
Loads the the ePIC Directory properties file
Parameters:
String - File name of the ePIC directory properties file
Returns:
Properties - Contains the ePIC directory properties
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method.

isLoggingRequired

public java.lang.Boolean isLoggingRequired(java.lang.String ePICAppId)
                                    throws EpicDirectoryException
Determines whether logging is required for an ePIC Application.
Parameters:
String - Contains the name of the ePIC Application Id
Returns:
Boolean - Returns a true/false whether logging is required. null when no more attribute values are present in the list
Throws:
EpicDirectoryException - Throws an exception if the logging attribute is null and re-throws other exceptions received in this method

lookup

public java.lang.Object lookup(java.lang.String dn)
                        throws EpicDirectoryException
Retrieves an object given its distinguished name.
Parameters:
dn - A non-null string name representing the distinguished name
Returns:
Object - The object (type known by caller)
Throws:
EpicDirectoryException - Wrappers a naming inconsistency in the lookup request

modify

public void modify(java.lang.String dn,
                   int modificationOp,
                   javax.naming.directory.Attributes attributes)
            throws EpicDirectoryException
Modify directory attributes according to the modificationOp and Attributes.
Parameters:
String - The Distinguished Name representing the directory entry to be modified
int - modificationOp value, must be either ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, or DELETE_ATTRIBUTE
Attributes - The set of attributes used for the modification.
Throws:
EpicDirectoryException - Throws an exception if NamingEnumeration is empty and re-throws other exceptions received in this method

read

public javax.naming.directory.Attributes read(java.lang.String dn)
                                       throws EpicDirectoryException
Retrieve all attributes associated with the distinguished name.
Parameters:
String - A non-null string name representing the distinguished name
Returns:
Attributes - The attributes associated with the distinguished name
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method

read

public javax.naming.directory.Attributes read(java.lang.String dn,
                                              java.lang.String[] returnAttrs)
                                       throws EpicDirectoryException
Retrieves the attributes listed in returnAttrs associated with a distinguished name.
Parameters:
String - A non-null string name representing the distinguished name
String - [] Contains the attributes ids to be returned. May be null.
Returns:
Attributes - The attributes identified in String[], or a subset thereof if some attributes are not found. Can be empty but not null.
Throws:
EpicDirectoryException - Re-throws other exceptions received in this method

search

public javax.naming.NamingEnumeration search(java.lang.String base,
                                             java.lang.String filter,
                                             int scope)
                                      throws EpicDirectoryException
Search the directory using a base, filter, and scope.
Parameters:
String - A non-null string name of the base context to start the search
String - A non-null string to use as the search filter
int - Search constraint value, must be either SUBTREE_SCOPE, ONELEVEL_SCOPE, or OBJECT_SCOPE
Returns:
NamingEnumeration - A non-null enumeration of directory entries which match the base and filter
Throws:
EpicDirectoryException - Throws an exception if NamingEnumeration is empty and re-throws other exceptions received in this method

search

public javax.naming.NamingEnumeration search(java.lang.String base,
                                             javax.naming.directory.Attributes matchingAttrs,
                                             java.lang.String[] returnAttrs)
                                      throws EpicDirectoryException
Search the directory using a base and matching attributes, DOES NOT WORK WITH SUN JNDI!!!!
Parameters:
String - A non-null string name of the context to search
Attributes - The attributes to search for. If null, all attributes will be matched.
String - [] The attributes to be returned. If null, all attributes will be returned.
Returns:
NamingEnumeration - A non-null enumeration of directory entries which match the base and searchAttrs
Throws:
EpicDirectoryException - Throws an exception if NamingEnumeration is empty and re-throws other exceptions received in this method

search

public javax.naming.NamingEnumeration search(java.lang.String base,
                                             java.lang.String filter,
                                             java.lang.String[] returnAttrs,
                                             int scope)
                                      throws EpicDirectoryException
Search the directory using a base, filter, return attributes and scope.
Parameters:
String - A non-null string name of the base context to start the search
String - A non-null string to use as the search filter
String - A string array containing return attributes. Returns all attributes if null.
int - Search constraint value, must be either SUBTREE_SCOPE, ONELEVEL_SCOPE, or OBJECT_SCOPE
Returns:
NamingEnumeration - A non-null enumeration of directory entries which match the base and filter
Throws:
EpicDirectoryException - Throws an exception if NamingEnumeration is empty and re-throws other exceptions received in this method

getDN

public java.lang.String getDN(java.lang.String base,
                              java.lang.String filter)
                       throws EpicDirectoryException
Returns the dn for the specifed filter. Creation date: (4/2/01 11:28:00 AM)
Parameters:
base - java.lang.String - base dn where to begin searching for entry. If multiple dn branches need to be specified, separate the dns with a semicolon (;).
filter - java.lang.String - filter that you wish to find dn for. i.e. "uid=Bob"
Returns:
java.lang.String - dn of entry found by the specified filter
Throws:
EpicDirectoryException - Throws DIR0011 Exception if it finds more than one entry for the given filter. Re-throws other exceptions received in this method.