Verified Owner
Top Description Fields Constructors Methods
org.jabref.http.server.resources

public Class LibrariesQueryResource

extends Object
Class Inheritance
Annotations
@Path:libraries:query
Imports
java.io.IOException, java.util.ArrayList, .EnumSet, .List, org.jabref.http.SrvStateManager, org.jabref.http.dto.LibraryQueryMatch, .LibraryQueryRequest, .LibraryQueryResponse, .LibraryQueryResult, org.jabref.http.server.services.ServerUtils, org.jabref.logic.preferences.CliPreferences, org.jabref.logic.util.strings.StringUtil, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.search.SearchFlags, org.jabref.model.search.query.SearchQuery, .SearchResults, jakarta.inject.Inject, jakarta.ws.rs.Consumes, .POST, .Path, .Produces, jakarta.ws.rs.core.MediaType, org.slf4j.Logger, .LoggerFactory

Custom-action endpoint that runs each query of the request against all open libraries.

The URL form libraries:query follows Google's API Improvement Proposal 136 — Custom methods: custom (non-standard CRUD) methods are spelled <resource>:<verb> with a literal colon and no separating slash. Quoting AIP-136:

Custom methods should use HTTP POST if they have side effects, or HTTP GET if they are side-effect free. ... Custom methods should generally take the form: https://service.googleapis.com/v1/resources/{id}:verb. ... For batch and collection-level custom methods, the colon is appended directly to the collection name: https://.../v1/resources:batchGet.

Practical reason for the colon here: the sibling LibraryResource is mounted at @Path("libraries/{id}"). A libraries/query sibling would lose JAX-RS path-specificity arbitration because the per-library path matches {id}=query with more literal characters — the request would dispatch to LibraryResource and return 405. The colon variant has no slash and therefore no collision.

Field Summary

Modifier and TypeField and Description
private static final Logger
private CliPreferences
private SrvStateManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public LibraryQueryResponse
query(LibraryQueryRequest request)

impl->req~jabsrv.query.search~1 Queries are processed independently and their results are returned in input order, so a caller matching a reference list can align the n-th query with the n-th reference.

private List<LibraryQueryMatch>
runQuery(String rawQuery, List<String> libraryIds)

Entries without a citation key are reported with the sentinel LibraryQueryMatch#UNSET_CITATION_KEY instead of an empty string, which would otherwise look indistinguishable from a present-but-empty key.

private List<BibEntry>
runSearch(BibDatabaseContext context, SearchQuery query)

Delegate to whichever org.jabref.logic.search.SearchContext the state manager provides.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER
preferencesback to summary
private CliPreferences preferences
Annotations
@Inject
srvStateManagerback to summary
private SrvStateManager srvStateManager
Annotations
@Inject

Constructor Detail

LibrariesQueryResourceback to summary
public LibrariesQueryResource()

Method Detail

queryback to summary
public LibraryQueryResponse query(LibraryQueryRequest request)

impl->req~jabsrv.query.search~1 Queries are processed independently and their results are returned in input order, so a caller matching a reference list can align the n-th query with the n-th reference.

Annotations
@POST
@Consumes:application/json
@Produces:application/json
runQueryback to summary
private List<LibraryQueryMatch> runQuery(String rawQuery, List<String> libraryIds)

Entries without a citation key are reported with the sentinel LibraryQueryMatch#UNSET_CITATION_KEY instead of an empty string, which would otherwise look indistinguishable from a present-but-empty key. Multiple unkeyed entries still collide on that sentinel — the API identifies entries by citation key, so disambiguation requires assigning keys.

runSearchback to summary
private List<BibEntry> runSearch(BibDatabaseContext context, SearchQuery query)

Delegate to whichever org.jabref.logic.search.SearchContext the state manager provides. In GUI mode this is the live orchestrator that may use the Postgres backend; in stand-alone mode this is a fresh in-memory context.