Skip to content

Commit

Permalink
support glutton server with prefix path
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed May 7, 2019
1 parent 68f43e6 commit 262475b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void init() {
}

initializePaths();
checkProperties();
//checkProperties();
loadPdf2XMLPath();
loadCrfEngine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Observable;
import java.util.concurrent.TimeUnit;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
Expand All @@ -28,6 +29,7 @@
import org.grobid.core.utilities.crossref.CrossrefRequestListener.Response;
import org.grobid.core.utilities.crossref.CrossrefDeserializer;
import org.grobid.core.utilities.crossref.CrossrefRequest;
import org.grobid.core.exceptions.GrobidResourceException;

import org.apache.commons.io.IOUtils;
import java.net.URL;
Expand Down Expand Up @@ -112,10 +114,10 @@ public void execute() {
url += ":" + portInt;
}
}
URIBuilder uriBuilder = new URIBuilder("http://" + url);
URIBuilder uriBuilder = new URIBuilder("http://" + url + BASE_PATH);

String path = BASE_PATH;
uriBuilder.setPath(path);
//String path = BASE_PATH;
//uriBuilder.setPath(path);

// check if we have a strong identifier directly supported by Glutton: DOI, PMID, PMCID
// more probably in the future
Expand Down Expand Up @@ -163,7 +165,9 @@ public void execute() {
if (limitIntervalHeader != null && limitLimitHeader != null)
message.setTimeLimit(limitIntervalHeader.getValue(), limitLimitHeader.getValue());
*/
if (message.status < 200 || message.status >= 300) {
if (message.status == 503) {
throw new GrobidResourceException();
} else if (message.status < 200 || message.status >= 300) {
message.errorMessage = response.getStatusLine().getReasonPhrase();
} else {

Expand All @@ -182,6 +186,18 @@ public void execute() {

httpclient.execute(httpget, responseHandler);

} catch (GrobidResourceException gre) {
try {
httpclient.close();
} catch (IOException e) {
// to log
}
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ie) {
// to log
}
execute();
} catch (Exception e) {
CrossrefRequestListener.Response<T> message = new CrossrefRequestListener.Response<T>();
message.setException(e, this.toString());
Expand Down

0 comments on commit 262475b

Please sign in to comment.