mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-24 02:13:09 +00:00
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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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'))
|
||||
|
||||
@@ -243,6 +243,17 @@
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</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>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -75,6 +75,8 @@ Common usage:
|
||||
<format property="build.date" pattern="yyyyMMdd-HHmmss" />
|
||||
</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 -->
|
||||
@@ -88,6 +90,13 @@ Common usage:
|
||||
</fileset>
|
||||
</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 -->
|
||||
@@ -927,10 +936,38 @@ Common usage:
|
||||
|
||||
<!-- installes GeoCity resolution database -->
|
||||
<target name="update_geolite">
|
||||
<echo>Downloading: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz</echo>
|
||||
<get src="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" 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" />
|
||||
<echo>Downloading: ${geolite}</echo>
|
||||
<trycatch property="geolite.error">
|
||||
<try>
|
||||
<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 name="check_geolite">
|
||||
|
||||
Reference in New Issue
Block a user