@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(); } }
/** * If it's not the right kind of node, throw an appropriate unchecked exception. * * @param subject to validate */ private void validateSubject(final Resource subject) { final String subjectURI = subject.getURI(); // blank nodes are okay if (!subject.isAnon()) { // hash URIs with the same base as the topic are okay final int hashIndex = subjectURI.lastIndexOf("#"); if (!(hashIndex > 0 && topic.getURI().equals(subjectURI.substring(0, hashIndex)))) { // the topic itself is okay if (!topic.equals(subject.asNode())) { // it's a bad subject, but it could still be in-domain if (idTranslator.inDomain(subject)) { LOGGER.error("{} is not in the topic of this RDF, which is {}.", subject, topic); throw new IncorrectTripleSubjectException(subject + " is not in the topic of this RDF, which is " + topic); } // it's not even in the right domain! LOGGER.error("subject ({}) is not in repository domain.", subject); throw new OutOfDomainSubjectException(subject.asNode()); } } } }
throw new IncorrectTripleSubjectException(subject + " is not in the topic of this RDF, which is " + topic);