Class PendingChangesHandler
java.lang.Object
com.ultikits.ultitools.utils.PendingChangesHandler
- All Implemented Interfaces:
CloudRequestHandler
Serves the panel's pending module changes on the connection's serial request worker.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate static final Stringprivate static final Patternprivate static final Stringprivate static final Stringprivate static final intprivate static final intprivate static final intprivate static final intprivate static final longprivate static final longprivate final Supplier<PendingChanges> private static final Patternprivate static final Stringprivate static final Stringprivate final ShutdownGateprivate final Supplier<List<ModuleFileTransactions.StartOutcome>> -
Constructor Summary
ConstructorsConstructorDescriptionPendingChangesHandler(Supplier<PendingChanges> pending, Supplier<List<ModuleFileTransactions.StartOutcome>> startOutcomes, ShutdownGate shutdown, Supplier<Logger> logger) -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringprivate static com.google.gson.JsonObjectchangeData(PendingChanges.Kind kind, String module, String fromVersion, String toVersion) private static com.google.gson.JsonObjectcontentKind(ModuleContentKind kind) private static com.google.gson.JsonObjectprivate static Stringprivate static com.google.gson.JsonArrayprivate static com.google.gson.JsonObjectfitList(String replyTo, int maxBytes, List<com.google.gson.JsonObject> entries, List<com.google.gson.JsonObject> lastStart, boolean truncated) private static booleanfitsListFrame(String replyTo, com.google.gson.JsonObject data, int maxBytes) voidhandle(CloudRequest request, CloudChannel channel) Validates the payload and handles it on the dispatching thread.private static booleanprivate static booleanprivate static voidkeepFittingPrefix(String replyTo, int maxBytes, com.google.gson.JsonObject data, String key, List<com.google.gson.JsonObject> entries) Finds the longest prefix by measuring whole frames, without re-encoding for every dropped entry.private static StringkindName(PendingChanges.Kind kind) private com.google.gson.JsonObjectprivate static com.google.gson.JsonArrayprivate static PendingChangesHandler.RevocationreadRevocation(CloudRequest request) private voidreplyRevoked(CloudChannel channel, String replyTo, long userId, PendingChanges.RevokeResult result) private static voidreplySafely(CloudChannel channel, String replyTo, String type, Runnable reply) private static com.google.gson.JsonElementrequesterData(PendingChanges.Requester requester) private voidrevoke(CloudChannel channel, String replyTo, PendingChangesHandler.Revocation request) private static MessageKeyprivate static com.google.gson.JsonObjectprivate static StringstateName(PendingChanges.State state) private static com.google.gson.JsonArraywarnings(ModuleContent content) private static StringwriteFailure(String error)
-
Field Details
-
LIST
- See Also:
-
LIST_RESULT
- See Also:
-
REVOKE
- See Also:
-
REVOKE_RESULT
- See Also:
-
TYPES
-
MAX_ITEMS
private static final int MAX_ITEMS- See Also:
-
MAX_FILES
private static final int MAX_FILES- See Also:
-
MAX_CONTENT_KINDS
private static final int MAX_CONTENT_KINDS- See Also:
-
MAX_MESSAGE_CHARS
private static final int MAX_MESSAGE_CHARS- See Also:
-
ENTRY_ID
-
REVISION
-
JAR_NAME
-
MAX_USER_ID
private static final long MAX_USER_ID- See Also:
-
MAX_TIMESTAMP
private static final long MAX_TIMESTAMP- See Also:
-
INTERNAL_ERROR
- See Also:
-
pending
-
startOutcomes
-
shutdown
-
logger
-
-
Constructor Details
-
PendingChangesHandler
PendingChangesHandler(Supplier<PendingChanges> pending, Supplier<List<ModuleFileTransactions.StartOutcome>> startOutcomes, ShutdownGate shutdown, Supplier<Logger> logger)
-
-
Method Details
-
handle
Description copied from interface:CloudRequestHandlerValidates the payload and handles it on the dispatching thread. No Bukkit main-thread scheduling is implied; handlers must schedule such work themselves. Synchronous payload validation failures become correlated invalid_message replies; other runtime failures become internal_error without exposing exception text. Asynchronous failures are the handler's responsibility.- Specified by:
handlein interfaceCloudRequestHandler- Parameters:
request- the parsed envelope with a defensively copied payloadchannel- the reply channel, which may close during processing
-
listData
-
hasExpectedRevision
-
fitList
-
keepFittingPrefix
-
prefix
-
fitsListFrame
-
entryData
-
changeData
private static com.google.gson.JsonObject changeData(PendingChanges.Kind kind, String module, String fromVersion, String toVersion) -
bounded
-
failureText
-
fileNames
-
isJarName
-
requesterData
-
warnings
-
contentKind
-
startData
-
kindName
-
revokeActionKey
-
stateName
-
readRevocation
-
revoke
-
replyRevoked
private void replyRevoked(CloudChannel channel, String replyTo, long userId, PendingChanges.RevokeResult result) -
writeFailure
-
replySafely
-