Class ContentServiceClient
Each call sends the shared provider's Alfresco ticket and a per-call deadline. Unary calls retry once after UNAUTHENTICATED if the provider supplies a different ticket. The caller owns the channel and should share one TicketProvider across service clients.
Downloads retry only before any payload bytes have been written. Uploads are never replayed because the supplied input stream may not be rewindable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMetadata and a single-use content stream owned by the caller. -
Constructor Summary
ConstructorsConstructorDescriptionContentServiceClient(io.grpc.Channel channel, TicketProvider tickets, Duration deadline) Creates this service client with shared authentication and a per-call deadline.ContentServiceClient(org.saidone.unrest.api.ContentServiceGrpc.ContentServiceBlockingStub stub, TicketProvider tickets, Duration deadline) Creates this service client with shared authentication and a per-call deadline. -
Method Summary
Modifier and TypeMethodDescriptionorg.saidone.unrest.api.ContentInfodownloadContent(String nodeRef, OutputStream out) Streams the stored bytes of a document intoout, which is not closed.org.saidone.unrest.api.GetContentResponseReads a bounded slice of stored content or extracted UTF-8 text, including continuation metadata.org.saidone.unrest.api.NodeReplaces an existing document's content immediately rather than returning a local writer handle.org.saidone.unrest.api.NodegetWriter(String nodeRef, org.saidone.unrest.api.Content content, com.google.protobuf.FieldMask fields) Replaces content and returns the selected response fields.openDownload(String nodeRef) Opens a pull-based download.openDownload(String nodeRef, org.saidone.unrest.api.DownloadRange range) Opens a download with an optional server-side byte range.org.saidone.unrest.api.NodereplaceContent(String nodeRef, String mimetype, String encoding, InputStream data) Replaces an existing document through bounded streaming, without closing or replaying the source.org.saidone.unrest.api.NodereplaceContent(String nodeRef, String mimetype, String encoding, InputStream data, com.google.protobuf.FieldMask fields) Replaces content and returns the selected response fields.org.saidone.unrest.api.NodeuploadContent(org.saidone.unrest.api.CreateDocumentHeader header, InputStream data) Creates a document: the header first, then the bytes ofdatain chunks of at most 1 MB.
-
Constructor Details
-
ContentServiceClient
Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
channel- shared gRPC channel; ownership remains with the callertickets- shared ticket provider, normally one AuthenticationServiceClientdeadline- per-call deadline applied to every RPC attempt
-
ContentServiceClient
public ContentServiceClient(org.saidone.unrest.api.ContentServiceGrpc.ContentServiceBlockingStub stub, TicketProvider tickets, Duration deadline) Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
stub- preconfigured stub for this repository servicetickets- shared ticket provider, normally one AuthenticationServiceClientdeadline- per-call deadline applied to every RPC attempt
-
-
Method Details
-
getReader
public org.saidone.unrest.api.GetContentResponse getReader(String nodeRef, boolean text, long offset, int maxBytes) Reads a bounded slice of stored content or extracted UTF-8 text, including continuation metadata.- Parameters:
nodeRef- node reference, bare workspace ID or supported repository aliastext- true for extracted UTF-8 text, false for the original stored bytesoffset- non-negative byte offset in the selected stored/text representationmaxBytes- maximum slice bytes; zero selects the server limit- Returns:
- the content slice, total representation size and continuation flag
-
getWriter
public org.saidone.unrest.api.Node getWriter(String nodeRef, org.saidone.unrest.api.Content content) Replaces an existing document's content immediately rather than returning a local writer handle.- Parameters:
nodeRef- node reference, bare workspace ID or supported repository aliascontent- document bytes and metadata; optional only on creation- Returns:
- the resulting node snapshot
-
getWriter
public org.saidone.unrest.api.Node getWriter(String nodeRef, org.saidone.unrest.api.Content content, com.google.protobuf.FieldMask fields) Replaces content and returns the selected response fields. -
downloadContent
Streams the stored bytes of a document intoout, which is not closed. The deadline covers the whole download. On UNAUTHENTICATED the ticket is renewed and the download retried once, but only while nothing has been written tooutyet; otherwise theStatusRuntimeExceptionis rethrown.- Parameters:
nodeRef- node reference, bare workspace ID or supported repository aliasout- destination stream, which remains open and owned by the caller- Returns:
- the stored content metadata; missing content has zero size
-
openDownload
Opens a pull-based download. Close its stream even when the response is only partially consumed. -
openDownload
public ContentServiceClient.Download openDownload(String nodeRef, org.saidone.unrest.api.DownloadRange range) Opens a download with an optional server-side byte range. -
uploadContent
public org.saidone.unrest.api.Node uploadContent(org.saidone.unrest.api.CreateDocumentHeader header, InputStream data) Creates a document: the header first, then the bytes ofdatain chunks of at most 1 MB. Returns the created node. The stream is read but not closed.The deadline covers the whole upload, so it must be generous for large files. An UNAUTHENTICATED answer drops the ticket (the next call logs in again) and rethrows the
StatusRuntimeException: this method is never retried, because the input stream cannot be rewound. Open the stream again and call it again.- Parameters:
header- parent, name, type, properties, aspects and content metadata of the new documentdata- source stream; it is read once and remains owned by the caller- Returns:
- the resulting node snapshot
-
replaceContent
public org.saidone.unrest.api.Node replaceContent(String nodeRef, String mimetype, String encoding, InputStream data) Replaces an existing document through bounded streaming, without closing or replaying the source. -
replaceContent
public org.saidone.unrest.api.Node replaceContent(String nodeRef, String mimetype, String encoding, InputStream data, com.google.protobuf.FieldMask fields) Replaces content and returns the selected response fields.
-