DLESE Tools
v1.6.0

org.dlese.dpc.services.dds.toolkit
Class RepositoryUtils

java.lang.Object
  extended by org.dlese.dpc.services.dds.toolkit.RepositoryUtils

public class RepositoryUtils
extends Object

Provides functions that use the DDSServicesToolkit to get information about collections, itemRecords, terms and other data from a DDS repository.

Author:
ostwald, weatherley

Constructor Summary
RepositoryUtils(DDSServicesToolkit ddsServicesToolkit)
          Constructor for the RepositoryUtils object
RepositoryUtils(String baseUrl)
          Constructor for the RepositoryUtils object
 
Method Summary
 String[] checkForErrorResponse(Document doc)
           
protected  CollectionInfo getCollectionInfo(String collection)
          Gets the collectionInfo instance for the specified collection
 List getCollectionInfos()
          Gets the collectionInfos attribute of the RepositoryUtils object
 List getCollectionKeys()
          Returns a List of collection keys (e.g., "dcc") defined in the repository.
protected  int getIntAtPath(Node baseElement, String relativePath)
          Gets the integer value of the node located at relativePath from given baseElement.
 Map getItemRecordMap(CollectionInfo collectionInfo, int startOffset, int numReturns)
          Returns an itemRecordMap for the specified collection, startOffset and batchSize
 Map getItemRecordMap(String collection)
          Gets a mapping of recordIds to itemRecords (as Documents) for the specified collection
 Collection getItemRecords(CollectionInfo collectionInfo, int startOffset, int numReturns)
          Gets a batch of itemRecords
 Collection getItemRecords(String collection)
          Returns the itemRecords of the specified collection as dom4j.Documents
 TermsInfo getTermsInfoForFields(String[] fields)
          Get terms data for one or more fields in a DDS repository index.
 DDSServicesToolkit getToolKit()
           
protected  String getValueAtPath(Node baseElement, String relativePath)
          Gets the textual value of the node located at relativePath from given baseElement.
static void main(String[] args)
          The main program for the RepositoryUtils class
protected  String subElementValue(Element parent, String childTagName)
          Gets the text value of the specified child of a given parent element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryUtils

public RepositoryUtils(String baseUrl)
Constructor for the RepositoryUtils object

Parameters:
baseUrl - DDSWebservice baseUrl (e.g., "http://www.dlese.org/dds/services/ddsws1-1")

RepositoryUtils

public RepositoryUtils(DDSServicesToolkit ddsServicesToolkit)
Constructor for the RepositoryUtils object

Parameters:
ddsServicesToolkit - A DDSServicesToolkit
Method Detail

getToolKit

public DDSServicesToolkit getToolKit()

getItemRecordMap

public Map getItemRecordMap(String collection)
                     throws Exception
Gets a mapping of recordIds to itemRecords (as Documents) for the specified collection

Parameters:
collection - collection key (e.g., "dcc")
Returns:
The itemRecordMap value
Throws:
Exception - if the itemRecordMap cannot be constructed

getItemRecordMap

public Map getItemRecordMap(CollectionInfo collectionInfo,
                            int startOffset,
                            int numReturns)
                     throws Exception
Returns an itemRecordMap for the specified collection, startOffset and batchSize

NOTE: to search over all records,

Parameters:
collectionInfo - NOT YET DOCUMENTED
startOffset - NOT YET DOCUMENTED
numReturns - NOT YET DOCUMENTED
Returns:
The itemRecordMap value
Throws:
Exception - NOT YET DOCUMENTED

checkForErrorResponse

public String[] checkForErrorResponse(Document doc)

getItemRecords

public Collection getItemRecords(String collection)
                          throws Exception
Returns the itemRecords of the specified collection as dom4j.Documents

Parameters:
collection - collection key ("dcc")
Returns:
The itemRecords value
Throws:
Exception - Description of the Exception

getItemRecords

public Collection getItemRecords(CollectionInfo collectionInfo,
                                 int startOffset,
                                 int numReturns)
                          throws Exception
Gets a batch of itemRecords

Parameters:
collectionInfo - NOT YET DOCUMENTED
startOffset - NOT YET DOCUMENTED
numReturns - NOT YET DOCUMENTED
Returns:
The itemRecords value
Throws:
Exception - NOT YET DOCUMENTED

getCollectionKeys

public List getCollectionKeys()
                       throws Exception
Returns a List of collection keys (e.g., "dcc") defined in the repository.

Returns:
The collectionKeys value
Throws:
Exception - NOT YET DOCUMENTED

getCollectionInfos

public List getCollectionInfos()
                        throws Exception
Gets the collectionInfos attribute of the RepositoryUtils object

Returns:
A list of CollectionInfo instances
Throws:
Exception - Description of the Exception

getCollectionInfo

protected CollectionInfo getCollectionInfo(String collection)
                                    throws Exception
Gets the collectionInfo instance for the specified collection

Parameters:
collection - collection key (e.g., "dcc")
Returns:
The collectionInfo value
Throws:
Exception - NOT YET DOCUMENTED

getValueAtPath

protected String getValueAtPath(Node baseElement,
                                String relativePath)
                         throws Exception
Gets the textual value of the node located at relativePath from given baseElement.

Parameters:
baseElement - Description of the Parameter
relativePath - Description of the Parameter
Returns:
The valueAtPath value
Throws:
Exception - if there is no node at relativePath from baseElement

getIntAtPath

protected int getIntAtPath(Node baseElement,
                           String relativePath)
                    throws Exception
Gets the integer value of the node located at relativePath from given baseElement.

Parameters:
baseElement - Description of the Parameter
relativePath - Description of the Parameter
Returns:
The intAtPath value
Throws:
Exception - if there is no node at relativePath from baseElement, or if the value found is not an integer

subElementValue

protected String subElementValue(Element parent,
                                 String childTagName)
Gets the text value of the specified child of a given parent element.

Parameters:
parent - Element whose child element supplies the text
childTagName - tagName of child element
Returns:
textual content of named child element

main

public static void main(String[] args)
                 throws Exception
The main program for the RepositoryUtils class

Parameters:
args - The command line arguments
Throws:
Exception - NOT YET DOCUMENTED

getTermsInfoForFields

public TermsInfo getTermsInfoForFields(String[] fields)
                                throws DDSServiceErrorResponseException,
                                       Exception
Get terms data for one or more fields in a DDS repository index. The request accepts one or more fields to list the terms data for. Note that this request is much less efficient when more than one field is requested.

Parameters:
fields - One or more fields to get terms data for
Returns:
The data about the terms in the given field(s)
Throws:
DDSServiceErrorResponseException - If service error
Exception - If other error

DLESE Tools
v1.6.0