JobResource.java 文件源码

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

项目:latte-rodeo 作者:
@Path("{identifier}/log.txt")
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getJobLog(@PathParam("identifier") JobIdentifier identifier) {
    final List<Job> list = model.query(new JobsByIdentifierOrStatus(identifier, null));
    if (list.isEmpty()) {
        return respondFileNotFound(identifier);
    }
    String dir = list.get(0).getWorkDirectory();
    if (dir == null) {
        return respondFileNotFound(identifier);
    }
    File workDirectory = new File(dir);
    final File file = new File(workDirectory, "log.txt");
    if (!file.exists()) {
        return respondFileNotFound(identifier);
    }
    StreamingOutput output = new StreamingOutput() {
        @Override
        public void write(OutputStream out) throws IOException {
            Files.copy(file.toPath(), out);
        }
    };
    return Response.ok(output, MediaType.TEXT_PLAIN).build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号