@@ -33,32 +33,32 @@ public class SpringerLink implements FulltextFetcher {
33
33
@ Override
34
34
public Optional <URL > findFullText (BibEntry entry ) throws IOException {
35
35
Objects .requireNonNull (entry );
36
- Optional <URL > pdfLink = Optional .empty ();
37
36
38
37
// Try unique DOI first
39
38
Optional <DOI > doi = entry .getField (StandardField .DOI ).flatMap (DOI ::parse );
40
39
41
- if (doi .isPresent ()) {
42
- // Available in catalog?
43
- try {
44
- HttpResponse <JsonNode > jsonResponse = Unirest .get (API_URL )
45
- .queryString ("api_key" , API_KEY )
46
- .queryString ("q" , String .format ("doi:%s" , doi .get ().getDOI ()))
47
- .asJson ();
48
- if (jsonResponse .getBody () != null ) {
49
- JSONObject json = jsonResponse .getBody ().getObject ();
50
- int results = json .getJSONArray ("result" ).getJSONObject (0 ).getInt ("total" );
40
+ if (!doi .isPresent ()) {
41
+ return Optional .empty ();
42
+ }
43
+ // Available in catalog?
44
+ try {
45
+ HttpResponse <JsonNode > jsonResponse = Unirest .get (API_URL )
46
+ .queryString ("api_key" , API_KEY )
47
+ .queryString ("q" , String .format ("doi:%s" , doi .get ().getDOI ()))
48
+ .asJson ();
49
+ if (jsonResponse .getBody () != null ) {
50
+ JSONObject json = jsonResponse .getBody ().getObject ();
51
+ int results = json .getJSONArray ("result" ).getJSONObject (0 ).getInt ("total" );
51
52
52
- if (results > 0 ) {
53
- LOGGER .info ("Fulltext PDF found @ Springer." );
54
- pdfLink = Optional .of (new URL ("http" , CONTENT_HOST , String .format ("/content/pdf/%s.pdf" , doi .get ().getDOI ())));
55
- }
53
+ if (results > 0 ) {
54
+ LOGGER .info ("Fulltext PDF found @ Springer." );
55
+ return Optional .of (new URL ("http" , CONTENT_HOST , String .format ("/content/pdf/%s.pdf" , doi .get ().getDOI ())));
56
56
}
57
- } catch (UnirestException e ) {
58
- LOGGER .warn ("SpringerLink API request failed" , e );
59
57
}
58
+ } catch (UnirestException e ) {
59
+ LOGGER .warn ("SpringerLink API request failed" , e );
60
60
}
61
- return pdfLink ;
61
+ return Optional . empty () ;
62
62
}
63
63
64
64
@ Override
0 commit comments