Class BookKeeperClient
java.lang.Object
edu.ucsb.nceas.metacat.dataone.quota.BookKeeperClient
A client class to access the BookKeeper service
- Author:
- tao
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
createUsage
(org.dataone.bookkeeper.api.Usage usage) Create a usage record for a given quota identifier in the book keeper service.int
deleteUsage
(int quotaId, String instanceId) Delete the usage with the given quota type and instance id in the remote book keeper servicestatic BookKeeperClient
Get the singleton instance of the BookKeeplerClient classList<org.dataone.bookkeeper.api.Quota>
listQuotas
(String quotaSubject, String requestor, String quotaType) List the quotas associated with the given subjectint
updateUsage
(int quotaId, String instanceId, org.dataone.bookkeeper.api.Usage usage) Update an existing usage with the given quota id and instance id
-
Field Details
-
DEFAULT_REMOTE_USAGE_ID
public static final int DEFAULT_REMOTE_USAGE_ID- See Also:
-
-
Constructor Details
-
BookKeeperClient
protected BookKeeperClient() throws org.dataone.service.exceptions.ServiceFailureA private constructor- Throws:
IOException
org.dataone.service.exceptions.ServiceFailure
-
-
Method Details
-
getInstance
Get the singleton instance of the BookKeeplerClient class- Returns:
- the instance of the class
- Throws:
IOException
org.dataone.service.exceptions.ServiceFailure
-
listQuotas
public List<org.dataone.bookkeeper.api.Quota> listQuotas(String quotaSubject, String requestor, String quotaType) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.InvalidRequest, UnsupportedEncodingException List the quotas associated with the given subject- Parameters:
quotaSubject
- the subject who owns the quotasrequestor
- the subject of user who will request a usagequotaType
- the type of the quotas (storage or portal)- Returns:
- the list of quotas associated with the subject.
- Throws:
IOException
org.apache.http.client.ClientProtocolException
org.dataone.service.exceptions.NotFound
org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.InvalidRequest
UnsupportedEncodingException
-
createUsage
public int createUsage(org.dataone.bookkeeper.api.Usage usage) throws org.apache.http.client.ClientProtocolException, IOException, org.dataone.service.exceptions.ServiceFailure Create a usage record for a given quota identifier in the book keeper service. If it fails, an exception will be thrown- Parameters:
usage
- the object of the usage will be created- Returns:
- the usage id from the remote book keeper server
- Throws:
org.apache.http.client.ClientProtocolException
IOException
org.dataone.service.exceptions.ServiceFailure
-
deleteUsage
public int deleteUsage(int quotaId, String instanceId) throws org.dataone.service.exceptions.InvalidRequest, org.apache.http.client.ClientProtocolException, org.dataone.service.exceptions.ServiceFailure, IOException Delete the usage with the given quota type and instance id in the remote book keeper service- Parameters:
quotaType
- the quota type associated with the usageinstanceId
- the instance id associated with the usage- Returns:
- the remote usage id which was deleted. If it returns the default value -1, it means there is no remote usage matching the quota id and instance id and Metacat did nothing.
- Throws:
org.dataone.service.exceptions.InvalidRequest
org.apache.http.client.ClientProtocolException
org.dataone.service.exceptions.ServiceFailure
IOException
-
updateUsage
public int updateUsage(int quotaId, String instanceId, org.dataone.bookkeeper.api.Usage usage) throws org.dataone.service.exceptions.InvalidRequest, org.apache.http.client.ClientProtocolException, org.dataone.service.exceptions.ServiceFailure, IOException Update an existing usage with the given quota id and instance id- Parameters:
quotaId
- the quota id which the existing usage matchesinstanceId
- the instance id which the existing usage matchesusage
- the new usage value will be used- Returns:
- the remote usage id which was updated. If it returns the default value -1, it means there is no remote usage matching the quota id and instance id and Metacat did nothing.
- Throws:
org.dataone.service.exceptions.InvalidRequest
org.apache.http.client.ClientProtocolException
org.dataone.service.exceptions.ServiceFailure
IOException
-