Class UploadLimits
A reservation made for a request that names the types it accepts is granted under limits narrowed to them (withTypes(String), CC-UPLOAD-U1): a file must then be permitted by the configured list and by the request's list both (isPermitted(String, String, String)).
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intChunk size in bytes.final intIdle timeout in seconds.final longMaximum declared size of one file in bytes.final intMaximum file count per reservation.final intMaximum pause time in seconds: how long a reservation may stay paused before it is cancelled.static final StringThe relative upload path every reservation reports, ending with '/'.final StringThe permitted types as configured, empty for any.final StringThe types the request of the reservation accepts, as given, empty for none of its own.final longServer-global quota in bytes, 0 for unlimited.final longPer-application-session quota in bytes, 0 for unlimited.final intStart timeout in seconds.Constructor Summary
ConstructorsConstructorDescriptionUploadLimits(long serverQuotaBytes, long sessionQuotaBytes, int maxFiles, long maxFileBytes, int chunkBytes, int idleSeconds, int startSeconds, int maxPauseSeconds, String permittedTypes) Constructor.UploadLimits(long serverQuotaBytes, long sessionQuotaBytes, int maxFiles, long maxFileBytes, int chunkBytes, int idleSeconds, int startSeconds, String permittedTypes) Constructor with the default maximum pause time (ServerSettings.DEFAULT_UPLOAD_MAX_PAUSE).Method Summary
Modifier and TypeMethodDescriptionstatic UploadLimitsfrom(ServerSettings ss) Snapshots the server settings.booleanisPermitted(String name, String type, String verified) Checks a file against the permitted list and the types of the reservation's request, at reservation and at verification.booleanisTypePermitted(String type) Checks a media type against the permitted list.toString()Outputs to string.Narrows these limits to the types a request accepts, for the one reservation made from it: a file must then be permitted by the configured list and by the request's list both.
Field Details
PATH
The relative upload path every reservation reports, ending with '/'.- See Also:
serverQuotaBytes
public final long serverQuotaBytesServer-global quota in bytes, 0 for unlimited.sessionQuotaBytes
public final long sessionQuotaBytesPer-application-session quota in bytes, 0 for unlimited.maxFiles
public final int maxFilesMaximum file count per reservation.maxFileBytes
public final long maxFileBytesMaximum declared size of one file in bytes.chunkBytes
public final int chunkBytesChunk size in bytes.idleSeconds
public final int idleSecondsIdle timeout in seconds.startSeconds
public final int startSecondsStart timeout in seconds.maxPauseSeconds
public final int maxPauseSecondsMaximum pause time in seconds: how long a reservation may stay paused before it is cancelled.permittedTypes
The permitted types as configured, empty for any.requestTypes
The types the request of the reservation accepts, as given, empty for none of its own.
Constructor Details
UploadLimits
public UploadLimits(long serverQuotaBytes, long sessionQuotaBytes, int maxFiles, long maxFileBytes, int chunkBytes, int idleSeconds, int startSeconds, String permittedTypes) Constructor with the default maximum pause time (ServerSettings.DEFAULT_UPLOAD_MAX_PAUSE).- Parameters:
serverQuotaBytes- Server-global quota in bytes, 0 for unlimited.sessionQuotaBytes- Per-session quota in bytes, 0 for unlimited.maxFiles- Maximum file count per reservation, at least 1.maxFileBytes- Maximum declared size of one file in bytes, at least 1.chunkBytes- Chunk size in bytes, at least 1.idleSeconds- Idle timeout in seconds, at least 1.startSeconds- Start timeout in seconds, at least 1.permittedTypes- Comma-separated media types, empty or null for any.- Throws:
IllegalArgumentException- If a value is below its minimum.
UploadLimits
public UploadLimits(long serverQuotaBytes, long sessionQuotaBytes, int maxFiles, long maxFileBytes, int chunkBytes, int idleSeconds, int startSeconds, int maxPauseSeconds, String permittedTypes) Constructor.- Parameters:
serverQuotaBytes- Server-global quota in bytes, 0 for unlimited.sessionQuotaBytes- Per-session quota in bytes, 0 for unlimited.maxFiles- Maximum file count per reservation, at least 1.maxFileBytes- Maximum declared size of one file in bytes, at least 1.chunkBytes- Chunk size in bytes, at least 1.idleSeconds- Idle timeout in seconds, at least 1.startSeconds- Start timeout in seconds, at least 1.maxPauseSeconds- Maximum pause time in seconds, at least 1.permittedTypes- Comma-separated media types, empty or null for any.- Throws:
IllegalArgumentException- If a value is below its minimum.
Method Details
from
Snapshots the server settings.- Parameters:
ss- The settings.- Returns:
- The limits.
isTypePermitted
Checks a media type against the permitted list.- Parameters:
type- The type, lower case; empty means "undeclared".- Returns:
- true if the list is empty, or the type or its
type/*family is listed.
withTypes
Narrows these limits to the types a request accepts, for the one reservation made from it: a file must then be permitted by the configured list and by the request's list both.- Parameters:
types- The request's types in the syntax of the HTMLacceptattribute: comma-separated media types,type/*families and.extfile name extensions; null or blank for none.- Returns:
- The narrowed limits, or these when the request has no types of its own.
isPermitted
Checks a file against the permitted list and the types of the reservation's request, at reservation and at verification.The configured list is checked on the type, as
isTypePermitted(String)does. The request's types, when it has any, must permit the file as well: by a media type or family entry matching the type, or by an extension entry matching the end of the name. An extension entry is a statement about the name, not the content, so at verification it stops counting when the content was recognized as something else than what that extension names: a ZIP archive calleda.pdfis not permitted by.pdf. An extension the sniffer has no type for (.txt,.docx) permits by the name alone.- Parameters:
name- The original file name, or null to check the type only.type- The type: at reservation the declared one; at verification the type the content was found to be, else the declared one. Empty means "undeclared".verified- The type the content was found to be; empty or null when it was not recognized, and at reservation.- Returns:
- true if both lists permit the file.
toString