org.oclc.da.gdfr.registryprototype.pvt.dbxml
Class DBXMLCollectionHelper

java.lang.Object
  extended by org.oclc.da.gdfr.registryprototype.pvt.dbxml.DBXMLCollectionHelper

public class DBXMLCollectionHelper
extends java.lang.Object


Constructor Summary
DBXMLCollectionHelper()
          Default Constructor Instantiates XPathEvaluator and JarHelper objects
 
Method Summary
 boolean addAllIndexesToProfile(StructuredDataObject original)
          Parses a template for the given Collection and creates indexes (name/xpath/type) for each element.
 void addAttrToProps(java.util.Properties p, java.lang.String name, java.lang.String path)
          Adds the given name/path pair to the given Properties object.
 boolean checkIndexes(StructuredDataObject orig)
          Checks to make sure a profile contains the indexes "cql.any" and "srw.serverChoice"
 java.util.Properties combineProps(java.util.Properties p1, java.util.Properties p2)
          Merge two Properties Objects, removing duplicate entries
 java.util.Properties createCollectionProperties(StructuredDataObject profile)
          Generates a Properties object containing all the XPath statements necessary for the Collection.
 java.lang.String createDate()
          Returns an ISO formated date string of the current time This was taken from the following website: http://www.dpawson.co.uk/relaxng/schema/datetime.html#d674e136
 java.lang.String encodeIdentifier(java.lang.String id)
          URL encodes the given resourceID's item label.
 Query encodeItemLabel(Query query)
           
 java.lang.String encodeLabel(java.lang.String query, java.lang.String index)
           
 java.lang.String formNameFromPath(java.lang.String path)
          Forms and attribute name from a given XPath.
 java.lang.String getAttrAsText(StructuredDataObject obj, java.lang.String attr)
          Makes a call to getAttr(attr) on the provide BasicStructuredObject and returns the text of the result
 java.lang.String getFileAsString(java.lang.String location)
          Reads a file from Classpath and returns contents as a String
 java.lang.String getIndexPath(java.lang.String index)
          Return the path of an index
 java.util.Properties getIndexProps(StructuredDataObject profile)
          Create Properties containing index names/xPath pairs
 java.lang.String getIndexType(java.lang.String index)
          Return the type of an index
 java.lang.String getNamespacePrefix(java.lang.String name)
          Removes a namespace prefix from the given element name
 java.lang.String getNodeName(java.lang.String xml)
          Returns a node name from a given XML element
 java.lang.String getURIAsString(java.lang.String location)
          Reads a URI and returns the contents as a String
 java.lang.String inputStreamToString(java.io.InputStream stream)
          Converts and InputStream to a String
 boolean isComparableType(java.lang.String type)
          Determines if the given type is comparable with one of the following operators: {=, >, <, <=, >=, <>}
 boolean isImported(CollectionItem item)
          Determines if a CollectionItem has been harvested/imported
 java.lang.String stripTags(java.lang.String element)
          Strips XML tags off an XML element
 java.lang.String stripTextFromPath(java.lang.String path)
          Removes /text() from the end of an XPath expression
 CollectionItem updateSAMLVersion(CollectionItem item)
          Incoming IWSADeposit records that are updated via the UI contain a SAML Assertion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBXMLCollectionHelper

public DBXMLCollectionHelper()
Default Constructor Instantiates XPathEvaluator and JarHelper objects

Method Detail

addAllIndexesToProfile

public boolean addAllIndexesToProfile(StructuredDataObject original)
                               throws RegistryException
Parses a template for the given Collection and creates indexes (name/xpath/type) for each element. The indexes are then added to the profile passed as the parameter.

Parameters:
original - Collection Profile to add indexes to
Returns:
boolean true if successful
Throws:
RegistryException

addAttrToProps

public void addAttrToProps(java.util.Properties p,
                           java.lang.String name,
                           java.lang.String path)
Adds the given name/path pair to the given Properties object. If the name does not exist, it is added as given. If the name does exist, then the old and new name are refactored. Parent element names are added to both names until each have a unique name.

Parameters:
p -
name -
path -

checkIndexes

public boolean checkIndexes(StructuredDataObject orig)
                     throws RegistryException
Checks to make sure a profile contains the indexes "cql.any" and "srw.serverChoice"

Parameters:
orig - The profile to examine
Returns:
The same profile with correct indexes
Throws:
RegistryException

combineProps

public java.util.Properties combineProps(java.util.Properties p1,
                                         java.util.Properties p2)
Merge two Properties Objects, removing duplicate entries

Parameters:
p1 - First Properties
p2 - Second Properties
Returns:
Properties representing a merge of p1, p2 without duplicates

createCollectionProperties

public java.util.Properties createCollectionProperties(StructuredDataObject profile)
                                                throws RegistryException
Generates a Properties object containing all the XPath statements necessary for the Collection. The object is expected to conform to the profile schema

Parameters:
profile - The profile of the Collection
Returns:
Properties object
Throws:
RegistryException

createDate

public java.lang.String createDate()
Returns an ISO formated date string of the current time This was taken from the following website: http://www.dpawson.co.uk/relaxng/schema/datetime.html#d674e136


encodeIdentifier

public java.lang.String encodeIdentifier(java.lang.String id)
URL encodes the given resourceID's item label.

Parameters:
id -
Returns:

encodeItemLabel

public Query encodeItemLabel(Query query)

encodeLabel

public java.lang.String encodeLabel(java.lang.String query,
                                    java.lang.String index)

formNameFromPath

public java.lang.String formNameFromPath(java.lang.String path)
Forms and attribute name from a given XPath. The convention is to only use the deepest element name. If this name gives collisions, it is resolved by prepending parent element names until a unique string is found. Element names are separated by '_'.

Parameters:
path - String representing an XPath
Returns:
String representing the index name for the XPath

getIndexPath

public java.lang.String getIndexPath(java.lang.String index)
Return the path of an index

Parameters:
index - String of the form INDEX_SEPARATOR
Returns:
The path of the index

getIndexType

public java.lang.String getIndexType(java.lang.String index)
Return the type of an index

Parameters:
index - String of the form ::
Returns:
The type of the index

getIndexProps

public java.util.Properties getIndexProps(StructuredDataObject profile)
                                   throws RegistryException
Create Properties containing index names/xPath pairs

Parameters:
profile - The profile to get indexes from
Returns:
Properties object containing names/xPath pairs
Throws:
RegistryException

getFileAsString

public java.lang.String getFileAsString(java.lang.String location)
Reads a file from Classpath and returns contents as a String

Parameters:
location - The path to the file on the Classpath
Returns:
String representing the contents of the file

getNodeName

public java.lang.String getNodeName(java.lang.String xml)
Returns a node name from a given XML element

Parameters:
node -
Returns:

getNamespacePrefix

public java.lang.String getNamespacePrefix(java.lang.String name)
Removes a namespace prefix from the given element name

Parameters:
name -
Returns:

getURIAsString

public java.lang.String getURIAsString(java.lang.String location)
Reads a URI and returns the contents as a String

Parameters:
location - The URI to read
Returns:
String representing URI's contents

inputStreamToString

public java.lang.String inputStreamToString(java.io.InputStream stream)
Converts and InputStream to a String

Parameters:
stream -
Returns:

isImported

public boolean isImported(CollectionItem item)
Determines if a CollectionItem has been harvested/imported

Parameters:
item -
Returns:

isComparableType

public boolean isComparableType(java.lang.String type)
Determines if the given type is comparable with one of the following operators: {=, >, <, <=, >=, <>}

Parameters:
type - The type to examine
Returns:
True if the type can be compared by all of the above operators, false otherwise

getAttrAsText

public java.lang.String getAttrAsText(StructuredDataObject obj,
                                      java.lang.String attr)
Makes a call to getAttr(attr) on the provide BasicStructuredObject and returns the text of the result

Parameters:
obj - Object to get from
attr - Attribute name to get
Returns:
String representing the attribute without tags

stripTextFromPath

public java.lang.String stripTextFromPath(java.lang.String path)
Removes /text() from the end of an XPath expression

Parameters:
path -
Returns:

stripTags

public java.lang.String stripTags(java.lang.String element)
Strips XML tags off an XML element

Parameters:
element - XML element with opening/closing tags
Returns:
String element without the tags

updateSAMLVersion

public CollectionItem updateSAMLVersion(CollectionItem item)
Incoming IWSADeposit records that are updated via the UI contain a SAML Assertion. Since the currentDateTime() function is not supported in Xalan (Xpath processor used), we have to do token substition

Parameters:
item -
Returns:


Copyright © 2008 OCLC Online Computer Library Center, Inc.. All Rights Reserved.