public class PreviewStorage extends java.lang.Object implements java.io.Serializable, LRUStorageManagedDirectory.DeleteHandler
| Modifier and Type | Class and Description |
|---|---|
class |
PreviewStorage.NotifyingFileOutputStream |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CACHE_AGE
Max cache age in days - Redefine this constant to change the default policy.
|
static long |
MAX_CACHE_SIZE
Max cache size in bytes - Redefine this constant to change the default policy.
|
protected java.io.File |
mMetadataDirectory |
protected java.io.File |
mPreviewDirectory |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Long> |
mRecentlyWrittenFiles |
protected java.io.File |
mThumbnailDirectory |
protected static java.util.concurrent.atomic.AtomicLong |
TEMP_COUNTER |
protected java.lang.String |
TEMP_EXTENSION |
| Constructor and Description |
|---|
PreviewStorage(BoxSession session) |
PreviewStorage(BoxSession session,
long maxCacheSize,
int expirationDays)
Default implementation of Serializable PreviewStorage
|
| Modifier and Type | Method and Description |
|---|---|
void |
cacheMetadata(BoxItem boxItem,
java.lang.String tag)
Caches BoxItem metadata by writing the given object in a file.
|
void |
clearCacheForFile(BoxFile fileInfo)
Clears the storage of all files associated with the provided BoxFile
|
java.io.OutputStream |
createPreviewOutputStream(BoxFile boxFile)
This stream must be flushed upon successful completion.
|
java.io.OutputStream |
createPreviewOutputStream(BoxFile boxFile,
java.lang.String tag) |
java.io.OutputStream |
createThumbnailOutputStream(BoxFile boxFile)
Deprecated.
|
java.io.OutputStream |
createThumbnailOutputStream(BoxFile boxFile,
java.lang.String tag) |
java.io.InputStream |
getCachedPreview(BoxFile boxFile)
Deprecated.
|
java.io.InputStream |
getCachedPreview(BoxFile boxFile,
java.lang.String tag) |
java.io.File |
getCachedPreviewFile(BoxFile boxFile,
java.lang.String tag) |
java.io.InputStream |
getCachedThumbnail(BoxFile boxFile)
Deprecated.
|
java.io.InputStream |
getCachedThumbnail(BoxFile boxFile,
java.lang.String tag) |
java.io.File |
getCachedThumbnailFile(BoxFile boxFile,
java.lang.String tag) |
protected java.lang.String |
getCacheName(BoxItem boxItem,
java.lang.String tag,
java.lang.String ext) |
<T extends BoxItem> |
getMetadata(BoxItem boxItem,
java.lang.String tag)
Gets cached metadata for the given BoxItem.
|
protected java.io.File |
getMetadataFile(BoxFile boxFile,
java.lang.String tag) |
protected java.io.File |
getMetadataFile(BoxFolder boxFolder,
java.lang.String tag) |
protected java.io.File |
getPreviewFile(BoxFile boxFile,
java.lang.String tag) |
protected java.io.File |
getThumbnailFile(BoxFile boxFile,
java.lang.String tag) |
protected void |
init(BoxSession session) |
boolean |
isThumbnailFilePresent(BoxFile boxFile) |
boolean |
isThumbnailFilePresent(BoxFile boxFile,
java.lang.String tag) |
void |
onFileDeleted(java.io.File file,
boolean deleteSuccessful) |
boolean |
shouldDelete(java.io.File file) |
protected static transient java.util.concurrent.atomic.AtomicLong TEMP_COUNTER
protected final java.lang.String TEMP_EXTENSION
public static long MAX_CACHE_SIZE
public static int MAX_CACHE_AGE
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Long> mRecentlyWrittenFiles
protected java.io.File mThumbnailDirectory
protected java.io.File mPreviewDirectory
protected java.io.File mMetadataDirectory
public PreviewStorage(BoxSession session,
long maxCacheSize,
int expirationDays)
session - - BoxSession from the content sdk after the user is authenticatedmaxCacheSize - - Maximum size of the cache in bytes.expirationDays - - Days beyond which files in cache can be clearedpublic PreviewStorage(BoxSession session)
protected void init(BoxSession session)
public boolean shouldDelete(java.io.File file)
shouldDelete in interface LRUStorageManagedDirectory.DeleteHandlerfile - the file this class is planning to delete.public void onFileDeleted(java.io.File file,
boolean deleteSuccessful)
onFileDeleted in interface LRUStorageManagedDirectory.DeleteHandlerfile - the file this class attempted to delete.deleteSuccessful - true if the file was successfully deleted, false if the delete failed.@Deprecated public java.io.InputStream getCachedPreview(BoxFile boxFile)
public java.io.InputStream getCachedPreview(BoxFile boxFile,
java.lang.String tag)
public java.io.File getCachedPreviewFile(BoxFile boxFile,
java.lang.String tag)
@Deprecated public java.io.InputStream getCachedThumbnail(BoxFile boxFile)
public boolean isThumbnailFilePresent(BoxFile boxFile)
public boolean isThumbnailFilePresent(BoxFile boxFile,
java.lang.String tag)
public java.io.InputStream getCachedThumbnail(BoxFile boxFile,
java.lang.String tag)
public java.io.File getCachedThumbnailFile(BoxFile boxFile,
java.lang.String tag)
protected java.io.File getPreviewFile(BoxFile boxFile,
java.lang.String tag)
protected java.io.File getThumbnailFile(BoxFile boxFile,
java.lang.String tag)
protected java.io.File getMetadataFile(BoxFile boxFile,
java.lang.String tag)
protected java.io.File getMetadataFile(BoxFolder boxFolder,
java.lang.String tag)
protected java.lang.String getCacheName(BoxItem boxItem,
java.lang.String tag,
java.lang.String ext)
@Deprecated public java.io.OutputStream createThumbnailOutputStream(BoxFile boxFile)
boxFile - the box file to get stream for.public java.io.OutputStream createThumbnailOutputStream(BoxFile boxFile,
java.lang.String tag)
public java.io.OutputStream createPreviewOutputStream(BoxFile boxFile)
boxFile - the box file to get stream for.public java.io.OutputStream createPreviewOutputStream(BoxFile boxFile,
java.lang.String tag)
public void cacheMetadata(BoxItem boxItem,
java.lang.String tag)
boxItem - Given BoxItem objecttag - Metadata identifierpublic <T extends BoxItem> T getMetadata(BoxItem boxItem,
java.lang.String tag)
boxItem - Input Box itemtag - Metadata identifierpublic void clearCacheForFile(BoxFile fileInfo)
fileInfo - The BoxFile of the files that should be removed