Verified Owner
Top Constructors Methods
org.jabref.http.server.services

public Class ServerUtils

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, java.nio.charset.StandardCharsets, java.nio.file.Path, java.util.List, .Optional, org.jabref.http.SrvStateManager, org.jabref.logic.ai.chatting.ChatModel, org.jabref.logic.ai.chatting.util.ChatModelFactory, org.jabref.logic.importer.FetcherException, .ImportFormatPreferences, org.jabref.logic.importer.fileformat.BibtexImporter, org.jabref.logic.importer.plaincitation.PlainCitationParserChoice, .PlainCitationParserFactory, org.jabref.logic.preferences.CliPreferences, org.jabref.model.database.BibDatabase, .BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.util.DummyFileUpdateMonitor, com.google.common.html.HtmlEscapers, jakarta.ws.rs.NotFoundException, org.jspecify.annotations.NonNull

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static @NonNull BibDatabaseContext
getBibDatabaseContext(String
- also "demo" for the bundled Chocolate.bib demo library, and "current" for the active GUI database
id
,
SrvStateManager srvStateManager, ImportFormatPreferences importFormatPreferences)

Returns the BibDatabaseContext for the given library id.

Looks up the context from the state manager's open databases.

public static @NonNull Path
getLibraryPath(String id, SrvStateManager srvStateManager)

Returns the on-disk path of the library with the given id, looking it up in the state manager's open databases (the same source as getBibDatabaseContext).

public static List<String>
openLibraryIds(SrvStateManager srvStateManager)

Returns ids of all libraries the state manager currently considers open.

public static Optional<BibEntry>
parsePlainCitation(CliPreferences preferences, String citationText)

Parses a single plain-text bibliography reference into a BibEntry using the plain-citation parser the user selected in preferences (including the LLM parser).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ServerUtilsback to summary
public ServerUtils()

Method Detail

getBibDatabaseContextback to summary
public static @NonNull BibDatabaseContext getBibDatabaseContext(String id, SrvStateManager srvStateManager, ImportFormatPreferences importFormatPreferences) throws IOException

Returns the BibDatabaseContext for the given library id.

Looks up the context from the state manager's open databases. In stand-alone server mode those are parsed once at startup and held for the lifetime of the process; in GUI mode they are the user's open library tabs. Either way, the returned context is the same object the state manager registered a org.jabref.logic.search.SearchContext for, so callers can pass it straight to SrvStateManager#getSearchContext.

Parameters
id:String

- also "demo" for the bundled Chocolate.bib demo library, and "current" for the active GUI database

Exceptions
NotFoundException:
if no library with the given id is found
getLibraryPathback to summary
public static @NonNull Path getLibraryPath(String id, SrvStateManager srvStateManager)

Returns the on-disk path of the library with the given id, looking it up in the state manager's open databases (the same source as getBibDatabaseContext).

Exceptions
NotFoundException:
if no library with the given id is found
openLibraryIdsback to summary
public static List<String> openLibraryIds(SrvStateManager srvStateManager)

Returns ids of all libraries the state manager currently considers open. Used by every resource that operates across the open collection (libraries listing, batch query, ...).

parsePlainCitationback to summary
public static Optional<BibEntry> parsePlainCitation(CliPreferences preferences, String citationText) throws org.jabref.logic.importer.FetcherException

Parses a single plain-text bibliography reference into a BibEntry using the plain-citation parser the user selected in preferences (including the LLM parser).

Shared by the entries and citations resources so the parser wiring stays in one place.