public abstract class FileMetadata
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FileMetadata.LockState |
static class |
FileMetadata.OpenState
The state of a file in a particular session.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
appendName
The name of the appendable version of this unfinalized file.
|
protected ContentType |
contentType |
protected java.lang.String |
currentSequenceKey
If this instance is for writing and it has not yet been finalized, then
this variable stores the current sequence key
|
protected boolean |
finalized |
protected java.lang.String |
readName
The name of the readable version of this file once it is finalized.
|
protected java.io.ByteArrayOutputStream |
tempBytes
If this instance is for writing and it has not yet been finalized, then
this variable stores the current bytes.
|
protected int |
tempBytesSizeWhenFinalized |
Constructor and Description |
---|
FileMetadata(java.lang.String readName,
java.lang.String appendName,
ContentType contentType) |
Modifier and Type | Method and Description |
---|---|
void |
append(AppendRequest request)
Handle an append request
|
protected static void |
checkParameters(java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.String... names) |
protected static long |
copy(java.io.InputStream from,
java.io.OutputStream to,
long maxBytes)
Copies
maxBytes bytes from the input stream to the output stream. |
java.lang.String |
getAppendName() |
abstract com.google.appengine.api.blobstore.BlobInfo |
getBlobInfo() |
ContentType |
getContentType() |
protected abstract java.io.InputStream |
getInputStream() |
FileMetadata.LockState |
getLockState(Session session) |
FileMetadata.OpenState |
getOpenState(Session session) |
protected abstract java.io.OutputStream |
getOutputStream() |
protected int |
getTempBytesSize() |
boolean |
isFinalized() |
boolean |
isOpenInDifferentSession(Session session) |
void |
lock(Session session) |
static FileMetadata |
newReadableInstance(LocalFileService localFileService,
Clock clock,
ParsedFileName parsedName)
Returns a new instance of
FileMetadata if possible. |
ByteString |
read(ReadRequest request)
Handle a Read request
|
protected void |
saveBlobInfo(com.google.appengine.api.datastore.DatastoreService datastore,
com.google.appengine.api.blobstore.BlobKey blobKey,
java.lang.String entityKind,
java.lang.String mimeType,
long currentTime,
java.lang.String fileName,
java.lang.String creationHandle) |
void |
setFinalized() |
void |
setState(FileMetadata.OpenState state,
Session session) |
protected ContentType contentType
protected boolean finalized
protected final java.lang.String readName
protected final java.lang.String appendName
protected java.lang.String currentSequenceKey
protected java.io.ByteArrayOutputStream tempBytes
protected int tempBytesSizeWhenFinalized
public FileMetadata(java.lang.String readName, java.lang.String appendName, ContentType contentType)
protected final int getTempBytesSize()
public java.lang.String getAppendName()
public void setFinalized()
public abstract com.google.appengine.api.blobstore.BlobInfo getBlobInfo()
BlobInfo
of the file. File must have been finalized.{@link
- IllegalStateException} if file is not finalized.{@link
- com.google.apphosting.api.ApiProxy.ApplicationException}
if the blobInfo can't be found for any other reasons.public boolean isFinalized()
public ContentType getContentType()
public void lock(Session session)
public FileMetadata.LockState getLockState(Session session)
public void setState(FileMetadata.OpenState state, Session session)
public FileMetadata.OpenState getOpenState(Session session)
public boolean isOpenInDifferentSession(Session session)
public ByteString read(ReadRequest request)
request
- the requestByteString
containing the read bytespublic void append(AppendRequest request)
request
- the requestprotected abstract java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
protected abstract java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
protected static void checkParameters(java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String... names)
protected static long copy(java.io.InputStream from, java.io.OutputStream to, long maxBytes) throws java.io.IOException
maxBytes
bytes from the input stream to the output stream.java.io.IOException
protected void saveBlobInfo(com.google.appengine.api.datastore.DatastoreService datastore, com.google.appengine.api.blobstore.BlobKey blobKey, java.lang.String entityKind, java.lang.String mimeType, long currentTime, java.lang.String fileName, java.lang.String creationHandle)
public static FileMetadata newReadableInstance(LocalFileService localFileService, Clock clock, ParsedFileName parsedName)
FileMetadata
if possible. This method is
called in response to an Open-for-Read request in the case that no
meta-data is found for the requested file in the in-memory cache. If it is
determined that the given file name corresponds to an existing, finalized
file, then an instance of FileMetadata
will be returned. Otherwise
null
will be returned.FileMetadata
or null
if no
corresponding entity could be found in the datastore.