/** * Builds the value for the Content-Type header. The value is constructed out of data provided by the * Response Format Type. * * @param responseFormatType data object that contains information necessary to build the response headers * @return the value for the Content-Type header */ public String getContentTypeValue(ResponseFormatType responseFormatType) { return responseFormatType.getContentType() + "; charset=" + responseFormatType.getCharset(); }
@Override public boolean accepts(ResponseFormatType formatType) { return formatType.accepts(this.toString()); }
/** * 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; }