/** * Get the first value for the specified header * * @param name name of the header to retrieve * @return First value of the header, or null if not present */ public String getHeaderValue(final String name) { final List<String> values = getHeaderValues(name); if (values == null || values.size() == 0) { return null; } return values.get(0); }
/** * Retrieve link header values matching the given relationship * * @param relationship the relationship of links to return * @return list of link header URIs matching the given relationship */ public List<URI> getLinkHeaders(final String relationship) { return getHeaderValues(LINK).stream().map(FcrepoLink::new).filter(link -> link.getRel().equals(relationship)) .map(FcrepoLink::getUri).collect(toList()); }
/** * Return true if the response represents a resource with the given type * * @param typeUri URI of the type * @return true if the type is present. */ public boolean hasType(final URI typeUri) { return getHeaderValues(LINK).stream() .map(FcrepoLink::new) .anyMatch(l -> l.getRel().equals(TYPE_REL) && l.getUri().equals(typeUri)); }