1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 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 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
Description: patch for building against libunirest-java using android-json
Author: tony mancill <tmancill@debian.org>
Forwarded: not-needed
--- a/src/main/java/net/sf/jabref/gui/worker/VersionWorker.java
+++ b/src/main/java/net/sf/jabref/gui/worker/VersionWorker.java
@@ -17,6 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.json.JSONException;
/**
@@ -53,7 +54,7 @@
protected List<Version> doInBackground() throws Exception {
try {
return Version.getAllAvailableVersions();
- } catch (IOException ioException) {
+ } catch (IOException | JSONException ioException) {
LOGGER.warn("Could not connect to the updateserver.", ioException);
return Collections.emptyList();
}
--- a/src/main/java/net/sf/jabref/logic/util/Version.java
+++ b/src/main/java/net/sf/jabref/logic/util/Version.java
@@ -16,6 +16,7 @@
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.json.JSONException;
/**
* Represents the Application Version with the major and minor number, the full Version String and if it's a developer version
@@ -87,7 +88,7 @@
*
* @throws IOException
*/
- public static List<Version> getAllAvailableVersions() throws IOException {
+ public static List<Version> getAllAvailableVersions() throws IOException, JSONException {
URLConnection connection = new URL(JABREF_GITHUB_RELEASES).openConnection();
connection.setRequestProperty("Accept-Charset", "UTF-8");
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
--- a/src/main/java/net/sf/jabref/logic/importer/fetcher/SpringerLink.java
+++ b/src/main/java/net/sf/jabref/logic/importer/fetcher/SpringerLink.java
@@ -17,6 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
+import org.json.JSONException;
/**
* FulltextFetcher implementation that attempts to find a PDF URL at SpringerLink.
@@ -53,7 +54,7 @@
LOGGER.info("Fulltext PDF found @ Springer.");
pdfLink = Optional.of(new URL("http", CONTENT_HOST, String.format("/content/pdf/%s.pdf", doi.get().getDOI())));
}
- } catch(UnirestException e) {
+ } catch(UnirestException | JSONException e) {
LOGGER.warn("SpringerLink API request failed", e);
}
}
--- a/src/main/java/net/sf/jabref/logic/importer/fetcher/CrossRef.java
+++ b/src/main/java/net/sf/jabref/logic/importer/fetcher/CrossRef.java
@@ -59,7 +59,7 @@
LOGGER.debug("DOI " + dataDOI + " for " + title.get() + " found.");
return DOI.build(dataDOI);
}
- } catch (UnirestException e) {
+ } catch (UnirestException | JSONException e) {
LOGGER.warn("Unable to query CrossRef API: " + e.getMessage(), e);
}
return doi;
--- a/src/main/java/net/sf/jabref/logic/importer/util/JSONEntryParser.java
+++ b/src/main/java/net/sf/jabref/logic/importer/util/JSONEntryParser.java
@@ -10,6 +10,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
+import org.json.JSONException;
import org.json.JSONObject;
public class JSONEntryParser {
@@ -29,11 +30,13 @@
// Fields that are accessible in the journal part of the BibJson object
String[] journalSingleFieldStrings = {FieldName.PUBLISHER, FieldName.NUMBER, FieldName.VOLUME};
-
-
BibEntry entry = new BibEntry();
entry.setType("article");
+ // Debian:
+ // wrap method logic in try/catch for JSONException thrown by libandroid-json-java
+ try {
+
// Authors
if (bibJsonEntry.has("author")) {
JSONArray authors = bibJsonEntry.getJSONArray("author");
@@ -124,6 +127,10 @@
}
}
+ } catch (JSONException e) {
+ LOGGER.error(e);
+ } // Debian: end try/catch wrapper
+
return entry;
}
@@ -141,6 +148,10 @@
BibEntry entry = new BibEntry();
String nametype;
+ // Debian:
+ // wrap method logic in try/catch for JSONException thrown by libandroid-json-java
+ try {
+
// Guess publication type
String isbn = springerJsonEntry.optString("isbn");
if (com.google.common.base.Strings.isNullOrEmpty(isbn)) {
@@ -221,6 +232,10 @@
}
});
+ } catch (JSONException e) {
+ LOGGER.error(e);
+ } // Debian: end try/catch wrapper
+
return entry;
}
}
--- a/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java
+++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java
@@ -197,6 +197,10 @@
StringBuilder bibtexQueryURLStringBuf = new StringBuilder();
bibtexQueryURLStringBuf.append(URL_BIBTEX_START);
+ // Debian:
+ // wrap method logic in try/catch for JSONException thrown by libandroid-json-java
+ try {
+
//loop over each record and create a comma-separate list of article numbers which will be used to download the raw Bibtex
JSONArray recordsJsonArray = searchResultsJson.getJSONArray("records");
for (int n = 0; n < recordsJsonArray.length(); n++) {
@@ -216,6 +220,10 @@
bibtexQueryURLStringBuf.append("&citations-format=citation-only");
}
+ } catch (JSONException e) {
+ LOGGER.error(e);
+ } // Debian: end try/catch wrapper
+
//append the remaining URL
bibtexQueryURLStringBuf.append(URL_BIBTEX_END);
--- a/src/main/java/net/sf/jabref/gui/importer/fetcher/SpringerFetcher.java
+++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/SpringerFetcher.java
@@ -22,6 +22,7 @@
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.json.JSONException;
public class SpringerFetcher implements EntryFetcher {
@@ -97,7 +98,7 @@
Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE);
return false;
}
- } catch (IOException | UnirestException e) {
+ } catch (IOException | UnirestException | JSONException e) {
LOGGER.error("Error while fetching from " + getTitle(), e);
((ImportInspectionDialog)inspector).showErrorMessage(this.getTitle(), e.getLocalizedMessage());
}
--- a/src/main/java/net/sf/jabref/gui/importer/fetcher/DOAJFetcher.java
+++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/DOAJFetcher.java
@@ -19,6 +19,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
+import org.json.JSONException;
import org.json.JSONObject;
public class DOAJFetcher implements EntryFetcher {
@@ -93,7 +94,7 @@
Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE);
return false;
}
- } catch (UnirestException e) {
+ } catch (UnirestException | JSONException e) {
LOGGER.error("Error while fetching from " + getTitle(), e);
((ImportInspectionDialog)inspector).showErrorMessage(this.getTitle(), e.getLocalizedMessage());
return false;
|