mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 18:39:50 +00:00
detect session expired
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@342 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
3053fececf
commit
45465a87ee
1 changed files with 15 additions and 13 deletions
|
@ -37,6 +37,7 @@ import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.Station;
|
import de.schildbach.pte.dto.Station;
|
||||||
|
import de.schildbach.pte.exception.SessionExpiredException;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +159,7 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
"<select name=\"(REQ0JourneyStopsS0K|REQ0JourneyStopsZ0K|REQ0JourneyStops1\\.0K)\"[^>]*>(.*?)</select>", Pattern.DOTALL);
|
"<select name=\"(REQ0JourneyStopsS0K|REQ0JourneyStopsZ0K|REQ0JourneyStops1\\.0K)\"[^>]*>(.*?)</select>", Pattern.DOTALL);
|
||||||
private static final Pattern P_ADDRESSES = Pattern.compile("<option[^>]*>\\s*(.*?)\\s*</option>", Pattern.DOTALL);
|
private static final Pattern P_ADDRESSES = Pattern.compile("<option[^>]*>\\s*(.*?)\\s*</option>", Pattern.DOTALL);
|
||||||
private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern
|
private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern
|
||||||
.compile("(zu dicht beieinander|mehrfach vorhanden oder identisch)|(leider konnte zu Ihrer Anfrage keine Verbindung gefunden werden)|(derzeit nur Auskünfte vom)");
|
.compile("(zu dicht beieinander|mehrfach vorhanden oder identisch)|(leider konnte zu Ihrer Anfrage keine Verbindung gefunden werden)|(derzeit nur Auskünfte vom)|(zwischenzeitlich nicht mehr gespeichert)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||||
|
@ -167,17 +168,6 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
final String uri = connectionsQueryUri(from, via, to, date, dep);
|
final String uri = connectionsQueryUri(from, via, to, date, dep);
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
|
||||||
final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);
|
|
||||||
if (mError.find())
|
|
||||||
{
|
|
||||||
if (mError.group(1) != null)
|
|
||||||
return QueryConnectionsResult.TOO_CLOSE;
|
|
||||||
if (mError.group(2) != null)
|
|
||||||
return QueryConnectionsResult.NO_CONNECTIONS;
|
|
||||||
if (mError.group(3) != null)
|
|
||||||
return QueryConnectionsResult.INVALID_DATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Location> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Location> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Location> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
@ -217,7 +207,6 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
||||||
{
|
{
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
|
||||||
return queryConnections(uri, page);
|
return queryConnections(uri, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +226,19 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
private QueryConnectionsResult queryConnections(final String uri, final CharSequence page) throws IOException
|
private QueryConnectionsResult queryConnections(final String uri, final CharSequence page) throws IOException
|
||||||
{
|
{
|
||||||
|
final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);
|
||||||
|
if (mError.find())
|
||||||
|
{
|
||||||
|
if (mError.group(1) != null)
|
||||||
|
return QueryConnectionsResult.TOO_CLOSE;
|
||||||
|
if (mError.group(2) != null)
|
||||||
|
return QueryConnectionsResult.NO_CONNECTIONS;
|
||||||
|
if (mError.group(3) != null)
|
||||||
|
return QueryConnectionsResult.INVALID_DATE;
|
||||||
|
if (mError.group(4) != null)
|
||||||
|
throw new SessionExpiredException();
|
||||||
|
}
|
||||||
|
|
||||||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||||
if (mHead.matches())
|
if (mHead.matches())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue