TranslationService.java 文件源码

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

项目:InComb 作者:
/**
 * Returns Translations of a given {@link Locale}
 * @param locale to get the Translation of
 * @param request The HTTP-Request - is injected automatically
 * @return the translation
 */
@GET
public Response getTranslations(@PathParam("locale") final String locale,
        @Context final Request request) {

    final Translator translator = TranslatorManager.getTranslator(LocaleUtil.toLocale(locale));
    if(translator == null) {
        throw new NotFoundException();
    }

    final File file = translator.getFile();
    final Date lastModified = new Date(file.lastModified());

    ResponseBuilder respBuilder = request.evaluatePreconditions(lastModified);
    if(respBuilder == null) {
        respBuilder = Response.ok();
    }

    return respBuilder.lastModified(lastModified).entity(new StreamingOutput() {
        @Override
        public void write(final OutputStream output) throws IOException, WebApplicationException {
            IOUtils.copy(new FileInputStream(file), output);
        }
    }).build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号