当前位置: 首页>>代码示例>>Java>>正文


Java ResponseBuilder.tag方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Response.ResponseBuilder.tag方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder.tag方法的具体用法?Java ResponseBuilder.tag怎么用?Java ResponseBuilder.tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Response.ResponseBuilder的用法示例。


在下文中一共展示了ResponseBuilder.tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLdpRs

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
private ResponseBuilder getLdpRs(final String identifier, final Resource res, final ResponseBuilder builder,
        final RDFSyntax syntax, final IRI profile) {

    // Check for a cache hit
    final EntityTag etag = new EntityTag(md5Hex(res.getModified() + identifier), true);
    checkCache(req.getRequest(), res.getModified(), etag);

    builder.tag(etag);
    if (res.isMemento()) {
        builder.header(ALLOW, join(",", GET, HEAD, OPTIONS));
    } else if (ACL.equals(req.getExt())) {
        builder.header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH));
    } else if (res.getInteractionModel().equals(LDP.RDFSource)) {
        builder.header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE));
    } else {
        builder.header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST));
    }

    // URI Templates
    builder.header(LINK_TEMPLATE, "<" + identifier + "{?subject,predicate,object}>; rel=\""
            + LDP.Resource.getIRIString() + "\"");

    final Prefer prefer = ACL.equals(req.getExt()) ?
        new Prefer(PREFER_REPRESENTATION, singletonList(PreferAccessControl.getIRIString()),
                of(PreferUserManaged, LDP.PreferContainment, LDP.PreferMembership).map(IRI::getIRIString)
                    .collect(toList()), null, null, null) : req.getPrefer();

    ofNullable(prefer).ifPresent(p -> builder.header(PREFERENCE_APPLIED, PREFER_RETURN + "=" + p.getPreference()
                .orElse(PREFER_REPRESENTATION)));


    if (ofNullable(prefer).flatMap(Prefer::getPreference).filter(PREFER_MINIMAL::equals).isPresent()) {
        return builder.status(NO_CONTENT);
    }

    // Short circuit HEAD requests
    if (HEAD.equals(req.getRequest().getMethod())) {
        return builder;
    }

    // Stream the rdf content
    final StreamingOutput stream = new StreamingOutput() {
        @Override
        public void write(final OutputStream out) throws IOException {
            try (final Stream<? extends Quad> stream = res.stream()) {
                ioService.write(stream.filter(filterWithPrefer(prefer))
                    .map(unskolemizeQuads(resourceService, getBaseUrl()))
                    .filter(filterWithLDF(req.getSubject(), req.getPredicate(), req.getObject()))
                    .map(Quad::asTriple), out, syntax,
                        ofNullable(profile).orElseGet(() -> getDefaultProfile(syntax, identifier)));
            }
        }
    };
    return builder.entity(stream);
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:56,代码来源:GetHandler.java


注:本文中的javax.ws.rs.core.Response.ResponseBuilder.tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。