@ Override public void escape ( ) throws IOException { LOG . debug ( "...ContentEscape escape()" ) ; if ( contentAccess == null ) { LOG . warn ( "No content to output" ) ; } else { String mimeType = contentAccess . getMimeType ( ) ; Response response = getResponse ( ) ; response . setContentType ( mimeType ) ; if ( isCacheable ( ) ) { getResponse ( ) . setHeader ( "Cache-Control" , CacheType . CONTENT_CACHE . getSettings ( ) ) ; } else { getResponse ( ) . setHeader ( "Cache-Control" , CacheType . CONTENT_NO_CACHE . getSettings ( ) ) ; } if ( contentAccess . getDescription ( ) != null ) { String fileName = WebUtilities . encodeForContentDispositionHeader ( contentAccess . getDescription ( ) ) ; if ( displayInline ) { response . setHeader ( "Content-Disposition" , "inline; filename=" + fileName ) ; } else { response . setHeader ( "Content-Disposition" , "attachment; filename=" + fileName ) ; } } if ( contentAccess instanceof ContentStreamAccess ) { InputStream stream = null ; try { stream = ( ( ContentStreamAccess ) contentAccess ) . getStream ( ) ; if ( stream == null ) { throw new SystemException ( "ContentAccess returned null stream, access=" + contentAccess ) ; } StreamUtil . copy ( stream , response . getOutputStream ( ) ) ; } finally { StreamUtil . safeClose ( stream ) ; } } else { byte [ ] bytes = contentAccess . getBytes ( ) ; if ( bytes == null ) { throw new SystemException ( "ContentAccess returned null data, access=" + contentAccess ) ; } response . getOutputStream ( ) . write ( bytes ) ; } } }
Writes the content to the response .