Package com.arms.api.wiki.service
Class OtService
java.lang.Object
com.arms.api.wiki.service.OtService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDocumentContent(String sessionId, String documentId) Gets the current content for a specific document from Redis.getOperationHistory(String sessionId, String documentId) Gets a copy of the operation history (List) from the Redis list. intgetRevision(String sessionId, String documentId) Gets the current server revision number (size of history list) from Redis.receiveOperation(String sessionId, String documentId, int clientRevision, TextOperation operation) Process an incoming operation from a client against a specified revision for a specific document using Redis state.voidresetSessionDocument(String sessionId, String documentId) Resets the state (content and history) for a specific document in Redis.voidsetDocumentContent(String sessionId, String documentId, String content) Sets the document content directly in Redis and clears its history list.
-
Constructor Details
-
OtService
-
-
Method Details
-
getDocumentContent
Gets the current content for a specific document from Redis.- Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document.- Returns:
- The content of the document, or empty string if not found.
-
getRevision
Gets the current server revision number (size of history list) from Redis.- Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document.- Returns:
- The revision number for the document (0 if history list doesn't exist).
-
receiveOperation
public TextOperation receiveOperation(String sessionId, String documentId, int clientRevision, TextOperation operation) throws IllegalArgumentException Process an incoming operation from a client against a specified revision for a specific document using Redis state. Transforms the operation against concurrent operations, applies it, updates Redis, and adds it to the history list in Redis. NOTE: Updates to content and history are NOT atomic across Redis keys without using MULTI/EXEC or Lua scripts. The instance-level lock prevents races within this single instance, but not across multiple instances.- Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document being modified.clientRevision- The revision number the client based their operation on.operation- The operation from the client.- Returns:
- The transformed operation that was applied.
- Throws:
IllegalArgumentException- if the clientRevision is invalid or transformation/application fails.
-
setDocumentContent
Sets the document content directly in Redis and clears its history list.- Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document.content- The new document content.
-
resetSessionDocument
Resets the state (content and history) for a specific document in Redis.- Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document to reset.
-
getOperationHistory
Gets a copy of the operation history (List) from the Redis list. - Parameters:
sessionId- The identifier of the session.documentId- The identifier of the document.- Returns:
- A list of all operations in the document's history, or an empty list if not found or on error.
-