-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d3bfb5
commit 43d0c7d
Showing
22 changed files
with
154 additions
and
226 deletions.
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
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 was deleted.
Oops, something went wrong.
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
51 changes: 0 additions & 51 deletions
51
src/main/java/net/sf/jabref/logic/crawler/ScienceDirect.java
This file was deleted.
Oops, something went wrong.
21 changes: 2 additions & 19 deletions
21
...java/net/sf/jabref/logic/crawler/ACS.java → ...java/net/sf/jabref/logic/fetcher/ACS.java
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
24 changes: 24 additions & 0 deletions
24
src/main/java/net/sf/jabref/logic/fetcher/FullTextFinder.java
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,24 @@ | ||
package net.sf.jabref.logic.fetcher; | ||
|
||
import net.sf.jabref.BibtexEntry; | ||
|
||
import java.net.URL; | ||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
/** | ||
* This interface is used for classes that try to resolve a full-text PDF url for a BibTex entry. | ||
* Implementing classes should specialize on specific article sites. | ||
* See e.g. @link{http://libguides.mit.edu/apis}. | ||
*/ | ||
public interface FullTextFinder { | ||
/** | ||
* Tries to find a fulltext URL for a given BibTex entry. | ||
* | ||
* @param entry The Bibtex entry | ||
* @return The fulltext PDF URL Optional, if found, or an empty Optional if not found. | ||
* @throws NullPointerException if no BibTex entry is given | ||
* @throws java.io.IOException | ||
*/ | ||
Optional<URL> findFullText(BibtexEntry entry) throws IOException; | ||
} |
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
57 changes: 57 additions & 0 deletions
57
src/main/java/net/sf/jabref/logic/fetcher/ScienceDirect.java
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,57 @@ | ||
package net.sf.jabref.logic.fetcher; | ||
|
||
import com.mashape.unirest.http.HttpResponse; | ||
import com.mashape.unirest.http.Unirest; | ||
import com.mashape.unirest.http.exceptions.UnirestException; | ||
import net.sf.jabref.BibtexEntry; | ||
import net.sf.jabref.logic.util.DOI; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.io.IOException; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* FullTextFinder implementation that attempts to find a PDF URL from a ScienceDirect article page. | ||
* | ||
* @see http://dev.elsevier.com/ | ||
*/ | ||
public class ScienceDirect implements FullTextFinder { | ||
private static final Log LOGGER = LogFactory.getLog(ScienceDirect.class); | ||
|
||
private static final String API_URL = "http://api.elsevier.com/content/article/doi/"; | ||
private static final String API_KEY = "fb82f2e692b3c72dafe5f4f1fa0ac00b"; | ||
@Override | ||
public Optional<URL> findFullText(BibtexEntry entry) throws IOException { | ||
Objects.requireNonNull(entry); | ||
Optional<URL> pdfLink = Optional.empty(); | ||
|
||
// Try unique DOI first | ||
Optional<DOI> doi = DOI.build(entry.getField("doi")); | ||
|
||
if(doi.isPresent()) { | ||
// Available in catalog? | ||
try { | ||
String request = API_URL + doi.get().getDOI(); | ||
HttpResponse<InputStream> response = Unirest.get(request) | ||
.header("X-ELS-APIKey", API_KEY) | ||
.queryString("httpAccept", "application/pdf") | ||
.asBinary(); | ||
|
||
if (response.getStatus() == 200) { | ||
LOGGER.info("Fulltext PDF found @ ScienceDirect."); | ||
pdfLink = Optional.of(new URL(request + "?httpAccept=application/pdf")); | ||
} | ||
} catch(UnirestException e) { | ||
LOGGER.warn("Elsevier API request failed: " + e.getMessage()); | ||
} | ||
} | ||
|
||
// TODO: title search | ||
// We can also get abstract automatically! | ||
return pdfLink; | ||
} | ||
} |
24 changes: 2 additions & 22 deletions
24
...sf/jabref/logic/crawler/SpringerLink.java → ...sf/jabref/logic/fetcher/SpringerLink.java
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.