protected void addResourceHttpHeaders ( final FedoraResource resource ) { if ( resource instanceof FedoraBinary ) { final FedoraBinary binary = ( FedoraBinary ) resource ; final Date createdDate = binary . getCreatedDate ( ) != null ? Date . from ( binary . getCreatedDate ( ) ) : null ; final Date modDate = binary . getLastModifiedDate ( ) != null ? Date . from ( binary . getLastModifiedDate ( ) ) : null ; final ContentDisposition contentDisposition = ContentDisposition . type ( "attachment" ) . fileName ( binary . getFilename ( ) ) . creationDate ( createdDate ) . modificationDate ( modDate ) . size ( binary . getContentSize ( ) ) . build ( ) ; servletResponse . addHeader ( CONTENT_TYPE , binary . getMimeType ( ) ) ; // Returning content-length > 0 causes the client to wait for additional data before following the redirect. if ( ! binary . isRedirect ( ) ) { servletResponse . addHeader ( CONTENT_LENGTH , String . valueOf ( binary . getContentSize ( ) ) ) ; } servletResponse . addHeader ( "Accept-Ranges" , "bytes" ) ; servletResponse . addHeader ( CONTENT_DISPOSITION , contentDisposition . toString ( ) ) ; } servletResponse . addHeader ( LINK , "<" + LDP_NAMESPACE + "Resource>;rel=\"type\"" ) ; if ( resource instanceof FedoraBinary ) { servletResponse . addHeader ( LINK , "<" + LDP_NAMESPACE + "NonRDFSource>;rel=\"type\"" ) ; } else if ( resource instanceof Container || resource instanceof FedoraTimeMap ) { servletResponse . addHeader ( LINK , "<" + CONTAINER . getURI ( ) + ">;rel=\"type\"" ) ; servletResponse . addHeader ( LINK , buildLink ( RDF_SOURCE . getURI ( ) , "type" ) ) ; if ( resource . hasType ( LDP_BASIC_CONTAINER ) ) { servletResponse . addHeader ( LINK , "<" + BASIC_CONTAINER . getURI ( ) + ">;rel=\"type\"" ) ; } else if ( resource . hasType ( LDP_DIRECT_CONTAINER ) ) { servletResponse . addHeader ( LINK , "<" + DIRECT_CONTAINER . getURI ( ) + ">;rel=\"type\"" ) ; } else if ( resource . hasType ( LDP_INDIRECT_CONTAINER ) ) { servletResponse . addHeader ( LINK , "<" + INDIRECT_CONTAINER . getURI ( ) + ">;rel=\"type\"" ) ; } else { servletResponse . addHeader ( LINK , "<" + BASIC_CONTAINER . getURI ( ) + ">;rel=\"type\"" ) ; } } else { servletResponse . addHeader ( LINK , buildLink ( RDF_SOURCE . getURI ( ) , "type" ) ) ; } if ( httpHeaderInject != null ) { httpHeaderInject . addHttpHeaderToResponseStream ( servletResponse , uriInfo , resource ) ; } addLinkAndOptionsHttpHeaders ( resource ) ; addAclHeader ( resource ) ; addMementoHeaders ( resource ) ; }
Add any resource - specific headers to the response