public class DropboxBlobProvider extends AbstractBlobProvider implements BatchUpdateBlobProvider
blobProviderId, properties
MAX_RESULT
Constructor and Description |
---|
DropboxBlobProvider() |
Modifier and Type | Method and Description |
---|---|
protected static URI |
asURI(String link)
Parse a
URI . |
List<DocumentModel> |
checkChangesAndUpdateBlob(List<DocumentModel> docs)
Check the given list of document for change and update if needed.
|
void |
close()
Closes this blob provider and releases resources that may be held by it.
|
protected InputStream |
doGet(URI url)
Executes a GET request
|
ManagedBlob |
freezeVersion(ManagedBlob blob,
Document doc)
Returns a new managed blob pointing to a fixed version of the original blob.
|
Map<String,URI> |
getAvailableConversions(ManagedBlob blob,
BlobManager.UsageHint hint)
Gets a map of available MIME type conversions and corresponding
URI for a managed blob. |
protected Blob |
getBlob(String fileInfo)
Gets the blob for a Dropbox file.
|
String |
getBlobProviderId() |
protected String |
getClientId() |
InputStream |
getConvertedStream(ManagedBlob blob,
String mimeType,
DocumentModel doc)
Gets an
InputStream for a conversion to the given MIME type. |
protected com.google.api.client.auth.oauth2.Credential |
getCredential(String user) |
protected OAuthCredentialFactory |
getCredentialFactory() |
protected com.dropbox.core.DbxClient |
getDropboxClient(com.google.api.client.auth.oauth2.Credential credential) |
protected com.dropbox.core.DbxClient |
getDropboxClient(String accessToken) |
protected com.dropbox.core.DbxEntry.File |
getFile(String user,
String filePath)
Retrieves and caches a
DbxEntry.File resource. |
protected String |
getFileInfo(String key)
Removes the prefix from the key.
|
protected String[] |
getFileInfoParts(String fileInfo) |
protected com.dropbox.core.DbxEntry.File |
getFileNoCache(String user,
String filePath) |
protected String |
getFilePath(String fileInfo) |
protected DropboxOAuth2ServiceProvider |
getOAuth2Provider() |
String |
getPageProviderNameForUpdate() |
InputStream |
getStream(ManagedBlob blob)
Gets an
InputStream for the data of a managed blob. |
protected InputStream |
getStream(URI uri) |
InputStream |
getThumbnail(ManagedBlob blob)
Gets an
InputStream for a thumbnail of a managed blob. |
URI |
getURI(ManagedBlob blob,
BlobManager.UsageHint usage,
javax.servlet.http.HttpServletRequest servletRequest)
Gets an
URI for the content of a managed blob. |
protected String |
getUser(String fileInfo) |
Blob |
readBlob(BlobManager.BlobInfo blobInfo)
Reads a
Blob from storage. |
boolean |
supportsUserUpdate()
Checks if user update is supported.
|
String |
writeBlob(Blob blob,
Document doc)
Writes a
Blob to storage and returns information about it. |
initialize, supportsUserUpdateDefaultFalse, supportsUserUpdateDefaultTrue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processDocumentsUpdate
getAppLinks, getBinaryManager, isVersion
public DropboxBlobProvider()
public void close()
BlobProvider
close
in interface BlobProvider
public Blob readBlob(BlobManager.BlobInfo blobInfo) throws IOException
BlobProvider
Blob
from storage.readBlob
in interface BlobProvider
blobInfo
- the blob informationIOException
public boolean supportsUserUpdate()
BlobProvider
A user update refers to the fact that a blob from this provider may be overwritten with another blob, wherever the original blob may occur (usually in a document property).
supportsUserUpdate
in interface BlobProvider
supportsUserUpdate
in class AbstractBlobProvider
true
if user update is supportedpublic String writeBlob(Blob blob, Document doc)
BlobProvider
Blob
to storage and returns information about it.
Called to store a user-created blob.
writeBlob
in interface BlobProvider
blob
- the blobdoc
- the document to which this blob belongspublic URI getURI(ManagedBlob blob, BlobManager.UsageHint usage, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
BlobProvider
URI
for the content of a managed blob.getURI
in interface BlobProvider
blob
- the managed blobusage
- BlobManager.UsageHint
servletRequest
- the servlet request, or null
URI
, or null
if none availableIOException
protected InputStream getStream(URI uri) throws IOException
IOException
public Map<String,URI> getAvailableConversions(ManagedBlob blob, BlobManager.UsageHint hint) throws IOException
BlobProvider
URI
for a managed blob.getAvailableConversions
in interface BlobProvider
blob
- the managed blobhint
- BlobManager.UsageHint
URI
, which may be emptyIOException
public InputStream getThumbnail(ManagedBlob blob) throws IOException
BlobProvider
InputStream
for a thumbnail of a managed blob.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
getThumbnail
in interface BlobProvider
blob
- the managed blobIOException
public InputStream getStream(ManagedBlob blob) throws IOException
BlobProvider
InputStream
for the data of a managed blob.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
getStream
in interface BlobProvider
blob
- the managed blobIOException
public InputStream getConvertedStream(ManagedBlob blob, String mimeType, DocumentModel doc) throws IOException
BlobProvider
InputStream
for a conversion to the given MIME type.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
getConvertedStream
in interface BlobProvider
blob
- the managed blobmimeType
- the MIME type to convert todoc
- the document that holds the blobnull
if no conversion is available for the given MIME typeIOException
public ManagedBlob freezeVersion(ManagedBlob blob, Document doc) throws IOException
BlobProvider
freezeVersion
in interface BlobProvider
blob
- the original managed blobdoc
- the document that holds the blobnull
if no change is neededIOException
protected Blob getBlob(String fileInfo) throws IOException
fileInfo
- the file info ({email}:{filePath})IOException
protected String getFileInfo(String key)
protected String getFilePath(String fileInfo)
protected String[] getFileInfoParts(String fileInfo)
protected com.google.api.client.auth.oauth2.Credential getCredential(String user) throws IOException
IOException
protected OAuthCredentialFactory getCredentialFactory()
protected com.dropbox.core.DbxClient getDropboxClient(com.google.api.client.auth.oauth2.Credential credential) throws IOException
IOException
protected com.dropbox.core.DbxClient getDropboxClient(String accessToken) throws IOException
IOException
protected com.dropbox.core.DbxEntry.File getFile(String user, String filePath) throws IOException
DbxEntry.File
resource.DbxEntry.File
resource.IOException
protected InputStream doGet(URI url) throws IOException
IOException
protected String getClientId()
protected DropboxOAuth2ServiceProvider getOAuth2Provider()
public List<DocumentModel> checkChangesAndUpdateBlob(List<DocumentModel> docs)
BatchUpdateBlobProvider
checkChangesAndUpdateBlob
in interface BatchUpdateBlobProvider
protected com.dropbox.core.DbxEntry.File getFileNoCache(String user, String filePath) throws com.dropbox.core.DbxException, IOException
com.dropbox.core.DbxException
IOException
public String getPageProviderNameForUpdate()
getPageProviderNameForUpdate
in interface BatchUpdateBlobProvider
public String getBlobProviderId()
getBlobProviderId
in interface BatchUpdateBlobProvider
Copyright © 2015 Nuxeo SA. All rights reserved.