From 91dd450be4304753d8011bc4acf0b69cc25cbd1c Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Thu, 1 Sep 2011 20:33:19 +0000 Subject: [PATCH] Fix for DS-878 : update_geolite timesout when downloading GeoLiteCity.dat.gz See comments on that JIRA ticket. Essentially this ensures you can install DSpace without GeoLite (if a download error occurs), and also gives more options to install Geolite later on (if it failed during the initial DSpace install) git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6636 9c30dcfa-912a-0410-8fc2-9e0234be79fd --- .../org/dspace/statistics/SolrLogger.java | 11 +++-- .../statistics/util/StatisticsImporter.java | 14 +++++- dspace/pom.xml | 11 +++++ dspace/src/main/config/build.xml | 45 +++++++++++++++++-- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/dspace-stats/src/main/java/org/dspace/statistics/SolrLogger.java b/dspace-stats/src/main/java/org/dspace/statistics/SolrLogger.java index c1ac64ae6b..3161028c4d 100644 --- a/dspace-stats/src/main/java/org/dspace/statistics/SolrLogger.java +++ b/dspace-stats/src/main/java/org/dspace/statistics/SolrLogger.java @@ -9,6 +9,7 @@ package org.dspace.statistics; import com.maxmind.geoip.Location; import com.maxmind.geoip.LookupService; +import java.io.FileNotFoundException; import org.apache.commons.lang.time.DateFormatUtils; import org.apache.log4j.Logger; import org.apache.solr.client.solrj.SolrQuery; @@ -46,7 +47,7 @@ import java.util.*; */ public class SolrLogger { - private static Logger log = Logger.getLogger(SolrLogger.class); + private static final Logger log = Logger.getLogger(SolrLogger.class); private static final CommonsHttpSolrServer solr; @@ -95,14 +96,18 @@ public class SolrLogger service = new LookupService(dbfile, LookupService.GEOIP_STANDARD); } + catch (FileNotFoundException fe) + { + log.error("The GeoLite Database file is missing (" + dbfile + ")! Solr Statistics cannot generate location based reports! Please see the DSpace installation instructions for instructions to install this file.", fe); + } catch (IOException e) { - e.printStackTrace(); + log.error("Unable to load GeoLite Database file (" + dbfile + ")! You may need to reinstall it. See the DSpace installation instructions for more details.", e); } } else { - // System.out.println("NO SOLR DB FILE !"); + log.error("The required 'dbfile' configuration is missing in solr-statistics.cfg!"); } locationService = service; diff --git a/dspace-stats/src/main/java/org/dspace/statistics/util/StatisticsImporter.java b/dspace-stats/src/main/java/org/dspace/statistics/util/StatisticsImporter.java index 83cb0a182b..4c279e7ea9 100644 --- a/dspace-stats/src/main/java/org/dspace/statistics/util/StatisticsImporter.java +++ b/dspace-stats/src/main/java/org/dspace/statistics/util/StatisticsImporter.java @@ -472,7 +472,19 @@ public class StatisticsImporter metadataStorageInfo = SolrLogger.getMetadataStorageInfo(); String dbfile = ConfigurationManager.getProperty("solr-statistics", "dbfile"); - geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD); + try + { + geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD); + } + catch (FileNotFoundException fe) + { + log.error("The GeoLite Database file is missing (" + dbfile + ")! Solr Statistics cannot generate location based reports! Please see the DSpace installation instructions for instructions to install this file.", fe); + } + catch (IOException e) + { + log.error("Unable to load GeoLite Database file (" + dbfile + ")! You may need to reinstall it. See the DSpace installation instructions for more details.", e); + } + StatisticsImporter si = new StatisticsImporter(local); if (line.hasOption('m')) diff --git a/dspace/pom.xml b/dspace/pom.xml index 86a627bb70..4dbccf82b9 100644 --- a/dspace/pom.xml +++ b/dspace/pom.xml @@ -243,6 +243,17 @@ javax.servlet servlet-api + + ant-contrib + ant-contrib + 1.0b3 + + + ant + ant + + + diff --git a/dspace/src/main/config/build.xml b/dspace/src/main/config/build.xml index a8ca6e5c79..de6fd239c5 100644 --- a/dspace/src/main/config/build.xml +++ b/dspace/src/main/config/build.xml @@ -75,6 +75,8 @@ Common usage: + + @@ -88,6 +90,13 @@ Common usage: + + + + + @@ -927,10 +936,38 @@ Common usage: - Downloading: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz - - - + Downloading: ${geolite} + + + + + + + + +==================================================================== +WARNING : FAILED TO DOWNLOAD GEOLITE DATABASE FILE + (Used for DSpace Solr Usage Statistics) + +Underlying Error: ${geolite.error} + +In order to use DSpace Solr Usage Statistics, you will need to +manually re-run: + +ant update_geolite + +OR + +You may manually install this file by following these steps: +(1) Download the file from ${geolite} +(2) Unzip it to create a file named 'GeoLiteCity.dat' +(3) Copy that file to '${dspace.dir}/config/GeoLiteCity.dat' + +==================================================================== + + + +