Class ContentServiceClient

java.lang.Object
org.saidone.unrest.client.ContentServiceClient

public class ContentServiceClient extends Object
Client of the platform's content service: byte slices, writes, downloads and streaming document creation.

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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    Metadata and a single-use content stream owned by the caller.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ContentServiceClient(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 Type
    Method
    Description
    org.saidone.unrest.api.ContentInfo
    Streams the stored bytes of a document into out, which is not closed.
    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.
    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.
    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.
    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.Node
    replaceContent(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.Node
    replaceContent(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.Node
    uploadContent(org.saidone.unrest.api.CreateDocumentHeader header, InputStream data)
    Creates a document: the header first, then the bytes of data in chunks of at most 1 MB.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContentServiceClient

      public ContentServiceClient(io.grpc.Channel channel, 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:
      channel - shared gRPC channel; ownership remains with the caller
      tickets - shared ticket provider, normally one AuthenticationServiceClient
      deadline - 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 service
      tickets - shared ticket provider, normally one AuthenticationServiceClient
      deadline - 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 alias
      text - true for extracted UTF-8 text, false for the original stored bytes
      offset - non-negative byte offset in the selected stored/text representation
      maxBytes - 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 alias
      content - 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

      public org.saidone.unrest.api.ContentInfo downloadContent(String nodeRef, OutputStream out)
      Streams the stored bytes of a document into out, 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 to out yet; otherwise the StatusRuntimeException is rethrown.
      Parameters:
      nodeRef - node reference, bare workspace ID or supported repository alias
      out - destination stream, which remains open and owned by the caller
      Returns:
      the stored content metadata; missing content has zero size
    • openDownload

      public ContentServiceClient.Download openDownload(String nodeRef)
      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 of data in 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 document
      data - 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.