Package org.alfresco.repo.content
Class AbstractContentReader
- java.lang.Object
-
- org.alfresco.repo.content.AbstractContentAccessor
-
- org.alfresco.repo.content.AbstractContentReader
-
- All Implemented Interfaces:
org.alfresco.service.cmr.repository.ContentAccessor,org.alfresco.service.cmr.repository.ContentReader
- Direct Known Subclasses:
EmptyContentReader,FileContentReader,HttpAlfrescoContentReader,SpoofedTextContentReader
@AlfrescoPublicApi public abstract class AbstractContentReader extends AbstractContentAccessor implements org.alfresco.service.cmr.repository.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(java.lang.String contentUrl)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(org.alfresco.service.cmr.repository.ContentStreamListener listener)Adds the listener after checking that the output stream isn't already in use.static booleancompareContentReaders(org.alfresco.service.cmr.repository.ContentReader left, org.alfresco.service.cmr.repository.ContentReader right)Does a comparison of the binaries associated with two readers.protected abstract org.alfresco.service.cmr.repository.ContentReadercreateReader()A factory method for subclasses to implement that will ensure the proper implementation of theContentReader.getReader()method.voidgetContent(java.io.File file)voidgetContent(java.io.OutputStream os)Copies theinput streamto the givenOutputStreamjava.io.InputStreamgetContentInputStream()java.lang.StringgetContentString()Makes use of the encoding, if available, to convert bytes to a string.java.lang.StringgetContentString(int length)protected abstract java.nio.channels.ReadableByteChannelgetDirectReadableChannel()Provides low-level access to read content from the repository.java.nio.channels.FileChannelgetFileChannel()TransformationOptionLimitsgetLimits()Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.java.nio.channels.ReadableByteChannelgetReadableChannel()org.alfresco.service.cmr.repository.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
-
-
-
-
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:
addListenerin interfaceorg.alfresco.service.cmr.repository.ContentAccessor
-
createReader
protected abstract org.alfresco.service.cmr.repository.ContentReader createReader() throws org.alfresco.service.cmr.repository.ContentIOExceptionA 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:
org.alfresco.service.cmr.repository.ContentIOException
-
getReader
public final org.alfresco.service.cmr.repository.ContentReader getReader() throws org.alfresco.service.cmr.repository.ContentIOExceptionPerforms checks and copies required reader attributes- Specified by:
getReaderin interfaceorg.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:
isClosedin interfaceorg.alfresco.service.cmr.repository.ContentReader
-
isChannelOpen
public boolean isChannelOpen()
- Specified by:
isChannelOpenin interfaceorg.alfresco.service.cmr.repository.ContentAccessor
-
getDirectReadableChannel
protected abstract java.nio.channels.ReadableByteChannel getDirectReadableChannel() throws org.alfresco.service.cmr.repository.ContentIOExceptionProvides 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:
getReadableChannelin interfaceorg.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:
getFileChannelin interfaceorg.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:
getContentInputStreamin interfaceorg.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.ContentIOExceptionCopies theinput streamto the givenOutputStream- Specified by:
getContentin interfaceorg.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:
getContentin interfaceorg.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:
getContentStringin interfaceorg.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.ContentIOExceptionMakes 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 interfaceorg.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.ContentIOExceptionDoes 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:
org.alfresco.service.cmr.repository.ContentIOException
-
-