Import & Add PDF Upload Endpoint#14907
Conversation
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
koppor
left a comment
There was a problem hiding this comment.
The issue causing the 500 was different - see #14930
I found out by using the debugger, breakpoints, and following the call hierarchy. The main cause was that the wrong http server constructor was called - without uiMessageHandler.
Please submit Implement PDF Upload (EntryResource.java) as separate PR (based on upstreammain`)
Reason: For each use case a different PR
In case you want to have all updates integrated in your IDE, use GitButler - and maybe magic-merge-commit
CHANGELOG.md
Outdated
| - REST-API: Added more commands (`selectentries`, `open`, `focus`). | ||
| - REST-API: Added the possibility to trigger the import dialog |
There was a problem hiding this comment.
Something is wrong with this PR - maybe not a clean base on upstream/main?
Maybe try:
- Ensure everything is committed
gitk --all&(to start gitk to have the commit IDs ready if something goes wrong)git merge upstream/main(to merge the latest upstream changes)git reset upstream/main(to discard all commits and start a fresh commit)git gui(to craft a new commit. Do NOT commit the changes in the submodule. Try to revert these changes using "Commit" -> "Revert Changes")- Create a new commit using
git gui(maybe other git tooling you use) git push -f(to overwrite the changes also in this PR)
| // Fallback: Use the directory where the bib file is located | ||
| if (targetDirOpt.isEmpty()) { | ||
| targetDirOpt = databaseContext.getDatabasePath().map(java.nio.file.Path::getParent); | ||
| } | ||
|
|
||
| if (targetDirOpt.isEmpty()) { | ||
| throw new BadRequestException("Library must be saved or have a file directory configured to attach files."); | ||
| } |
There was a problem hiding this comment.
No fallback - return bad request if there is no dir.
When did you experience this? Mayge at a new, unsaved library.
| if (Files.exists(finalPath)) { | ||
| String name = com.google.common.io.Files.getNameWithoutExtension(suggestedName); | ||
| String ext = com.google.common.io.Files.getFileExtension(suggestedName); | ||
| finalPath = targetDir.resolve(name + "_" + System.currentTimeMillis() + "." + ext); |
There was a problem hiding this comment.
Can't one write directly to this file?
| String name = com.google.common.io.Files.getNameWithoutExtension(suggestedName); | ||
| String ext = com.google.common.io.Files.getFileExtension(suggestedName); |
There was a problem hiding this comment.
Please useorg.jabref.logic.util.io.FileUtil#getFileExtension(java.nio.file.Path) and org.jabref.logic.util.io.FileUtil#getBaseName(java.lang.String)
| FilesToServe filesToServe = serviceLocator.getService(FilesToServe.class); | ||
| SrvStateManager srvStateManager = serviceLocator.getService(SrvStateManager.class); | ||
| CliPreferences preferences = serviceLocator.getService(CliPreferences.class); | ||
|
|
||
| if (filesToServe == null || srvStateManager == null || preferences == null) { | ||
| throw new IOException("Required services not found in ServiceLocator"); | ||
| } |
There was a problem hiding this comment.
All these changes are not necessary AFAIK.
| // Required for CLI only | ||
| // GUI uses HttpServerManager |
There was a problem hiding this comment.
Strong hint that this is AI generated and the resulting code not reviewed.
There was a problem hiding this comment.
Yes, this is because I have the issue with the http 500 and I ask AI about it. But I am sure that I have reverted everything, pull the latest code for importing and enabling http in Jabref Application. It worked then I implemented the PDF Uploading Endpoints with the same concept of Import. Maybe i have committed no-needed code in Server.java and I don't remember about it. Sorry
0b2941d to
3642482
Compare
|
I have checked that the Import function works without error 500 |
|
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
| if (Files.exists(finalPath)) { | ||
| String name = com.google.common.io.Files.getNameWithoutExtension(suggestedName); | ||
| String ext = com.google.common.io.Files.getFileExtension(suggestedName); | ||
| finalPath = targetDir.resolve(name + "_" + System.currentTimeMillis() + "." + ext); |
There was a problem hiding this comment.
Please do not use a timestamp for the filename. This is not user friendly. Just keep the original name.
|
In the exchange today, we decided to go on with this PR. This comment needs to be resolved: https://github.com/JabRef/jabref/pull/14907/changes#r2730600414 This comment needs to be resolved: https://github.com/JabRef/jabref/pull/14907/changes#r2743826996 This one needs more thought and can be skipped for now to move forward: https://github.com/JabRef/jabref/pull/14907/changes#r2730594969 |
|
I merged |
d785360 to
7875d6f
Compare
|
Hey, we noticed that you force-pushed your changes. Force pushing is a bad practice when working together on a project (mainly because it is not supported well by GitHub itself). Commits are lost and comments on commits lose their context, thus making it harder to review changes. When the pull request is getting integrated into In future, please avoid that. For now, you can continue working. |
7875d6f to
8ce862d
Compare
|
Follow-up: #14963 |
PR Description
Sumary
This PR fixes critical UnsatisfiedDependencyException errors preventing the HTTP Import API from working (as introduced in #14855) and implements the missing PDF Upload endpoint (POST .../files) required for the Researcher Cockpit extension.
Fix Dependency Injection (Server.java)
Fix CLI Server Crash (EntriesResource.java)
Steps to test
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)