@Override public Response toResponse(final InvalidMementoPathException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final CannotCreateResourceException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final InteractionModelViolationException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(CONFLICT).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
.links(PageUtils.getNavLinks(uriInfo, totalCount, perPage, page)) .build();
builder.links(links.stream().map(this::filterLinkParams).toArray(Link[]::new)) .link(Resource.getIRIString(), TYPE).link(RDFSource.getIRIString(), TYPE) .header(ALLOW, join(",", GET, HEAD, OPTIONS));
/** * @param connection the RepositoryConnection (with active transaction) to read extra data from. WILL BE COMMITTED OR ROLLBACKED * @throws RepositoryException */ private Response buildPostResponse(RepositoryConnection connection, String container, String newResource, LdpService.InteractionModel interactionModel, InputStream requestBody, MediaType type) throws RepositoryException { final String mimeType = LdpUtils.getMimeType(type); //checking if resource (container) exists is done later in the service try { String location = ldpService.addResource(connection, container, newResource, interactionModel, mimeType, requestBody); final Response.ResponseBuilder response = createResponse(connection, Response.Status.CREATED, container).location(java.net.URI.create(location)); if (newResource.compareTo(location) != 0) { response.links(Link.fromUri(newResource).rel(LINK_REL_DESCRIBEDBY).param(LINK_PARAM_ANCHOR, location).build()); } connection.commit(); return response.build(); } catch (IOException | RDFParseException e) { final Response.ResponseBuilder resp = createResponse(connection, Response.Status.BAD_REQUEST, container).entity(e.getClass().getSimpleName() + ": " + e.getMessage()); connection.rollback(); return resp.build(); } catch (UnsupportedRDFormatException e) { final Response.ResponseBuilder resp = createResponse(connection, Response.Status.UNSUPPORTED_MEDIA_TYPE, container).entity(e); connection.rollback(); return resp.build(); } }
public Response head(UriInfo uriInfo) { UriBuilder absolute = uriInfo.getBaseUriBuilder(); URI claimUrl = absolute.clone().path("claims").build(); URI idpUrl = absolute.clone().path("idps").build(); URI applicationUrl = absolute.clone().path("applications").build(); URI trustedIdpUrl = absolute.clone().path("trusted-idps").build(); URI rolesUrl = absolute.clone().path("roles").build(); URI entitlementsUrl = absolute.clone().path("entitlements").build(); javax.ws.rs.core.Link claims = javax.ws.rs.core.Link.fromUri(claimUrl).rel("claims") .type("application/xml").build(); javax.ws.rs.core.Link idps = javax.ws.rs.core.Link.fromUri(idpUrl).rel("idps") .type("application/xml").build(); javax.ws.rs.core.Link applications = javax.ws.rs.core.Link.fromUri(applicationUrl).rel("applications") .type("application/xml").build(); javax.ws.rs.core.Link trustedIdps = javax.ws.rs.core.Link.fromUri(trustedIdpUrl).rel("trusted-idps") .type("application/xml").build(); javax.ws.rs.core.Link roles = javax.ws.rs.core.Link.fromUri(rolesUrl).rel("roles") .type("application/xml").build(); javax.ws.rs.core.Link entitlements = javax.ws.rs.core.Link.fromUri(entitlementsUrl).rel("entitlements") .type("application/xml").build(); Response.ResponseBuilder builder = Response.ok().links( claims, idps, applications, trustedIdps, roles, entitlements); return builder.build(); }
/** * Create a response builder for a TimeGate response. * * @param mementos the list of memento ranges * @param req the LDP request * @param baseUrl the base URL * @return a response builder object */ public ResponseBuilder getTimeGateBuilder(final SortedSet<Instant> mementos, final TrellisRequest req, final String baseUrl) { final String identifier = getBaseUrl(baseUrl, req) + req.getPath(); return status(FOUND) .location(fromUri(identifier + "?version=" + req.getDatetime().getInstant().getEpochSecond()).build()) .link(identifier, ORIGINAL + " " + TIMEGATE) .links(getMementoLinks(identifier, mementos).map(this::filterLinkParams).toArray(Link[]::new)) .header(VARY, ACCEPT_DATETIME); }
/** * Add the memento headers. * @param builder the ResponseBuilder * @param mementos the list of memento ranges * @return the response builder */ public ResponseBuilder addMementoHeaders(final ResponseBuilder builder, final SortedSet<Instant> mementos) { // Only show memento links for the user-managed graph (not ACL) if (!ACL.equals(getRequest().getExt())) { builder.link(getIdentifier(), "original timegate") .links(MementoResource.getMementoLinks(getIdentifier(), mementos) .map(link -> MementoResource.filterLinkParams(link, !includeMementoDates)) .toArray(Link[]::new)); } return builder; }
@Override public Response toResponse(final ConstraintViolationException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final OutOfDomainSubjectException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final ServerManagedPropertyException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(CONFLICT).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
@Override public Response toResponse(final ExternalMessageBodyException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
@Override public Response toResponse(final InvalidACLException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(CONFLICT).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final RequestWithAclLinkHeaderException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(BAD_REQUEST).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); }
@Override public Response toResponse(final IncorrectTripleSubjectException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(FORBIDDEN).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
@Override public Response toResponse(final ServerManagedTypeException e) { debugException(this, e, LOGGER); final Link link = buildConstraintLink(e, context, uriInfo); final String msg = e.getMessage(); return status(CONFLICT).entity(msg).links(link).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
@GET @Path("/link") public Response getBookLink() { URI selfUri = ui.getBaseUriBuilder().path(BookStoreSpring.class).build(); Link link = Link.fromUri(selfUri).rel("self").build(); return Response.ok().links(link).build(); }