Package io.milton.http.quota
Class DefaultStorageChecker
java.lang.Object
io.milton.http.quota.DefaultStorageChecker
- All Implemented Interfaces:
StorageChecker
Default storage checking mechanism checks to see if the nearest parent
resource implements QuotaResource, and if so uses the available bytes
property from that to determine whether to allow a PUT
Note that there is not always information available giving the size of new content,
and in the case of replacing an existing resource, we might not have that resource's
size. In these cases we cant determine perfectly whether we should allow or reject
a PUT request. So we allow these requests if the available storage is greater then
zero, but disallow if less then or equal to zero.
- Author:
- brad
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.milton.http.quota.StorageChecker
StorageChecker.StorageErrorReason -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckStorageOnAdd(Request request, CollectionResource nearestParent, Path parentPath, String host) Check to see if the operation should be allowed, when there is no existing resource.checkStorageOnReplace(Request request, CollectionResource parent, Resource replaced, String host) Check to see if the operation should be allowed, when an existing resource is to be overwritten or replaced.
-
Constructor Details
-
DefaultStorageChecker
public DefaultStorageChecker()
-
-
Method Details
-
checkStorageOnReplace
public StorageChecker.StorageErrorReason checkStorageOnReplace(Request request, CollectionResource parent, Resource replaced, String host) Description copied from interface:StorageCheckerCheck to see if the operation should be allowed, when an existing resource is to be overwritten or replaced.- Specified by:
checkStorageOnReplacein interfaceStorageCheckerreplaced- - the resource being replaced- Returns:
- - null if the operation should proceed, otherwise a reason for the error
-
checkStorageOnAdd
public StorageChecker.StorageErrorReason checkStorageOnAdd(Request request, CollectionResource nearestParent, Path parentPath, String host) Description copied from interface:StorageCheckerCheck to see if the operation should be allowed, when there is no existing resource. The parent collection may or may not exist, so only its path is provided.- Specified by:
checkStorageOnAddin interfaceStorageCheckerparentPath- - the path to the parent collection. E.g. http://abc.com/path = /path- Returns:
- - null if the operation should proceed, or the reason for the failure
-