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 |
lastModified
BLOBHOLDER_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, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted, getApplicationStartedOrder
protected 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 DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
public String storeBlobs(List<Blob> blobs)
storeBlobs
in interface DownloadService
DownloadService.getDownloadUrl(String)
public String getDownloadUrl(DocumentModel doc, String xpath, String filename)
DownloadService
The URL is relative to the Nuxeo Web Application context.
Returns something like nxbigfile/reponame/docuuid/blobholder:0/foo.jpg
getDownloadUrl
in interface DownloadService
doc
- 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)
DownloadService
The URL is relative to the Nuxeo Web Application context.
Returns something like nxbigfile/reponame/docuuid/blobholder:0/foo.jpg
getDownloadUrl
in interface DownloadService
repositoryName
- 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)
DownloadService
The URL is relative to the Nuxeo Web Application context.
Returns something like nxbigblob/key
getDownloadUrl
in interface DownloadService
protected 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)
DownloadService
resolveBlobFromDownloadUrl
in interface DownloadService
url
- 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
DownloadService
handleDownload
in interface DownloadService
req
- the requestresp
- the responsebaseUrl
- the request baseUrlpath
- the request path, without the contextIOException
protected void handleDownload(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String downloadPath, String baseUrl, boolean info) throws IOException
IOException
public void downloadBlobStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason) throws IOException
DownloadService
AsyncBlob
download which gives information about an asynchronous blob.downloadBlobStatus
in interface DownloadService
key
- the stored blobs keyreason
- the download reasonIOException
public void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason) throws IOException
DownloadService
downloadBlob
in interface DownloadService
key
- the stored blobs keyreason
- the download reasonIOException
protected void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String key, String reason, boolean status) throws IOException
IOException
public void downloadBlob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason) throws IOException
DownloadService
downloadBlob
in interface DownloadService
doc
- the document, if availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blob, if already fetchedfilename
- the filename to usereason
- the download reasonIOException
public 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
DownloadService
downloadBlob
in interface DownloadService
doc
- 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 logIOException
public 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
DownloadService
downloadBlob
in interface DownloadService
doc
- 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-dispositionIOException
public 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
DownloadService
DownloadExecutor
.downloadBlob
in interface DownloadService
doc
- 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 blobIOException
protected void transferBlobWithByteRange(Blob blob, DownloadService.ByteRange byteRange, javax.servlet.http.HttpServletResponse response) throws UncheckedIOException
UncheckedIOException
public void transferBlobWithByteRange(Blob blob, DownloadService.ByteRange byteRange, Supplier<OutputStream> outputStreamSupplier) throws UncheckedIOException
DownloadService
OutputStream
.transferBlobWithByteRange
in interface DownloadService
blob
- the blobbyteRange
- the byte rangeoutputStreamSupplier
- the OutputStream
supplierUncheckedIOException
public Blob resolveBlob(DocumentModel doc)
DownloadService
resolveBlob
in interface DownloadService
doc
- the documentnull
if not availablepublic Blob resolveBlob(DocumentModel doc, String xpath)
DownloadService
resolveBlob
in interface DownloadService
doc
- the documentxpath
- the xpath or blobholder indexnull
if not foundpublic boolean checkPermission(DocumentModel doc, String xpath, Blob blob, String reason, Map<String,Serializable> extendedInfos)
DownloadService
checkPermission
in interface DownloadService
doc
- 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)
DownloadService
logDownload
in interface DownloadService
doc
- 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.