Class ValueFactoryImpl

java.lang.Object
org.apache.jackrabbit.oak.plugins.value.jcr.PartialValueFactory
org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl
All Implemented Interfaces:
ValueFactory, JackrabbitValueFactory

public class ValueFactoryImpl extends PartialValueFactory implements JackrabbitValueFactory
Implementation of ValueFactory interface.
  • Constructor Details

    • ValueFactoryImpl

      public ValueFactoryImpl(@NotNull @NotNull Root root, @NotNull @NotNull NamePathMapper namePathMapper, @NotNull @NotNull org.apache.jackrabbit.oak.api.blob.BlobAccessProvider blobAccessProvider)
      Creates a new instance of ValueFactory.
      Parameters:
      root - the root instance for creating binary values
      namePathMapper - The name/path mapping used for converting JCR names/paths to
      blobAccessProvider - The blob access provider the internal representation.
    • ValueFactoryImpl

      public ValueFactoryImpl(@NotNull @NotNull Root root, @NotNull @NotNull NamePathMapper namePathMapper)
      Creates a new instance of ValueFactory. The Values created by this value factory instance will not be backed by a blob access provider and never return a download URI for a binary value.
      Parameters:
      root - the root instance for creating binary values
      namePathMapper - The name/path mapping used for converting JCR names/paths to the internal representation.
  • Method Details

    • createValue

      @NotNull public @NotNull Value createValue(@NotNull @NotNull InputStream value)
      Description copied from interface: ValueFactory
      Returns a Value object of PropertyType.BINARY with a value consisting of the content of the specified InputStream.

      The passed InputStream is closed before this method returns either normally or because of an exception.

      Specified by:
      createValue in interface ValueFactory
      Parameters:
      value - an InputStream
      Returns:
      a Value of PropertyType.BINARY
    • createValue

      @NotNull public @NotNull Value createValue(@NotNull @NotNull Binary value)
      Description copied from interface: ValueFactory
      Returns a Value object of PropertyType.BINARY with a value consisting of the content of the specified Binary.
      Specified by:
      createValue in interface ValueFactory
      Parameters:
      value - a Binary
      Returns:
      a Value of PropertyType.BINARY
    • createBinary

      @NotNull public @NotNull Binary createBinary(@NotNull @NotNull InputStream stream) throws RepositoryException
      Description copied from interface: ValueFactory
      Returns a Binary object with a value consisting of the content of the specified InputStream.

      The passed InputStream is closed before this method returns either normally or because of an exception.

      Specified by:
      createBinary in interface ValueFactory
      Parameters:
      stream - an InputStream
      Returns:
      a Binary
      Throws:
      RepositoryException - if an error occurs.
    • initiateBinaryUpload

      @Nullable public @Nullable BinaryUpload initiateBinaryUpload(long maxSize, int maxParts)
      Description copied from interface: JackrabbitValueFactory
      Initiate a transaction to upload a binary directly to a storage location and return BinaryUpload instructions for a remote client. Returns null if the feature is not available.

      IllegalArgumentException will be thrown if an upload cannot be supported for the required parameters, or if the parameters are otherwise invalid. Each service provider has specific limitations.

      Specified by:
      initiateBinaryUpload in interface JackrabbitValueFactory
      Parameters:
      maxSize - The exact size of the binary to be uploaded or the estimated maximum size if the exact size is unknown. If the estimation was too small, the transaction should be restarted by invoking this method again using the correct size.
      maxParts - The maximum number of upload URIs that the client can accept, for example due to message size limitations. A value of -1 indicates no limit. Upon a successful return, it is ensured that an upload of maxSize can be completed by splitting the binary into maxURIs parts, otherwise IllegalArgumentException will be thrown.
      Returns:
      A BinaryUpload providing the upload instructions, or null if the implementation does not support the direct upload feature.
    • initiateBinaryUpload

      @Nullable public @Nullable BinaryUpload initiateBinaryUpload(long maxSize, int maxParts, @NotNull @NotNull BinaryUploadOptions options)
      Description copied from interface: JackrabbitValueFactory
      Initiate a transaction to upload a binary directly to a storage location and return BinaryUpload instructions for a remote client. Returns null if the feature is not available.

      IllegalArgumentException will be thrown if an upload cannot be supported for the required parameters, or if the parameters are otherwise invalid. Each service provider has specific limitations.

      Specified by:
      initiateBinaryUpload in interface JackrabbitValueFactory
      Parameters:
      maxSize - The exact size of the binary to be uploaded or the estimated maximum size if the exact size is unknown. If the estimation was too small, the transaction should be restarted by invoking this method again using the correct size.
      maxParts - The maximum number of upload URIs that the client can accept, for example due to message size limitations. A value of -1 indicates no limit. Upon a successful return, it is ensured that an upload of maxSize can be completed by splitting the binary into maxURIs parts, otherwise IllegalArgumentException will be thrown.
      options - A BinaryUploadOptions instance containing any options for this call.
      Returns:
      A BinaryUpload providing the upload instructions, or null if the implementation does not support the direct upload feature.
    • completeBinaryUpload

      @Nullable public @Nullable Binary completeBinaryUpload(@NotNull @NotNull String uploadToken) throws RepositoryException
      Description copied from interface: JackrabbitValueFactory
      Complete the transaction of uploading a binary directly to a storage location and return a Binary to set as value for a binary JCR property. The binary is not automatically associated with any location in the JCR.

      The client must provide a valid upload token, obtained from BinaryUpload.getUploadToken() when this transaction was initialized using JackrabbitValueFactory.initiateBinaryUpload(long, int). If the uploadToken is unreadable or invalid, an IllegalArgumentException will be thrown. This method is idempotent. Calling the method more than one time with the same upload token must not cause an existing binary to be modified; thus if a prior call with this upload token succeeded in creating the binary, subsequent calls with the same upload token have no effect on the binary. This method should always return the binary that was uploaded with this upload token, even in subsequent calls with the same upload token (in other words, calling this method twice with the same upload token results in the same binary being returned both times).

      Specified by:
      completeBinaryUpload in interface JackrabbitValueFactory
      Parameters:
      uploadToken - A String identifying the upload transaction.
      Returns:
      The uploaded Binary, or null if the implementation does not support the direct upload feature.
      Throws:
      RepositoryException - if another error occurs.
    • createBinary

      @Nullable public @Nullable Binary createBinary(Blob blob) throws RepositoryException
      Throws:
      RepositoryException
    • getBlob

      @Nullable public @Nullable Blob getBlob(Binary binary) throws RepositoryException
      Throws:
      RepositoryException