Skip to content

Conversation

@iloveskittles82
Copy link
Contributor

@iloveskittles82 iloveskittles82 commented Jul 9, 2025

Aims to tackle #12280

With this PR, the HTTP-Server is expanded to supply JabMap with necessary data. Several Endpoints have been added (see LibraryRessource.java and rest-api.http) as well as some DTOs.
The repo for JabMap with a detailed setup description can be found here

I'm marking this as a draft for now to document changes, check mergability and present it to the dev team. It'll stay like this until its integrated properly (tbd).

Steps to test

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

if the server doest find a .jmp, it now returns a mindmap with on a root node saying "JabMap"

private java.nio.file.Path getJabMapDemoPath() {
java.nio.file.Path result = java.nio.file.Path.of(System.getProperty("java.io.tmpdir")).resolve("demo.jmp");
// TODO: make this debug - and adapt "tinylog.properties" locally to use debug level
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address this TODO (and remove this line)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately I don't know why this TODO is here. I don't know what it is adressing tbh. I believe you added it? What did you mean by make this debug - and adapt "tinylog.properties" locally to use debug level?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my sugestions, it is just about changing the letters error to debug. Easy.

I think, you don't want to inspect the .jmp file. Otherwise, you would need to learn about tinylog.properties outlined at https://devdocs.jabref.org/code-howtos/logging.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!

responseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
} else if (requestOrigin.contains("://localhost")) {
responseContext.getHeaders().add("Access-Control-Allow-Origin", requestOrigin);
} else if (requestOrigin.endsWith("://jabref.github.io")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this can be simplified to always return the *

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, please check the code again to confirm I understood you (or rather the code x) correctly

@koppor koppor mentioned this pull request Jul 10, 2025
1 task
*/
public class PdfAnnotationDTO {
// save a LinkedPDFFileDTO which contains all necessary info to make a request back to the http server (e. g. to update the annotation content)
// see https://github.com/JabRef/jabmap/issues/21 first before working with the "path" attribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented there how to make a path absolute.


private java.nio.file.Path getJabMapDemoPath() {
java.nio.file.Path result = java.nio.file.Path.of(System.getProperty("java.io.tmpdir")).resolve("demo.jmp");
// TODO: make this debug - and adapt "tinylog.properties" locally to use debug level
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my sugestions, it is just about changing the letters error to debug. Easy.

I think, you don't want to inspect the .jmp file. Otherwise, you would need to learn about tinylog.properties outlined at https://devdocs.jabref.org/code-howtos/logging.html

@Path("entries/{entryId}")
@Produces(MediaType.TEXT_HTML + ";charset=UTF-8")
public String getHTMLRepresentation(@PathParam("id") String id, @PathParam("entryId") String entryId) throws IOException {
// get entry with given citationkey (entryId)
Copy link
Member

@koppor koppor Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// get entry with given citationkey (entryId)

Comment on lines 304 to 318
// loop through all entries to extract pdfs and paths
for (BibEntry entry : entries) {
List<LinkedFile> pathsToFiles = entry.getFiles();
if (!pathsToFiles.isEmpty()) {
for (LinkedFile file : pathsToFiles) {
// ignore all non pdf files and online references
if (!file.getFileType().equals("PDF") || LinkedFile.isOnlineLink(file.getLink())) {
continue;
}
// add file to response body
LinkedPdfFileDTO localPdfFile = new LinkedPdfFileDTO(entry, file);
response.add(localPdfFile);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good excercise would be to convert this to a Java Stream - but this might be too much for now.

@koppor koppor changed the title Adding HTTP-Server Jabmap Add http endpoints for JabMap Jul 11, 2025
@koppor koppor marked this pull request as ready for review July 15, 2025 17:24
@koppor koppor enabled auto-merge July 15, 2025 17:24
@trag-bot
Copy link

trag-bot bot commented Jul 15, 2025

@trag-bot didn't find any issues in the code! ✅✨

@koppor koppor added this pull request to the merge queue Jul 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 15, 2025
@koppor
Copy link
Member

koppor commented Jul 15, 2025

org.jabref.logic.importer.FetcherException: Error getting response code

Not relevant for this - all checks passed

Therefore manually merging.

@koppor koppor merged commit 25ae95d into JabRef:main Jul 15, 2025
1 check was pending
@koppor koppor deleted the jabmap branch July 15, 2025 17:59
Siedlerchr added a commit that referenced this pull request Aug 2, 2025
* upstream/main:
  Add http endpoints for JabMap (#13519)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants