mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 00:09:55 +00:00
moved empty page retry mechanism to ParserUtils
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@83 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
f74f4419b7
commit
6648d8fa30
2 changed files with 14 additions and 19 deletions
|
@ -213,12 +213,8 @@ public class MvvProvider implements NetworkProvider
|
|||
final LocationType toType, final String to, final Date date, final boolean dep) throws IOException
|
||||
{
|
||||
final String uri = connectionsQueryUri(fromType, from, viaType, via, toType, to, date, dep);
|
||||
CharSequence page = ParserUtils.scrape(uri);
|
||||
while (page.length() == 0)
|
||||
{
|
||||
System.out.println("Got empty page, retrying...");
|
||||
page = ParserUtils.scrape(uri);
|
||||
}
|
||||
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);
|
||||
if (mError.find())
|
||||
|
@ -266,12 +262,7 @@ public class MvvProvider implements NetworkProvider
|
|||
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
||||
{
|
||||
CharSequence page = ParserUtils.scrape(uri);
|
||||
while (page.length() == 0)
|
||||
{
|
||||
System.out.println("Got empty page, retrying...");
|
||||
page = ParserUtils.scrape(uri);
|
||||
}
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
return queryConnections(uri, page);
|
||||
}
|
||||
|
@ -383,12 +374,7 @@ public class MvvProvider implements NetworkProvider
|
|||
|
||||
public GetConnectionDetailsResult getConnectionDetails(final String uri) throws IOException
|
||||
{
|
||||
CharSequence page = ParserUtils.scrape(uri);
|
||||
while (page.length() == 0)
|
||||
{
|
||||
System.out.println("Got empty page, retrying...");
|
||||
page = ParserUtils.scrape(uri);
|
||||
}
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
final Matcher mHead = P_CONNECTION_DETAILS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
|
|
|
@ -85,7 +85,16 @@ public final class ParserUtils
|
|||
}
|
||||
|
||||
pageReader.close();
|
||||
|
||||
if (buffer.length() > 0)
|
||||
return buffer;
|
||||
else
|
||||
{
|
||||
if (tries-- > 0)
|
||||
System.out.println("got empty page, retrying...");
|
||||
else
|
||||
throw new IOException("got empty page: " + url);
|
||||
}
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue