au.csiro.pidclient
Class AndsPidClient

java.lang.Object
  extended by au.csiro.pidclient.AndsPidClient

public class AndsPidClient
extends Object

This is the main interface to the ANDS PID Client library. It allows the caller to interact with the Persistent IDentifier Service provided by the Australian National Data Service. You will need to register with ANDS to be able to use the service.

Usage:

Create a new instance of the class using either the empty constructor and then calling the four setters, or using the constructors. This should be compatible with use as a singleton bean in Spring or other DI (dependency injection) frameworks. Example:

You can then mint new handles using the mintHandle method, and manage the properties associated with the handle addValue, modifyValueByIndex and deleteValueByIndex methods. Note that these methods return the raw XML response as a string. You can also use the FormattedResponse versions to get back an interpreted result as a standard Java bean.

Copyright 2010, CSIRO Australia All rights reserved.

Version:
$Revision: 7131 $ $Date: 2010-06-09 14:25:15 +1000 (Wed, 09 Jun 2010) $
Author:
Robert Bridle on 05/02/2010

Nested Class Summary
static class AndsPidClient.HandleType
          The possible types of properties that can be associated with a handle.
 
Constructor Summary
AndsPidClient()
          Default constructor.
AndsPidClient(String pidServiceHost, int pidServicePort, String pidServicePath, AndsPidIdentity requestorIdentity)
           
AndsPidClient(String pidServiceHost, int pidServicePort, String pidServicePath, String appId, String identifier, String authDomain)
           
 
Method Summary
 String addValue(String handle, AndsPidClient.HandleType type, String value)
          Adds a value to an existing handle.
 String addValueByIndex(String handle, int index, AndsPidClient.HandleType type, String value)
          Adds a value to a particular index of an existing handle.
 AndsPidResponse addValueByIndexFormattedResponse(String handle, int index, AndsPidClient.HandleType type, String value)
          Adds a value to a particular index of an existing handle.
 AndsPidResponse addValueFormattedResponse(String handle, AndsPidClient.HandleType type, String value)
          Adds a value to an existing handle.
 String deleteValueByIndex(String handle, int index)
          Deletes a value associated with an existing handle.
 AndsPidResponse deleteValueByIndexFormattedResponse(String handle, int index)
          Deletes a value associated with an existing handle.
 String getHandle(String handle)
          Retrieves the values associated with a given handle.
 AndsPidResponse getHandleFormattedResponse(String handle)
          Retrieves the values associated with a given handle.
 String getPidServiceHost()
          Retrieve the current ANDS Persistent Identifier host name
 String getPidServicePath()
          Retrieve the current ANDS Persistent Identifier path name (web application context name)
 int getPidServicePort()
          Retrieve the ANDS Persistent Identifier port number
 AndsPidIdentity getRequestorIdentity()
          Retrieve the identity information of the calling application/organisation.
 String listHandles()
          List the handles owned by the caller of the ANDS PID service.
 AndsPidResponse listHandlesFormattedResponse()
          List the handles owned by the caller of the ANDS PID service.
 String mintHandle(AndsPidClient.HandleType type, int index, String value)
          Responsible for the creation of a handle with a value at a specific index.
 String mintHandle(AndsPidClient.HandleType type, String value)
          Responsible for the creation of a handle.
 AndsPidResponse mintHandleFormattedResponse(AndsPidClient.HandleType type, int index, String value)
          Responsible for the creation of a handle with a value at a specific index.
 AndsPidResponse mintHandleFormattedResponse(AndsPidClient.HandleType type, String value)
          Responsible for the creation of a handle.
 String modifyValueByIndex(String handle, int index, String newValue)
          Changes a value associated with an existing handle.
 AndsPidResponse modifyValueByIndexFormattedResponse(String handle, int index, String newValue)
          Changes a value associated with an existing handle.
 void setPidServiceHost(String pidServiceHost)
          Set the ANDS Persistent Identifier host name.
 void setPidServicePath(String pidServicePath)
          Set the current ANDS Persistent Identifier path name (web application context name)
 void setPidServicePort(int pidServicePort)
          Set the ANDS Persistent Identifier port number
 void setRequestorIdentity(AndsPidIdentity requestorIdentity)
          Set the identity information of the calling application/organisation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndsPidClient

public AndsPidClient()
Default constructor. You will still need to supply the configuration data via the public setters.


AndsPidClient

public AndsPidClient(String pidServiceHost,
                     int pidServicePort,
                     String pidServicePath,
                     String appId,
                     String identifier,
                     String authDomain)
Parameters:
pidServiceHost - the ANDS Persistent Identifier host name.
pidServicePort - the ANDS Persistent Identifier port number.
pidServicePath - the ANDS Persistent Identifier path name (web application context name).
appId - the unique Id provided to the caller upon IP registration with the ANDS Persistent Identifier service.
identifier - the identifier or name of the repository calling the service.
authDomain - the domain of the organisation calling the service.

AndsPidClient

public AndsPidClient(String pidServiceHost,
                     int pidServicePort,
                     String pidServicePath,
                     AndsPidIdentity requestorIdentity)
Parameters:
pidServiceHost - the ANDS Persistent Identifier host name.
pidServicePort - the ANDS Persistent Identifier port number.
pidServicePath - the ANDS Persistent Identifier path name (web application context name).
requestorIdentity - represents the identity information of the caller AndsPidIdentity.
Method Detail

mintHandle

public String mintHandle(AndsPidClient.HandleType type,
                         String value)
                  throws IllegalStateException,
                         IllegalArgumentException,
                         org.apache.commons.httpclient.HttpException,
                         IOException
Responsible for the creation of a handle.

If the type and value arguments are both empty, a handle with no values is created. The handle is assigned to an owner, specified by the AndsPidIdentity.getAppId() value. If the owner is not known to the handle system, an owner is created from the AndsPidIdentity.getIdentifier() and AndsPidIdentity.getIdentifier() values.

Parameters:
type - the type AndsPidClient.HandleType of value which will be associated with the newly minted handle.
value - the value which will be associated with the newly minted handle.
Returns:
a formatted XML response that contains a handle, the handle is associated with the value argument.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
IOException - thrown when attempting to read response.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.

mintHandleFormattedResponse

public AndsPidResponse mintHandleFormattedResponse(AndsPidClient.HandleType type,
                                                   String value)
                                            throws IllegalStateException,
                                                   IllegalArgumentException,
                                                   org.apache.commons.httpclient.HttpException,
                                                   IOException,
                                                   XPathExpressionException,
                                                   ParserConfigurationException,
                                                   SAXException
Responsible for the creation of a handle.

If the type and value arguments are both empty, a handle with no values is created. The handle is assigned to an owner, specified by the AndsPidIdentity.getAppId() value. If the owner is not known to the handle system, an owner is created from the AndsPidIdentity.getIdentifier() and AndsPidIdentity.getIdentifier() values.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
type - the type AndsPidClient.HandleType of value which will be associated with the newly minted handle.
value - the value which will be associated with the newly minted handle.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

mintHandle

public String mintHandle(AndsPidClient.HandleType type,
                         int index,
                         String value)
                  throws IllegalStateException,
                         IllegalArgumentException,
                         org.apache.commons.httpclient.HttpException,
                         IOException
Responsible for the creation of a handle with a value at a specific index.

If the type and value arguments are both empty, a handle with no values is created. The handle is assigned to an owner, specified by the AndsPidIdentity.getAppId() value. If the owner is not known to the handle system, an owner is created from the AndsPidIdentity.getIdentifier() and AndsPidIdentity.getIdentifier() values.

Parameters:
type - the type AndsPidClient.HandleType of value which will be associated with the newly minted handle.
index - the index of the value which will be associated with the newly minted handle.
value - the value which will be associated with the newly minted handle.
Returns:
a formatted XML response that contains a handle, the handle is associated with the value argument.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
IOException - thrown when attempting to read response.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.

mintHandleFormattedResponse

public AndsPidResponse mintHandleFormattedResponse(AndsPidClient.HandleType type,
                                                   int index,
                                                   String value)
                                            throws IllegalStateException,
                                                   IllegalArgumentException,
                                                   org.apache.commons.httpclient.HttpException,
                                                   IOException,
                                                   XPathExpressionException,
                                                   ParserConfigurationException,
                                                   SAXException
Responsible for the creation of a handle with a value at a specific index.

If the type and value arguments are both empty, a handle with no values is created. The handle is assigned to an owner, specified by the AndsPidIdentity.getAppId() value. If the owner is not known to the handle system, an owner is created from the AndsPidIdentity.getIdentifier() and AndsPidIdentity.getIdentifier() values.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
type - the type AndsPidClient.HandleType of value which will be associated with the newly minted handle.
index - the index of the value which will be associated with the newly minted handle.
value - the value which will be associated with the newly minted handle.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

addValue

public String addValue(String handle,
                       AndsPidClient.HandleType type,
                       String value)
                throws IllegalStateException,
                       IllegalArgumentException,
                       org.apache.commons.httpclient.HttpException,
                       IOException
Adds a value to an existing handle.

Only the owner of the handle is able to add a value to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be added.

Parameters:
handle - the handle to which a new value is to be associated.
type - the type of the value to be added to the handle, must be either AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC.
value - the value to be added to the handle.
Returns:
a formatted XML response that contains the details of the updated handle.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
IOException - thrown when attempting to read response.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.

addValueFormattedResponse

public AndsPidResponse addValueFormattedResponse(String handle,
                                                 AndsPidClient.HandleType type,
                                                 String value)
                                          throws IllegalStateException,
                                                 IllegalArgumentException,
                                                 org.apache.commons.httpclient.HttpException,
                                                 IOException,
                                                 XPathExpressionException,
                                                 ParserConfigurationException,
                                                 SAXException
Adds a value to an existing handle.

Only the owner of the handle is able to add a value to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be added.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
handle - the handle to which a new value is to be associated.
type - the type of the value to be added to the handle, must be either AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC.
value - the value to be minted.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

addValueByIndex

public String addValueByIndex(String handle,
                              int index,
                              AndsPidClient.HandleType type,
                              String value)
                       throws IllegalStateException,
                              IllegalArgumentException,
                              org.apache.commons.httpclient.HttpException,
                              IOException
Adds a value to a particular index of an existing handle.

Only the owner of the handle is able to add a value to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be added.

Parameters:
handle - the handle to which a new value is to be associated.
index - the index in which to add the value.
type - the type of the value to be added to the handle, must be either AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC.
value - the value to be added to the handle.
Returns:
a formatted XML response that contains the details of the updated handle.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
IOException - thrown when attempting to read response.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.

addValueByIndexFormattedResponse

public AndsPidResponse addValueByIndexFormattedResponse(String handle,
                                                        int index,
                                                        AndsPidClient.HandleType type,
                                                        String value)
                                                 throws IllegalStateException,
                                                        IllegalArgumentException,
                                                        org.apache.commons.httpclient.HttpException,
                                                        IOException,
                                                        XPathExpressionException,
                                                        ParserConfigurationException,
                                                        SAXException
Adds a value to a particular index of an existing handle.

Only the owner of the handle is able to add a value to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be added.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
handle - the handle to which a new value is to be associated.
index - the index in which to add the value.
type - the type of the value to be added to the handle, must be either AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC.
value - the value to be minted.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

modifyValueByIndex

public String modifyValueByIndex(String handle,
                                 int index,
                                 String newValue)
                          throws IllegalStateException,
                                 IllegalArgumentException,
                                 org.apache.commons.httpclient.HttpException,
                                 IOException
Changes a value associated with an existing handle.

Only the owner of the handle is able to modify a value associated with the handle and only values with the type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be modified.

Parameters:
handle - the handle that is to have one of its values modified.
index - the index of the value to modify.
newValue - the new value.
Returns:
a formatted XML response that contains the details of the updated handle.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.

modifyValueByIndexFormattedResponse

public AndsPidResponse modifyValueByIndexFormattedResponse(String handle,
                                                           int index,
                                                           String newValue)
                                                    throws IllegalStateException,
                                                           IllegalArgumentException,
                                                           org.apache.commons.httpclient.HttpException,
                                                           IOException,
                                                           XPathExpressionException,
                                                           ParserConfigurationException,
                                                           SAXException
Changes a value associated with an existing handle.

Only the owner of the handle is able to modify a value associated with the handle and only values with the type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be modified.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
handle - the handle that is to have one of its values modified.
index - the index of the value to modify.
newValue - the new value.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

deleteValueByIndex

public String deleteValueByIndex(String handle,
                                 int index)
                          throws IllegalStateException,
                                 IllegalArgumentException,
                                 org.apache.commons.httpclient.HttpException,
                                 IOException
Deletes a value associated with an existing handle.

Only the owner of the handle is able to delete a value associated to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be deleted.

Parameters:
handle - the handle that is to have one of its values deleted.
index - the index of the value to be deleted.
Returns:
a formatted XML response that contains the details of the updated handle.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.

deleteValueByIndexFormattedResponse

public AndsPidResponse deleteValueByIndexFormattedResponse(String handle,
                                                           int index)
                                                    throws IllegalStateException,
                                                           IllegalArgumentException,
                                                           org.apache.commons.httpclient.HttpException,
                                                           IOException,
                                                           XPathExpressionException,
                                                           ParserConfigurationException,
                                                           SAXException
Deletes a value associated with an existing handle. Only values with the type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be deleted.

Only the owner of the handle is able to delete a value associated to the handle and only values of type AndsPidClient.HandleType.URL or AndsPidClient.HandleType.DESC can be deleted.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
handle - the handle that is to have one of its indexes deleted.
index - the index to be deleted.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

listHandles

public String listHandles()
                   throws IllegalStateException,
                          org.apache.commons.httpclient.HttpException,
                          IOException
List the handles owned by the caller of the ANDS PID service.

This service is intended for listing a small number of handles in a GUI environment, therefore its response is limited in the number of handles returned.

Returns:
a formatted XML response that contains the details of the handles owned by the caller.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.

listHandlesFormattedResponse

public AndsPidResponse listHandlesFormattedResponse()
                                             throws IllegalStateException,
                                                    org.apache.commons.httpclient.HttpException,
                                                    IOException,
                                                    XPathExpressionException,
                                                    ParserConfigurationException,
                                                    SAXException
List the handles owned by the caller of the ANDS PID service.

This service is intended for listing a small number of handles in a GUI environment, therefore its response is limited in the number of handles returned.

The XML response is parsed and returned by the object AndsPidResponse.

Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

getHandle

public String getHandle(String handle)
                 throws IllegalStateException,
                        IllegalArgumentException,
                        org.apache.commons.httpclient.HttpException,
                        IOException
Retrieves the values associated with a given handle.

Parameters:
handle - the handle whose details are to be retrieved.
Returns:
a formatted XML response that contains the details of the handle.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.

getHandleFormattedResponse

public AndsPidResponse getHandleFormattedResponse(String handle)
                                           throws IllegalStateException,
                                                  IllegalArgumentException,
                                                  org.apache.commons.httpclient.HttpException,
                                                  IOException,
                                                  XPathExpressionException,
                                                  ParserConfigurationException,
                                                  SAXException
Retrieves the values associated with a given handle.

The XML response is parsed and returned by the object AndsPidResponse.

Parameters:
handle - the handle whose details are to be retrieved.
Returns:
the ANDS Persistent Identifier service response represented by the object AndsPidResponse.
Throws:
IllegalStateException - thrown if the parameters need to call the ANDS PID service have not been provided.
IllegalArgumentException - thrown when method is called with invalid arguments.
org.apache.commons.httpclient.HttpException - thrown when attempting to execute method call.
IOException - thrown when attempting to read response.
XPathExpressionException - thrown when attempting to execute XPath on XML response.
ParserConfigurationException - thrown when attempting to convert response to an XML document.
SAXException - thrown when attempting to convert response to an XML document.

getPidServiceHost

public String getPidServiceHost()
Retrieve the current ANDS Persistent Identifier host name

Returns:
the ANDS Persistent Identifier host name

setPidServiceHost

public void setPidServiceHost(String pidServiceHost)
Set the ANDS Persistent Identifier host name.

Parameters:
pidServiceHost - the ANDS Persistent Identifier host name to set

getPidServicePort

public int getPidServicePort()
Retrieve the ANDS Persistent Identifier port number

Returns:
the ANDS Persistent Identifier port number

setPidServicePort

public void setPidServicePort(int pidServicePort)
Set the ANDS Persistent Identifier port number

Parameters:
pidServicePort - the ANDS Persistent Identifier port number to set

getPidServicePath

public String getPidServicePath()
Retrieve the current ANDS Persistent Identifier path name (web application context name)

Returns:
the ANDS Persistent Identifier path name

setPidServicePath

public void setPidServicePath(String pidServicePath)
Set the current ANDS Persistent Identifier path name (web application context name)

Parameters:
pidServicePath - the ANDS Persistent Identifier path name to set

getRequestorIdentity

public AndsPidIdentity getRequestorIdentity()
Retrieve the identity information of the calling application/organisation.

Returns:
the identity of the caller

setRequestorIdentity

public void setRequestorIdentity(AndsPidIdentity requestorIdentity)
Set the identity information of the calling application/organisation.

Parameters:
requestorIdentity - the identity object to set


Copyright © 2010. All Rights Reserved.