Class AbstractContentReader

    • Constructor Detail

      • AbstractContentReader

        protected AbstractContentReader​(java.lang.String contentUrl)
        Parameters:
        contentUrl - the content URL - this should be relative to the root of the store and not absolute: to enable moving of the stores
    • Method Detail

      • setLimits

        @Deprecated
        public void setLimits​(TransformationOptionLimits limits)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      • getLimits

        @Deprecated
        public TransformationOptionLimits getLimits()
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      • setTransformerDebug

        @Deprecated
        public void setTransformerDebug​(TransformerDebug transformerDebug)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      • getTransformerDebug

        @Deprecated
        public TransformerDebug getTransformerDebug()
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      • setUseBufferedInputStream

        public void setUseBufferedInputStream​(boolean useBufferedInputStream)
      • getUseBufferedInputStream

        public boolean getUseBufferedInputStream()
      • addListener

        public void addListener​(org.alfresco.service.cmr.repository.ContentStreamListener listener)
        Adds the listener after checking that the output stream isn't already in use.
        Specified by:
        addListener in interface org.alfresco.service.cmr.repository.ContentAccessor
      • createReader

        protected abstract org.alfresco.service.cmr.repository.ContentReader createReader()
                                                                                   throws org.alfresco.service.cmr.repository.ContentIOException
        A factory method for subclasses to implement that will ensure the proper implementation of the ContentReader.getReader() method.

        Only the instance need be constructed. The required mimetype, encoding, etc will be copied across by this class.

        Returns:
        Returns a reader onto the location referenced by this instance. The instance must always be a new instance.
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • getReader

        public final org.alfresco.service.cmr.repository.ContentReader getReader()
                                                                          throws org.alfresco.service.cmr.repository.ContentIOException
        Performs checks and copies required reader attributes
        Specified by:
        getReader in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • isClosed

        public final boolean isClosed()
        An automatically created listener sets the flag
        Specified by:
        isClosed in interface org.alfresco.service.cmr.repository.ContentReader
      • isChannelOpen

        public boolean isChannelOpen()
        Specified by:
        isChannelOpen in interface org.alfresco.service.cmr.repository.ContentAccessor
      • getDirectReadableChannel

        protected abstract java.nio.channels.ReadableByteChannel getDirectReadableChannel()
                                                                                   throws org.alfresco.service.cmr.repository.ContentIOException
        Provides low-level access to read content from the repository.

        This is the only of the content reading methods that needs to be implemented by derived classes. All other content access methods make use of this in their underlying implementations.

        Returns:
        Returns a channel from which content can be read
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException - if the channel could not be opened or the underlying content has disappeared
      • getReadableChannel

        public final java.nio.channels.ReadableByteChannel getReadableChannel()
                                                                       throws org.alfresco.service.cmr.repository.ContentIOException
        Specified by:
        getReadableChannel in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
        See Also:
        getDirectReadableChannel(), getCallbackReadableChannel(ReadableByteChannel, List)
      • getFileChannel

        public java.nio.channels.FileChannel getFileChannel()
                                                     throws org.alfresco.service.cmr.repository.ContentIOException
        Specified by:
        getFileChannel in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • getContentInputStream

        public java.io.InputStream getContentInputStream()
                                                  throws org.alfresco.service.cmr.repository.ContentIOException
        Specified by:
        getContentInputStream in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
        See Also:
        Channels.newInputStream(java.nio.channels.ReadableByteChannel)
      • getContent

        public final void getContent​(java.io.OutputStream os)
                              throws org.alfresco.service.cmr.repository.ContentIOException
        Copies the input stream to the given OutputStream
        Specified by:
        getContent in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • getContent

        public final void getContent​(java.io.File file)
                              throws org.alfresco.service.cmr.repository.ContentIOException
        Specified by:
        getContent in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • getContentString

        public final java.lang.String getContentString​(int length)
                                                throws org.alfresco.service.cmr.repository.ContentIOException
        Specified by:
        getContentString in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
      • getContentString

        public final java.lang.String getContentString()
                                                throws org.alfresco.service.cmr.repository.ContentIOException
        Makes use of the encoding, if available, to convert bytes to a string.

        All the content is streamed into memory. So, like the interface said, be careful with this method.

        Specified by:
        getContentString in interface org.alfresco.service.cmr.repository.ContentReader
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException
        See Also:
        ContentAccessor.getEncoding()
      • compareContentReaders

        public static boolean compareContentReaders​(org.alfresco.service.cmr.repository.ContentReader left,
                                                    org.alfresco.service.cmr.repository.ContentReader right)
                                             throws org.alfresco.service.cmr.repository.ContentIOException
        Does a comparison of the binaries associated with two readers. Several shortcuts are assumed to be valid:
        - if the readers are the same instance, then the binaries are the same
        - if the size field is different, then the binaries are different
        Otherwise the binaries are compared.
        Returns:
        Returns true if the underlying binaries are the same
        Throws:
        org.alfresco.service.cmr.repository.ContentIOException