-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduces test http server #9748
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7c1df88
Introduces test http server
koppor 37dd6b9
Remove temporary code
koppor 8f05677
Fix checkstyle
koppor 057e982
Create http-server.md with a how-to for the SSL certificate generation
koppor 0d5a695
Merge remote-tracking branch 'upstream/main' into min-http-api
koppor be12664
Enables passing files to a test Server
koppor 817d77d
Merge branch 'main' into min-http-api
koppor 9299917
Merge remote-tracking branch 'upstream/main' into min-http-api
Siedlerchr 9cde0a6
fix some gradle tasks
Siedlerchr 7fb5100
fix test build
Siedlerchr 75e7de1
Fix broken JavaDoc
koppor ef1c34a
upgrade jersey to 3.1.3
Siedlerchr f003363
Merge branch 'min-http-api' of github.com:JabRef/jabref into min-http…
Siedlerchr 94a05ca
Fix checkstyle
koppor e09ead0
Update http-server.md
koppor 29072fc
rewrite run
Siedlerchr 7f0172a
Merge branch 'min-http-api' of github.com:JabRef/jabref into min-http…
Siedlerchr 59788d0
rename to avoid clash
Siedlerchr 018277e
Hints on http server
koppor 1c15c60
Update http-server.md
koppor 2e9ae7d
Better parameter name
koppor 2d9e8db
Add missing "requires"
koppor bccf22d
Create resource path only if required
koppor 72d0593
Refine howto
koppor 19e73e6
Add IntelliJ hint
koppor 6f51b07
Add AllowedToUseStandardStreams
koppor 8deec24
Also exclude TestBibFile
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
parent: Code Howtos | ||
--- | ||
# HTTP Server | ||
|
||
## Get SSL Working | ||
|
||
(Based on <https://stackoverflow.com/a/57511038/873282>) | ||
|
||
Howto for Windows - other operating systems work similar: | ||
|
||
1. As admin `choco install mkcert` | ||
2. As admin: `mkcert -install` | ||
3. `cd %APPDATA%\..\local\org.jabref\jabref\ssl` | ||
4. `mkcert -pkcs12 jabref.desktop jabref localhost 127.0.0.1 ::1` | ||
5. Rename the file to `server.p12` | ||
|
||
Note: If you do not do this, you get following error message: | ||
|
||
Could not find server key store C:\Users\USERNAME\AppData\Local\org.jabref\jabref\ssl\server.p12. | ||
|
||
## Start http server | ||
|
||
The class starting the server is `org.jabref.http.server.Server`. | ||
|
||
Test files to server can be passed as arguments. | ||
If no files are passed, the last opened files are served. | ||
If that list is also empty, the file `src/main/resources/org/jabref/http/server/http-server-demo.bib` is served. | ||
|
||
### Starting with gradle | ||
|
||
Does not work. | ||
|
||
Current try: | ||
|
||
./gradlew run -Pcomment=httpserver | ||
|
||
However, there are with `ForkJoin` (discussion at https://discuss.gradle.org/t/is-it-ok-to-use-collection-parallelstream-or-other-potentially-multi-threaded-code-within-gradle-plugin-code/28003) | ||
|
||
Gradle output: | ||
|
||
``` | ||
> Task :run | ||
2023-04-22 11:30:59 [main] org.jabref.http.server.Server.main() | ||
DEBUG: Libraries served: [C:\git-repositories\jabref-all\jabref\src\main\resources\org\jabref\http\server\http-server-demo.bib] | ||
2023-04-22 11:30:59 [main] org.jabref.http.server.Server.startServer() | ||
DEBUG: Starting server... | ||
<============-> 92% EXECUTING [2m 27s] | ||
> :run | ||
``` | ||
|
||
IntelliJ output, if `org.jabref.http.server.Server#main` is executed: | ||
|
||
``` | ||
DEBUG: Starting server... | ||
2023-04-22 11:44:59 [ForkJoinPool.commonPool-worker-1] org.glassfish.grizzly.http.server.NetworkListener.start() | ||
INFO: Started listener bound to [localhost:6051] | ||
2023-04-22 11:44:59 [ForkJoinPool.commonPool-worker-1] org.glassfish.grizzly.http.server.HttpServer.start() | ||
INFO: [HttpServer] Started. | ||
2023-04-22 11:44:59 [ForkJoinPool.commonPool-worker-1] org.jabref.http.server.Server.lambda$startServer$4() | ||
DEBUG: Server started. | ||
``` | ||
|
||
## Developing with IntelliJ | ||
|
||
IntelliJ Ultimate offers a Markdown-based http-client. One has to open the file `src/test/java/org/jabref/testutils/interactive/http/rest-api.http`. | ||
Then, there are play buttons appearing for interacting with the server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
nav_order: 27 | ||
parent: Decision Records | ||
--- | ||
<!-- we need to disable MD025, because we use the different heading "ADR Template" in the homepage (see above) than it is foreseen in the template --> | ||
<!-- markdownlint-disable-next-line MD025 --> | ||
# Return BibTeX string and CSL Item JSON in the API | ||
|
||
## Context and Problem Statement | ||
|
||
In the context of an http server, when a http client `GETs` a JSON data structure containing BibTeX data, which format should that have? | ||
|
||
## Considered Options | ||
|
||
* Offer both, BibTeX string and CSL JSON | ||
* Return BibTeX as is as string | ||
* Convert BibTeX to JSON | ||
|
||
## Decision Outcome | ||
|
||
Chosen option: "Offer both, BibTeX string and CSL JSON", because there are many browser libraries out there being able to parse BibTeX. Thus, we don't need to convert it. | ||
|
||
## Pros and Cons of the Options | ||
|
||
### Offer both, BibTeX string and CSL JSON | ||
|
||
- Good, because this follows "Backend for Frontend" | ||
- Good, because Word Addin works seamless with the data provided (and does not need another dependency) | ||
- Good, because other clients can work with BibTeX data | ||
- Bad, because two serializations have to be kept | ||
|
||
### Return BibTeX as is as string | ||
|
||
- Good, because we don't need to think about any conversion | ||
- Bad, because it is unclear how to ship BibTeX data where the entry is dependent on | ||
- Bad, because client needs add additional parsing logic | ||
|
||
### Convert BibTeX to JSON | ||
|
||
More thought has to be done when converting to JSON. | ||
There seems to be a JSON format from [@citation-js/plugin-bibtex](https://www.npmjs.com/package/@citation-js/plugin-bibtex). | ||
We could do an additional self-made JSON format, but this increases the number of available JSON serializations for BibTeX. | ||
|
||
- Good, because it could flatten BibTeX data (example: `author = first # " and " # second`) | ||
- Bad, because conversion is difficult in BibTeX special cases. For instance, if Strings are used (example: `author = first # " and " # second`) and one doesn't want to flatten ("normalize") this. | ||
|
||
## More Information | ||
|
||
Existing JavaScript BibTeX libraries: | ||
|
||
* [bibtex-js](https://github.com/digitalheir/bibtex-js) | ||
* [bibtexParseJS](https://github.com/ORCID/bibtexParseJs) | ||
* [@citation-js/plugin-bibtex](https://www.npmjs.com/package/@citation-js/plugin-bibtex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this jul adapter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The Grizzly http server uses java-util-logging. To be able to handle the log output with our logging framework tinylog, we need jul-slf4j-tinylog.
More detailed:
The alternative can be to disable logging of Grizzly completely and bring it back (with the bridge) if needed.