20
20
import org .jabref .model .entry .BibEntry ;
21
21
import org .jabref .model .entry .BibEntryTypesManager ;
22
22
import org .jabref .model .entry .LinkedFile ;
23
- import org .jabref .model .entry .field .StandardField ;
24
23
25
24
import com .airhacks .afterburner .injection .Injector ;
26
25
import com .google .gson .Gson ;
@@ -45,16 +44,16 @@ public class LibraryResource {
45
44
private static final Logger LOGGER = LoggerFactory .getLogger (LibraryResource .class );
46
45
47
46
@ Inject
48
- CliPreferences preferences ;
47
+ private CliPreferences preferences ;
49
48
50
49
@ Inject
51
- SrvStateManager srvStateManager ;
50
+ private SrvStateManager srvStateManager ;
52
51
53
52
@ Inject
54
- FilesToServe filesToServe ;
53
+ private FilesToServe filesToServe ;
55
54
56
55
@ Inject
57
- Gson gson ;
56
+ private Gson gson ;
58
57
59
58
/**
60
59
* At http://localhost:23119/libraries/{id}
@@ -202,101 +201,7 @@ private BibDatabaseContext getDatabaseContext(String id) throws IOException {
202
201
return ServerUtils .getBibDatabaseContext (id , filesToServe , srvStateManager , preferences .getImportFormatPreferences ());
203
202
}
204
203
205
- /**
206
- * At http://localhost:23119/libraries/{id}/entries/{entryId} <br><br>
207
- *
208
- * Combines attributes of a given BibEntry into a basic entry preview for as plain text.
209
- *
210
- * @param id The name of the library
211
- * @param entryId The CitationKey of the BibEntry
212
- * @return a basic entry preview as plain text
213
- * @throws IOException
214
- * @throws NotFoundException
215
- */
216
- @ GET
217
- @ Path ("entries/{entryId}" )
218
- @ Produces (MediaType .TEXT_PLAIN + ";charset=UTF-8" )
219
- public String getPlainRepresentation (@ PathParam ("id" ) String id , @ PathParam ("entryId" ) String entryId ) throws IOException {
220
- BibDatabaseContext databaseContext = getDatabaseContext (id );
221
- List <BibEntry > entriesByCitationKey = databaseContext .getDatabase ().getEntriesByCitationKey (entryId );
222
- if (entriesByCitationKey .isEmpty ()) {
223
- throw new NotFoundException ("Entry with citation key '" + entryId + "' not found in library " + id );
224
- }
225
- if (entriesByCitationKey .size () > 1 ) {
226
- LOGGER .warn ("Multiple entries found with citation key '{}'. Using the first one." , entryId );
227
- }
228
-
229
- // TODO: Currently, the preview preferences are in GUI package, which is not accessible here.
230
- // build the preview
231
- BibEntry entry = entriesByCitationKey .getFirst ();
232
-
233
- String author = entry .getField (StandardField .AUTHOR ).orElse ("(N/A)" );
234
- String title = entry .getField (StandardField .TITLE ).orElse ("(N/A)" );
235
- String journal = entry .getField (StandardField .JOURNAL ).orElse ("(N/A)" );
236
- String volume = entry .getField (StandardField .VOLUME ).orElse ("(N/A)" );
237
- String number = entry .getField (StandardField .NUMBER ).orElse ("(N/A)" );
238
- String pages = entry .getField (StandardField .PAGES ).orElse ("(N/A)" );
239
- String releaseDate = entry .getField (StandardField .DATE ).orElse ("(N/A)" );
240
-
241
- // the only difference to the HTML version of this method is the format of the output:
242
- String preview =
243
- "Author: " + author
244
- + "\n Title: " + title
245
- + "\n Journal: " + journal
246
- + "\n Volume: " + volume
247
- + "\n Number: " + number
248
- + "\n Pages: " + pages
249
- + "\n Released on: " + releaseDate ;
250
-
251
- return preview ;
252
- }
253
204
254
- /**
255
- * At http://localhost:23119/libraries/{id}/entries/{entryId} <br><br>
256
- *
257
- * Combines attributes of a given BibEntry into a basic entry preview for as HTML text.
258
- *
259
- * @param id The name of the library
260
- * @param entryId The CitationKey of the BibEntry
261
- * @return a basic entry preview as HTML text
262
- * @throws IOException
263
- */
264
- @ GET
265
- @ Path ("entries/{entryId}" )
266
- @ Produces (MediaType .TEXT_HTML + ";charset=UTF-8" )
267
- public String getHTMLRepresentation (@ PathParam ("id" ) String id , @ PathParam ("entryId" ) String entryId ) throws IOException {
268
- List <BibEntry > entriesByCitationKey = getDatabaseContext (id ).getDatabase ().getEntriesByCitationKey (entryId );
269
- if (entriesByCitationKey .isEmpty ()) {
270
- throw new NotFoundException ("Entry with citation key '" + entryId + "' not found in library " + id );
271
- }
272
- if (entriesByCitationKey .size () > 1 ) {
273
- LOGGER .warn ("Multiple entries found with citation key '{}'. Using the first one." , entryId );
274
- }
275
-
276
- // TODO: Currently, the preview preferences are in GUI package, which is not accessible here.
277
- // build the preview
278
- BibEntry entry = entriesByCitationKey .getFirst ();
279
-
280
- String author = entry .getField (StandardField .AUTHOR ).orElse ("(N/A)" );
281
- String title = entry .getField (StandardField .TITLE ).orElse ("(N/A)" );
282
- String journal = entry .getField (StandardField .JOURNAL ).orElse ("(N/A)" );
283
- String volume = entry .getField (StandardField .VOLUME ).orElse ("(N/A)" );
284
- String number = entry .getField (StandardField .NUMBER ).orElse ("(N/A)" );
285
- String pages = entry .getField (StandardField .PAGES ).orElse ("(N/A)" );
286
- String releaseDate = entry .getField (StandardField .DATE ).orElse ("(N/A)" );
287
-
288
- // the only difference to the plain text version of this method is the format of the output:
289
- String preview =
290
- "<strong>Author:</strong> " + author + "<br>" +
291
- "<strong>Title:</strong> " + title + "<br>" +
292
- "<strong>Journal:</strong> " + journal + "<br>" +
293
- "<strong>Volume:</strong> " + volume + "<br>" +
294
- "<strong>Number:</strong> " + number + "<br>" +
295
- "<strong>Pages:</strong> " + pages + "<br>" +
296
- "<strong>Released on:</strong> " + releaseDate ;
297
-
298
- return preview ;
299
- }
300
205
301
206
/**
302
207
* At http://localhost:23119/libraries/{id}/entries/pdffiles <br><br>
0 commit comments