Class AbstractQuotaService<T extends QuotaKey>
- java.lang.Object
-
- org.silverpeas.core.admin.quota.service.AbstractQuotaService<T>
-
- All Implemented Interfaces:
QuotaService<T>
- Direct Known Subclasses:
AbstractSpaceQuotaService
,UserDomainQuotaService
public abstract class AbstractQuotaService<T extends QuotaKey> extends Object implements QuotaService<T>
- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description AbstractQuotaService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Quota
get(T key)
Gets the quota of the resource from a given quota key.Quota
initialize(T key, long maxCount)
Initializes the quota of the resource for the given quota key.Quota
initialize(T key, long minCount, long maxCount)
Initializes the quota of the resource for the given quota key.Quota
initialize(T key, Quota quota)
Initializes the quota of the resource for the given quota key and from an existing quota.protected abstract boolean
isActivated()
Indicates if the type of quota is activatedvoid
remove(T key)
Removes quietly the quota of the resource from a given quota key.Quota
verify(T key)
Verifies if the quota is full or not enough from a given quota key.Quota
verify(T key, Quota quota)
Verifies if the given loaded and computed quota.Quota
verify(T key, Quota quota, AbstractQuotaCountingOffset countingOffset)
Verifies if the given loaded and computed quota by adding a counting offset.Quota
verify(T key, AbstractQuotaCountingOffset countingOffset)
Verifies if the quota is full or not enough from a given quota key and adding a counting offset.protected Quota
verifyQuota(Quota quota, AbstractQuotaCountingOffset countingOffset)
This method ensures that no recursion can be done between service signatures.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.admin.quota.service.QuotaService
getCurrentCount
-
-
-
-
Method Detail
-
initialize
public Quota initialize(T key, long maxCount) throws QuotaException
Description copied from interface:QuotaService
Initializes the quota of the resource for the given quota key.- Specified by:
initialize
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keymaxCount
- the maximum count- Returns:
- the quota
- Throws:
QuotaException
- on error
-
initialize
public Quota initialize(T key, Quota quota) throws QuotaException
Description copied from interface:QuotaService
Initializes the quota of the resource for the given quota key and from an existing quota.- Specified by:
initialize
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keyquota
- a quota- Returns:
- the quota
- Throws:
QuotaException
- on error
-
initialize
public Quota initialize(T key, long minCount, long maxCount) throws QuotaException
Description copied from interface:QuotaService
Initializes the quota of the resource for the given quota key.- Specified by:
initialize
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keyminCount
- the minimum countmaxCount
- the maximum count- Returns:
- the quota
- Throws:
QuotaException
- on error
-
get
public Quota get(T key) throws QuotaException
Description copied from interface:QuotaService
Gets the quota of the resource from a given quota key. A save operation is done if the current count has changed.- Specified by:
get
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the key- Returns:
- the quota mapped with the key
- Throws:
QuotaException
-
verify
public Quota verify(T key) throws QuotaException
Description copied from interface:QuotaService
Verifies if the quota is full or not enough from a given quota key.Be aware of that the quota count will be loaded and computed each time this signature is called.
If full then a quota full exception is thrown If not enough then a quota not enough exception is thrown.- Specified by:
verify
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the key- Returns:
- the quota used by the verify treatment
- Throws:
QuotaException
- on error
-
verify
public Quota verify(T key, AbstractQuotaCountingOffset countingOffset) throws QuotaException
Description copied from interface:QuotaService
Verifies if the quota is full or not enough from a given quota key and adding a counting offset.Be aware of that the quota count will be loaded and computed each time this signature is called.
If full then a quota full exception is throw. If not enough then a quota not enough exception is throw.- Specified by:
verify
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keycountingOffset
- a counting offset- Returns:
- the quota used by the verify treatment
- Throws:
QuotaException
- on error
-
verify
public Quota verify(T key, Quota quota) throws QuotaException
Description copied from interface:QuotaService
Verifies if the given loaded and computed quota.Be aware of that the quota count is not again computed by this service. When this signature is called, it means that the
If full then a quota full exception is thrown If not enough then a quota not enough exception is thrown.Quota
instance has been already loaded and there is no need to perform again the counting.- Specified by:
verify
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keyquota
- a loaded quota- Returns:
- the quota used by the verify treatment
- Throws:
QuotaException
- on error
-
verify
public Quota verify(T key, Quota quota, AbstractQuotaCountingOffset countingOffset) throws QuotaException
Description copied from interface:QuotaService
Verifies if the given loaded and computed quota by adding a counting offset.Be aware of that the quota count is not again computed by this service. When this signature is called, it means that the
If full then a quota full exception is thrown. If not enough then a quota not enough exception is thrown.Quota
instance has been already loaded and there is no need to perform again the counting.- Specified by:
verify
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the keyquota
- a loaded quotacountingOffset
- a counting offset- Returns:
- a copied quota from the given one containing the count with the offset used by the verify treatment
- Throws:
QuotaException
- on error
-
verifyQuota
protected final Quota verifyQuota(Quota quota, AbstractQuotaCountingOffset countingOffset) throws QuotaException
This method ensures that no recursion can be done between service signatures.The count of given quota MUST have been computed before calling this method.
- Parameters:
quota
- the quota to verify.countingOffset
- an offset to apply.- Returns:
- a copied quota from the given one containing the count with the offset used by the verify treatment
- Throws:
QuotaException
- when the quota is reached.
-
remove
public void remove(T key)
Description copied from interface:QuotaService
Removes quietly the quota of the resource from a given quota key.- Specified by:
remove
in interfaceQuotaService<T extends QuotaKey>
- Parameters:
key
- the key
-
isActivated
protected abstract boolean isActivated()
Indicates if the type of quota is activated- Returns:
- true if activated, false otherwise
-
-