From 84d47b6202882fb3e34509e747db3ba0ca3d2472 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 5 Jun 2014 12:52:39 +0200 Subject: [PATCH] Use FileNotFoundException in favour of own NotFoundException on HTTP status "not found". --- .../schildbach/pte/AbstractEfaProvider.java | 4 +- .../pte/exception/NotFoundException.java | 46 ------------------- .../de/schildbach/pte/util/ParserUtils.java | 6 +-- 3 files changed, 5 insertions(+), 51 deletions(-) delete mode 100644 enabler/src/de/schildbach/pte/exception/NotFoundException.java diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 241b22b0..c236979a 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -18,6 +18,7 @@ package de.schildbach.pte; import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -69,7 +70,6 @@ import de.schildbach.pte.dto.StationDepartures; import de.schildbach.pte.dto.Stop; import de.schildbach.pte.dto.Trip; import de.schildbach.pte.exception.InvalidDataException; -import de.schildbach.pte.exception.NotFoundException; import de.schildbach.pte.exception.ParserException; import de.schildbach.pte.exception.ProtocolException; import de.schildbach.pte.exception.SessionExpiredException; @@ -2225,7 +2225,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { throw new ParserException(x); } - catch (final NotFoundException x) + catch (final FileNotFoundException x) { throw new SessionExpiredException(); } diff --git a/enabler/src/de/schildbach/pte/exception/NotFoundException.java b/enabler/src/de/schildbach/pte/exception/NotFoundException.java deleted file mode 100644 index 2534ad7c..00000000 --- a/enabler/src/de/schildbach/pte/exception/NotFoundException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2014 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.exception; - -import java.io.IOException; -import java.net.URL; - -/** - * @author Andreas Schildbach - */ -public class NotFoundException extends IOException -{ - private final URL url; - - public NotFoundException() - { - this.url = null; - } - - public NotFoundException(final URL url) - { - super(url.toString()); - - this.url = url; - } - - public URL getUrl() - { - return url; - } -} diff --git a/enabler/src/de/schildbach/pte/util/ParserUtils.java b/enabler/src/de/schildbach/pte/util/ParserUtils.java index e9552c84..1c4442fc 100644 --- a/enabler/src/de/schildbach/pte/util/ParserUtils.java +++ b/enabler/src/de/schildbach/pte/util/ParserUtils.java @@ -18,6 +18,7 @@ package de.schildbach.pte.util; import java.io.BufferedInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -41,7 +42,6 @@ import java.util.zip.GZIPInputStream; import de.schildbach.pte.exception.BlockedException; import de.schildbach.pte.exception.InternalErrorException; -import de.schildbach.pte.exception.NotFoundException; import de.schildbach.pte.exception.UnexpectedRedirectException; /** @@ -179,7 +179,7 @@ public final class ParserUtils } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { - throw new NotFoundException(url); + throw new FileNotFoundException(url.toString()); } else if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) { @@ -306,7 +306,7 @@ public final class ParserUtils } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { - throw new NotFoundException(url); + throw new FileNotFoundException(url.toString()); } else if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {