Class FileContentWriter
java.lang.Object
org.alfresco.repo.content.AbstractContentAccessor
org.alfresco.repo.content.AbstractContentWriter
org.alfresco.repo.content.filestore.FileContentWriter
- All Implemented Interfaces:
ContentAccessor,ContentWriter,MimetypeServiceAware
- Direct Known Subclasses:
ContentCacheImpl.CacheWriter
Provides direct access to a local file.
This class does not provide remote access to the file.
- Author:
- Derek Hulley
-
Nested Class Summary
Nested classes/interfaces inherited from class org.alfresco.repo.content.AbstractContentAccessor
AbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise -
Constructor Summary
ConstructorsConstructorDescriptionFileContentWriter(File file) Constructor that builds a URL based on the absolute path of the file.FileContentWriter(File file, String url, ContentReader existingContentReader) Constructor that explicitely sets the URL that the reader represents.FileContentWriter(File file, ContentReader existingContentReader) Constructor that builds a URL based on the absolute path of the file. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanWrite()protected ContentReaderThe URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t. the stream state.protected WritableByteChannelProvides low-level access to write content to the repository.getFile()longgetSize()Methods inherited from class org.alfresco.repo.content.AbstractContentWriter
addListener, getContentLimitProvider, getContentOutputStream, getExistingContentReader, getFileChannel, getReader, getWritableChannel, guessEncoding, guessMimetype, isChannelOpen, isClosed, putContent, putContent, putContent, putContent, setContentLimitProvider, setMimetypeServiceMethods inherited from class org.alfresco.repo.content.AbstractContentAccessor
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, toStringMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setEncoding, setLocale, setMimetype
-
Constructor Details
-
FileContentWriter
Constructor that builds a URL based on the absolute path of the file.- Parameters:
file- the file for writing. This will most likely be directly related to the content URL.
-
FileContentWriter
Constructor that builds a URL based on the absolute path of the file.- Parameters:
file- the file for writing. This will most likely be directly related to the content URL.existingContentReader- a reader of a previous version of this content
-
FileContentWriter
Constructor that explicitely sets the URL that the reader represents.- Parameters:
file- the file for writing. This will most likely be directly related to the content URL.url- the relative url that the reader representsexistingContentReader- a reader of a previous version of this content
-
-
Method Details
-
getFile
- Returns:
- Returns the file that this writer accesses
-
getSize
public long getSize()- Returns:
- Returns the size of the underlying file or
-
createReader
The URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t. the stream state.- Specified by:
createReaderin classAbstractContentWriter- Returns:
- Returns a reader onto the location referenced by this instance. The instance must always be a new instance and never null.
- Throws:
ContentIOException
-
getDirectWritableChannel
Description copied from class:AbstractContentWriterProvides low-level access to write content to the repository.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.
- Specified by:
getDirectWritableChannelin classAbstractContentWriter- Returns:
- Returns a channel with which to write content
- Throws:
ContentIOException- if the channel could not be opened
-
canWrite
public boolean canWrite()- Returns:
- Returns true always
-