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
This commit is contained in:
Tim Donohue
2011-09-01 20:33:19 +00:00
parent dd9229d9a2
commit 91dd450be4
4 changed files with 73 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ package org.dspace.statistics;
import com.maxmind.geoip.Location; import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService; import com.maxmind.geoip.LookupService;
import java.io.FileNotFoundException;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
@@ -46,7 +47,7 @@ import java.util.*;
*/ */
public class SolrLogger 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; private static final CommonsHttpSolrServer solr;
@@ -95,14 +96,18 @@ public class SolrLogger
service = new LookupService(dbfile, service = new LookupService(dbfile,
LookupService.GEOIP_STANDARD); 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) 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 else
{ {
// System.out.println("NO SOLR DB FILE !"); log.error("The required 'dbfile' configuration is missing in solr-statistics.cfg!");
} }
locationService = service; locationService = service;

View File

@@ -472,7 +472,19 @@ public class StatisticsImporter
metadataStorageInfo = SolrLogger.getMetadataStorageInfo(); metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
String dbfile = ConfigurationManager.getProperty("solr-statistics", "dbfile"); 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); StatisticsImporter si = new StatisticsImporter(local);
if (line.hasOption('m')) if (line.hasOption('m'))

View File

@@ -243,6 +243,17 @@
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>servlet-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -75,6 +75,8 @@ Common usage:
<format property="build.date" pattern="yyyyMMdd-HHmmss" /> <format property="build.date" pattern="yyyyMMdd-HHmmss" />
</tstamp> </tstamp>
<!-- Default location of GeoLiteCity.dat.gz to download. This may be overridden, if URL path changes. -->
<property name="geolite" value="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" />
<!-- ============================================================= --> <!-- ============================================================= -->
<!-- The DSpace class path for executing installation targets --> <!-- The DSpace class path for executing installation targets -->
@@ -88,6 +90,13 @@ Common usage:
</fileset> </fileset>
</path> </path>
<!-- ============================================================= -->
<!-- Load various Ant libraries which define extra tasks. -->
<!-- ============================================================= -->
<!--Load/initialize all Ant-Contrib libraries from DSpace 'class.path' above.
For more info, see:
http://ant-contrib.sourceforge.net/tasks/index.html -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="class.path"/>
<!-- ============================================================= --> <!-- ============================================================= -->
<!-- Print some useful help text --> <!-- Print some useful help text -->
@@ -927,10 +936,38 @@ Common usage:
<!-- installes GeoCity resolution database --> <!-- installes GeoCity resolution database -->
<target name="update_geolite"> <target name="update_geolite">
<echo>Downloading: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz</echo> <echo>Downloading: ${geolite}</echo>
<get src="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" dest="${dspace.dir}/config/GeoLiteCity.dat.gz" verbose="true" /> <trycatch property="geolite.error">
<gunzip src="${dspace.dir}/config/GeoLiteCity.dat.gz" dest="${dspace.dir}/config/GeoLiteCity.dat" /> <try>
<delete file="${dspace.dir}/config/GeoLiteCity.dat.gz" /> <get src="${geolite}" dest="${dspace.dir}/config/GeoLiteCity.dat.gz" verbose="true"/>
<gunzip src="${dspace.dir}/config/GeoLiteCity.dat.gz" dest="${dspace.dir}/config/GeoLiteCity.dat" />
<delete file="${dspace.dir}/config/GeoLiteCity.dat.gz" />
</try>
<catch>
<echo>
====================================================================
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'
====================================================================
</echo>
</catch>
</trycatch>
</target> </target>
<target name="check_geolite"> <target name="check_geolite">