Class GrpcContentService
- All Implemented Interfaces:
io.grpc.BindableService,AutoCloseable,org.saidone.unrest.api.ContentServiceGrpc.AsyncService
getReader(org.saidone.unrest.api.GetContentRequest, io.grpc.stub.StreamObserver<org.saidone.unrest.api.GetContentResponse>) returns a byte slice or extracted UTF-8 text, and getWriter(org.saidone.unrest.api.UpdateContentRequest, io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node>) replaces document
content. Unlike local Alfresco readers and writers, these RPCs exchange bytes rather than live Java handles.
The streaming extensions download stored bytes and upload new documents larger than a unary message can hold.
Downloads resolve the reader in a read-only transaction, then stream outside that transaction to avoid
duplicate output on transaction retries. Uploads stage bytes in bounded memory or a temporary file and create the document in a
retryable read-write transaction only after the client completes. Repository work always runs as the
authenticated caller. Downloads respect transport readiness and use a dedicated bounded executor. The
owner must call close() when disposing a directly constructed adapter.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcContentService(org.alfresco.service.ServiceRegistry services) Creates the content adapter; non-plain-text extraction is unavailable without a transform client.GrpcContentService(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms) Creates the adapter and its repository helpers without starting repository work. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Cancels active transfers and releases download workers and upload staging resources.voiddownloadContent(org.saidone.unrest.api.DownloadContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.DownloadContentResponse> observer) Streams stored document bytes without text extraction.voidgetReader(org.saidone.unrest.api.GetContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.GetContentResponse> observer) Returns a bounded slice of stored bytes or extracted UTF-8 text.voidgetWriter(org.saidone.unrest.api.UpdateContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Replaces the stored bytes of an existing document and returns its updated metadata.io.grpc.stub.StreamObserver<org.saidone.unrest.api.UploadContentRequest> replaceContent(io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Streams replacement bytes for an existing document, identified by header.parent_ref.io.grpc.stub.StreamObserver<org.saidone.unrest.api.UploadContentRequest> uploadContent(io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Creates a new document from a client stream consisting of one header followed by data chunks.Methods inherited from class org.saidone.unrest.api.ContentServiceGrpc.ContentServiceImplBase
bindService
-
Constructor Details
-
GrpcContentService
public GrpcContentService(org.alfresco.service.ServiceRegistry services) Creates the content adapter; non-plain-text extraction is unavailable without a transform client.- Parameters:
services- Alfresco service registry; repository work uses its secured services
-
GrpcContentService
public GrpcContentService(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms) Creates the adapter and its repository helpers without starting repository work.- Parameters:
services- Alfresco service registry; repository work uses its secured servicestransforms- synchronous text-transform client, or null to disable non-plain-text extraction
-
-
Method Details
-
getReader
public void getReader(org.saidone.unrest.api.GetContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.GetContentResponse> observer) Returns a bounded slice of stored bytes or extracted UTF-8 text. Offsets are byte offsets in the selected representation. A zero limit selects 2 MiB; explicit limits must be 1..2 MiB. Text slices avoid ending inside a UTF-8 character. Text offsets inside a character and limits too small for the first character yieldINVALID_ARGUMENT; callers must use a character boundary and a sufficient byte limit.A missing transform facility or unsupported input format yields
FAILED_PRECONDITION; transform content failures yieldUNAVAILABLE. This RPC materializes bytes rather than returning an Alfresco reader handle.- Specified by:
getReaderin interfaceorg.saidone.unrest.api.ContentServiceGrpc.AsyncService- Parameters:
request- document reference, text-extraction flag, byte offset and slice limitobserver- receives one content slice with total size and continuation flag, or a gRPC error
-
getWriter
public void getWriter(org.saidone.unrest.api.UpdateContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Replaces the stored bytes of an existing document and returns its updated metadata. Content must be supplied; empty bytes are allowed. A blank MIME type is guessed from the node name and a blank encoding defaults to UTF-8.This remote adaptation performs the write immediately rather than returning an Alfresco writer handle. The request must fit the configured inbound message size.
- Specified by:
getWriterin interfaceorg.saidone.unrest.api.ContentServiceGrpc.AsyncService- Parameters:
request- document reference and required content bytes with optional MIME type and encodingobserver- receives one updated document snapshot, or a gRPC error
-
downloadContent
public void downloadContent(org.saidone.unrest.api.DownloadContentRequest request, io.grpc.stub.StreamObserver<org.saidone.unrest.api.DownloadContentResponse> observer) Streams stored document bytes without text extraction. The response starts with content metadata, followed by data messages of at most 1 MiB. A document without stored content emits only metadata.The reader is resolved transactionally as the caller; bytes are emitted afterwards so transaction retries cannot duplicate output. I/O failures yield
INTERNAL; client cancellation stops the transfer. Excess concurrent transfers yield RESOURCE_EXHAUSTED; paused transfers retain their slot.- Specified by:
downloadContentin interfaceorg.saidone.unrest.api.ContentServiceGrpc.AsyncService- Parameters:
request- document or frozen-version node reference to downloadobserver- receives metadata followed by ordered byte chunks, then completion, or a gRPC error
-
close
public void close()Cancels active transfers and releases download workers and upload staging resources.- Specified by:
closein interfaceAutoCloseable
-
uploadContent
public io.grpc.stub.StreamObserver<org.saidone.unrest.api.UploadContentRequest> uploadContent(io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Creates a new document from a client stream consisting of one header followed by data chunks.Bytes are staged before repository creation; no node is created until the client completes. The maximum total payload is
MAX_UPLOAD_BYTES. Protocol violations and excess size yieldINVALID_ARGUMENT; missing caller identity yieldsUNAUTHENTICATED. Exhausted concurrency or temporary-storage budgets yieldRESOURCE_EXHAUSTED. Memory pressure falls back to disk.- Specified by:
uploadContentin interfaceorg.saidone.unrest.api.ContentServiceGrpc.AsyncService- Parameters:
observer- receives one created document after commit, or a gRPC error- Returns:
- a request observer that consumes the header and content chunks
-
replaceContent
public io.grpc.stub.StreamObserver<org.saidone.unrest.api.UploadContentRequest> replaceContent(io.grpc.stub.StreamObserver<org.saidone.unrest.api.Node> observer) Streams replacement bytes for an existing document, identified by header.parent_ref.- Specified by:
replaceContentin interfaceorg.saidone.unrest.api.ContentServiceGrpc.AsyncService
-