@AlfrescoPublicApi public abstract class AbstractContentWriter extends AbstractContentAccessor implements org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.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,
org.alfresco.service.cmr.repository.ContentReader existingContentReader) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(org.alfresco.service.cmr.repository.ContentStreamListener listener)
Adds the listener after checking that the output stream isn't already in
use.
|
protected abstract org.alfresco.service.cmr.repository.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 org.alfresco.service.cmr.repository.ContentReader |
getExistingContentReader() |
FileChannel |
getFileChannel(boolean truncate) |
org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.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, toString
protected AbstractContentWriter(String contentUrl, org.alfresco.service.cmr.repository.ContentReader existingContentReader)
contentUrl
- the content URLexistingContentReader
- a reader of a previous version of this contentpublic void setContentLimitProvider(ContentLimitProvider limitProvider)
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
setMimetypeService
in interface org.alfresco.service.cmr.repository.MimetypeServiceAware
protected org.alfresco.service.cmr.repository.ContentReader getExistingContentReader()
public void addListener(org.alfresco.service.cmr.repository.ContentStreamListener listener)
addListener
in interface org.alfresco.service.cmr.repository.ContentAccessor
protected abstract org.alfresco.service.cmr.repository.ContentReader createReader() throws org.alfresco.service.cmr.repository.ContentIOException
ContentWriter.getReader()
method.
Only the instance need be constructed. The required mimetype, encoding, etc will be copied across by this class.
org.alfresco.service.cmr.repository.ContentIOException
public final org.alfresco.service.cmr.repository.ContentReader getReader() throws org.alfresco.service.cmr.repository.ContentIOException
getReader
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
protected ContentLimitProvider getContentLimitProvider()
ContentLimitProvider
for this writer.
By default a ContentLimitProvider.NoLimitProvider
will be returned.public final boolean isClosed()
isClosed
in interface org.alfresco.service.cmr.repository.ContentWriter
public boolean isChannelOpen()
isChannelOpen
in interface org.alfresco.service.cmr.repository.ContentAccessor
protected abstract WritableByteChannel getDirectWritableChannel() throws org.alfresco.service.cmr.repository.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.
org.alfresco.service.cmr.repository.ContentIOException
- if the channel could not be openedpublic final WritableByteChannel getWritableChannel() throws org.alfresco.service.cmr.repository.ContentIOException
getWritableChannel
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
getDirectWritableChannel()
,
getCallbackWritableChannel(java.nio.channels.WritableByteChannel, List)
public FileChannel getFileChannel(boolean truncate) throws org.alfresco.service.cmr.repository.ContentIOException
getFileChannel
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
public OutputStream getContentOutputStream() throws org.alfresco.service.cmr.repository.ContentIOException
getContentOutputStream
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
Channels.newOutputStream(java.nio.channels.WritableByteChannel)
public void putContent(org.alfresco.service.cmr.repository.ContentReader reader) throws org.alfresco.service.cmr.repository.ContentIOException
putContent
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
ContentReader.getContentInputStream()
,
putContent(InputStream)
public final void putContent(InputStream is) throws org.alfresco.service.cmr.repository.ContentIOException
putContent
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
public final void putContent(File file) throws org.alfresco.service.cmr.repository.ContentIOException
putContent
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
public final void putContent(String content) throws org.alfresco.service.cmr.repository.ContentIOException
putContent
in interface org.alfresco.service.cmr.repository.ContentWriter
org.alfresco.service.cmr.repository.ContentIOException
ContentAccessor.getEncoding()
public void guessEncoding()
guessEncoding
in interface org.alfresco.service.cmr.repository.ContentWriter
ContentWriter.guessEncoding()
public void guessMimetype(String filename)
guessMimetype
in interface org.alfresco.service.cmr.repository.ContentWriter
ContentWriter.guessMimetype(String)
Copyright © 2005–2017 Alfresco Software. All rights reserved.