public class DDSServicesToolkit
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
SORT_ORDER_ASCENDING
Indicates the optional sort order for search results should be ascending
|
static int |
SORT_ORDER_DESCENDING
Indicates the optional sort order for search results should be descending
|
static int |
SORT_ORDER_NO_SORT
Indicates no sorting should be applied to search results
|
Constructor and Description |
---|
DDSServicesToolkit(java.lang.String ddsServicesUrl,
java.lang.String clientName)
Constructor for the DDSServicesToolkit object
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String[] |
checkForErrorResponseDDSUpdateWS(org.dom4j.Document ddsupdateResponse)
Checks for the existance of an error response from a DDS update service request (DDSUpdateWS).
|
protected java.lang.String[] |
checkForErrorResponseDDSWS(org.dom4j.Document ddswsResponse)
Checks for the existance of an error response from a DDS service request (DDSWS).
|
DDSServicesResponse |
deleteRecord(java.lang.String recordId)
Deletes a record from a DDS repository.
|
protected static java.lang.String |
getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout:
|
java.lang.String |
getIndexVersion()
Gets the index version, which can be useful to determine if a service response cache needs to be updated.
|
DDSServicesResponse |
getRecord(java.lang.String id,
java.lang.String showRelation,
java.lang.String xmlFormat,
java.util.Map additionalRequestParams,
boolean soAllRecords,
boolean localizeXml)
Performs a GetRecord request from a DDSWS repository.
|
boolean |
hasCollection(java.lang.String collectionKey,
java.lang.String xmlFormat)
Determines whether the given collection is in this DDS repository.
|
boolean |
hasRecord(java.lang.String id,
java.lang.String xmlFormat)
Determines whether the given record is in this DDS repository.
|
DDSServicesResponse |
listCollections(boolean localizeXml)
Performs a ListCollections request from a DDSWS repository.
|
DDSServicesResponse |
listFields(boolean localizeXml)
Performs a ListFields request from a DDSWS repository.
|
DDSServicesResponse |
listTerms(java.lang.String[] fields,
boolean localizeXml)
Performs a ListTerms request from a DDSWS repository.
|
DDSServicesResponse |
putCollection(java.lang.String collectionKey,
java.lang.String xmlFormat,
java.lang.String collectionName,
java.lang.String collectionDescription)
Puts a collection into a DDS repository.
|
org.dom4j.Document |
putRecord(java.lang.String recordId,
java.lang.String recordXml,
java.lang.String collectionKey,
java.lang.String xmlFormat)
Puts a record into a DDS repository.
|
DDSServicesResponse |
search(java.lang.String query,
java.lang.String xmlFormat,
int startOffset,
int numReturns,
java.lang.String sortByField,
int sortOrder,
java.lang.String showRelation,
java.util.Map additionalRequestParams,
boolean soAllRecords,
boolean localizeXml)
Performs a Search request from a DDSWS repository.
|
DDSServicesResponse |
serviceInfo(boolean localizeXml)
Performs a ServiceInfo request from a DDSWS repository.
|
static void |
setDebug(boolean db)
Sets the debug attribute of the object
|
public static int SORT_ORDER_ASCENDING
public static int SORT_ORDER_DESCENDING
public static int SORT_ORDER_NO_SORT
public DDSServicesToolkit(java.lang.String ddsServicesUrl, java.lang.String clientName)
ddsServicesUrl
- Common baseUrl for DDS services, for example http://www.dlese.org/dds/services/clientName
- The client name, or null to send nonepublic DDSServicesResponse getRecord(java.lang.String id, java.lang.String showRelation, java.lang.String xmlFormat, java.util.Map additionalRequestParams, boolean soAllRecords, boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
id
- Record IDshowRelation
- The relation data to include in the response for example
isAnnotatedBy, or null for nonexmlFormat
- The XML format to return, or null for native formatadditionalRequestParams
- A Map that contains param/value pairs. Values must be of
type String to indicate a single value, or a String [] to indicate multiple values. Map may be null
for none.soAllRecords
- True to search all records including non-discoverable ones
(client must be authorized by IP)localizeXml
- True to localize the responseDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic boolean hasRecord(java.lang.String id, java.lang.String xmlFormat) throws DDSServiceErrorResponseException, java.lang.Exception
id
- The record idxmlFormat
- The XML format to check availability for, or null for
any/allDDSServiceErrorResponseException
- If service errorjava.lang.Exception
- If other errorpublic DDSServicesResponse search(java.lang.String query, java.lang.String xmlFormat, int startOffset, int numReturns, java.lang.String sortByField, int sortOrder, java.lang.String showRelation, java.util.Map additionalRequestParams, boolean soAllRecords, boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
query
- The search query, or nullxmlFormat
- The xmlFormat for which results must be dissiminated, or
null for any/allstartOffset
- Starting offset in the returnsnumReturns
- Number of records to returnshowRelation
- The relation data to include in the response for example
isAnnotatedBy, or null for noneadditionalRequestParams
- A Map that contains param/value pairs. Values must be of
type String to indicate a single value, or a String [] to indicate multiple values. Map may be null
for none.soAllRecords
- True to search all records including non-discoverable ones
(client must be authorized by IP)localizeXml
- True to localize the responsesortByField
- Indicates the search field to sort the results by, or null
for nonesortOrder
- The sort order to apply (ascending, descending). Ignored if
no sortByField has been indicatedDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic DDSServicesResponse listCollections(boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
localizeXml
- True to localize the response XMLDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic DDSServicesResponse serviceInfo(boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
localizeXml
- True to localize the response XMLDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic java.lang.String getIndexVersion() throws DDSServiceErrorResponseException, java.lang.Exception
DDSServiceErrorResponseException
- If DDSServiceErrorResponseException errorjava.lang.Exception
- If exceptionpublic DDSServicesResponse listFields(boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
localizeXml
- True to localize the response XMLDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic DDSServicesResponse listTerms(java.lang.String[] fields, boolean localizeXml) throws DDSServiceErrorResponseException, java.lang.Exception
fields
- One or more fields to list terms forlocalizeXml
- True to localize the response XMLDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic boolean hasCollection(java.lang.String collectionKey, java.lang.String xmlFormat) throws DDSServiceErrorResponseException, java.lang.Exception
collectionKey
- The collection key, for example 'dcc'xmlFormat
- The xml format for this collection, for example 'adn'DDSServiceErrorResponseException
- If service errorjava.lang.Exception
- If other errorprotected java.lang.String[] checkForErrorResponseDDSWS(org.dom4j.Document ddswsResponse)
ddswsResponse
- The service responsepublic org.dom4j.Document putRecord(java.lang.String recordId, java.lang.String recordXml, java.lang.String collectionKey, java.lang.String xmlFormat) throws DDSServiceErrorResponseException, java.lang.Exception
recordId
- recordIdrecordXml
- recordXmlcollectionKey
- collectionKeyxmlFormat
- xmlFormatjava.lang.Exception
- If errorDDSServiceErrorResponseException
- Standard service error if one was returnedpublic DDSServicesResponse deleteRecord(java.lang.String recordId) throws DDSServiceErrorResponseException, java.lang.Exception
recordId
- recordIdDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occurspublic DDSServicesResponse putCollection(java.lang.String collectionKey, java.lang.String xmlFormat, java.lang.String collectionName, java.lang.String collectionDescription) throws DDSServiceErrorResponseException, java.lang.Exception
collectionKey
- The collection key, for example 'dcc'xmlFormat
- The xml format, for example 'adn'collectionName
- The name of the collectioncollectionDescription
- Description of the collectionDDSServiceErrorResponseException
- Standard service error if one was returnedjava.lang.Exception
- If other error occursprotected java.lang.String[] checkForErrorResponseDDSUpdateWS(org.dom4j.Document ddsupdateResponse)
ddsupdateResponse
- The DDS responseprotected static final java.lang.String getDateStamp()
public static void setDebug(boolean db)
db
- The new debug value