|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.nds.dirxml.job.JobUtil
public abstract class JobUtil
Collection of utility methods to make it easier to write a job.
Nested Class Summary | |
---|---|
static class |
JobUtil.Association
Class representing the association value on an object that corresponds to a given driver. |
static class |
JobUtil.Instance
Class encapsulating the information in an XDS instance element. |
static class |
JobUtil.StructuredValue
Class to report values for structured eDirectory attribute syntaxes. |
Constructor Summary | |
---|---|
JobUtil()
|
Method Summary | |
---|---|
static Element |
constructXdsInputDocument()
Construct an input document. |
static Element |
constructXdsInputDocument(String product,
String productVersion,
String contact)
Construct an input document. |
static Socket |
createKMOSocket(String host,
int port,
String kmoName)
Create a secure (SSL/TLS) client Socket based on Novell's NTLS socket implementation with the
encryption keys and certificate from an eDirectory Key Material Object (KMO). |
static String |
generateEventID(String prefix)
Construct an event-id string based on a prefix, the current time, and an event number. |
static JobUtil.Association[] |
getAssociationsForDriver(DirectoryObject object,
DirectoryObject driver,
JobManager manager)
Get the associations on an eDirectory object that correspond to a driver. |
static JobUtil.Association[] |
getAssociationsForDriver(JobUtil.Instance instance,
DirectoryObject driver)
Get the associations from an Instance that correspond to a driver. |
static String |
getThrowableLongString(Throwable t)
Get a String for a Throwable that has the stack backtrace info. |
static String |
getVersionFromManifest(String className)
Get the "Implementation-Version" string from the jar file manifest. |
static void |
populateCommonEntryAttrs(Element element,
JobUtil.Instance instance)
Populate an element with command XDS entry attributes from an instance. |
static Map |
readAttributes(DirectoryObject entry,
String[] attrNames,
JobManager manager)
Read attribute values from an eDirectory object. |
static JobUtil.Instance |
readEntry(DirectoryObject entry,
String[] attrNames,
JobManager manager)
Read information from an eDirectory entry. |
static JobResult |
resultFromStatusElement(Element statusElement,
JobManager manager)
Allocate and populate a JobResult instance from the data in an XDS status element. |
static JobResult[] |
resultListToArray(List results)
Utility method to convert JobResult instances in a
List into an array. |
static JobResult[] |
resultsFromOutputDocument(Document outputDocument,
JobManager manager)
Return 0 or more JobResult instances based on <status> elements in an XDS
output document. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JobUtil()
Method Detail |
---|
public static JobUtil.Instance readEntry(DirectoryObject entry, String[] attrNames, JobManager manager)
entry
- the eDirectory entry to readattrNames
- attributes whose values should be read. This may be null
, indicating no values should be read, or
it may have a single element of "*"
indicating all attributes values should be read.manager
- query will be via manager.getCommandProcessor()
null
if the entry couldn't be read.public static Map readAttributes(DirectoryObject entry, String[] attrNames, JobManager manager)
String
s.StructuredValue
objects.
entry
- reference to eDir objectattrNames
- array of attribute names (must not be null
or empty,
may have one entry of "*"
meaning read all)manager
- query will be via manager.getCommandProcessor()
public static JobUtil.Association[] getAssociationsForDriver(JobUtil.Instance instance, DirectoryObject driver)
Instance
that correspond to a driver. The instance must have values for
the DirXML-Associations attribute. The returned
Association
instances are abstractions of the association values. In particular, if an association value
has no application key and is not disabled, it is not returned.
instance
- eDirectory object representation obtained from readEntry()
driver
- reference to the DirXML-Driver object.
Association
instances (will not be null
)public static JobUtil.Association[] getAssociationsForDriver(DirectoryObject object, DirectoryObject driver, JobManager manager)
Association
instances are abstractions of the association values. In particular, if an association value
has no application key and is not disabled, it is not returned.
object
- reference to eDirectory object whose association values are to be returneddriver
- reference to the DirXML-Driver
object.manager
- query will be via manager.getCommandProcessor()
null
)public static Element constructXdsInputDocument()
<nds dtd-version="2.0"> <input/> </nds>and the input
Element
is returned.
Element
public static Element constructXdsInputDocument(String product, String productVersion, String contact)
<nds dtd-version="2.0"> <source> <product version="productVersion">product</product> <contact>contact</contact> </source> <input/> </nds>and the input
Element
is returned.
product
- product name (may be null
)productVersion
- product version string (may be null
)contact
- contact information (e.g., a URL string or email address) (may be null
)
Element
public static void populateCommonEntryAttrs(Element element, JobUtil.Instance instance)
element
- XDS element to be populated (e.g., "modify", "add", etc.)instance
- encapsulation of entry datapublic static JobResult resultFromStatusElement(Element statusElement, JobManager manager)
JobResult
instance from the data in an XDS status element.
Status level mapping is as follows:"success" -> JobResult.SUCCESS
"retry" -> JobResult.WARNING
"warning" -> JobResult.WARNING
"error" -> JobResult.ERROR
"error" -> JobResult.ERROR
anything else -> JobResult.ERROR
statusElement
- the status elementmanager
- used to allocate JobResult
instance
public static JobResult[] resultsFromOutputDocument(Document outputDocument, JobManager manager)
JobResult
instances based on <status> elements in an XDS
output document. Uses resultFromStatusElement
to do the heavy lifting.
outputDocument
- XDS output documentmanager
- used to allocated JobResult
instances
null
or an array of JobResult
instancesresultFromStatusElement(org.w3c.dom.Element,com.novell.nds.dirxml.job.JobManager)
public static String generateEventID(String prefix)
generateEventID
requests during the current second
minus 1.
The string is of the form
prefix
- value to prepend to generated event-id value
public static String getVersionFromManifest(String className)
className
- dot-delimited class name of job implementation
"?.?.?.?"
if
the version couldn't be obtained.public static JobResult[] resultListToArray(List results)
JobResult
instances in a
List
into an array.
results
- List
of JobResult
instances
null
if results == null
or
results.size() == 0
, or an array of JobResult
instancespublic static Socket createKMOSocket(String host, int port, String kmoName) throws IOException, UnknownHostException
Socket
based on Novell's NTLS socket implementation with the
encryption keys and certificate from an eDirectory Key Material Object (KMO).
The kmoName
parameter is not a DN; rather it is what is termed the "key pair" name - that part of the
Key Material Object name before the '-' and server name.
host
- host name or IP addressport
- TCP port number on which to connectkmoName
- name of Key Material Object to use for encryption keys
IOException
- if an error occurs establishing the connection
UnknownHostException
public static String getThrowableLongString(Throwable t)
String
for a Throwable
that has the stack backtrace info. This is equivalent to:
StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw, true)); sw.flush(); return sw.toString();
t
- the Throwable
object
t.printStackTrace
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |