Skip to content

refine-jabsrv#13044

Merged
koppor merged 31 commits into
mainfrom
refine-http-api-tests
May 2, 2025
Merged

refine-jabsrv#13044
koppor merged 31 commits into
mainfrom
refine-http-api-tests

Conversation

@koppor

@koppor koppor commented May 2, 2025

Copy link
Copy Markdown
Member

Fixes jabsrv

  • Runs :)
  • List of opened libraries now known to the resources
  • Switches to Chocolate.bib
  • Makes rest-api.http "running" without SSL

Future work: Get SSL working again

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.


private java.nio.file.Path getLibraryPath(String id) {
return preferences.getLastFilesOpenedPreferences().getLastFilesOpened()
return filesToServe.getFilesToServe()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The method getLibraryPath uses a filter to find a file path, but it throws a NotFoundException if no match is found. This is using exceptions for control flow, which is not recommended.

Comment on lines +15 to +17
public List<Path> getFilesToServe() {
return filesToServe;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The method getFilesToServe() should not return null. It should return an Optional to avoid potential null pointer exceptions.


exports org.jabref.http.dto to com.google.gson, org.glassfish.hk2.locator;

opens org.jabref.http.server to org.glassfish.hk2.utilities, org.glassfish.hk2.locator;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The 'opens' directive is reformatted without adding new statements. Reformatting should only occur with new statements to avoid unnecessary changes.


import org.jabref.logic.util.io.BackupFileUtil;

/// Holds information about test .bib files

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment uses three slashes which is not standard JavaDoc format. JavaDoc should be used for method and class comments to provide a high-level summary.


/// Holds information about test .bib files
///
/// We cannot use a string constant as the path changes from OS to OS. Therefore, we need to dynamically create the expected result.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment is trivial and restates the obvious from the code. Comments should provide new information or reasoning not plainly derived from the code.

@koppor koppor added the component: jabsrv JabRef's http server label May 2, 2025
@koppor koppor added the automerge PR is tagged with that label will be merged if workflows are green label May 2, 2025
jabref-machine
jabref-machine previously approved these changes May 2, 2025
@koppor koppor enabled auto-merge May 2, 2025 08:20
@koppor

koppor commented May 2, 2025

Copy link
Copy Markdown
Member Author

"automerge" as this is kind of a "hot fix" (a student group is relying in a working http server)

Comment on lines +24 to +27
String expected = """
[
"%s"
]""".formatted(TestBibFile.GENERAL_SERVER_TEST.id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using Java Text blocks for single-line strings is unnecessary and can reduce readability. Text blocks are more suitable for multi-line strings.

@koppor koppor enabled auto-merge May 2, 2025 08:26
@koppor koppor added automerge PR is tagged with that label will be merged if workflows are green and removed automerge PR is tagged with that label will be merged if workflows are green labels May 2, 2025
jabref-machine
jabref-machine previously approved these changes May 2, 2025
@koppor koppor disabled auto-merge May 2, 2025 08:50
@koppor koppor removed the automerge PR is tagged with that label will be merged if workflows are green label May 2, 2025
@koppor koppor added the automerge PR is tagged with that label will be merged if workflows are green label May 2, 2025
SLF4JBridgeHandler.install();

final List<Path> lastFilesOpened = new ArrayList<>(); // JabRefCliPreferences.getInstance().getGuiPreferences().getLastFilesOpened();
final List<Path> filesToServe = JabRefCliPreferences.getInstance().getLastFilesOpenedPreferences().getLastFilesOpened().stream().collect(Collectors.toCollection(ArrayList::new));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The use of Collectors.toCollection(ArrayList::new) is unnecessary. The Stream API provides a simpler toList() method that should be used for better readability and maintainability.

@koppor koppor enabled auto-merge May 2, 2025 09:07
@koppor koppor added this pull request to the merge queue May 2, 2025
@github-actions

github-actions Bot commented May 2, 2025

Copy link
Copy Markdown
Contributor

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

Merged via the queue into main with commit ae457db May 2, 2025
2 checks passed
@koppor koppor deleted the refine-http-api-tests branch May 2, 2025 10:32
Siedlerchr added a commit that referenced this pull request May 2, 2025
* upstream/main:
  Fix directory path validation checks (#13029)
  Keep merge=union for JabRef_en.properties
  Merging Entry Creation Buttons Into a Single Tool (#13020)
  refine-jabsrv (#13044)
  Switch if branches for readbility (#13042)
  Updating the gradle wrapper does not need any JDK (#13037)
  Fix path - and fix typo (#13038)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge PR is tagged with that label will be merged if workflows are green component: jabsrv JabRef's http server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants