}
public static String getETag(RepositoryConnection conn, URI resource) throws RepositoryException {
if (resource == null) return "";
Hasher hasher = buildHasher();
hasher.putString(resource.stringValue(), Charset.defaultCharset());
//FIXME: The order of the statements is not defined -> might result in different hash!
RepositoryResult<Statement> outgoing = conn.getStatements(resource, null, null, true);
try {
while (outgoing.hasNext()) {
Statement statement = outgoing.next();
hasher.putString(statement.getPredicate().stringValue(), Charset.defaultCharset());
hasher.putString(statement.getObject().stringValue(), Charset.defaultCharset());
//TODO: statement modification date?
}
} finally {
outgoing.close();
}
RepositoryResult<Statement> incoming = conn.getStatements(null, null, resource, true);
try {
while (incoming.hasNext()) {
Statement statement = incoming.next();
hasher.putString(statement.getSubject().stringValue(), Charset.defaultCharset());
hasher.putString(statement.getPredicate().stringValue(), Charset.defaultCharset());
//TODO: statement modification date?
}
} finally {
incoming.close();
}
return hasher.hash().toString();
}