public interface PassClient
| Modifier and Type | Method and Description |
|---|---|
<T extends PassEntity> |
createAndReadResource(T modelObj,
Class<T> modelClass)
Takes any
PassEntity and persists it in the database, and returns an updated version of the resource if
successful or appropriate exception if not. |
URI |
createResource(PassEntity modelObj)
Takes any
PassEntity and persists it in the database, returns the URI if successful
or appropriate exception if not. |
void |
deleteResource(URI uri)
Deletes the entity matching the URI provided
|
<T extends PassEntity> |
findAllByAttribute(Class<T> modelClass,
String attribute,
Object value)
Retrieves URIs for MULTIPLE MATCHING RECORDS by matching the entity type and filtering by the field
specified using the value provided.
|
<T extends PassEntity> |
findAllByAttribute(Class<T> modelClass,
String attribute,
Object value,
int limit,
int offset)
Retrieves URIs for MULTIPLE MATCHING RECORDS by matching the entity type and filtering by the field
specified using the value provided.
|
<T extends PassEntity> |
findAllByAttributes(Class<T> modelClass,
Map<String,Object> attributeValuesMap)
Retrieves URIs for MULTIPLE MATCHING RECORDS by matching the entity type and filtering by the attributes
and values specified.
|
<T extends PassEntity> |
findAllByAttributes(Class<T> modelClass,
Map<String,Object> attributeValuesMap,
int limit,
int offset)
Retrieves URIs for MULTIPLE MATCHING RECORDS by matching the entity type and filtering by the attributes
and values specified.
|
<T extends PassEntity> |
findByAttribute(Class<T> modelClass,
String attribute,
Object value)
Retrieves URI for a SINGLE RECORD by matching the entity type and filtering by the field
specified using the value provided.
|
Map<String,Collection<URI>> |
getIncoming(URI passEntity)
Retrieve inbound links to the repository resource identified by
PassEntity. |
default <T extends PassEntity> |
processAllEntities(Consumer<URI> processor)
Visit all PASS entities
|
<T extends PassEntity> |
processAllEntities(Consumer<URI> processor,
Class<T> modelClass)
Visit all PASS entities in the repository of a given class.
|
<T extends PassEntity> |
readResource(URI uri,
Class<T> modelClass)
Retrieves the entity matching the URI provided, populates the appropriate Java class with its values.
|
<T extends PassEntity> |
updateAndReadResource(T modelObj,
Class<T> modelClass)
Takes any
PassEntity, and updates the record matching the ID field. |
void |
updateResource(PassEntity modelObj)
Takes any
PassEntity, and updates the record matching the ID field. |
URI |
upload(URI entityUri,
InputStream content)
POSTs the content to entityUri. |
URI |
upload(URI entityUri,
InputStream content,
Map<String,?> params)
POSTs the supplied content to the supplied entityUri. |
URI createResource(PassEntity modelObj)
PassEntity and persists it in the database, returns the URI if successful
or appropriate exception if not. Note that PassEntities that are being created should
have null as their ID, the URI will the the ID field when reading the resource backmodelObj - The entity to be created<T extends PassEntity> T createAndReadResource(T modelObj, Class<T> modelClass)
PassEntity and persists it in the database, and returns an updated version of the resource if
successful or appropriate exception if not. Note that PassEntities that are being created should
have null as their ID; the URI will be present on the returned object.T - PASS entity typemodelObj - the object to be created.modelClass - The class of PASS entity.void updateResource(PassEntity modelObj)
PassEntity, and updates the record matching the ID field.
Note that if you attempt to update an object that was updated between the readResource and the
updateResource, a runtime exception will be thrown. This comparison is based on
the value in PassEntity.versionTag. Setting versionTag to null will ignore conflicts and do the update.modelObj - The object to be updated<T extends PassEntity> T updateAndReadResource(T modelObj, Class<T> modelClass)
PassEntity, and updates the record matching the ID field.
Note that if you attempt to update an object that was updated between the readResource and the
updateResource, a runtime exception will be thrown. This comparison is based on
the value in PassEntity.versionTag. Setting versionTag to null will ignore conflicts and do the update.T - PASS entity typemodelObj - The entity to be updatedmodelClass - The class of the PASS entity.void deleteResource(URI uri)
uri - the URI of the resource to be deleted.<T extends PassEntity> T readResource(URI uri, Class<T> modelClass)
T - PASS entity typeuri - The URI of the resource to be read.modelClass - The class of PASS entity.<T extends PassEntity> URI findByAttribute(Class<T> modelClass, String attribute, Object value)
Grant using the awardNumber:
For example, to find the Grant using the awardNumber:
String awardNum = "abcdef123";
URI grantId = findByAttribute(Grant.class, "awardNumber", awardNum);
If >1 records are found, a RuntimeException will be thrown. If no records are found it will return null.
The value parameter will be converted to a String for the purpose of searching the index. The value parameter cannot be a Collection. Where the attribute is a multi-valued field, only one value from that field should be provided. For example, if searching on Submission.repositories, a single repository URI should be provided for matching
T - PASS entity typemodelClass - The PASS entity class.attribute - JSON attribute name.value - value of the attribute.<T extends PassEntity> Set<URI> findAllByAttribute(Class<T> modelClass, String attribute, Object value)
For example, to find Deposits using a Repository.id:
URI repositoryId = new URI("https://example.com/fedora/repositories/3");
Set<URI> entityUris = findByAttribute(Deposit.class, "repository", repositoryId);
By default this will return a maximum of 200 matching records, unless the pass.elasticsearch.limit environment variable is set. If there are no matches, it will return an empty list.
The value parameter will be converted to a String for the purpose of searching the index. The value parameter cannot be a Collection. Where the attribute is a multi-valued field, only one value from that field should be provided. For example, if searching on Submission.repositories, a single repository URI should be provided for matching
T - PASS entity typemodelClass - The class of PASS entity.attribute - JSON attribute name.value - The value of the PASS attribute.<T extends PassEntity> Set<URI> findAllByAttribute(Class<T> modelClass, String attribute, Object value, int limit, int offset)
For example, to find Deposits using a Repository.id starting from record number 40, retrieving 20 records:
URI repositoryId = new URI("https://example.com/fedora/repositories/3");
Set<URI> entityUris = findByAttribute(Deposit.class, "repository", repositoryId, 20, 40);
The number of records will be limited by limit provided, and the offset will be applied to the default sorting. If there are no matches, it will return an empty list. This will override the limit env variable
The value parameter will be converted to a String for the purpose of searching the index. The value parameter cannot be a Collection. Where the attribute is a multi-valued field, only one value from that field should be provided. For example, if searching on Submission.repositories, a single repository URI should be provided for matching
T - PASS entity typemodelClass - The class of PASS entity.attribute - JSON attribute name.value - The value of the PASS attribute.limit - Maximum number of results.offset - Result offset.<T extends PassEntity> Set<URI> findAllByAttributes(Class<T> modelClass, Map<String,Object> attributeValuesMap)
For example, to find a Submission using a GrantId AND DOI:
Map<String, Object> map = new HashMap<String, Object>();
URI grantId = new URI("https://example.com/fedora/grants/3");
String doi = "10.001/12345abc";
map.put("grants", grantId)
map.put("doi", doi);
Set<URI> entityUris = findByAttribute(Submission.class, map);
By default this will return a maximum of 200 matching records, unless the pass.elasticsearch.limit environment variable is set. If there are no matches, it will return an empty list.
The Map "value" parameter will be converted to a String for the purpose of searching the index. The map's value cannot be a Collection. Where the attribute is a multi-valued field, only one value from that field should be provided. For example, if searching on Submission.repositories, a single repository URI should be provided for matching.
T - PASS entity typemodelClass - The class of PASS entity.attributeValuesMap - Map of JSON attributes to values.<T extends PassEntity> Set<URI> findAllByAttributes(Class<T> modelClass, Map<String,Object> attributeValuesMap, int limit, int offset)
For example, to find a Submission using a GrantId and DOI:
Map<String, Object> map = new HashMap<String, Object>();
URI grantId = new URI("https://example.com/fedora/grants/3");
String doi = "10.001/12345abc";
map.put("grants", grantId)
map.put("doi", doi);
Set<URI> entityUris = findByAttribute(Submission.class, map);
The number of records will be limited by limit provided, and the offset will be applied to the default sorting. If there are no matches, it will return an empty list. This will override the limit env variable
The Map "value" parameter will be converted to a String for the purpose of searching the index. The map's value cannot be a Collection. Where the attribute is a multi-valued field, only one value from that field should be provided. For example, if searching on Submission.repositories, a single repository URI should be provided for matching.
T - PASS entity typemodelClass - The class of PASS entity.attributeValuesMap - Map of JSON attribute name to values.limit - Maximum number of results.offset - Result offset.Map<String,Collection<URI>> getIncoming(URI passEntity)
PassEntity.
Keys in the returned map will be the predicate, and values will be the incoming URIs that reference the
PassEntity.
passEntity - the URI of a repository resourceMap keyed by predicate, may be empty but never nullURI upload(URI entityUri, InputStream content)
POSTs the content to entityUri.
The entityUri must already exist.
entityUri - a URI identifying an existing resource in the repositorycontent - the content to POST to the resourceURI used to retrieve the uploaded contentURI upload(URI entityUri, InputStream content, Map<String,?> params)
POSTs the supplied content to the supplied entityUri. Optional parameters may be
supplied by the caller, and used by the implementation to, e.g., supply checksums, suggest a "name" for
the uploaded content.
The entityUri must already exist.
Supported parameters include:
content to be POSTed; added as a Content-Type headerSlug headercontent; added as Digest headercontent; added as Digest headercontent; added as Digest headercontent; added to a Content-Disposition headerentityUri - an existing entity in the repositorycontent - the content to POST to the entityparams - optional parameters to the POST, i.e. HTTP header valuesURI used to retrieve the uploaded content<T extends PassEntity> int processAllEntities(Consumer<URI> processor, Class<T> modelClass)
The search space for resources is set by the implementation. For example, all resources underneath a base URI in Fedora.
T - PASS entity typeprocessor - Consumer that is given a URI for every resource visited.modelClass - Class of PASS entity to visit. If null, will visit all classes.default <T extends PassEntity> int processAllEntities(Consumer<URI> processor)
The search space for resources is set by the implementation. For example, all resources underneath a base URI in Fedora.
T - PASS entity typeprocessor - Consumer that is given a URI for every resource visited.Copyright © 2019. All rights reserved.