Added URL connexion error management.
This commit is contained in:
parent
2166819c24
commit
0a5fba2ea5
3 changed files with 84 additions and 53 deletions
|
@ -173,9 +173,16 @@ public class Factory
|
|||
{
|
||||
URL inputURL = new URL(property.getValue());
|
||||
Organization organization = loadOrganization(inputURL, cache);
|
||||
if (organization == null)
|
||||
{
|
||||
logger.error("Loading organization failed for [{}]", property.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
result.getOrganizations().add(organization);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -233,6 +240,12 @@ public class Factory
|
|||
|
||||
File inputFile = cache.restoreFile(inputURL);
|
||||
|
||||
if (inputFile == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
PathProperties properties = PathPropertyUtils.load(inputFile);
|
||||
result = new Organization(properties);
|
||||
result.setInputFile(inputFile);
|
||||
|
@ -251,6 +264,7 @@ public class Factory
|
|||
result.getServices().add(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package fr.devinsy.statoolinfos.crawl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -147,6 +148,9 @@ public class Crawler
|
|||
*/
|
||||
public static void crawl(final URL url, final CrawlCache cache) throws StatoolInfosException, IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
logger.info("Crawling " + url);
|
||||
|
||||
// Crawl.
|
||||
|
@ -182,4 +186,10 @@ public class Crawler
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (java.net.ConnectException | FileNotFoundException exception)
|
||||
{
|
||||
logger.error("ERROR: crawl failed for [{}]: {}", url.toString(), exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,12 @@ public class PathPropertyUtils
|
|||
{
|
||||
PathProperties result;
|
||||
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File parameter is null.");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new PathPropertyList();
|
||||
|
||||
BufferedReader in = null;
|
||||
|
@ -115,6 +121,7 @@ public class PathPropertyUtils
|
|||
{
|
||||
IOUtils.closeQuietly(in);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue