/** * Builds the value for the Content-Disposition header. If downloadFilename is null or empty a default name is * generated instead. * * @param containerRequestContext container request context of the request currently being handled * @param requestedFilename the filename for the response to be downloaded as * @param responseFormatType data object that contains information necessary to build the response headers * @return the value for the Content-Disposition header */ public String getContentDispositionValue( ContainerRequestContext containerRequestContext, String requestedFilename, ResponseFormatType responseFormatType ) { String downloadFilename = requestedFilename; if (requestedFilename == null || requestedFilename.isEmpty()) { downloadFilename = generateDefaultFileNameNoExtension(containerRequestContext); } downloadFilename = replaceReservedCharacters(downloadFilename); String filepath = truncateFilename(downloadFilename); String extension = responseFormatType.getFileExtension(); return CONTENT_DISPOSITION_HEADER_PREFIX + filepath + extension; }