Class AppGyroFileUploaderService
- All Implemented Interfaces:
IFileUploadService, FileUploadRegistry.IEvents
The WebSocket authorizes and HTTPS carries the bytes: this class never sees file content except in the verification pass, which decodes a completed part on a server executor thread, never on a servlet thread and never on the session's worker.
Created lazily by AppSessionGyro.getFileUploadService() and disposed of in AppSessionGyro.dispose() beside the session's file provider: when disposed of, all transfers are cancelled and removed.
Two things reach the client from here (rulings of 2026-09-24). The App's pause and resume of a file are pushed to every registered IUploadClientChannel (row 12), the client side of which is the JS transport order's; the client's own pause notices come in through onClientPauseNotice(String, int, boolean, String). And a cancellation only the server knows about (idle, start, maxPause) is shown as ONE message box per reservation listing its files (row 25), through the session context's message-box queue (row 21: kept for the next client, dropped with the session), unless the App switched it off for the reservation (row 20).
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe texts of the failure notice (A1-10, CC-UPLOAD-C1): looked up by their text IDs,"srv.upload_"followed by the constant's name, in the text tables of the session the notice is shown in, throughIEnumLocaleString; the English text is the fallback.Constructor Summary
ConstructorsConstructorDescriptionAppGyroFileUploaderService(IUploadSessionContext context, FileUploadRegistry registry, UploadStagingStore store, Executor verifier, BooleanSupplier mounted) Constructor.Method Summary
Modifier and TypeMethodDescriptionbooleanaddClientChannel(IUploadClientChannel channel) Registers a client's channel: the App's pauses and resumes are pushed to it from now on, and every file the App holds paused right now is told to it at once, so a reconnecting client learns what it must not send.booleanaddListener(IFileUploadListener listener) Adds a listener for every reservation of this application session.voiddispose()Disposes of the service: every transfer of the session is cancelled and removed, the listeners are cleared.getReservation(String reservationID) Gets a live reservation of this application session.List<? extends IUploadReservation> Gets the live reservations of this application session.Gets the application session UUID this service serves.booleanChecks if disposed of.booleanChecks if uploads are enabled for new reservations: the live$upload.allowsetting AND the chunk route mounted.voidThe App resumed a file it held, but the client still holds it: the file stays paused and noFileUploadRegistry.IEvents.onFileResumed(UploadReservation, UploadFileEntry, boolean)is given, yet the client must learn the App no longer holds it.voidonClientPauseNotice(String reservationID, int fileIndex, boolean paused, String reason) The client's pause notice for a file of this session (its page hidden, its network gone, or back again): the listener hears it and the idle timeout is suspended while paused.voidonFileCancelled(UploadReservation r, UploadFileEntry f, String reason) --- FileUploadRegistry.IEvents (routed here by the module for this session) ---voidCalled by the servlet after the last chunk of a file has been recorded: runs the verification pass on the executor and reports the outcome to the listeners.voidonFileFailed(UploadReservation r, UploadFileEntry f, String reason) A file failed; its bytes are gone.voidonFilePaused(UploadReservation r, UploadFileEntry f, String reason, boolean byApp) A file enteredUploadState.PAUSED.voidReports a chunk's progress; called by the servlet at most once per second per file.voidonFileResumed(UploadReservation r, UploadFileEntry f, boolean byApp) A file leftUploadState.PAUSED: every party that held it has resumed it.voidReports the first accepted chunk of a file.voidEvery file of the reservation is final.booleanremoveClientChannel(IUploadClientChannel channel) Removes a client's channel (its client session is disposed of).booleanremoveListener(IFileUploadListener listener) Removes a listener.reserve(List<UploadFileRequest> files, IFileUploadListener listener, boolean notices, String types) Reserves a transfer of one or more files that must also be of the types the requester accepts.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IFileUploadService
reserve, reserve
Constructor Details
AppGyroFileUploaderService
public AppGyroFileUploaderService(IUploadSessionContext context, FileUploadRegistry registry, UploadStagingStore store, Executor verifier, BooleanSupplier mounted) Constructor.- Parameters:
context- The session context.registry- The server-global registry.store- The staging store.verifier- The executor for the verification pass.mounted- Whether the chunk route is mounted (FileUploadModule.isRouteAvailable()in production): a reservation is refuseddisabledwhile it is not.
Method Details
getSessionUUID
Gets the application session UUID this service serves.- Returns:
- The UUID string.
isEnabled
public boolean isEnabled()Checks if uploads are enabled for new reservations: the live$upload.allowsetting AND the chunk route mounted. The mount gate is read once, at server ready, so the setting turned on at run time (or aregisterServletthat failed at start) must not hand out reservations whose chunks have no route: they are refuseddisableduntil a restart mounts it. Turned off at run time, the mounted route keeps serving transfers in flight and new reservations are refused here.- Specified by:
isEnabledin interfaceIFileUploadService- Returns:
- true if
reserve(List, IFileUploadListener, boolean, String)would consider a request.
reserve
public IUploadReservation reserve(List<UploadFileRequest> files, IFileUploadListener listener, boolean notices, String types) Description copied from interface:IFileUploadServiceReserves a transfer of one or more files that must also be of the types the requester accepts. The request's types narrow$upload.typesfor this reservation only: a file is accepted when both permit it - at reservation on the declared type and name, and again at verification on the type the content was found to be, where a file that is not what it was declared as failstypeNotPermitted.- Specified by:
reservein interfaceIFileUploadService- Parameters:
files- The files the client declares, at least one.listener- A listener for this reservation only, or null; the service-level listeners see it as well.notices- Whether a cancellation only the server knows about (idle,start,maxPause) is shown to the client as one message box listing the files; false when the App reports failures its own way.types- The types the requester accepts, in the syntax of the HTMLacceptattribute: comma-separated media types (image/png), families (image/*) and file name extensions (.pdf); null or empty for no types of its own.- Returns:
- The reservation, accepted or refused; never null.
getReservation
Description copied from interface:IFileUploadServiceGets a live reservation of this application session.- Specified by:
getReservationin interfaceIFileUploadService- Parameters:
reservationID- The reservation ID.- Returns:
- The reservation, or null if unknown, swept or not of this session.
getReservations
Description copied from interface:IFileUploadServiceGets the live reservations of this application session.- Specified by:
getReservationsin interfaceIFileUploadService- Returns:
- The reservations, never null.
addListener
Description copied from interface:IFileUploadServiceAdds a listener for every reservation of this application session.- Specified by:
addListenerin interfaceIFileUploadService- Parameters:
listener- The listener.- Returns:
- true if added, false if already present.
removeListener
Description copied from interface:IFileUploadServiceRemoves a listener.- Specified by:
removeListenerin interfaceIFileUploadService- Parameters:
listener- The listener.- Returns:
- true if removed, false if not present.
onFileComplete
Called by the servlet after the last chunk of a file has been recorded: runs the verification pass on the executor and reports the outcome to the listeners.- Parameters:
r- The reservation.f- The complete file.
addClientChannel
Registers a client's channel: the App's pauses and resumes are pushed to it from now on, and every file the App holds paused right now is told to it at once, so a reconnecting client learns what it must not send.- Parameters:
channel- The channel.- Returns:
- true if added, false if already registered.
- Throws:
NullPointerException- If the channel is null.
removeClientChannel
Removes a client's channel (its client session is disposed of).- Parameters:
channel- The channel.- Returns:
- true if removed, false if not registered.
onClientPauseNotice
The client's pause notice for a file of this session (its page hidden, its network gone, or back again): the listener hears it and the idle timeout is suspended while paused. A notice for an unknown reservation or file is ignored; a chunk arriving on a client-paused file is that client's resume, so a late resume notice is harmless.- Parameters:
reservationID- The reservation ID.fileIndex- The file index, or -1 for every file.paused- true for a pause, false for a resume.reason- The client's reason, null or empty forpaused.
onFileCancelled
--- FileUploadRegistry.IEvents (routed here by the module for this session) ---- Specified by:
onFileCancelledin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.f- The file.reason- The reason.
onFilePaused
Description copied from interface:FileUploadRegistry.IEventsA file enteredUploadState.PAUSED.- Specified by:
onFilePausedin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.f- The file.reason- The reason given by whoever paused it.byApp- true if the App paused it, false if the client did.
onFileResumed
Description copied from interface:FileUploadRegistry.IEventsA file leftUploadState.PAUSED: every party that held it has resumed it.- Specified by:
onFileResumedin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.f- The file.byApp- true if the App's resume freed it, false if the client's did.
onAppReleased
Description copied from interface:FileUploadRegistry.IEventsThe App resumed a file it held, but the client still holds it: the file stays paused and noFileUploadRegistry.IEvents.onFileResumed(UploadReservation, UploadFileEntry, boolean)is given, yet the client must learn the App no longer holds it.- Specified by:
onAppReleasedin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.f- The file.
onFileFailed
Description copied from interface:FileUploadRegistry.IEventsA file failed; its bytes are gone.- Specified by:
onFileFailedin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.f- The file.reason- The reason.
onReservationClosed
Description copied from interface:FileUploadRegistry.IEventsEvery file of the reservation is final.- Specified by:
onReservationClosedin interfaceFileUploadRegistry.IEvents- Parameters:
r- The reservation.
onFileProgress
Reports a chunk's progress; called by the servlet at most once per second per file.- Parameters:
r- The reservation.f- The file.
onFileStarted
Reports the first accepted chunk of a file.- Parameters:
r- The reservation.f- The file.
dispose
public void dispose()Disposes of the service: every transfer of the session is cancelled and removed, the listeners are cleared. Called fromAppSessionGyro.dispose(), after the worker is gone, so nothing is posted.isDisposed
public boolean isDisposed()Checks if disposed of.- Returns:
- true if disposed.