Skip to content

Commit

Permalink
Merge pull request #127 from atmire/DS-1291
Browse files Browse the repository at this point in the history
[DS-1291] Statistics no longer working.
  • Loading branch information
Robin Taylor committed Nov 13, 2012
2 parents d70faeb + 77393e4 commit c871e71
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions dspace-api/src/main/java/org/dspace/statistics/SolrLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean accept(File file) {

LookupService service = null;
// Get the db file for the location
String dbfile = ConfigurationManager.getProperty("solr-statistics", "dbfile");
String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
if (dbfile != null)
{
try
Expand Down Expand Up @@ -298,30 +298,33 @@ private static SolrInputDocument getCommonSolrDoc(DSpaceObject dspaceObject, Htt

// Save the location information if valid, save the event without
// location information if not valid
Location location = locationService.getLocation(ip);
if (location != null
&& !("--".equals(location.countryCode)
&& location.latitude == -180 && location.longitude == -180))
if(locationService != null)
{
try
{
doc1.addField("continent", LocationUtils
.getContinentCode(location.countryCode));
}
catch (Exception e)
Location location = locationService.getLocation(ip);
if (location != null
&& !("--".equals(location.countryCode)
&& location.latitude == -180 && location.longitude == -180))
{
System.out
.println("COUNTRY ERROR: " + location.countryCode);
}
doc1.addField("countryCode", location.countryCode);
doc1.addField("city", location.city);
doc1.addField("latitude", location.latitude);
doc1.addField("longitude", location.longitude);
doc1.addField("isBot",isSpiderBot);
try
{
doc1.addField("continent", LocationUtils
.getContinentCode(location.countryCode));
}
catch (Exception e)
{
System.out
.println("COUNTRY ERROR: " + location.countryCode);
}
doc1.addField("countryCode", location.countryCode);
doc1.addField("city", location.city);
doc1.addField("latitude", location.latitude);
doc1.addField("longitude", location.longitude);
doc1.addField("isBot",isSpiderBot);

if(request.getHeader("User-Agent") != null)
{
doc1.addField("userAgent", request.getHeader("User-Agent"));
if(request.getHeader("User-Agent") != null)
{
doc1.addField("userAgent", request.getHeader("User-Agent"));
}
}
}
}
Expand Down

0 comments on commit c871e71

Please sign in to comment.