com.novell.emframe.dev
Class DirUtils

java.lang.Object
  extended bycom.novell.emframe.dev.DirUtils

public class DirUtils
extends java.lang.Object

Utility methods for accessing the directory.


Constructor Summary
DirUtils()
           
 
Method Summary
 void addASXMLFilterInfoToRM(FilterResultModifier rm, java.lang.String filterXML, TaskContext context)
          Parses filterXML (produced by AdvancedSelection widget) and adds filter to an FilterResultModifier.
 void addASXMLFilterInfoToRM(NDSFilterResultModifier rm, java.lang.String filterXML, TaskContext context)
          Parses filterXML (produced by AdvancedSelection widget) and adds filter to an NDSFilterResultModifier.
static java.lang.String[] attributeReader(ObjectEntry oe, java.lang.String[] attr)
          Reads attribute values of an eDirectory object.
static void attributeWriter(ObjectEntry oe, java.lang.String[] attr, java.lang.String[] attrVal)
          Sets attributes of an eDirectory object.
static NSObject createObject(ObjectEntry parentEntry, java.lang.String objectName, java.lang.String className, java.lang.String namingAttr)
          Simple API for creating eDirectory objects.
 void createSortedTypeArrays(java.util.ArrayList types, java.util.ArrayList localizedTypes, TaskContext context)
          Takes a list of ds types (classes) and returns a sorted list of localized types.
static NSObject createUser(java.lang.String className, ObjectEntry parentEntry, java.lang.String userStr, java.lang.String surname)
          Simple API for creating user objects.
 java.util.ArrayList getAllSubClasses(java.lang.String[] superTypes)
          Inspects the eDirectory schema and finds all sub classes (not just direct children).
 java.lang.String getAttributeDisplayName(java.lang.String attributeName, PluginContext context)
          Used for getting localized display name for an attributeName.
 java.lang.String[] getContainerTypes()
          Returns a list of all container object classes in the tree.
static java.lang.String getLeftMostName(java.lang.String objectName)
          Gets the left most part of a NDAP DN name.
 MappingObject getMappingObject()
          Table that maps ldap and ndap attribute names.
 java.lang.String getObjectEntryImageName(ObjectEntry oe)
          Returns a relative path to an icon matching the objectEntry.
 java.lang.String getObjectTypeDisplayName(java.lang.String objectTypeName, PluginContext context)
          Used for getting localized display name for an objectTypeName.
 java.lang.String getObjectTypeImageName(java.lang.String typeName)
          Returns a relative path to an icon matching the objectEntry.
 java.lang.String getRealName(java.lang.String strSafeName)
          Returns the real object name from a typename which contains no alpha-numeric characters.
static java.lang.String[] getRights(ObjectEntry targetOE, ObjectEntry trusteeOE, java.lang.String[] attrib)
          Reads eDirectory rights.
 java.lang.String getSafeName(java.lang.String typeName)
          Returns typename which contains no alpha-numeric characters.
 java.lang.String[] getSelectableContainerTypes()
          Returns a list of the selectable container types.
 java.lang.String[] getSelectableContainerTypes(java.util.HashSet excludeTypes)
          Returns a list of the selectable container types except for the excluded list passed in.
 java.lang.String[] getSelectableLeafTypes()
          Returns a list of selectable leaf object types.
 java.lang.String[] getSelectableLeafTypes(java.util.HashSet excludeTypes)
          Returns a list of selectable leaf object types except for the excluded list passed in.
 java.lang.String[] getSelectableTypes()
          Returns a list of all selectable object types.
 java.lang.String[] getSelectableTypes(java.util.HashSet excludeTypes)
          Returns a list of all selectable object types except for the excluded list passed in.
 java.lang.String[] getSortedAttributeDisplayNames(TaskContext context)
          Returns a sorted list of attribute display names.
 java.lang.String[] getSortedAttrs()
          Returns a sorted list of attributes.
 java.lang.String[] getSortedClasses()
          Returns a sorted list of class names.
 java.lang.String[] getSubClasses(java.lang.String strName)
          Inspects schema and finds direct and indirect children sub classes (supports inheritance).
 java.lang.String[] getSuperClasses(java.lang.String strName)
          Inspects the eDirectory schema and finds all super classes (not just direct parents).
 boolean getUniversalPwdState(java.lang.String containerStr)
          Returns whether Universal Passwords are set for a specific container.
 boolean isAuxClass(java.lang.String typeName)
          Determines whether a specified type/class is an auxiliary class.
 boolean isContainer(java.lang.String objectType)
          Returns whether an object type is a container.
static boolean isObjectInThisTree(ObjectEntry oeTree, java.lang.String objectFullName)
          Tests if the DN has the tree name represnted by the ObjectEntry at the end of the DN.
 boolean isOfAuxClass(ObjectEntry oe, java.lang.String auxClass)
          Determines whether a specified ObjectEntry has been extended with a specific auxClass.
static boolean isOfType(ObjectType type, java.lang.String strKnownType, boolean bDerivedOK)
          Determines whether a given object type is of a known type or, optionally, whether it is derived from a known type.
static boolean MoveObject(ObjectEntry objectEntry, ObjectEntry destObjectEntry, boolean createAliasFlag)
          Simple API for moving eDirectory object to a new container.
static java.lang.String readAttributeXML(TaskContext context, java.lang.Object theObj, java.lang.String attrName)
          API for reading attributes and receiving values as XML; Used by EDAS.
static java.lang.String removeRightMostName(java.lang.String objectName)
          Removed the right most part of a NDAP DN name.
static java.lang.String removeTreeFromFullName(ObjectEntry oeTree, java.lang.String objectFullName)
          Removes the tree name from a full DN (admin.novell.baggins_tree => admin.novell).
 void setSimplePassword(java.lang.String treeName, java.lang.String userName, java.lang.String newPassword, boolean doDelay)
          Sets the eDirectory simple password.
static void writeAttributeXML(TaskContext context, java.lang.Object theObj, java.lang.String attrName, java.lang.String value)
          API for writing values to NSObject or MOOManager thought XML; Used by EDAS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirUtils

public DirUtils()
Method Detail

addASXMLFilterInfoToRM

public void addASXMLFilterInfoToRM(FilterResultModifier rm,
                                   java.lang.String filterXML,
                                   TaskContext context)
Parses filterXML (produced by AdvancedSelection widget) and adds filter to an FilterResultModifier. This can be used later in a getChildren call.

Parameters:
rm - FilterResultModifier filter to be used with get children call
filterXML - XML String produced by AdvancedSelection widget
context - TaskContext of the plug-in

addASXMLFilterInfoToRM

public void addASXMLFilterInfoToRM(NDSFilterResultModifier rm,
                                   java.lang.String filterXML,
                                   TaskContext context)
Parses filterXML (produced by AdvancedSelection widget) and adds filter to an NDSFilterResultModifier. This can be used later in a getChildren call.

Parameters:
rm - NDSFilterResultModifier filter to be used with get children call
filterXML - XML String produced by AdvancedSelection widget
context - TaskContext of the plug-in

attributeReader

public static java.lang.String[] attributeReader(ObjectEntry oe,
                                                 java.lang.String[] attr)
                                          throws SPIException
Reads attribute values of an eDirectory object.

This is a simple helper routine for easier reading of eDirectory attributes. This API does not support setting multi values for attributes. This API supports a limited set of attribute syntaxes (any syntax whose strategy can convert a attribute value to a String).

Supports Strings syntaxes like: Case Exact String, Case Ignore String, Email Address, etc Supports Boolean: values should be "true" or "false" Doesn't support many other syntaxes: Network Address, OctectList, Hold, etc For specific syntaxes view the javadoc for the appropriate Strategy (com.novell.admin.ns.nds package).

NOTE: this API is not recommend for use. While it is more simplistic, its current implemention is expensive (especially if only one or two attributes are being read).

Parameters:
oe - ObjectEntry for the object where the attribute resides
attr - String array containing the attributes to be read
Returns:
the values of the attributes read from the directory
Throws:
SPIException - thrown by the Java layer
See Also:
attributeWriter(com.novell.application.console.snapin.ObjectEntry, java.lang.String[], java.lang.String[])

attributeWriter

public static void attributeWriter(ObjectEntry oe,
                                   java.lang.String[] attr,
                                   java.lang.String[] attrVal)
                            throws NamespaceException,
                                   SPIException,
                                   SnapinVetoException,
                                   ComponentCreationException
Sets attributes of an eDirectory object.

This is a simple helper routine for easier setting of eDirectory attributes. This API does not support setting multi values for attributes. This API supports a limited set of attribute syntaxes (any syntax whose strategy can convert a String to an appriate value).

Supports Strings syntaxes like: Case Exact String, Case Ignore String, Email Address, etc Supports Boolean: values should be "true" or "false" Doesn't support many other syntaxes: Network Address, OctectList, Hold, etc For specific syntaxes view the javadoc for the appropriate Strategy (com.novell.admin.ns.nds package).

NOTE: this API is not recommend for use. While it is more simplistic, its current implemention is expensive (especially if only one or two attributes are being read).

Parameters:
oe - ObjectEntry representing the object to write to
attr - String array that contains the names attributes to be written
attrVal - String array that contains the values of attribute to write
Throws:
NamespaceException - thrown from the eMFrame Namespace
SPIException - thrown by the Java layer
SnapinVetoException - thrown by the eMFrame shell
ComponentCreationException
See Also:
attributeReader(com.novell.application.console.snapin.ObjectEntry, java.lang.String[])

createObject

public static NSObject createObject(ObjectEntry parentEntry,
                                    java.lang.String objectName,
                                    java.lang.String className,
                                    java.lang.String namingAttr)
                             throws NamespaceException,
                                    SPIException,
                                    SnapinVetoException
Simple API for creating eDirectory objects. The object class must not have any mandatory attributes other than the naming attribute.

Parameters:
parentEntry - ObjectEntry containing the parent entry of the object
objectName - String containing the name of the object to be created
className - String containing the class name of the object to be created
namingAttr - String containing the naming attribute for the object to be created (mandatory attribute)
Returns:
NSObject for the newly created object
Throws:
NamespaceException - thrown from the eMFrame Namespace
SPIException - thrown by the Java layer
SnapinVetoException - thrown by the eMFrame shell

createSortedTypeArrays

public void createSortedTypeArrays(java.util.ArrayList types,
                                   java.util.ArrayList localizedTypes,
                                   TaskContext context)
Takes a list of ds types (classes) and returns a sorted list of localized types. The original type array will be "shuffled" so that the elements are in the same order as those in the localized types arraylist, as well.

Parameters:
types - ArrayList containing a list of ds types. Will be reordered to match the order in the localized types array.
localizedTypes - ArrayList that is empty where sorted localizated ds types (classes) will be placed.
context - TaskContext of the plug-in

createUser

public static NSObject createUser(java.lang.String className,
                                  ObjectEntry parentEntry,
                                  java.lang.String userStr,
                                  java.lang.String surname)
                           throws NamespaceException,
                                  SPIException,
                                  SnapinVetoException
Simple API for creating user objects.

Parameters:
className - String containing class name of the user object to create
parentEntry - ObjectEntry of the parent entry of the object
userStr - String containing the user's name (mandatory attribute)
surname - String containing the user's surname/last name (mandatory attribute)
Returns:
NSObject for the newly created object.
Throws:
NamespaceException - thrown from the eMFrame Namespace
SPIException - thrown by the Java layer
SnapinVetoException - thrown by the eMFrame shell

getAllSubClasses

public java.util.ArrayList getAllSubClasses(java.lang.String[] superTypes)
Inspects the eDirectory schema and finds all sub classes (not just direct children).

Parameters:
superTypes - String array containing names of types
Returns:
ArrayList of names of all sub classes; So all types returned will be a decendend of at least one of the superTypes passed in.

getAttributeDisplayName

public java.lang.String getAttributeDisplayName(java.lang.String attributeName,
                                                PluginContext context)
Used for getting localized display name for an attributeName.

Parameters:
attributeName - String containing the attribute type name
context - PluginContext of the plug-in
Returns:
String containing the localized display name for attributeName

getContainerTypes

public java.lang.String[] getContainerTypes()
Returns a list of all container object classes in the tree.

Returns:
String array of all containers object classes in the tree

getLeftMostName

public static java.lang.String getLeftMostName(java.lang.String objectName)
Gets the left most part of a NDAP DN name. Handles escaped dots. Used to get the object's simple name.

Parameters:
objectName - String containing the NDAP DN name
Returns:
String containing simple object name

getMappingObject

public MappingObject getMappingObject()
Table that maps ldap and ndap attribute names.

Returns:
MappingObject to map ndap and ldap attribute names

getObjectEntryImageName

public java.lang.String getObjectEntryImageName(ObjectEntry oe)
Returns a relative path to an icon matching the objectEntry. If no icon is available, an generic icon is returned.

Parameters:
oe - ObjectEntry for which an icon is requested
Returns:
String which is relative path to icon

getObjectTypeDisplayName

public java.lang.String getObjectTypeDisplayName(java.lang.String objectTypeName,
                                                 PluginContext context)
Used for getting localized display name for an objectTypeName.

Parameters:
objectTypeName - String containing the object type name
context - PluginContext of the plug-in
Returns:
String containing the localized display name for objectTypeName

getObjectTypeImageName

public java.lang.String getObjectTypeImageName(java.lang.String typeName)
Returns a relative path to an icon matching the objectEntry. If no icon is available, an generic icon is returned.

Parameters:
typeName - object class for which an icon is requested
Returns:
String which is relative path to icon

getRealName

public java.lang.String getRealName(java.lang.String strSafeName)
Returns the real object name from a typename which contains no alpha-numeric characters. Inverse of DirUtils.getSafeName.

Parameters:
strSafeName - String containing safe name for class or attribute
Returns:
String containing real name for class or attribute
See Also:
getSafeName(java.lang.String)

getRights

public static final java.lang.String[] getRights(ObjectEntry targetOE,
                                                 ObjectEntry trusteeOE,
                                                 java.lang.String[] attrib)
                                          throws PageException
Reads eDirectory rights.

The possible return values are:

Parameters:
targetOE - ObjectEntry of the target
trusteeOE - ObjectEntry of the trustee
attrib - String array containing attribute names
Returns:
String array of attrib rights ("RW", "R", or "")
Throws:
PageException

getSafeName

public java.lang.String getSafeName(java.lang.String typeName)
Returns typename which contains no alpha-numeric characters.

Parameters:
typeName - String containing the typen name
Returns:
String containing typeName but with non-alphanumber chars replaced with an underscore

getSelectableContainerTypes

public java.lang.String[] getSelectableContainerTypes()
Returns a list of the selectable container types. Utility method used by the ObjectSelector.

NOTE: This routine returns container types that can be search for and selected in the Object Selector (when the [containers] flag is set). Top is eliminated because everything is subclassed from Top and including it means all leaf objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Returns:
String array of object class names

getSelectableContainerTypes

public java.lang.String[] getSelectableContainerTypes(java.util.HashSet excludeTypes)
Returns a list of the selectable container types except for the excluded list passed in. Utility method used by the ObjectSelector.

NOTE: This routine returns container types that can be search for and selected in the Object Selector (when the [containers] flag is set). Top is eliminated because everything is subclassed from Top and including it means all leaf objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Parameters:
excludeTypes - HashSet of object class names to not include in the list of selectable container types
Returns:
String array of object class names

getSelectableLeafTypes

public java.lang.String[] getSelectableLeafTypes()
Returns a list of selectable leaf object types. Utility method used by the ObjectSelector.

This routine returns leaf (non-container) types that can be search for and selected in the Object Selector (when the [non-containers] flag is set). Top is eliminated because everything is subclassed from Top and including it means all container objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Returns:
String array containg the object class names that are selectable

getSelectableLeafTypes

public java.lang.String[] getSelectableLeafTypes(java.util.HashSet excludeTypes)
Returns a list of selectable leaf object types except for the excluded list passed in. Utility method used by the ObjectSelector.

This routine returns leaf (non-container) types that can be search for and selected in the Object Selector (when the [non-containers] flag is set). Top is eliminated because everything is subclassed from Top and including it means all container objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Parameters:
excludeTypes - HashSet of object class names to not include in the list of selectable leaf types
Returns:
String array containg the object class names that are selectable

getSelectableTypes

public java.lang.String[] getSelectableTypes()
Returns a list of all selectable object types. Utility method used by the ObjectSelector.

This routine returns all types that can be search for and selected in the Object Selector. Top is eliminated because everything is subclassed from Top and including it means all container objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Returns:
String array containg the object class names that are selectable

getSelectableTypes

public java.lang.String[] getSelectableTypes(java.util.HashSet excludeTypes)
Returns a list of all selectable object types except for the excluded list passed in. Utility method used by the ObjectSelector.

This routine returns all types that can be search for and selected in the Object Selector. Top is eliminated because everything is subclassed from Top and including it means all container objects are marked as selectable in the object selector when ShowSubClasses mode is enabled.

Parameters:
excludeTypes - HashSet of object class names to not include in the list of selectable types
Returns:
String array containg the object class names that are selectable

getSortedAttributeDisplayNames

public java.lang.String[] getSortedAttributeDisplayNames(TaskContext context)
Returns a sorted list of attribute display names. Many times plug-ins need a sorted list of schema names. For effeciency purposes this is done by the framework once.

Parameters:
context - TaskContext of the plug-in
Returns:
String array parallel to getSortedAttrs(), but the localized displayNames
See Also:
getSortedAttrs()

getSortedAttrs

public java.lang.String[] getSortedAttrs()
Returns a sorted list of attributes. Many times plug-ins need a sorted list of schema names. For effeciency purposes this is done by the framework once.

Returns:
String array of sorted attribute names
See Also:
getSortedAttributeDisplayNames(com.novell.emframe.dev.TaskContext)

getSortedClasses

public java.lang.String[] getSortedClasses()
Returns a sorted list of class names. Many times plug-ins need a sorted list of schema names. For effeciency purposes this is done by the framework once.

Returns:
String array of sorted class names

getSubClasses

public java.lang.String[] getSubClasses(java.lang.String strName)
Inspects schema and finds direct and indirect children sub classes (supports inheritance).

Parameters:
strName - String containing name of object class
Returns:
String array containing all sub classes (direct and indirect) of an object class

getSuperClasses

public java.lang.String[] getSuperClasses(java.lang.String strName)
                                   throws NamespaceException
Inspects the eDirectory schema and finds all super classes (not just direct parents). Does not include duplicates if ancestor appears multiple times in inheritance heiarchy.

Parameters:
strName - String containing the name of objectClass
Returns:
String array containing names of all super classes
Throws:
NamespaceException

getUniversalPwdState

public boolean getUniversalPwdState(java.lang.String containerStr)
                             throws PluginException
Returns whether Universal Passwords are set for a specific container.

Parameters:
containerStr - String containing a "." formated string representing the container where to begin checking if universal password is enabled
Returns:
boolean: true if Univeral Password is enabled within this container, false if otherwise
Throws:
PluginException - if an error occurs trying to determine if Univeral Password is enabled

isAuxClass

public boolean isAuxClass(java.lang.String typeName)
Determines whether a specified type/class is an auxiliary class.

Parameters:
typeName - String containing the object type
Returns:
boolean: true if the object type is an auxiliary class, false if otherwise

isContainer

public boolean isContainer(java.lang.String objectType)
Returns whether an object type is a container.

Parameters:
objectType - String containing the object type
Returns:
boolean: true if the objectType is a container, false if otherwise

isObjectInThisTree

public static boolean isObjectInThisTree(ObjectEntry oeTree,
                                         java.lang.String objectFullName)
Tests if the DN has the tree name represnted by the ObjectEntry at the end of the DN.

Parameters:
oeTree - ObjectEntry containing the tree
objectFullName - String containing full DN including the tree name (ex. admin.novell.baggins_tree)
Returns:
boolean: true if object is in the current tree, false if otherwise

isOfAuxClass

public boolean isOfAuxClass(ObjectEntry oe,
                            java.lang.String auxClass)
Determines whether a specified ObjectEntry has been extended with a specific auxClass.

Parameters:
oe - ObjectEntry in question
auxClass - String containing the auxClass to be checked for.
Returns:
boolean: true if the object type has been extended with the auxiliary class, false if otherwise

isOfType

public static boolean isOfType(ObjectType type,
                               java.lang.String strKnownType,
                               boolean bDerivedOK)
Determines whether a given object type is of a known type or, optionally, whether it is derived from a known type.

Parameters:
type - ObjectType to be checked
strKnownType - String containing the name of the type to look for
bDerivedOK - boolean set to true if the object type can be derived from the known type, otherwise set to false
Returns:
boolean: true if the object type is of the known type, false if otherwise

MoveObject

public static boolean MoveObject(ObjectEntry objectEntry,
                                 ObjectEntry destObjectEntry,
                                 boolean createAliasFlag)
                          throws NamespaceException,
                                 SPIException,
                                 SnapinVetoException
Simple API for moving eDirectory object to a new container.

Parameters:
objectEntry - ObjectEntry of the source object
destObjectEntry - ObjectEntry of the destination object
createAliasFlag - boolean indicates whether an alias should be created for the moved object
Returns:
boolean: true if move successful, false if otherwise
Throws:
NamespaceException - thrown from the eMFrame Namespace
SPIException - thrown by the Java layer
SnapinVetoException - thrown by the eMFrame shell

readAttributeXML

public static final java.lang.String readAttributeXML(TaskContext context,
                                                      java.lang.Object theObj,
                                                      java.lang.String attrName)
                                               throws eDirAccessServiceException
API for reading attributes and receiving values as XML; Used by EDAS.

Parameters:
context - TaskContext of the plug-in
theObj - Object must be NSObject of MOOManager to read data from
attrName - String containing the attribute to read
Returns:
String containing XML as text representing the value
Throws:
eDirAccessServiceException
See Also:
writeAttributeXML(com.novell.emframe.dev.TaskContext, java.lang.Object, java.lang.String, java.lang.String)

removeRightMostName

public static java.lang.String removeRightMostName(java.lang.String objectName)
Removed the right most part of a NDAP DN name. Handles escaped dots.

Parameters:
objectName - String containing the NDAP DN name
Returns:
String containing the objectName without right most part

removeTreeFromFullName

public static java.lang.String removeTreeFromFullName(ObjectEntry oeTree,
                                                      java.lang.String objectFullName)
Removes the tree name from a full DN (admin.novell.baggins_tree => admin.novell). If the DN doesn't include the tree name, it is returned unchanged.

Parameters:
oeTree - ObjectEntry containing the tree
objectFullName - String containing full DN including the tree name (ex. admin.novell.baggins_tree)
Returns:
String containing the DN without the treename

setSimplePassword

public void setSimplePassword(java.lang.String treeName,
                              java.lang.String userName,
                              java.lang.String newPassword,
                              boolean doDelay)
                       throws PluginException
Sets the eDirectory simple password.

Parameters:
treeName - String containing the treename. This parameter is not used by the called routines but may not be null.
userName - String representing the user name in "." format without the tree name. For example: "admin.provo.novell".
newPassword - String containing the new password (extented characters should be fine)
doDelay - boolean - if doing a create the object may not have been replicated to the partition the LDAP extension is talking to. If true, this will wait and retry if a -601 occurs.
Throws:
PluginException - if there is a problem setting the passworld.

writeAttributeXML

public static void writeAttributeXML(TaskContext context,
                                     java.lang.Object theObj,
                                     java.lang.String attrName,
                                     java.lang.String value)
                              throws eDirAccessServiceException
API for writing values to NSObject or MOOManager thought XML; Used by EDAS.

Parameters:
context - TaskContext of the plug-in
theObj - Object must be NSObject or MOOManager
attrName - String containing the name of attribute to set
value - String containing the attribute value to set
Throws:
eDirAccessServiceException
See Also:
readAttributeXML(com.novell.emframe.dev.TaskContext, java.lang.Object, java.lang.String)


API Documentation Copyright © 1998-2004 Novell, Inc. All rights reserved.
NDS is a registered trademark of Novell, Inc. in the United States and other countries.
Generated September 2 2004 0111.