Package org.dlese.dpc.ndr.reader
Class NdrObjectReader
java.lang.Object
org.dlese.dpc.ndr.reader.NdrObjectReader
- Direct Known Subclasses:
AgentReader,GroupingObjectReader,MetadataReader
Base Class for reading NDR responses to GET Requests, used primarily to
support NDR Import operations. Extended to read specific types of NDR
Objects, such as Metadata and MetadataProvider.
- Author:
- ostwald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected org.dom4j.Documentprotected Listprotected Stringprotected Stringprotected StringNative data stream format for this objectprotected org.jaxen.SimpleNamespaceContextnsContext to support xpath opsprotected NDRConstants.NDRObjectType -
Constructor Summary
ConstructorsConstructorDescriptionNdrObjectReader(String handle) Constructor for the NdrObjectReader object with ndrHandleNdrObjectReader(String handle, String nativeDataStreamFormat) Constructor for the NdrObjectReader object with ndrHandle and specified nativeDataStreamFormat.NdrObjectReader(org.dom4j.Document response) Constructor for the NdrObjectReader object with a XML Document (for testing purposes)NdrObjectReader(org.dom4j.Document ndrResponse, String nativeDataStreamFormat) Constructor for the NdrObjectReader object -
Method Summary
Modifier and TypeMethodDescriptionorg.dom4j.ElementReturns the NON_NATIVE data stream labeled simply as "nsdl_dc" with no versionGets the fedora-view:createdDate property of the NdrObject as a Date objectGets the fedora-view:createdDate property of the NdrObjectorg.dom4j.ElementgetDataStream(String format) Gets the dataStream of the NdrObjectReader for specified format.org.dom4j.ElementgetDataStream(String format, String version) Gets the dataStream matching the provided formatSpec, or null if requested stream is not present.org.dom4j.DocumentGets the original "get" response for this reader object as a dom4j.Document instance.Returns the data stream formats as a Set.Gets the handle attribute of the NdrObjectReader object.Gets the fedora-view:lastModifiedDate property of the NdrObject as a Date objectGets the fedora-view:lastModifiedDate property of the NdrObject as a stringorg.dom4j.ElementgetNativeDataStream(String format) Gets the native dataStream of the NdrObject for the specified native "format".org.dom4j.ElementgetNativeDataStream(String format, String version) Gets the navite dataStream of the NdrObject for specified format and version.protected org.dom4j.NodeGets a single Node satisfying give XPath.protected ListGet all Nodes satisfying the given xpath.protected StringgetNodeText(String xpath) Return the Text of a Node satisfying the given XPath.protected org.jaxen.SimpleNamespaceContextReturns a namespace context instance, containing namespaces occuring in NDR objects, that is used in xpath operations.Gets the objectType property of the NdrObject.getProperty(String prop) Gets the specified property of the NdrObjectReader object (returning the first if more than one property is present).getPropertyValues(String name) Gets a list of values for the specified propertygetRelationship(String name) Gets the FIRST relationship (there may be more) with specified name, which is assumed to be in "nsdl" namespace if no prefix is present.getRelationshipValues(String name) Gets all the relationships for the specified name.getState()Gets the fedora-model:state property of the NdrObjectprotected org.dom4j.XPathConverts the provided xpath string into an XPath instance using the nsContext (seegetNsContext())protected voidBuilds a map containing entries for each datastream format in this object, but does not populate the values of the map until necessary.protected static voidpp(org.dom4j.Node node) Prints a dom4j.Node as formatted string.static voidsetDebug(boolean bool) Sets the debug attribute of the NdrObjectReader class
-
Field Details
-
doc
protected org.dom4j.Document doc -
dsFormats
-
handle
-
objectType
-
lastModifiedDate
-
createdDate
-
nativeDataStreamFormat
Native data stream format for this object -
nsContext
protected org.jaxen.SimpleNamespaceContext nsContextnsContext to support xpath ops
-
-
Constructor Details
-
NdrObjectReader
Constructor for the NdrObjectReader object with a XML Document (for testing purposes)- Parameters:
response- NOT YET DOCUMENTED- Throws:
Exception- NOT YET DOCUMENTED
-
NdrObjectReader
Constructor for the NdrObjectReader object with ndrHandle- Parameters:
handle- handle of NDR object to read- Throws:
Exception- if object cannot be read from NDR
-
NdrObjectReader
Constructor for the NdrObjectReader object with ndrHandle and specified nativeDataStreamFormat.- Parameters:
handle- handle of NDR object to readnativeDataStreamFormat- native metadata format (helps extract native data_stream)- Throws:
Exception- NOT YET DOCUMENTED
-
NdrObjectReader
public NdrObjectReader(org.dom4j.Document ndrResponse, String nativeDataStreamFormat) throws Exception Constructor for the NdrObjectReader object- Parameters:
ndrResponse- NOT YET DOCUMENTEDnativeDataStreamFormat- NOT YET DOCUMENTED- Throws:
Exception- NOT YET DOCUMENTED
-
-
Method Details
-
getNsContext
protected org.jaxen.SimpleNamespaceContext getNsContext()Returns a namespace context instance, containing namespaces occuring in NDR objects, that is used in xpath operations.- Returns:
- The nsContext value
-
getDocument
public org.dom4j.Document getDocument()Gets the original "get" response for this reader object as a dom4j.Document instance.- Returns:
- The document value
-
getProperty
Gets the specified property of the NdrObjectReader object (returning the first if more than one property is present). If provide prop is not qualified, a namespace prefix of "nsdl" is assumed. If a namespace prefix is provided (e.g., "ncs:status"), it must be contained in the nameSpace Context for this reader.- Parameters:
prop- Description of the Parameter- Returns:
- The property value
-
getPropertyValues
Gets a list of values for the specified property- Parameters:
name- propertyname, qualifed with "nsdl" if no namespace prefix is present.- Returns:
- a list of property values for specified property.
-
getRelationship
Gets the FIRST relationship (there may be more) with specified name, which is assumed to be in "nsdl" namespace if no prefix is present.- Parameters:
name- relationship name ("auth:authorizedToChange")- Returns:
- the relationship value (a ndrHandle)
-
getRelationshipValues
Gets all the relationships for the specified name.- Parameters:
name- Relationship name ("auth:authorizedToChange)- Returns:
- List of relationship values (ndr handles) for provided name
-
getHandle
Gets the handle attribute of the NdrObjectReader object.- Returns:
- The handle value
-
getObjectType
Gets the objectType property of the NdrObject. Can be used as integrity check.- Returns:
- The objectType value
-
getState
Gets the fedora-model:state property of the NdrObject- Returns:
- The state value
-
getLastModifiedDate
Gets the fedora-view:lastModifiedDate property of the NdrObject as a string- Returns:
- The lastModifiedDate value
-
getLastModified
Gets the fedora-view:lastModifiedDate property of the NdrObject as a Date object- Returns:
- The lastModified value
-
getCreatedDate
Gets the fedora-view:createdDate property of the NdrObject- Returns:
- The createdDate value
-
getCreated
Gets the fedora-view:createdDate property of the NdrObject as a Date object- Returns:
- The created value
-
initDataStreams
protected void initDataStreams()Builds a map containing entries for each datastream format in this object, but does not populate the values of the map until necessary.NOTE: datastreams ending in "_info" are ignored and therefore not accessible by "getDataStream"
DataStream elements have format attribute named "format_"+DATA_STREAM_FORMAT"
-
getFormats
Returns the data stream formats as a Set.- Returns:
- The formats value
-
getNativeDataStream
Gets the native dataStream of the NdrObject for the specified native "format".Note: this method cannot return a non-native datastream.
- Parameters:
format- native datastream format (e.g., "oai_dc")- Returns:
- The dataStream value
-
getNativeDataStream
Gets the navite dataStream of the NdrObject for specified format and version. If version is provided, the datastream must exactly match the version.Note: this method cannot return a non-native datastream.
- Parameters:
format- native datastream format (.e.g, "oai_dc")version- version (e.g., "v1.01")- Returns:
- The nativeDataStream value
-
getDataStream
Gets the dataStream of the NdrObjectReader for specified format.- Parameters:
format- datastream format (e.g., "nsdl_dc")- Returns:
- The dataStream value
-
getDataStream
Gets the dataStream matching the provided formatSpec, or null if requested stream is not present. Examples of formatSpec:- "nsdl_dc"
- "native_nsdl_dc", "v1.02"
- "native_msp2"
- Parameters:
format- datastream format (e.g., "nsdl_dc")version- version (e.g., "v1.01")- Returns:
- The dataStream value
-
getCanonicalNsdlDcDataStream
public org.dom4j.Element getCanonicalNsdlDcDataStream()Returns the NON_NATIVE data stream labeled simply as "nsdl_dc" with no version- Returns:
- The canonicalNsdlDcDataStream value
-
getNodes
Get all Nodes satisfying the given xpath.- Parameters:
path- NOT YET DOCUMENTED- Returns:
- a List of all nodes satisfying given XPath, or null if path does not exist.
-
getXPath
Converts the provided xpath string into an XPath instance using the nsContext (seegetNsContext())- Parameters:
path- string representation of an xpath- Returns:
- The xPath value
-
getNode
Gets a single Node satisfying give XPath. If more than one Node is found, the first is returned (and a msg is printed).- Parameters:
xpath- an XPath- Returns:
- a dom4j Node
-
getNodeText
Return the Text of a Node satisfying the given XPath.- Parameters:
xpath- an XPath- Returns:
- Text of Node or empty String if no Node is found
-
setDebug
public static void setDebug(boolean bool) Sets the debug attribute of the NdrObjectReader class- Parameters:
bool- The new debug value
-
pp
protected static void pp(org.dom4j.Node node) Prints a dom4j.Node as formatted string.- Parameters:
node- NOT YET DOCUMENTED
-