@AlfrescoPublicApi public interface ContentWriter extends ContentAccessor
Implementations of this interface might be Serializable
but client code could should check suitability before attempting to serialize
it.
Implementations that are able to provide inter-VM streaming, such as accessing
WebDAV, would be Serializable
. An accessor that has to access a
local file on the server could not provide inter-VM streaming unless it specifically
makes remote calls and opens sockets, etc.
ContentReader
Modifier and Type | Method and Description |
---|---|
OutputStream |
getContentOutputStream()
Get a stream to write to the underlying channel.
|
FileChannel |
getFileChannel(boolean truncate)
Provides read-write, random-access to the underlying content.
|
ContentReader |
getReader()
Convenience method to get a reader onto newly written content.
|
WritableByteChannel |
getWritableChannel()
Provides low-level access to write to repository content.
|
void |
guessEncoding()
Attempts to guess the encoding of the Content based on
the contents.
|
void |
guessMimetype(String filename)
Attempts to guess the mimetype of the Content based on
the contents and the filename.
|
boolean |
isClosed()
Convenience method to find out if this writer has been closed.
|
void |
putContent(ContentReader reader)
Copies content from the reader.
|
void |
putContent(File file)
Puts content to the repository direct from file
|
void |
putContent(InputStream is)
Puts content to the repository
|
void |
putContent(String content)
Puts content to the repository direct from
String . |
addListener, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, isChannelOpen, setEncoding, setLocale, setMimetype
ContentReader getReader() throws ContentIOException
ContentIOException
boolean isClosed()
WritableByteChannel getWritableChannel() throws ContentIOException
The channel returned to the client should remain open (subject to timeouts) until closed by the client. All lock detection, read-only access and other concurrency issues are dealt with during this operation. It remains possible that implementations will throw exceptions when the channel is closed.
The stream will notify any listeners according to the listener interface.
ContentIOException
FileChannel getFileChannel(boolean truncate) throws ContentIOException
getWritableChannel()
.
Underlying implementations use the truncate
parameter to determine the
most effective means of providing access to the content.
truncate
- true to start with zero length contentContentIOException
getWritableChannel()
,
RandomAccessFile.getChannel()
OutputStream getContentOutputStream() throws ContentIOException
ContentIOException
getWritableChannel()
void putContent(ContentReader reader) throws ContentIOException
All resources will be closed automatically.
reader
- the reader acting as the source of the contentContentIOException
getWritableChannel()
void putContent(InputStream is) throws ContentIOException
All resources will be closed automatically.
is
- the input stream from which the content will be readContentIOException
getWritableChannel()
void putContent(File file) throws ContentIOException
All resources will be closed automatically.
file
- the file to load the content fromContentIOException
getWritableChannel()
void putContent(String content) throws ContentIOException
String
.
If the encoding
is known then it will be used
otherwise the default system String to byte[] conversion
will be used.
All resources will be closed automatically.
content
- a string representation of the contentContentIOException
getWritableChannel()
,
String.getBytes(java.lang.String)
void guessMimetype(String filename)
If the content has already been written, then the mimetype guessing will occur immediately. If the content has yet to be written, then the guessing will occur once the content write has completed.
filename
- The filename of the content (if known)void guessEncoding()
If the content has already been written, then the encoding guessing will occur immediately. If the content has yet to be written, then the guessing will occur once the content write has completed.
Copyright © 2005–2018 Alfresco Software. All rights reserved.