public class DownloadServiceImpl extends DefaultComponent implements DownloadService
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DownloadServiceImpl.Action |
static class |
DownloadServiceImpl.DownloadPermissionRegistry |
DownloadService.ByteRange| Modifier and Type | Field and Description |
|---|---|
protected static int |
DOWNLOAD_BUFFER_SIZE |
protected RedirectResolver |
redirectResolver |
protected List<RedirectResolverDescriptor> |
redirectResolverContributions |
lastModifiedBLOBHOLDER_0, BLOBHOLDER_PREFIX, EVENT_NAME, NXBIGBLOB, NXBIGFILE, NXBIGZIPFILE, NXBLOBSTATUS, NXDOWNLOADINFO, NXFILE, TRANSIENT_STORE_PARAM_ERROR, TRANSIENT_STORE_PARAM_PROGRESS, TRANSIENT_STORE_STORE_NAME| Constructor and Description |
|---|
DownloadServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCacheControlHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Internet Explorer file downloads over SSL do not work with certain HTTP cache control headers
|
boolean |
checkPermission(DocumentModel doc,
String xpath,
Blob blob,
String reason,
Map<String,Serializable> extendedInfos)
Checks whether the download of the blob is allowed.
|
void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
DocumentModel doc,
String xpath,
Blob blob,
String filename,
String reason)
Triggers a blob download.
|
void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
DocumentModel doc,
String xpath,
Blob blob,
String filename,
String reason,
Map<String,Serializable> extendedInfos)
Triggers a blob download.
|
void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
DocumentModel doc,
String xpath,
Blob blob,
String filename,
String reason,
Map<String,Serializable> extendedInfos,
Boolean inline)
Triggers a blob download.
|
void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
DocumentModel doc,
String xpath,
Blob blob,
String filename,
String reason,
Map<String,Serializable> extendedInfos,
Boolean inline,
Consumer<DownloadService.ByteRange> blobTransferer)
Triggers a blob download.
|
void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String key,
String reason)
Triggers a blobs download.
|
protected void |
downloadBlob(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String key,
String reason,
boolean status) |
void |
downloadBlobStatus(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String key,
String reason)
Triggers a
AsyncBlob download which gives information about an asynchronous blob. |
protected String |
fixXPath(String xpath) |
protected static boolean |
forceNoCacheOnMSIE() |
protected org.apache.commons.lang3.tuple.Pair<String,DownloadServiceImpl.Action> |
getDownloadPathAndAction(String path)
Gets the download path and action of the URL to use to download blobs.
|
String |
getDownloadUrl(DocumentModel doc,
String xpath,
String filename)
Gets the URL to use to download the blob at the given xpath in the given document.
|
String |
getDownloadUrl(String storeKey)
Gets the URL to use to download the blobs identified by a storage key.
|
String |
getDownloadUrl(String repositoryName,
String docId,
String xpath,
String filename)
Gets the URL to use to download the blob at the given xpath in the given document.
|
protected String |
getFilenameWithoutPath(String filename) |
protected static NuxeoPrincipal |
getPrincipal() |
void |
handleDownload(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String baseUrl,
String path)
Handles the download of a document.
|
protected void |
handleDownload(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String downloadPath,
String baseUrl,
boolean info) |
void |
logDownload(DocumentModel doc,
String xpath,
String filename,
String reason,
Map<String,Serializable> extendedInfos)
Logs a download.
|
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
Blob |
resolveBlob(DocumentModel doc)
Finds a document's blob.
|
Blob |
resolveBlob(DocumentModel doc,
String xpath)
Finds a document's blob given an xpath or blobholder index
|
Blob |
resolveBlobFromDownloadUrl(String url)
Finds a document's blob given the URL to use to download the blob.
|
String |
storeBlobs(List<Blob> blobs)
Stores the blobs for later download.
|
protected void |
transferBlobWithByteRange(Blob blob,
DownloadService.ByteRange byteRange,
javax.servlet.http.HttpServletResponse response) |
void |
transferBlobWithByteRange(Blob blob,
DownloadService.ByteRange byteRange,
Supplier<OutputStream> outputStreamSupplier)
Copies the blob stream at the given byte range into the supplied
OutputStream. |
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
activate, deactivate, getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, start, stop, unregisterExtensionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplicationStarted, getApplicationStartedOrderprotected static final int DOWNLOAD_BUFFER_SIZE
protected RedirectResolver redirectResolver
protected List<RedirectResolverDescriptor> redirectResolverContributions
public DownloadServiceImpl()
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution in class DefaultComponentpublic void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution in class DefaultComponentpublic String storeBlobs(List<Blob> blobs)
storeBlobs in interface DownloadServiceDownloadService.getDownloadUrl(String)public String getDownloadUrl(DocumentModel doc, String xpath, String filename)
DownloadServiceThe URL is relative to the Nuxeo Web Application context.
Returns something like nxbigfile/reponame/docuuid/blobholder:0/foo.jpg
getDownloadUrl in interface DownloadServicedoc - the documentxpath - the blob's xpath or blobholder index, or null for defaultfilename - the blob's filename, or null for defaultpublic String getDownloadUrl(String repositoryName, String docId, String xpath, String filename)
DownloadServiceThe URL is relative to the Nuxeo Web Application context.
Returns something like nxbigfile/reponame/docuuid/blobholder:0/foo.jpg
getDownloadUrl in interface DownloadServicerepositoryName - the document repositorydocId - the document idxpath - the blob's xpath or blobholder index, or null for defaultfilename - the blob's filename, or null for defaultprotected String getFilenameWithoutPath(String filename)
public String getDownloadUrl(String storeKey)
DownloadServiceThe URL is relative to the Nuxeo Web Application context.
Returns something like nxbigblob/key
getDownloadUrl in interface DownloadServiceprotected org.apache.commons.lang3.tuple.Pair<String,DownloadServiceImpl.Action> getDownloadPathAndAction(String path)
path - the path of the URL to use to download blobspublic Blob resolveBlobFromDownloadUrl(String url)
DownloadServiceresolveBlobFromDownloadUrl in interface DownloadServiceurl - the URL to use to download the blobnull if not foundpublic void handleDownload(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String baseUrl, String path) throws IOException
DownloadServicehandleDownload in interface DownloadServicereq - the requestresp - the responsebaseUrl - the request baseUrlpath - the request path, without the contextIOExceptionprotected void handleDownload(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String downloadPath, String baseUrl, boolean info) throws IOException
IOExceptionpublic void downloadBlobStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason) throws IOException
DownloadServiceAsyncBlob download which gives information about an asynchronous blob.downloadBlobStatus in interface DownloadServicekey - the stored blobs keyreason - the download reasonIOExceptionpublic void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason) throws IOException
DownloadServicedownloadBlob in interface DownloadServicekey - the stored blobs keyreason - the download reasonIOExceptionprotected void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason, boolean status) throws IOException
IOExceptionpublic void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason) throws IOException
DownloadServicedownloadBlob in interface DownloadServicedoc - the document, if availablexpath - the blob's xpath or blobholder index, if availableblob - the blob, if already fetchedfilename - the filename to usereason - the download reasonIOExceptionpublic void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason, Map<String,Serializable> extendedInfos) throws IOException
DownloadServicedownloadBlob in interface DownloadServicedoc - the document, if availablexpath - the blob's xpath or blobholder index, if availableblob - the blob, if already fetchedfilename - the filename to usereason - the download reasonextendedInfos - an optional map of extended informations to logIOExceptionpublic void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason, Map<String,Serializable> extendedInfos, Boolean inline) throws IOException
DownloadServicedownloadBlob in interface DownloadServicedoc - the document, if availablexpath - the blob's xpath or blobholder index, if availableblob - the blob, if already fetchedfilename - the filename to usereason - the download reasonextendedInfos - an optional map of extended informations to loginline - if not null, force the inline flag for content-dispositionIOExceptionpublic void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason, Map<String,Serializable> extendedInfos, Boolean inline, Consumer<DownloadService.ByteRange> blobTransferer) throws IOException
DownloadServiceDownloadExecutor.downloadBlob in interface DownloadServicedoc - the document, if availablexpath - the blob's xpath or blobholder index, if availableblob - the blob, if already fetchedfilename - the filename to usereason - the download reasonextendedInfos - an optional map of extended informations to loginline - if not null, force the inline flag for content-dispositionblobTransferer - the transferer of the actual blobIOExceptionprotected void transferBlobWithByteRange(Blob blob, DownloadService.ByteRange byteRange, javax.servlet.http.HttpServletResponse response) throws UncheckedIOException
UncheckedIOExceptionpublic void transferBlobWithByteRange(Blob blob, DownloadService.ByteRange byteRange, Supplier<OutputStream> outputStreamSupplier) throws UncheckedIOException
DownloadServiceOutputStream.transferBlobWithByteRange in interface DownloadServiceblob - the blobbyteRange - the byte rangeoutputStreamSupplier - the OutputStream supplierUncheckedIOExceptionpublic Blob resolveBlob(DocumentModel doc)
DownloadServiceresolveBlob in interface DownloadServicedoc - the documentnull if not availablepublic Blob resolveBlob(DocumentModel doc, String xpath)
DownloadServiceresolveBlob in interface DownloadServicedoc - the documentxpath - the xpath or blobholder indexnull if not foundpublic boolean checkPermission(DocumentModel doc, String xpath, Blob blob, String reason, Map<String,Serializable> extendedInfos)
DownloadServicecheckPermission in interface DownloadServicedoc - the doc for which this download occurs, if availableblob - the blobreason - the download reasonextendedInfos - an optional map of extended informations to logtrue if download is allowedprotected void addCacheControlHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
See http://support.microsoft.com/kb/323308/
What is not mentioned in the above Knowledge Base is that "Pragma: no-cache" also breaks download in MSIE over SSL
protected static boolean forceNoCacheOnMSIE()
public void logDownload(DocumentModel doc, String xpath, String filename, String reason, Map<String,Serializable> extendedInfos)
DownloadServicelogDownload in interface DownloadServicedoc - the doc for which this download occurs, if availablexpath - the blob's xpath or blobholder index, if availablefilename - the filenamereason - the download reasonextendedInfos - an optional map of extended informations to logprotected static NuxeoPrincipal getPrincipal()
Copyright © 2018 Nuxeo. All rights reserved.