Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

org.alfresco.service.cmr.repository
Interface ContentWriter
All Superinterfaces:
ContentAccessor
All Known Implementing Classes:
AbstractContentWriter, FileContentWriter

@org.alfresco.api.AlfrescoPublicApi
public interface ContentWriter
extends ContentAccessor
Represents a handle to write specific content. Content may only be accessed once per instance.

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.

Author:
Derek Hulley
See Also:
ContentReader

Method Summary
getContentOutputStream()
          Get a stream to write to the underlying channel.
getFileChannel(boolean truncate)
          Provides read-write, random-access to the underlying content.
getReader()
          Convenience method to get a reader onto newly written content.
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.
Methods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
addListener, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, isChannelOpen, setEncoding, setLocale, setMimetype
Method Detail
getReader
ContentReader getReader()
                 throws ContentIOException
Convenience method to get a reader onto newly written content. This method will return null if the content has not yet been written by the writer or if the output stream is still open.
Returns:
Returns a reader onto the underlying content that this writer will or has written to
Throws:
ContentIOException

isClosed
boolean isClosed()
Convenience method to find out if this writer has been closed. Once closed, the content can no longer be written to and it become possible to get readers onto the written content.
Returns:
Return true if the content output stream has been used and closed otherwise false.

getWritableChannel
WritableByteChannel getWritableChannel()
                                throws ContentIOException
Provides low-level access to write to repository content.

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.

Returns:
Returns a channel with which to write content
Throws:
ContentIOException

getFileChannel
FileChannel getFileChannel(boolean truncate)
                    throws ContentIOException
Provides read-write, random-access to the underlying content. In general, this method should be considered more expensive than the sequential-access method, getWritableChannel().

Underlying implementations use the truncate parameter to determine the most effective means of providing access to the content.

Parameters:
truncate - true to start with zero length content
Returns:
Returns a random-access channel onto the content
Throws:
ContentIOException
See Also:
getWritableChannel(), RandomAccessFile.getChannel()

getContentOutputStream
OutputStream getContentOutputStream()
                             throws ContentIOException
Get a stream to write to the underlying channel.
Returns:
Returns an output stream onto the underlying channel
Throws:
ContentIOException
See Also:
getWritableChannel()

putContent
void putContent(ContentReader reader)
         throws ContentIOException
Copies content from the reader.

All resources will be closed automatically.

Parameters:
reader - the reader acting as the source of the content
Throws:
ContentIOException
See Also:
getWritableChannel()

putContent
void putContent(InputStream is)
         throws ContentIOException
Puts content to the repository

All resources will be closed automatically.

Parameters:
is - the input stream from which the content will be read
Throws:
ContentIOException
See Also:
getWritableChannel()

putContent
void putContent(File file)
         throws ContentIOException
Puts content to the repository direct from file

All resources will be closed automatically.

Parameters:
file - the file to load the content from
Throws:
ContentIOException
See Also:
getWritableChannel()

putContent
void putContent(String content)
         throws ContentIOException
Puts content to the repository direct from 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.

Parameters:
content - a string representation of the content
Throws:
ContentIOException
See Also:
getWritableChannel(), String.getBytes(java.lang.String)

guessMimetype
void guessMimetype(String filename)
Attempts to guess the mimetype of the Content based on the contents and the 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.

Parameters:
filename - The filename of the content (if known)

guessEncoding
void guessEncoding()
Attempts to guess the encoding of the Content based on the contents.

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.


Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2018 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.