public abstract class JobUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
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 and Description |
---|
JobUtil() |
Modifier and Type | Method and Description |
---|---|
static org.w3c.dom.Element |
constructXdsInputDocument()
Construct an input document.
|
static org.w3c.dom.Element |
constructXdsInputDocument(java.lang.String product,
java.lang.String productVersion,
java.lang.String contact)
Construct an input document.
|
static java.net.Socket |
createKMOSocket(java.lang.String host,
int port,
java.lang.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 java.lang.String |
generateEventID(java.lang.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 java.lang.String |
getThrowableLongString(java.lang.Throwable t)
Get a
String for a Throwable that has the stack backtrace info. |
static java.lang.String |
getVersionFromManifest(java.lang.String className)
Get the "Implementation-Version" string from the jar file manifest.
|
static void |
populateCommonEntryAttrs(org.w3c.dom.Element element,
JobUtil.Instance instance)
Populate an element with command XDS entry attributes from an instance.
|
static java.util.Map |
readAttributes(DirectoryObject entry,
java.lang.String[] attrNames,
JobManager manager)
Read attribute values from an eDirectory object.
|
static JobUtil.Instance |
readEntry(DirectoryObject entry,
java.lang.String[] attrNames,
JobManager manager)
Read information from an eDirectory entry.
|
static JobResult |
resultFromStatusElement(org.w3c.dom.Element statusElement,
JobManager manager)
Allocate and populate a
JobResult instance from the data in an XDS status element. |
static JobResult[] |
resultListToArray(java.util.List results)
Utility method to convert
JobResult instances in a
List into an array. |
static JobResult[] |
resultsFromOutputDocument(org.w3c.dom.Document outputDocument,
JobManager manager)
Return 0 or more
JobResult instances based on <status> elements in an XDS
output document. |
public static JobUtil.Instance readEntry(DirectoryObject entry, java.lang.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 java.util.Map readAttributes(DirectoryObject entry, java.lang.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 org.w3c.dom.Element constructXdsInputDocument()
<nds dtd-version="2.0"> <input/> </nds>and the input
Element
is returned.Element
public static org.w3c.dom.Element constructXdsInputDocument(java.lang.String product, java.lang.String productVersion, java.lang.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(org.w3c.dom.Element element, JobUtil.Instance instance)
element
- XDS element to be populated (e.g., "modify", "add", etc.)instance
- encapsulation of entry datapublic static JobResult resultFromStatusElement(org.w3c.dom.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
instancepublic static JobResult[] resultsFromOutputDocument(org.w3c.dom.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
instancesnull
or an array of JobResult
instancesresultFromStatusElement(org.w3c.dom.Element,com.novell.nds.dirxml.job.JobManager)
public static java.lang.String generateEventID(java.lang.String prefix)
generateEventID
requests during the current second
minus 1.
The string is of the form prefix
- value to prepend to generated event-id valuepublic static java.lang.String getVersionFromManifest(java.lang.String className)
className
- dot-delimited class name of job implementation"?.?.?.?"
if
the version couldn't be obtained.public static JobResult[] resultListToArray(java.util.List results)
JobResult
instances in a
List
into an array.results
- List
of JobResult
instancesnull
if results == null
or
results.size() == 0
, or an array of JobResult
instancespublic static java.net.Socket createKMOSocket(java.lang.String host, int port, java.lang.String kmoName) throws java.io.IOException, java.net.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 keysjava.io.IOException
- if an error occurs establishing the connectionjava.net.UnknownHostException
public static java.lang.String getThrowableLongString(java.lang.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
objectt.printStackTrace