DataDownload.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:openregister-java 作者:
@GET
@Path("/download-rsf/{total-entries-1}/{total-entries-2}")
@Produces({ExtraMediaType.APPLICATION_RSF, ExtraMediaType.TEXT_HTML})
@DownloadNotAvailable
@Timed
public Response downloadPartialRSF(@PathParam("total-entries-1") int totalEntries1, @PathParam("total-entries-2") int totalEntries2) {
    if (totalEntries1 < 0) {
        throw new BadRequestException("total-entries-1 must be 0 or greater");
    }

    if (totalEntries2 < totalEntries1) {
        throw new BadRequestException("total-entries-2 must be greater than or equal to total-entries-1");
    }

    int totalEntriesInRegister = register.getTotalEntries();

    if (totalEntries2 > totalEntriesInRegister) {
        throw new BadRequestException("total-entries-2 must not exceed number of total entries in the register");
    }

    String rsfFileName = String.format("attachment; filename=rsf-%d.%s", System.currentTimeMillis(), rsfFormatter.getFileExtension());
    return Response
            .ok((StreamingOutput) output -> rsfService.writeTo(output, rsfFormatter, totalEntries1, totalEntries2))
            .header("Content-Disposition", rsfFileName).build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号