Class QuotaServiceManager
java.lang.Object
edu.ucsb.nceas.metacat.dataone.quota.QuotaServiceManager
A class manages the quota service for users
- Author:
- tao
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static Date
combineDateAndGivenTime
(Date now, String givenTime) This method will combine a given date and given time string (in short format) to a new date.void
enforce
(String quotaSubject, org.dataone.service.types.v1.Subject requestor, org.dataone.service.types.v2.SystemMetadata sysmeta, String method) Enforce quota servicestatic QuotaServiceManager
Get the singleton instance of the serviceboolean
Check if the quota service is enabled.void
Start a timer to check failed usage reporting and report them again in daily base.
-
Field Details
-
USAGE
- See Also:
-
ACTIVE
- See Also:
-
INACTIVE
- See Also:
-
DELETED
- See Also:
-
CREATEMETHOD
- See Also:
-
UPDATEMETHOD
- See Also:
-
ARCHIVEMETHOD
- See Also:
-
DELETEMETHOD
- See Also:
-
PROPERTYNAMEOFPORTALNAMESPACE
- See Also:
-
QUOTASUBJECTHEADER
- See Also:
-
-
Method Details
-
getInstance
public static QuotaServiceManager getInstance() throws org.dataone.service.exceptions.ServiceFailureGet the singleton instance of the service- Returns:
- the quota service instance. The instance will have a bookeeperClient if the quota service is enabled.
- Throws:
IOException
org.dataone.service.exceptions.ServiceFailure
-
isEnabled
public boolean isEnabled()Check if the quota service is enabled.- Returns:
- true if it is enabled; otherwise false.
-
startDailyCheck
public void startDailyCheck()Start a timer to check failed usage reporting and report them again in daily base. Metacat only needs one timer, but this method will be called on four different servlet init methods. So the method has a indicator of already starting a timer and is synchronized to make sure only one timer will be started. -
enforce
public void enforce(String quotaSubject, org.dataone.service.types.v1.Subject requestor, org.dataone.service.types.v2.SystemMetadata sysmeta, String method) throws org.dataone.service.exceptions.InsufficientResources, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.NotFound Enforce quota service- Parameters:
quotaSubject
- the subject of the quota which will be usedrequestor
- the subject of the user who requests the usagesysmeta
- the system metadata of the object which will use the quotamethod
- the method name which will call the createUsage method (create or update- Throws:
org.dataone.service.exceptions.InsufficientResources
org.dataone.service.exceptions.InvalidRequest
org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.NotFound
org.dataone.service.exceptions.NotImplemented
-
combineDateAndGivenTime
This method will combine a given date and given time string (in short format) to a new date. If the given time (e.g 10:00 AM) is before the given date (e.g 2:00 PM Aug 21, 2005), then the time will set to the following day, 10:00 AM Aug 22, 2005. If the given time (e.g 10:00 AM) is after the given date (e.g 8:00 AM Aug 21, 2005), the time will set to be 10:00 AM Aug 21, 2005.- Parameters:
now
- the date will be combinegivenTime
- the format should be "10:00 AM " or "2:00 PM"- Returns:
- the Date object
- Throws:
HandlerException
-