private Response downloadArtifact ( Node node ) throws Exception { NodeRepresentation nodeRepresentation = nodeRepresentationService . getNodeRepresentation ( node , null ) ; if ( node . canAddMixin ( "exo:mavencounter" ) ) { node . addMixin ( "exo:mavencounter" ) ; node . getSession ( ) . save ( ) ; } node . setProperty ( "exo:downloadcounter" , node . getProperty ( "exo:downloadcounter" ) . getLong ( ) + 1l ) ; node . getSession ( ) . save ( ) ; long lastModified = nodeRepresentation . getLastModified ( ) ; String contentType = nodeRepresentation . getMediaType ( ) ; long contentLength = nodeRepresentation . getContentLenght ( ) ; InputStream entity = nodeRepresentation . getInputStream ( ) ; Response response = Response . ok ( entity , contentType ) . header ( HttpHeaders . CONTENT_LENGTH , Long . toString ( contentLength ) ) . lastModified ( new Date ( lastModified ) ) . build ( ) ; return response ; }
Get content of JCR node .