Verified Owner
Top Inners Fields Constructors Methods
org.jabref.http.server.cayw

public Class CAYWResource

extends Object
Class Inheritance
Annotations
@NullMarked
@org.jabref.architecture.AllowedToUseAwt
@Path:better-bibtex/cayw
Imports
java.awt.GraphicsEnvironment, java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, java.nio.charset.StandardCharsets, java.nio.file.Files, .InvalidPathException, .Path, java.util.ArrayList, .List, .Optional, .Set, java.util.concurrent.CompletableFuture, .ConcurrentHashMap, .CountDownLatch, .ExecutionException, java.util.regex.Pattern, java.util.stream.Collectors, javafx.application.Platform, javafx.scene.control.Alert, .ButtonBar, .ButtonType, .CheckBox, .Label, javafx.scene.input.ClipboardContent, javafx.scene.layout.VBox, org.jabref.architecture.AllowedToUseAwt, org.jabref.http.JabRefSrvStateManager, .SrvStateManager, org.jabref.http.server.cayw.format.CAYWFormatter, .FormatterService, org.jabref.http.server.cayw.gui.CAYWEntry, .SearchDialog, org.jabref.http.server.services.ServerUtils, org.jabref.logic.importer.fileformat.BibtexImporter, org.jabref.logic.l10n.Localization, org.jabref.logic.preferences.CliPreferences, org.jabref.logic.push.CitationCommandString, .PushToApplications, org.jabref.logic.search.inmemory.InMemoryLibrarySearcher, org.jabref.model.database.BibDatabase, .BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.search.query.SearchQuery, org.jabref.model.util.DummyFileUpdateMonitor, jakarta.inject.Inject, jakarta.ws.rs.BadRequestException, .BeanParam, .GET, .Produces, .WebApplicationException, jakarta.ws.rs.core.MediaType, .Response, org.jspecify.annotations.NullMarked, .Nullable, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private static volatile boolean
private static final Pattern
private static final Set<Path>
private static final String
private static final String
private static final String
private FormatterService
private static boolean
private static final String
private static final Logger
private static final String
private CliPreferences
private SrvStateManager
private static final Set<Path>
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private CAYWEntry
private List<CAYWEntry>
filterEntries(List<CAYWEntry> entries, String searchText, InMemoryLibrarySearcher searcher)

Filter strategy:

  • Empty input → return everything.
  • Valid Search.g4 expression → grammar-based filter via InMemoryLibrarySearcher.
  • Invalid expression (e.g. user is mid-typing author=) → fall back to a plain substring match across the CAYW labels so the list stays useful as the user types.
private BibDatabaseContext
private @Nullable InputStream
getChocolateBibAsStream()

Returns: a stream to the Chocolate.bib file in the classpath (is null only if the file was moved or there are issues with the classpath)

public Response
private BibDatabaseContext
private InputStream
private InputStream
private List<Path>
private synchronized void
private boolean
isLibraryPathAccessAllowed(Path requestedLibraryPath)

private boolean
isServedLibraryPath(Path requestedLibraryPath)

private boolean
matchesSubstring(CAYWEntry entry, String searchText)

private Path
private List<CAYWEntry>
openSearchGui(List<CAYWEntry> entries, BibDatabaseContext databaseContext)

private boolean
promptForLibraryPathAccess(Path requestedLibraryPath)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowAllLibraryPathsback to summary
private static volatile boolean allowAllLibraryPaths
ALLOWED_COMMANDback to summary
private static final Pattern ALLOWED_COMMAND
BLOCKED_LIBRARY_PATHSback to summary
private static final Set<Path> BLOCKED_LIBRARY_PATHS
CAYW_CONTENT_SECURITY_POLICYback to summary
private static final String CAYW_CONTENT_SECURITY_POLICY
CHOCOLATEBIB_PATHback to summary
private static final String CHOCOLATEBIB_PATH
CONTENT_SECURITY_POLICYback to summary
private static final String CONTENT_SECURITY_POLICY
formatterServiceback to summary
private FormatterService formatterService
Annotations
@Inject
initializedback to summary
private static boolean initialized
INVALID_LIBRARY_PATH_ERRORback to summary
private static final String INVALID_LIBRARY_PATH_ERROR
LOGGERback to summary
private static final Logger LOGGER
NO_SNIFFback to summary
private static final String NO_SNIFF
preferencesback to summary
private CliPreferences preferences
Annotations
@Inject
srvStateManagerback to summary
private SrvStateManager srvStateManager
Annotations
@Inject
TRUSTED_LIBRARY_PATHSback to summary
private static final Set<Path> TRUSTED_LIBRARY_PATHS
X_CONTENT_TYPE_OPTIONSback to summary
private static final String X_CONTENT_TYPE_OPTIONS

Constructor Detail

CAYWResourceback to summary
public CAYWResource()

Method Detail

createCAYWEntryback to summary
private CAYWEntry createCAYWEntry(BibEntry entry)
filterEntriesback to summary
private List<CAYWEntry> filterEntries(List<CAYWEntry> entries, String searchText, InMemoryLibrarySearcher searcher)

Filter strategy:

  • Empty input → return everything.
  • Valid Search.g4 expression → grammar-based filter via InMemoryLibrarySearcher.
  • Invalid expression (e.g. user is mid-typing author=) → fall back to a plain substring match across the CAYW labels so the list stays useful as the user types.
getBibDatabaseContextback to summary
private BibDatabaseContext getBibDatabaseContext(CAYWQueryParams queryParams) throws IOException
getChocolateBibAsStreamback to summary
private @Nullable InputStream getChocolateBibAsStream()
Returns:@Nullable InputStream

a stream to the Chocolate.bib file in the classpath (is null only if the file was moved or there are issues with the classpath)

getCitationback to summary
public Response getCitation(CAYWQueryParams queryParams) throws IOException, ExecutionException, InterruptedException
Annotations
@GET
@Produces:text/plain, application/json
getDatabaseContextFromStreamback to summary
private BibDatabaseContext getDatabaseContextFromStream(InputStream inputStream) throws IOException
getDatabaseStreamFromPathback to summary
private InputStream getDatabaseStreamFromPath(Path path) throws IOException
getLatestDatabaseStreamback to summary
private InputStream getLatestDatabaseStream() throws IOException
getServedLibraryPathsback to summary
private List<Path> getServedLibraryPaths()
initializeGUIback to summary
private synchronized void initializeGUI()
isLibraryPathAccessAllowedback to summary
private boolean isLibraryPathAccessAllowed(Path requestedLibraryPath)
isServedLibraryPathback to summary
private boolean isServedLibraryPath(Path requestedLibraryPath)
matchesSubstringback to summary
private boolean matchesSubstring(CAYWEntry entry, String searchText)
normalizeLibraryPathback to summary
private Path normalizeLibraryPath(String libraryPath)
openSearchGuiback to summary
private List<CAYWEntry> openSearchGui(List<CAYWEntry> entries, BibDatabaseContext databaseContext) throws InterruptedException, ExecutionException
promptForLibraryPathAccessback to summary
private boolean promptForLibraryPathAccess(Path requestedLibraryPath)
org.jabref.http.server.cayw back to summary

private final Record CAYWResource.LibraryPathAccessPromptResult

extends Record
Class Inheritance
Record Components
selectedButton:ButtonType 
dontAskAgain:boolean 

Field Summary

Modifier and TypeField and Description
private final boolean
dontAskAgain

Record Component accessed by dontAskAgain().

private final ButtonType
selectedButton

Record Component accessed by selectedButton().

Constructor Summary

AccessConstructor and Description
private
LibraryPathAccessPromptResult(ButtonType selectedButton, boolean dontAskAgain)

Method Summary

Modifier and TypeMethod and Description
public boolean
dontAskAgain()

Record Component getter of dontAskAgain.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public ButtonType
selectedButton()

Record Component getter of selectedButton.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

dontAskAgainback to summary
private final boolean dontAskAgain

Record Component accessed by dontAskAgain().

selectedButtonback to summary
private final ButtonType selectedButton

Record Component accessed by selectedButton().

Constructor Detail

LibraryPathAccessPromptResultback to summary
private LibraryPathAccessPromptResult(ButtonType selectedButton, boolean dontAskAgain)

Method Detail

dontAskAgainback to summary
public boolean dontAskAgain()

Record Component getter of dontAskAgain.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

selectedButtonback to summary
public ButtonType selectedButton()

Record Component getter of selectedButton.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.