@ Override public ResponseEntity < InputStream > downloadArtifact ( @ PathVariable ( "softwareModuleId" ) final Long softwareModuleId , @ PathVariable ( "artifactId" ) final Long artifactId ) { final SoftwareModule module = softwareModuleManagement . get ( softwareModuleId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( SoftwareModule . class , softwareModuleId ) ) ; final Artifact artifact = module . getArtifact ( artifactId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( Artifact . class , artifactId ) ) ; final AbstractDbArtifact file = artifactManagement . loadArtifactBinary ( artifact . getSha1Hash ( ) ) . orElseThrow ( ( ) -> new ArtifactBinaryNotFoundException ( artifact . getSha1Hash ( ) ) ) ; final HttpServletRequest request = requestResponseContextHolder . getHttpServletRequest ( ) ; final String ifMatch = request . getHeader ( HttpHeaders . IF_MATCH ) ; if ( ifMatch != null && ! HttpUtil . matchesHttpHeader ( ifMatch , artifact . getSha1Hash ( ) ) ) { return new ResponseEntity <> ( HttpStatus . PRECONDITION_FAILED ) ; } return FileStreamingUtil . writeFileResponse ( file , artifact . getFilename ( ) , artifact . getCreatedAt ( ) , requestResponseContextHolder . getHttpServletResponse ( ) , request , null ) ; }
Handles the GET request for downloading an artifact .