Package org.alfresco.repo.content
Class AbstractContentReader
java.lang.Object
org.alfresco.repo.content.AbstractContentAccessor
org.alfresco.repo.content.AbstractContentReader
- All Implemented Interfaces:
ContentAccessor,ContentReader
- Direct Known Subclasses:
EmptyContentReader,FileContentReader,HttpAlfrescoContentReader,SpoofedTextContentReader
@AlfrescoPublicApi
public abstract class AbstractContentReader
extends AbstractContentAccessor
implements ContentReader
Implements all the convenience methods of the interface. The only methods that need to be implemented, i.e. provide low-level content access are:
createReader()to read content from the repositorygetDirectReadableChannel()to provide direct storage access
- Author:
- Derek Hulley
-
Nested Class Summary
Nested classes/interfaces inherited from class org.alfresco.repo.content.AbstractContentAccessor
AbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ContentStreamListener listener) Adds the listener after checking that the output stream isn't already in use.static booleancompareContentReaders(ContentReader left, ContentReader right) Does a comparison of the binaries associated with two readers.protected abstract ContentReaderA factory method for subclasses to implement that will ensure the proper implementation of theContentReader.getReader()method.final voidgetContent(File file) final voidCopies theinput streamto the givenOutputStreamfinal StringMakes use of the encoding, if available, to convert bytes to a string.final StringgetContentString(int length) protected abstract ReadableByteChannelProvides low-level access to read content from the repository.Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.final ReadableByteChannelfinal ContentReaderPerforms checks and copies required reader attributesDeprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.booleanbooleanfinal booleanisClosed()An automatically created listener sets the flagvoidsetLimits(TransformationOptionLimits limits) Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.voidsetTransformerDebug(TransformerDebug transformerDebug) Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.voidsetUseBufferedInputStream(boolean useBufferedInputStream) Methods inherited from class org.alfresco.repo.content.AbstractContentAccessor
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, toStringMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetypeMethods inherited from interface org.alfresco.service.cmr.repository.ContentReader
exists, getLastModified
-
Constructor Details
-
AbstractContentReader
- 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 Details
-
setLimits
Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. -
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.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. -
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
Adds the listener after checking that the output stream isn't already in use.- Specified by:
addListenerin interfaceContentAccessor
-
createReader
A factory method for subclasses to implement that will ensure the proper implementation of theContentReader.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:
ContentIOException
-
getReader
Performs checks and copies required reader attributes- Specified by:
getReaderin interfaceContentReader- Throws:
ContentIOException
-
isClosed
public final boolean isClosed()An automatically created listener sets the flag- Specified by:
isClosedin interfaceContentReader
-
isChannelOpen
public boolean isChannelOpen()- Specified by:
isChannelOpenin interfaceContentAccessor
-
getDirectReadableChannel
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:
ContentIOException- if the channel could not be opened or the underlying content has disappeared
-
getReadableChannel
- Specified by:
getReadableChannelin interfaceContentReader- Throws:
ContentIOException- See Also:
-
getDirectReadableChannel()getCallbackReadableChannel(ReadableByteChannel, List)
-
getFileChannel
- Specified by:
getFileChannelin interfaceContentReader- Throws:
ContentIOException
-
getContentInputStream
- Specified by:
getContentInputStreamin interfaceContentReader- Throws:
ContentIOException- See Also:
-
getContent
Copies theinput streamto the givenOutputStream- Specified by:
getContentin interfaceContentReader- Throws:
ContentIOException
-
getContent
- Specified by:
getContentin interfaceContentReader- Throws:
ContentIOException
-
getContentString
- Specified by:
getContentStringin interfaceContentReader- Throws:
ContentIOException
-
getContentString
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:
getContentStringin interfaceContentReader- Throws:
ContentIOException- See Also:
-
compareContentReaders
public static boolean compareContentReaders(ContentReader left, ContentReader right) throws 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 arecompared.- Returns:
- Returns true if the underlying binaries are the same
- Throws:
ContentIOException
-