|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.content.AbstractContentAccessor
org.alfresco.repo.content.AbstractContentWriter
public abstract class AbstractContentWriter
Implements all the convenience methods of the interface. The only methods that need to be implemented, i.e. provide low-level content access are:
AbstractContentWriter.getReader()
to create a reader to the underlying contentAbstractContentWriter.getDirectWritableChannel()
to write content to the repository
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.alfresco.repo.content.AbstractContentAccessor |
---|
AbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise |
Constructor Summary | |
---|---|
protected |
AbstractContentWriter(java.lang.String contentUrl,
ContentReader existingContentReader)
|
Method Summary | |
---|---|
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. |
java.io.OutputStream |
getContentOutputStream()
Get a stream to write to the underlying channel. |
protected abstract java.nio.channels.WritableByteChannel |
getDirectWritableChannel()
Provides low-level access to write content to the repository. |
protected ContentReader |
getExistingContentReader()
|
java.nio.channels.FileChannel |
getFileChannel(boolean truncate)
Provides read-write, random-access to the underlying content. |
ContentReader |
getReader()
Performs checks and copies required reader attributes |
java.nio.channels.WritableByteChannel |
getWritableChannel()
Provides low-level access to write to repository content. |
boolean |
isChannelOpen()
Gets the open/close state of the underlying IO Channel. |
boolean |
isClosed()
An automatically created listener sets the flag |
void |
putContent(ContentReader reader)
Copies content from the reader. |
void |
putContent(java.io.File file)
Puts content to the repository direct from file |
void |
putContent(java.io.InputStream is)
Puts content to the repository |
void |
putContent(java.lang.String content)
Makes use of the encoding, if available, to convert the string to bytes. |
Methods inherited from class org.alfresco.repo.content.AbstractContentAccessor |
---|
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, setRetryingTransactionHelper, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor |
---|
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetype, setRetryingTransactionHelper |
Constructor Detail |
---|
protected AbstractContentWriter(java.lang.String contentUrl, ContentReader existingContentReader)
contentUrl
- the content URLexistingContentReader
- a reader of a previous version of this contentMethod Detail |
---|
protected ContentReader getExistingContentReader()
public void addListener(ContentStreamListener listener)
addListener
in interface ContentAccessor
listener
- a listener that will be called for output stream
event notificationContentAccessor.setRetryingTransactionHelper(RetryingTransactionHelper)
protected 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.
ContentIOException
public final ContentReader getReader() throws ContentIOException
getReader
in interface ContentWriter
ContentIOException
public final boolean isClosed()
isClosed
in interface ContentWriter
public boolean isChannelOpen()
ContentAccessor
isChannelOpen
in interface ContentAccessor
protected abstract java.nio.channels.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 java.nio.channels.WritableByteChannel getWritableChannel() throws ContentIOException
ContentWriter
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.
getWritableChannel
in interface ContentWriter
ContentIOException
AbstractContentWriter.getDirectWritableChannel()
,
#getCallbackWritableChannel()
public java.nio.channels.FileChannel getFileChannel(boolean truncate) throws ContentIOException
ContentWriter.getWritableChannel()
.
Underlying implementations use the truncate
parameter to determine the
most effective means of providing access to the content.
getFileChannel
in interface ContentWriter
truncate
- true to start with zero length content
ContentIOException
ContentWriter.getWritableChannel()
,
RandomAccessFile.getChannel()
public java.io.OutputStream getContentOutputStream() throws ContentIOException
ContentWriter
getContentOutputStream
in interface ContentWriter
ContentIOException
Channels.newOutputStream(java.nio.channels.WritableByteChannel)
public void putContent(ContentReader reader) throws ContentIOException
ContentWriter
All resources will be closed automatically.
putContent
in interface ContentWriter
reader
- the reader acting as the source of the content
ContentIOException
ContentReader.getContentInputStream()
,
AbstractContentWriter.putContent(InputStream)
public final void putContent(java.io.InputStream is) throws ContentIOException
ContentWriter
All resources will be closed automatically.
putContent
in interface ContentWriter
is
- the input stream from which the content will be read
ContentIOException
ContentWriter.getWritableChannel()
public final void putContent(java.io.File file) throws ContentIOException
ContentWriter
All resources will be closed automatically.
putContent
in interface ContentWriter
file
- the file to load the content from
ContentIOException
ContentWriter.getWritableChannel()
public final void putContent(java.lang.String content) throws ContentIOException
putContent
in interface ContentWriter
content
- a string representation of the content
ContentIOException
ContentAccessor.getEncoding()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |