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

public Class EntriesResource

extends Object
Class Inheritance
Annotations
@Path:libraries/{id}/entries
Imports
java.io.BufferedWriter, .IOException, .Reader, .StringWriter, java.nio.charset.StandardCharsets, java.nio.file.Files, java.util.ArrayList, .List, .Optional, org.jabref.http.SrvStateManager, org.jabref.http.dto.LinkedPdfFileDTO, org.jabref.http.server.services.ServerUtils, org.jabref.logic.UiCommand, .UiMessageHandler, org.jabref.logic.bibtex.BibEntryWriter, .FieldWriter, org.jabref.logic.exporter.BibWriter, org.jabref.logic.importer.FetcherException, org.jabref.logic.importer.util.MediaTypes, org.jabref.logic.openoffice.ZoteroCitationMarkParser, org.jabref.logic.preferences.CliPreferences, org.jabref.logic.util.strings.StringUtil, org.jabref.model.database.BibDatabaseContext, .BibDatabaseMode, org.jabref.model.entry.BibEntry, .BibEntryTypesManager, .LinkedFile, com.google.gson.Gson, jakarta.inject.Inject, jakarta.ws.rs.BadRequestException, .Consumes, .GET, .NotFoundException, .POST, .Path, .PathParam, .Produces, .QueryParam, jakarta.ws.rs.core.MediaType, org.jspecify.annotations.Nullable, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
pack-priv BibEntryTypesManager
pack-priv Gson
private static final Logger
pack-priv CliPreferences
pack-priv SrvStateManager
pack-priv UiMessageHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addBibtex(String id, @Nullable String
optional name of a group the imported entries are additionally assigned to. If the group does not exist, it is created as a top-level group. JabRef merges the entries into the library (duplicate handling applies).
group
,
String bibtex)

Appends BibTeX entries to the currently selected library.

public void
addCslJson(String id, @Nullable String group, String cslJson)

Parses CSL-JSON (a single CSL item or an array of them, as produced by a Zotero / citation-js CSL-JSON export) into BibTeX entries and appends them to the selected library.

public void
addPlainCitation(String id, @Nullable String
optional name of a group the imported entry is additionally assigned to.
group
,
String citationText)

Parses a plain-text bibliography reference into a BibTeX entry and appends it to the currently selected library.

public void
public String
getPDFFilesAsList(String id)

Loops through all entries in the specified library and adds attached files of type "PDF" to a list and JSON serialises it.

private Optional<Path>
resolveTargetLibrary(String id)

Resolves the path-segment library id into the on-disk path the append should target.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entryTypesManagerback to summary
pack-priv BibEntryTypesManager entryTypesManager
Annotations
@Inject
gsonback to summary
pack-priv Gson gson
Annotations
@Inject
LOGGERback to summary
private static final Logger LOGGER
preferencesback to summary
pack-priv CliPreferences preferences
Annotations
@Inject
srvStateManagerback to summary
pack-priv SrvStateManager srvStateManager
Annotations
@Inject
uiMessageHandlerback to summary
pack-priv UiMessageHandler uiMessageHandler
Annotations
@Inject

Constructor Detail

EntriesResourceback to summary
public EntriesResource()

Method Detail

addBibtexback to summary
public void addBibtex(String id, @Nullable String group, String bibtex)

Appends BibTeX entries to the currently selected library.

impl->req~jabsrv.import.group~1

Parameters
group:@Nullable String

optional name of a group the imported entries are additionally assigned to. If the group does not exist, it is created as a top-level group. JabRef merges the entries into the library (duplicate handling applies).

Annotations
@POST
@Consumes:application/x-bibtex
addCslJsonback to summary
public void addCslJson(String id, @Nullable String group, String cslJson) throws IOException

Parses CSL-JSON (a single CSL item or an array of them, as produced by a Zotero / citation-js CSL-JSON export) into BibTeX entries and appends them to the selected library.

The CSL item type and fields are mapped to Bib(La)TeX via the citation-js-based mapping selected in ADR 0064, so a conference paper, book chapter, thesis, report, etc. yields the correct entry type instead of a flat @article. The produced entries carry no citation key; JabRef generates keys on import.

The optional group query parameter additionally files the imported entries under a top-level group of that name, creating it if it does not exist.

Annotations
@POST
@Consumes:application/vnd.citationstyles.csl+json
addPlainCitationback to summary
public void addPlainCitation(String id, @Nullable String group, String citationText) throws org.jabref.logic.importer.FetcherException, IOException

Parses a plain-text bibliography reference into a BibTeX entry and appends it to the currently selected library.

The reference is run through the plain-citation parser the user selected in JabRef's preferences (org.jabref.logic.importer.ImporterPreferences#getDefaultPlainCitationParser()), including the LLM parser.

Parameters
group:@Nullable String

optional name of a group the imported entry is additionally assigned to.

Annotations
@POST
@Consumes:text/plain
addUnknownback to summary
public void addUnknown(String id, Reader body) throws IOException
Annotations
@POST
@Consumes:*/*
getPDFFilesAsListback to summary
public String getPDFFilesAsList(String id) throws IOException

Loops through all entries in the specified library and adds attached files of type "PDF" to a list and JSON serialises it. FIXME: JabMap should serve the files per BibEntry. See https://github.com/JabRef/jabmap/issues/56 for details

Annotations
@GET
@Path:pdffiles
@Produces:application/json;charset=UTF-8
resolveTargetLibraryback to summary
private Optional<Path> resolveTargetLibrary(String id)

Resolves the path-segment library id into the on-disk path the append should target.

"current" keeps the previous behaviour (empty Optional -> active library). Any other id is looked up among the open libraries; an unknown or closed id yields 404 via ServerUtils#getLibraryPath.