@AlfrescoPublicApi public abstract class AbstractContentWriter extends AbstractContentAccessor implements ContentWriter, MimetypeServiceAware
getReader() to create a reader to the underlying contentgetDirectWritableChannel() to write content to the repositoryAbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise| Modifier | Constructor and Description |
|---|---|
protected |
AbstractContentWriter(String contentUrl,
ContentReader existingContentReader) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ContentStreamListener listener)
Adds the listener after checking that the output stream isn't already in
use.
|
protected abstract ContentReader |
createReader()
A factory method for subclasses to implement that will ensure the proper
implementation of the
ContentWriter.getReader() method. |
protected ContentLimitProvider |
getContentLimitProvider()
This method returns the configured
ContentLimitProvider for this writer. |
OutputStream |
getContentOutputStream() |
protected abstract WritableByteChannel |
getDirectWritableChannel()
Provides low-level access to write content to the repository.
|
protected ContentReader |
getExistingContentReader() |
FileChannel |
getFileChannel(boolean truncate) |
ContentReader |
getReader()
Performs checks and copies required reader attributes
|
WritableByteChannel |
getWritableChannel() |
void |
guessEncoding()
When the content has been written, attempt to guess
the encoding of it.
|
void |
guessMimetype(String filename)
When the content has been written, attempt to guess
the mimetype of it, using the filename and contents.
|
boolean |
isChannelOpen() |
boolean |
isClosed()
An automatically created listener sets the flag
|
void |
putContent(ContentReader reader) |
void |
putContent(File file) |
void |
putContent(InputStream is) |
void |
putContent(String content)
Makes use of the encoding, if available, to convert the string to bytes.
|
void |
setContentLimitProvider(ContentLimitProvider limitProvider) |
void |
setMimetypeService(MimetypeService mimetypeService)
Supplies the Mimetype Service to be used when guessing
encoding and mimetype information.
|
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, toStringclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetypeprotected AbstractContentWriter(String contentUrl, ContentReader existingContentReader)
contentUrl - the content URLexistingContentReader - a reader of a previous version of this contentpublic void setContentLimitProvider(ContentLimitProvider limitProvider)
public void setMimetypeService(MimetypeService mimetypeService)
setMimetypeService in interface MimetypeServiceAwareprotected ContentReader getExistingContentReader()
public void addListener(ContentStreamListener listener)
addListener in interface ContentAccessorprotected abstract ContentReader createReader() throws ContentIOException
ContentWriter.getReader() method.
Only the instance need be constructed. The required mimetype, encoding, etc will be copied across by this class.
ContentIOExceptionpublic final ContentReader getReader() throws ContentIOException
getReader in interface ContentWriterContentIOExceptionprotected ContentLimitProvider getContentLimitProvider()
ContentLimitProvider for this writer.
By default a ContentLimitProvider.NoLimitProvider will be returned.public final boolean isClosed()
isClosed in interface ContentWriterpublic boolean isChannelOpen()
isChannelOpen in interface ContentAccessorprotected abstract WritableByteChannel getDirectWritableChannel() throws ContentIOException
This is the only of the content writing methods that needs to be implemented by derived classes. All other content access methods make use of this in their underlying implementations.
ContentIOException - if the channel could not be openedpublic final WritableByteChannel getWritableChannel() throws ContentIOException
getWritableChannel in interface ContentWriterContentIOExceptiongetDirectWritableChannel(),
getCallbackWritableChannel(java.nio.channels.WritableByteChannel, List)public FileChannel getFileChannel(boolean truncate) throws ContentIOException
getFileChannel in interface ContentWriterContentIOExceptionpublic OutputStream getContentOutputStream() throws ContentIOException
getContentOutputStream in interface ContentWriterContentIOExceptionChannels.newOutputStream(java.nio.channels.WritableByteChannel)public void putContent(ContentReader reader) throws ContentIOException
putContent in interface ContentWriterContentIOExceptionContentReader.getContentInputStream(),
putContent(InputStream)public final void putContent(InputStream is) throws ContentIOException
putContent in interface ContentWriterContentIOExceptionpublic final void putContent(File file) throws ContentIOException
putContent in interface ContentWriterContentIOExceptionpublic final void putContent(String content) throws ContentIOException
putContent in interface ContentWriterContentIOExceptionContentAccessor.getEncoding()public void guessEncoding()
guessEncoding in interface ContentWriterContentWriter.guessEncoding()public void guessMimetype(String filename)
guessMimetype in interface ContentWriterContentWriter.guessMimetype(String)Copyright © 2005–2021 Alfresco Software. All rights reserved.