Class QuotaServiceManager

java.lang.Object
edu.ucsb.nceas.metacat.dataone.quota.QuotaServiceManager

public class QuotaServiceManager extends Object
A class manages the quota service for users
Author:
tao
  • Field Details

  • Method Details

    • getInstance

      public static QuotaServiceManager getInstance() throws org.dataone.service.exceptions.ServiceFailure
      Get 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 used
      requestor - the subject of the user who requests the usage
      sysmeta - the system metadata of the object which will use the quota
      method - 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

      protected static Date combineDateAndGivenTime(Date now, String givenTime) throws HandlerException
      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 combine
      givenTime - the format should be "10:00 AM " or "2:00 PM"
      Returns:
      the Date object
      Throws:
      HandlerException