public class MetacatRestClient extends java.lang.Object implements MetacatRest
DELETE, FUNCTION_KEYWORD, FUNCTION_NAME_GETALLDOCS, FUNCTION_NAME_GETNEXTOBJ, FUNCTION_NAME_GETNEXTREV, FUNCTION_NAME_INSERT, FUNCTION_NAME_ISREGISTERED, FUNCTION_NAME_LOGIN, FUNCTION_NAME_LOGOUT, FUNCTION_NAME_UPDATE, GET, POST, PUT, RESOURCE_IDENTIFIER, RESOURCE_OBJECTS, RESOURCE_SESSION
Constructor and Description |
---|
MetacatRestClient(java.lang.String contextRootUrl)
Constructor to create a new instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addLSID(java.lang.String identifierId)
Adds identifierId
|
java.io.Reader |
authenticatedGetObject(java.lang.String docid,
java.lang.String outFile)
Read XML document from server session, accessed by docid, and returned as a Reader.
|
java.io.Reader |
authenticatedQuery(java.io.Reader xmlQuery)
Query (as an authenticated user) the metacat document store with the given Ecogrid-compatible
query document and return the Ecogrid result set as a Reader.
|
java.lang.String |
create(java.lang.String docid,
java.io.Reader xmlDocument)
Create an XML document in the repository.
|
java.lang.String |
deleteObject(java.lang.String docid)
Delete an XML document in the repository.
|
java.util.Vector<java.lang.String> |
getAllDocids(java.lang.String scope)
return a list of all docids that match a given scope.
|
java.lang.String |
getNextObject(java.lang.String scope)
Return the highest document id for a given scope.
|
int |
getNextRevision(java.lang.String identifierId)
The method will return the latest revision in metacat server
for a given document id.
|
java.io.Reader |
getObject(java.lang.String docid,
java.lang.String outFile)
Read a public XML document , accessed by docid, and returned as a Reader.
|
java.lang.String |
getSessionId()
Get the session identifier for this session.
|
boolean |
isRegistered(java.lang.String identifierId)
return true of the given docid is registered, false if not
|
java.lang.String |
login(java.lang.String username,
java.lang.String password)
Method used to log in to a metacat server through REST API.
|
java.lang.String |
logout()
Method used to log out a metacat server.
|
java.io.Reader |
query(java.io.Reader xmlQuery)
Query the metacat document store with the given Ecogrid-compatible
query document and return the Ecogrid result set as a Reader.
|
void |
setContextRootUrl(java.lang.String contextRootUrl)
When the MetacatFactory creates an instance it needs to set the
MetacatUrl to which connections should be made.
|
void |
setSessionId(java.lang.String sessionId)
Set the session identifier for this session.
|
java.lang.String |
update(java.lang.String docid,
java.io.Reader xmlDocument)
Update an XML document in the repository, replacing an existing document.
|
public MetacatRestClient(java.lang.String contextRootUrl)
public java.lang.String login(java.lang.String username, java.lang.String password) throws MetacatAuthException, MetacatInaccessibleException
login
in interface MetacatRest
username
- the username of the user, like an LDAP DNpassword
- the password for that user for authenticationMetacatAuthException
- when the username/password could
not be authenticatedMetacatInaccessibleException
public java.lang.String logout() throws MetacatInaccessibleException, MetacatException
logout
in interface MetacatRest
MetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
public java.io.Reader getObject(java.lang.String docid, java.lang.String outFile) throws InsufficientKarmaException, MetacatInaccessibleException, DocumentNotFoundException, MetacatException
getObject
in interface MetacatRest
docid
- the identifier of the document to be readoutputFile
- name of the file to be written to local (optional)InsufficientKarmaException
- when the user has insufficent rights
for the operationMetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
- when the metacat server generates another errorDocumentNotFoundException
public java.io.Reader authenticatedGetObject(java.lang.String docid, java.lang.String outFile) throws InsufficientKarmaException, MetacatInaccessibleException, DocumentNotFoundException, MetacatException
authenticatedGetObject
in interface MetacatRest
docid
- the identifier of the document to be readoutputFile
- name of the file to be written to local (optional)InsufficientKarmaException
- when the user has insufficent rights
for the operationMetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
- when the metacat server generates another errorDocumentNotFoundException
public java.io.Reader query(java.io.Reader xmlQuery) throws MetacatInaccessibleException, java.io.IOException
query
in interface MetacatRest
xmlQuery
- a Reader for accessing the XML version of the queryMetacatInaccessibleException
java.io.IOException
public java.io.Reader authenticatedQuery(java.io.Reader xmlQuery) throws MetacatInaccessibleException, java.io.IOException
authenticatedQuery
in interface MetacatRest
xmlQuery
- a Reader for accessing the XML version of the queryMetacatInaccessibleException
java.io.IOException
public java.lang.String create(java.lang.String docid, java.io.Reader xmlDocument) throws InsufficientKarmaException, MetacatException, java.io.IOException, MetacatInaccessibleException
create
in interface MetacatRest
docid
- the docid to insert the documentxmlDocument
- a Reader for accessing the XML document to be insertedisInsert
- whether the operation is update or insertInsufficientKarmaException
- when the user has insufficent rights
for the operationMetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
- when the metacat server generates another errorjava.io.IOException
- when there is an error reading the xml documentpublic java.lang.String update(java.lang.String docid, java.io.Reader xmlDocument) throws InsufficientKarmaException, MetacatException, java.io.IOException, MetacatInaccessibleException
update
in interface MetacatRest
docid
- the docid to insert the documentxmlDocument
- a Reader for accessing the XML document to be insertedisInsert
- whether the operation is update or insertInsufficientKarmaException
- when the user has insufficent rights
for the operationMetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
- when the metacat server generates another errorjava.io.IOException
- when there is an error reading the xml documentpublic java.lang.String deleteObject(java.lang.String docid) throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException
deleteObject
in interface MetacatRest
docid
- the docid to deleteInsufficientKarmaException
- when the user has insufficent rights
for the operationMetacatInaccessibleException
- when the metacat server can not be
reached or does not respondMetacatException
- when the metacat server generates another errorpublic java.lang.String getNextObject(java.lang.String scope) throws MetacatException
getNextObject
in interface MetacatRest
scope
- String the scope to use for looking up the latest idMetacatException
- when an error occurspublic int getNextRevision(java.lang.String identifierId) throws MetacatException
getNextRevision
in interface MetacatRest
identifierId
- String the given docid you want to use. the docid it self
can have or haven't revision numberMetacatException
public java.util.Vector<java.lang.String> getAllDocids(java.lang.String scope) throws MetacatException
getAllDocids
in interface MetacatRest
scope
- String the scope to use to limit the docid queryMetacatException
- when an error occurspublic boolean isRegistered(java.lang.String identifierId) throws MetacatException
isRegistered
in interface MetacatRest
scope
- String the scope to use to limit the docid queryMetacatException
- when an error occurspublic java.lang.String addLSID(java.lang.String identifierId) throws MetacatException
addLSID
in interface MetacatRest
identifierId
- String the given docid you want to use.MetacatException
- when an error occurspublic void setContextRootUrl(java.lang.String contextRootUrl)
MetacatRest
setContextRootUrl
in interface MetacatRest
public java.lang.String getSessionId()
MetacatRest
getSessionId
in interface MetacatRest
public void setSessionId(java.lang.String sessionId)
MetacatRest
setSessionId
in interface MetacatRest
Copyright © 2020 Regents of the University of California. All Rights Reserved.