if( newContentLength == null ) {
log.debug( "new content length is not available, cant check quota, reject" );
return StorageErrorReason.SER_QUOTA_EXCEEDED;
}
if( replaced instanceof GetableResource ) {
GetableResource gr = (GetableResource) replaced;
Long existingLength = gr.getContentLength();
if( existingLength == null ) {
log.debug( "existing content length cant be determined, cant check quota, reject");
return StorageErrorReason.SER_QUOTA_EXCEEDED;
} else {
long diff = existingLength - newContentLength;
if( diff > 0 ) {
return null;
} else {
log.debug( "new content is larger then existing content, but no quota is available, reject");
return StorageErrorReason.SER_QUOTA_EXCEEDED;
}
}
} else {
log.debug( "existing content length cant be determined, cant check quota, reject");
return StorageErrorReason.SER_QUOTA_EXCEEDED;
}
} else {
// difference of new content to existing must be less then available, but if in doubt allow
Long newContentLength = request.getContentLengthHeader();
if( newContentLength == null ) {
log.debug( "new content length is not available, cant check quota, allow" );
return null;
}
if( replaced instanceof GetableResource ) {
GetableResource gr = (GetableResource) replaced;
Long existingLength = gr.getContentLength();
if( existingLength == null ) {
log.debug( "existing content length cant be determined, cant check quota, allow");
return null;
} else {
long diff = newContentLength - existingLength; // this is the amount extra needed