Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ private void validateReservedMetadataKeyNames(String key) {

private void generatePermanentId() {
if (this.document.permanentId == null) {
this.document.permanentId = DigestUtils.sha256Hex(this.document.uri);
String md5 = DigestUtils.md5Hex(this.document.uri);
String sha1 = DigestUtils.sha1Hex(this.document.uri);
this.document.permanentId = md5.substring(0, 30) + sha1.substring(0, 30);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ public void testWithPermanentId() {

@Test
public void testWithPermanentIdGeneration() {
assertTrue(
docBuilder = new DocumentBuilder("https://foo.com", "bar");
assertEquals(
"permanentId should be generated automatically if not set",
docBuilder.marshalJsonObject().get("permanentId").getAsString().length() > 0
"aa2e0510b66edff7f05e2b30d4f1b3a4b5481c06b69f41751c54675c5afb",
docBuilder.marshalJsonObject().get("permanentId").getAsString()
);
}

Expand Down Expand Up @@ -373,4 +375,4 @@ public void marshal() {
);
}

}
}