本文整理汇总了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);
}