mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-11 00:08:49 +00:00
parse session expiry on query more connections
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@358 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
4c95b4ef9a
commit
f50dbbe78d
1 changed files with 17 additions and 15 deletions
|
@ -40,6 +40,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.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
import de.schildbach.pte.exception.SessionExpiredException;
|
||||||
import de.schildbach.pte.util.Color;
|
import de.schildbach.pte.util.Color;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
|
@ -179,7 +180,7 @@ public final class BvgProvider implements NetworkProvider
|
||||||
private static final Pattern P_CHECK_FROM = Pattern.compile("Von:");
|
private static final Pattern P_CHECK_FROM = Pattern.compile("Von:");
|
||||||
private static final Pattern P_CHECK_TO = Pattern.compile("Nach:");
|
private static final Pattern P_CHECK_TO = Pattern.compile("Nach:");
|
||||||
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)|(keine geeigneten Haltestellen)|(keine Verbindung gefunden)|(derzeit nur Auskünfte vom)");
|
.compile("(zu dicht beieinander|mehrfach vorhanden oder identisch)|(keine geeigneten Haltestellen)|(keine Verbindung gefunden)|(derzeit nur Auskünfte vom)|(zwischenzeitlich nicht mehr gespeichert)");
|
||||||
|
|
||||||
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,
|
||||||
final String products, final WalkSpeed walkSpeed) throws IOException
|
final String products, final WalkSpeed walkSpeed) throws IOException
|
||||||
|
@ -187,19 +188,6 @@ public final class BvgProvider implements NetworkProvider
|
||||||
final String uri = connectionsQueryUri(from, via, to, date, dep, products);
|
final String uri = connectionsQueryUri(from, via, to, date, dep, products);
|
||||||
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.UNRESOLVABLE_ADDRESS;
|
|
||||||
if (mError.group(3) != null)
|
|
||||||
return QueryConnectionsResult.NO_CONNECTIONS;
|
|
||||||
if (mError.group(4) != null)
|
|
||||||
return QueryConnectionsResult.INVALID_DATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Matcher mAddress = P_CHECK_ADDRESS.matcher(page);
|
final Matcher mAddress = P_CHECK_ADDRESS.matcher(page);
|
||||||
|
|
||||||
final List<Location> addresses = new ArrayList<Location>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
|
@ -230,7 +218,6 @@ public final class BvgProvider implements NetworkProvider
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +236,21 @@ public final class BvgProvider implements NetworkProvider
|
||||||
|
|
||||||
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.UNRESOLVABLE_ADDRESS;
|
||||||
|
if (mError.group(3) != null)
|
||||||
|
return QueryConnectionsResult.NO_CONNECTIONS;
|
||||||
|
if (mError.group(4) != null)
|
||||||
|
return QueryConnectionsResult.INVALID_DATE;
|
||||||
|
if (mError.group(5) != 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