Class RepositoryUtils

java.lang.Object
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 Details

    • 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 Details

    • 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(org.dom4j.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(org.dom4j.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(org.dom4j.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(org.dom4j.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