Skip to content

Commit

Permalink
Fix arxiv fetcher not working correctly (JabRef#1780)
Browse files Browse the repository at this point in the history
* Fix JabRef#1776, remove Cookie Handler implementation, created problems with arxiv
UrlDl works without or own Cookie class, too

* Fix emptyLine
  • Loading branch information
Siedlerchr authored and ayanai1 committed Sep 5, 2016
1 parent 8db3106 commit c327a36
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 138 deletions.
8 changes: 5 additions & 3 deletions src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
public class ArXiv implements FulltextFetcher, SearchBasedFetcher, IdBasedFetcher {

private static final Log LOGGER = LogFactory.getLog(ArXiv.class);

private static final String API_URL = "http://export.arxiv.org/api/query";


@Override
public Optional<URL> findFullText(BibEntry entry) throws IOException {
Objects.requireNonNull(entry);
Expand Down Expand Up @@ -234,6 +234,7 @@ public Optional<BibEntry> performSearchById(String identifier) throws FetcherExc
return searchForEntryById(identifier).map(ArXivEntry::toBibEntry);
}


private static class ArXivEntry {

private final Optional<String> title;
Expand All @@ -247,6 +248,7 @@ private static class ArXivEntry {
private final Optional<String> journalReferenceText;
private final Optional<String> primaryCategory;


public ArXivEntry(Node item) {
// see http://arxiv.org/help/api/user-manual#_details_of_atom_results_returned

Expand Down Expand Up @@ -302,8 +304,8 @@ public ArXivEntry(Node item) {

// Primary category
// Ex: <arxiv:primary_category xmlns:arxiv="http://arxiv.org/schemas/atom" term="math-ph" scheme="http://arxiv.org/schemas/atom"/>
primaryCategory = XMLUtil.getNode(item, "arxiv:primary_category").flatMap(
node -> XMLUtil.getAttributeContent(node, "term"));
primaryCategory = XMLUtil.getNode(item, "arxiv:primary_category")
.flatMap(node -> XMLUtil.getAttributeContent(node, "term"));
}

/**
Expand Down
122 changes: 0 additions & 122 deletions src/main/java/net/sf/jabref/logic/net/CookieHandlerImpl.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/net/sf/jabref/logic/net/URLDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.net.CookieHandler;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -79,24 +78,12 @@ public URLDownload(URL source) {

addParameters("User-Agent", "JabRef");

URLDownload.setCookieHandler();
}

public URL getSource() {
return source;
}

private static void setCookieHandler() {
try {
// This should set up JabRef to receive cookies properly
if (CookieHandler.getDefault() == null) {
CookieHandler.setDefault(new CookieHandlerImpl());
}
} catch (SecurityException ignored) {
// Setting or getting the system default cookie handler is forbidden
// In this case cookie handling is not possible.
}
}

public String determineMimeType() throws IOException {
// this does not cause a real performance issue as the underlying HTTP/TCP connection is reused
Expand Down

0 comments on commit c327a36

Please sign in to comment.