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 Modifier Constructor Description protectedAbstractContentReader(String contentUrl)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(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 ContentReadercreateReader()A factory method for subclasses to implement that will ensure the proper implementation of theContentReader.getReader()method.voidgetContent(File file)voidgetContent(OutputStream os)Copies theinput streamto the givenOutputStreamInputStreamgetContentInputStream()StringgetContentString()Makes use of the encoding, if available, to convert bytes to a string.StringgetContentString(int length)protected abstract ReadableByteChannelgetDirectReadableChannel()Provides low-level access to read content from the repository.FileChannelgetFileChannel()TransformationOptionLimitsgetLimits()Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.ReadableByteChannelgetReadableChannel()ContentReadergetReader()Performs checks and copies required reader attributesTransformerDebuggetTransformerDebug()Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.booleangetUseBufferedInputStream()booleanisChannelOpen()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, toString
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetype
-
Methods inherited from interface org.alfresco.service.cmr.repository.ContentReader
exists, getLastModified
-
-
-
-
Constructor Detail
-
AbstractContentReader
protected AbstractContentReader(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(ContentStreamListener listener)
Adds the listener after checking that the output stream isn't already in use.- Specified by:
addListenerin interfaceContentAccessor
-
createReader
protected abstract ContentReader createReader() throws ContentIOException
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
public final ContentReader getReader() throws ContentIOException
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
protected abstract ReadableByteChannel getDirectReadableChannel() throws 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:
ContentIOException- if the channel could not be opened or the underlying content has disappeared
-
getReadableChannel
public final ReadableByteChannel getReadableChannel() throws ContentIOException
- Specified by:
getReadableChannelin interfaceContentReader- Throws:
ContentIOException- See Also:
getDirectReadableChannel(),getCallbackReadableChannel(ReadableByteChannel, List)
-
getFileChannel
public FileChannel getFileChannel() throws ContentIOException
- Specified by:
getFileChannelin interfaceContentReader- Throws:
ContentIOException
-
getContentInputStream
public InputStream getContentInputStream() throws ContentIOException
- Specified by:
getContentInputStreamin interfaceContentReader- Throws:
ContentIOException- See Also:
Channels.newInputStream(java.nio.channels.ReadableByteChannel)
-
getContent
public final void getContent(OutputStream os) throws ContentIOException
Copies theinput streamto the givenOutputStream- Specified by:
getContentin interfaceContentReader- Throws:
ContentIOException
-
getContent
public final void getContent(File file) throws ContentIOException
- Specified by:
getContentin interfaceContentReader- Throws:
ContentIOException
-
getContentString
public final String getContentString(int length) throws ContentIOException
- Specified by:
getContentStringin interfaceContentReader- Throws:
ContentIOException
-
getContentString
public final String getContentString() throws 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:
getContentStringin interfaceContentReader- Throws:
ContentIOException- See Also:
ContentAccessor.getEncoding()
-
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
-
-