Skip to content
Open
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 @@ -562,14 +562,20 @@ public Response updateSegment(@PathParam("idType") String idType, @PathParam("id
* if the id is malformed.
*/
private List<Metadata> lookupDocumentIdentifier(String idType, String id) throws QueryException {
// If the idType is RECORD_ID or DOCUMENT, treat the id provided as an internal id and perform a direct lookup
// against the annotations table, if that's enabled.
if (idType.equals("DOCUMENT") || idType.equals("RECORD_ID")) {
// If the idType is RECORD_ID or DOCUMENT treat the id provided is an internal id.
if (!config.isEnableInternalIdLookup()) {
final String message = String.format("Internal identifier lookup is disabled for '%s:%s' please use a valid document id type.", idType, id);
throw new QueryException(message);
}

return parseDocumentIdentifier(id);
} else {
// Otherwise, perform a lookup to find the internal id.
final LookupUUIDService lookup = initializeLookupUUIDService();
return lookup.executeLookupUUIDQuery(idType, id);
}

// Otherwise, use the lookup uuid service to perform a lookup to find the internal id in the shard table.
final LookupUUIDService lookup = initializeLookupUUIDService();
return lookup.executeLookupUUIDQuery(idType, id);
}

/**
Expand Down Expand Up @@ -671,4 +677,9 @@ private static Response jsonOk(Object responseObject) {
// TODO: do we want to return more? (e.g., include fields like internal id, etc..
return Response.ok(responseObject, MediaType.APPLICATION_JSON_TYPE.withCharset("utf-8")).build();
}

@VisibleForTesting
protected AnnotationManagerConfig getConfig() {
return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class AnnotationManagerConfig {
private String annotationTableName;
private String annotationSourceTableName;
private String connPoolName;
private boolean enableInternalIdLookup = false;
private ShardQueryLogic lookupUUIDQueryLogic;
private LookupUUIDServiceConfig lookupUUIDServiceConfig;
private AccumuloConnectionFactory.Priority priority = AccumuloConnectionFactory.Priority.LOW;
Expand Down Expand Up @@ -78,4 +79,12 @@ public VisibilityTransformer getVisibilityTransformer() {
public void setVisibilityTransformer(VisibilityTransformer visibilityTransformer) {
this.visibilityTransformer = visibilityTransformer;
}

public boolean isEnableInternalIdLookup() {
return enableInternalIdLookup;
}

public void setEnableInternalIdLookup(boolean enableInternalIdLookup) {
this.enableInternalIdLookup = enableInternalIdLookup;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@ public void testGetAnnotationInternalId() {
assertAnnotationsEqual(expectedAnnotation, annotationList.iterator().next());
}

@Test
public void testGetAnnotationInternalIdDisabled() {
AnnotationManagerBean bean = (AnnotationManagerBean) annotationManager;
AnnotationManagerConfig config = bean.getConfig();
config.setEnableInternalIdLookup(false);

Annotation testAnnotation = generateTestAnnotation();
Annotation expectedAnnotation = AnnotationUtils.injectAllHashes(testAnnotation);
Response response = annotationManager.getAnnotation("DOCUMENT", "20250704_249/testDataType/abcde.fghij.klmno", "23BD91EC");
assertResponseStatus(500, response);
String errorResponse = assertExpectedEntity(String.class, response);
assertContains("Internal identifier lookup is disabled for", errorResponse);
assertContains("20250704_249/testDataType/abcde.fghij.klmno", errorResponse);
}

@Test
public void testGetAnnotationMissingInternalId() {
Response response = annotationManager.getAnnotation("DOCUMENT", "20250704_249/testDataType/abcde.fghij.klmno", "aaaaaaaa");
Expand All @@ -441,7 +456,6 @@ public void testGetAnnotationMissingInternalId() {
assertContains("No annotations found for identifier", errorResponse);
assertContains("20250704_249/testDataType/abcde.fghij.klmno", errorResponse);
assertContains("aaaaaaaa", errorResponse);

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<property name="annotationTableName" value="annotation"/>
<property name="annotationSourceTableName" value="annotationSource"/>
<property name="connPoolName" value="WAREHOUSE" />
<property name="enableInternalIdLookup" value="true" />
<property name="lookupUUIDQueryLogic">
<bean scope="prototype" parent="BaseEventQuery">
<property name="auditType" value="NONE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<property name="annotationTableName" value="${annotation.table.name}"/>
<property name="annotationSourceTableName" value="${annotation.source.table.name}"/>
<property name="connPoolName" value="WAREHOUSE" />
<property name="enableInternalIdLookup" value="true" />
<property name="lookupUUIDQueryLogic">
<bean scope="prototype" parent="BaseEventQuery">
<property name="auditType" value="NONE" />
Expand Down