Package net.dona.doip.client
Class AbstractDoipClient
java.lang.Object
net.dona.doip.client.AbstractDoipClient
- All Implemented Interfaces:
AutoCloseable
,DoipClientInterface
- Direct Known Subclasses:
DoipClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
create
(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Creates a digital object at a service.create
(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Creates a digital object at a service.void
delete
(String targetId, AuthenticationInfo authInfo) Deletes a digital object.void
delete
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Deletes a digital object from a specified service.void
delete
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Deletes a digital object from a specified service.static DoipException
hello
(String targetId, AuthenticationInfo authInfo) Performs the "hello" operation.hello
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Performs the "hello" operation at a specified service.listOperations
(String targetId, AuthenticationInfo authInfo) Lists operations available for a digital object.listOperations
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Lists operations available for a digital object at a specified service.listOperations
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Lists operations available for a digital object at a specified service.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes) Performs an operation, looking up the target's service information by handle resolution.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input) Performs an operation, looking up the target's service information by handle resolution.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input, ServiceInfo serviceInfo) Performs an operation at a specified service.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, ServiceInfo serviceInfo) Performs an operation at a specified service.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, InDoipMessage input) Performs an operation, looking up the target's service information by handle resolution.performOperation
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, InDoipMessage input, ServiceInfo serviceInfo) Performs an operation at a specified service.performOperation
(DoipRequestHeaders headers, InDoipMessage input) Performs an operation, looking up the target's service information by handle resolution.abstract DoipClientResponse
performOperation
(DoipRequestHeaders headers, InDoipMessage input, ServiceInfo serviceInfo) com.google.gson.JsonElement
performOperationWithJsonResponse
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes) com.google.gson.JsonElement
performOperationWithJsonResponse
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input, ServiceInfo serviceInfo) com.google.gson.JsonElement
performOperationWithJsonResponse
(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, ServiceInfo serviceInfo) retrieve
(String targetId, boolean includeElementData, AuthenticationInfo authInfo) Retrieves a digital object, possibly including all element data.retrieve
(String targetId, boolean includeElementData, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Retrieves a digital object from a specified service, possibly including all element data.retrieve
(String targetId, com.google.gson.JsonObject attributes, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Retrieves a digital object from a specified service, possibly including attributes, like to include all element data or include only features allowed by a filter.retrieve
(String targetId, AuthenticationInfo authInfo) Retrieves a digital object.retrieve
(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Retrieves a digital object from a specified service.retrieveElement
(String targetId, String elementId, AuthenticationInfo authInfo) Retrieves an element from a digital object.retrieveElement
(String targetId, String elementId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Retrieves an element from a digital object at a specified service.retrieveElement
(String targetId, String elementId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Retrieves an element from a digital object at a specified service.retrievePartialElement
(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo) retrievePartialElement
(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Retrieves a byte range of an element from a digital object at a specified service.retrievePartialElement
(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Retrieves a byte range of an element from a digital object at a specified service.search
(String targetId, String query, QueryParams params, AuthenticationInfo authInfo) Search for digital objects, returning the full results as digital objects.search
(String targetId, String query, QueryParams params, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Search for digital objects, returning the full results as digital objects.searchIds
(String targetId, String query, QueryParams params, AuthenticationInfo authInfo) Search for digital objects, returning the ids of the results.searchIds
(String targetId, String query, QueryParams params, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Search for digital objects, returning the ids of the results.update
(DigitalObject dobj, AuthenticationInfo authInfo) Updates a digital object.update
(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo) Updates a digital object at a specified service.update
(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) Updates a digital object at a specified service.
-
Constructor Details
-
AbstractDoipClient
public AbstractDoipClient()
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDoipClientInterface
-
performOperationWithJsonResponse
public com.google.gson.JsonElement performOperationWithJsonResponse(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes) throws DoipException - Specified by:
performOperationWithJsonResponse
in interfaceDoipClientInterface
- Throws:
DoipException
-
performOperationWithJsonResponse
public com.google.gson.JsonElement performOperationWithJsonResponse(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, ServiceInfo serviceInfo) throws DoipException - Specified by:
performOperationWithJsonResponse
in interfaceDoipClientInterface
- Throws:
DoipException
-
performOperationWithJsonResponse
public com.google.gson.JsonElement performOperationWithJsonResponse(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input, ServiceInfo serviceInfo) throws DoipException - Specified by:
performOperationWithJsonResponse
in interfaceDoipClientInterface
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes) throws DoipException Performs an operation, looking up the target's service information by handle resolution. No input (beyond attributes) is provided to the operation.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operation- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input) throws DoipException Performs an operation, looking up the target's service information by handle resolution.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operationinput
- the input to the operation as a JsonElement- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, InDoipMessage input) throws DoipException Performs an operation, looking up the target's service information by handle resolution.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operationinput
- the input to the operation as an InDoipMessage- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, ServiceInfo serviceInfo) throws DoipException Performs an operation at a specified service. No input (beyond attributes) is provided to the operation.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operationserviceInfo
- the service at which to perform the operation- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, com.google.gson.JsonElement input, ServiceInfo serviceInfo) throws DoipException Performs an operation at a specified service.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operationinput
- the input to the operation as a JsonElementserviceInfo
- the service at which to perform the operation- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(String targetId, String operationId, AuthenticationInfo authInfo, com.google.gson.JsonObject attributes, InDoipMessage input, ServiceInfo serviceInfo) throws DoipException Performs an operation at a specified service.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
targetId
- the object on which to perform the operationoperationId
- the operation to performauthInfo
- the authentication to provideattributes
- the attributes to provide to the operationinput
- the input to the operation as an InDoipMessageserviceInfo
- the service at which to perform the operation- Returns:
- the response
- Throws:
DoipException
-
performOperation
public DoipClientResponse performOperation(DoipRequestHeaders headers, InDoipMessage input) throws DoipException Performs an operation, looking up the target's service information by handle resolution.- Specified by:
performOperation
in interfaceDoipClientInterface
- Parameters:
headers
- the content of the initial segment of the requestinput
- the input to the operation as an InDoipMessage- Returns:
- the response
- Throws:
DoipException
-
performOperation
public abstract DoipClientResponse performOperation(DoipRequestHeaders headers, InDoipMessage input, ServiceInfo serviceInfo) throws DoipException - Specified by:
performOperation
in interfaceDoipClientInterface
- Throws:
DoipException
-
create
public DigitalObject create(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Creates a digital object at a service.- Specified by:
create
in interfaceDoipClientInterface
- Parameters:
dobj
- the digital object to createauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the created digital object
- Throws:
DoipException
-
create
public DigitalObject create(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Creates a digital object at a service.- Specified by:
create
in interfaceDoipClientInterface
- Parameters:
dobj
- the digital object to createauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the created digital object
- Throws:
DoipException
-
update
Updates a digital object.- Specified by:
update
in interfaceDoipClientInterface
- Parameters:
dobj
- the digital object to updateauthInfo
- the authentication to provide- Returns:
- the updated digital object
- Throws:
DoipException
-
update
public DigitalObject update(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Updates a digital object at a specified service.- Specified by:
update
in interfaceDoipClientInterface
- Parameters:
dobj
- the digital object to updateauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the updated digital object
- Throws:
DoipException
-
update
public DigitalObject update(DigitalObject dobj, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Updates a digital object at a specified service.- Specified by:
update
in interfaceDoipClientInterface
- Parameters:
dobj
- the digital object to updateauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the updated digital object
- Throws:
DoipException
-
retrieve
Retrieves a digital object.- Specified by:
retrieve
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to retrieveauthInfo
- the authentication to provide- Returns:
- the digital object
- Throws:
DoipException
-
retrieve
public DigitalObject retrieve(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Retrieves a digital object from a specified service.- Specified by:
retrieve
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to retrieveauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the digital object
- Throws:
DoipException
-
retrieve
public DigitalObject retrieve(String targetId, boolean includeElementData, AuthenticationInfo authInfo) throws DoipException Retrieves a digital object, possibly including all element data.- Specified by:
retrieve
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to retrieveincludeElementData
- if true, include data for all elementsauthInfo
- the authentication to provide- Returns:
- the digital object
- Throws:
DoipException
-
retrieve
public DigitalObject retrieve(String targetId, boolean includeElementData, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Retrieves a digital object from a specified service, possibly including all element data.- Specified by:
retrieve
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to retrieveincludeElementData
- if true, include data for all elementsauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the digital object
- Throws:
DoipException
-
retrieve
public DigitalObject retrieve(String targetId, com.google.gson.JsonObject attributes, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Retrieves a digital object from a specified service, possibly including attributes, like to include all element data or include only features allowed by a filter.- Specified by:
retrieve
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to retrieveattributes
- like to include all element data or include only features allowed by a filterauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the digital object
- Throws:
DoipException
-
delete
Deletes a digital object.- Specified by:
delete
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to deleteauthInfo
- the authentication to provide- Throws:
DoipException
-
delete
public void delete(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Deletes a digital object from a specified service.- Specified by:
delete
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to deleteauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Throws:
DoipException
-
delete
public void delete(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Deletes a digital object from a specified service.- Specified by:
delete
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the object to deleteauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Throws:
DoipException
-
listOperations
public List<String> listOperations(String targetId, AuthenticationInfo authInfo) throws DoipException Lists operations available for a digital object.- Specified by:
listOperations
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectauthInfo
- the authentication to provide- Returns:
- the list of available operation ids
- Throws:
DoipException
-
listOperations
public List<String> listOperations(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Lists operations available for a digital object at a specified service.- Specified by:
listOperations
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the list of available operation ids
- Throws:
DoipException
-
listOperations
public List<String> listOperations(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Lists operations available for a digital object at a specified service.- Specified by:
listOperations
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the list of available operation ids
- Throws:
DoipException
-
searchIds
public SearchResults<String> searchIds(String targetId, String query, QueryParams params, AuthenticationInfo authInfo) throws DoipException Search for digital objects, returning the ids of the results.- Specified by:
searchIds
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)query
- the queryparams
- the query parametersauthInfo
- the authentication to provide- Returns:
- the search results as ids
- Throws:
DoipException
-
searchIds
public SearchResults<String> searchIds(String targetId, String query, QueryParams params, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Search for digital objects, returning the ids of the results.- Specified by:
searchIds
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)query
- the queryparams
- the query parametersauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the search results as ids
- Throws:
DoipException
-
search
public SearchResults<DigitalObject> search(String targetId, String query, QueryParams params, AuthenticationInfo authInfo) throws DoipException Search for digital objects, returning the full results as digital objects.- Specified by:
search
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)query
- the queryparams
- the query parametersauthInfo
- the authentication to provide- Returns:
- the search results as digital objects
- Throws:
DoipException
-
search
public SearchResults<DigitalObject> search(String targetId, String query, QueryParams params, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Search for digital objects, returning the full results as digital objects.- Specified by:
search
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)query
- the queryparams
- the query parametersauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the search results as digital objects
- Throws:
DoipException
-
hello
Performs the "hello" operation.- Specified by:
hello
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)authInfo
- the authentication to provide- Returns:
- the result of the hello operation as a service info digital object
- Throws:
DoipException
-
hello
public DigitalObject hello(String targetId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Performs the "hello" operation at a specified service.- Specified by:
hello
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the operation target (generally a DOIP service id)authInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- the result of the hello operation as a service info digital object
- Throws:
DoipException
-
retrieveElement
public InputStream retrieveElement(String targetId, String elementId, AuthenticationInfo authInfo) throws DoipException Retrieves an element from a digital object.- Specified by:
retrieveElement
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectelementId
- the id of the elementauthInfo
- the authentication to provide- Returns:
- an input stream with the bytes of the element
- Throws:
DoipException
-
retrieveElement
public InputStream retrieveElement(String targetId, String elementId, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Retrieves an element from a digital object at a specified service.- Specified by:
retrieveElement
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectelementId
- the id of the elementauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- an input stream with the bytes of the element
- Throws:
DoipException
-
retrieveElement
public InputStream retrieveElement(String targetId, String elementId, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Retrieves an element from a digital object at a specified service.- Specified by:
retrieveElement
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectelementId
- the id of the elementauthInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- an input stream with the bytes of the element
- Throws:
DoipException
-
retrievePartialElement
public InputStream retrievePartialElement(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo) throws DoipException - Specified by:
retrievePartialElement
in interfaceDoipClientInterface
- Throws:
DoipException
-
retrievePartialElement
public InputStream retrievePartialElement(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo, ServiceInfo serviceInfo) throws DoipException Retrieves a byte range of an element from a digital object at a specified service. Either start or end may be null. If neither are null, all bytes from start to end, inclusive, with the first byte of the element being numbered 0, are returned. If both are null, the entire element is returned. If only end is null, all bytes from start to the end of the element are returned. If only start is null, end indicates how many bytes to return from the end of the element. For example, if start is null and end is 500, the last 500 bytes of the element are returned.- Specified by:
retrievePartialElement
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectelementId
- the id of the elementstart
- the start byte of the desired range, or null (indicates that the number of bytes given by end should be retrieved from the end of the element)end
- the end byte of the desired range, or null (indicates the range should extend to the end of the element)authInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- an input stream with the bytes of the element from start to end inclusive
- Throws:
DoipException
-
retrievePartialElement
public InputStream retrievePartialElement(String targetId, String elementId, Long start, Long end, AuthenticationInfo authInfo, ServiceInfo serviceInfo, com.google.gson.JsonObject attributes) throws DoipException Retrieves a byte range of an element from a digital object at a specified service. Either start or end may be null. If neither are null, all bytes from start to end, inclusive, with the first byte of the element being numbered 0, are returned. If both are null, the entire element is returned. If only end is null, all bytes from start to the end of the element are returned. If only start is null, end indicates how many bytes to return from the end of the element. For example, if start is null and end is 500, the last 500 bytes of the element are returned.- Specified by:
retrievePartialElement
in interfaceDoipClientInterface
- Parameters:
targetId
- the id of the digital objectelementId
- the id of the elementstart
- the start byte of the desired range, or null (indicates that the number of bytes given by end should be retrieved from the end of the element)end
- the end byte of the desired range, or null (indicates the range should extend to the end of the element)authInfo
- the authentication to provideserviceInfo
- the service at which to perform the operation- Returns:
- an input stream with the bytes of the element from start to end inclusive
- Throws:
DoipException
-
doipExceptionFromDoipResponse
public static DoipException doipExceptionFromDoipResponse(DoipClientResponse resp) throws IOException - Throws:
IOException
-