Commit 47f441e
Add CSL-JSON import endpoint for correct entry-type mapping (#16151)
* Add CSL-JSON import endpoint for correct entry-type mapping
Extend `POST /libraries/{id}/entries` to accept CSL-JSON
(`application/vnd.citationstyles.csl+json`), so browser translators (and any
CSL-JSON producer) can hand items to JabRef and get the correct entry type
instead of a flat @Article.
Rather than a bespoke Zotero-itemType -> BibTeX map (rejected by ADR 0064),
reuse the merged citation-js-based CSL mapping (`CSLItemTypeDefinitions`,
PR #15946): extract the CSL-JSON -> BibEntry core from
`ZoteroCitationMarkParser.toBibEntry` into a new public
`parseCslJsonItems(String)` that accepts a bare CSL item or an array.
`EntriesResource.addCslJson` serialises the mapped entries to BibTeX and
appends them via the existing `AppendBibTeXToLibrary` command, preserving
duplicate handling and group assignment. Entries carry no citation key so
JabRef generates keys on import. Freshly built entries are written with
reformat=true (empty parsed serialisation otherwise writes nothing).
Tests: type/field mapping and array/object/blank/invalid handling in
`ZoteroCitationMarkParserTest`; endpoint conversion + 400 paths in
`EntriesResourceTest`.
Related to #15875
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(changelog): link CSL-JSON endpoint entry to PR #16151
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Drop dead null guards in parseCslJsonItems
The isJsonArray/isJsonObject guards already ensure Gson returns non-null, so
the != null checks were unreachable; removing them also satisfies the
no-null-check style rule.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add CSL-JSON demo requests to import.http
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Guard CSL-JSON import against explicit null fields
CSL-JSON that sets optional properties explicitly to null ("type": null,
"author": null, "issued": null, "issued": {"date-parts": null}) crashed the
import path with an NPE (Gson overwrites the field defaults with null, and the
immutable CSL mapping tables reject a null key lookup), surfacing as HTTP 500.
Normalise type/author/issued and guard date-parts before use. Add a
parameterised regression test covering each null shape.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Use Markdown Javadoc for the group parameter of addCslJson
Replace the traditional @param tag with a Markdown sentence, per the
project's Markdown-Javadoc guideline for new docs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Table-ise the null-field test with @CsvSource
Use @CsvSource with a `|` delimiter (JSON keeps its commas) so the null-field
cases read as a table of input -> expected entry type, and clean up the
provider imports.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Apply OpenRewrite cleanup to ZoteroCitationMarkParserTest
Replace list.get(0) with list.getFirst() per SequencedCollection recipe.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Update jablib/src/main/java/org/jabref/logic/openoffice/ZoteroCitationMarkParser.java
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>1 parent d5f9e8d commit 47f441e
6 files changed
Lines changed: 275 additions & 10 deletions
File tree
- jablib/src
- main/java/org/jabref/logic/openoffice
- test/java/org/jabref/logic/openoffice
- jabsrv/src
- main/java/org/jabref/http/server/resources
- test
- java/org/jabref/http/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
Lines changed: 54 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
55 | 91 | | |
56 | 92 | | |
57 | 93 | | |
| |||
63 | 99 | | |
64 | 100 | | |
65 | 101 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
74 | 118 | | |
75 | 119 | | |
76 | 120 | | |
| |||
92 | 136 | | |
93 | 137 | | |
94 | 138 | | |
95 | | - | |
| 139 | + | |
96 | 140 | | |
97 | 141 | | |
98 | 142 | | |
| |||
Lines changed: 91 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
340 | 343 | | |
341 | 344 | | |
342 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
343 | 434 | | |
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
87 | 130 | | |
88 | 131 | | |
89 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
102 | 143 | | |
103 | 144 | | |
104 | 145 | | |
| |||
116 | 157 | | |
117 | 158 | | |
118 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
119 | 167 | | |
120 | 168 | | |
121 | 169 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| |||
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
118 | 155 | | |
119 | 156 | | |
120 | 157 | | |
| 158 | + | |
121 | 159 | | |
122 | 160 | | |
123 | 161 | | |
| |||
0 commit comments