mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Log user agent if no location can be determined (ie always)
This commit is contained in:
@@ -11,15 +11,6 @@ import au.com.bytecode.opencsv.CSVReader;
|
|||||||
import au.com.bytecode.opencsv.CSVWriter;
|
import au.com.bytecode.opencsv.CSVWriter;
|
||||||
import com.maxmind.geoip.Location;
|
import com.maxmind.geoip.Location;
|
||||||
import com.maxmind.geoip.LookupService;
|
import com.maxmind.geoip.LookupService;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -56,6 +47,14 @@ import org.dspace.statistics.util.LocationUtils;
|
|||||||
import org.dspace.statistics.util.SpiderDetector;
|
import org.dspace.statistics.util.SpiderDetector;
|
||||||
import org.dspace.usage.UsageWorkflowEvent;
|
import org.dspace.usage.UsageWorkflowEvent;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static holder for a HttpSolrClient connection pool to issue
|
* Static holder for a HttpSolrClient connection pool to issue
|
||||||
* usage logging events to Solr from DSpace libraries, and some static query
|
* usage logging events to Solr from DSpace libraries, and some static query
|
||||||
@@ -327,7 +326,10 @@ public class SolrLogger
|
|||||||
log.error("Failed DNS Lookup for IP:" + ip);
|
log.error("Failed DNS Lookup for IP:" + ip);
|
||||||
log.debug(e.getMessage(),e);
|
log.debug(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
if(request.getHeader("User-Agent") != null)
|
||||||
|
{
|
||||||
|
doc1.addField("userAgent", request.getHeader("User-Agent"));
|
||||||
|
}
|
||||||
// Save the location information if valid, save the event without
|
// Save the location information if valid, save the event without
|
||||||
// location information if not valid
|
// location information if not valid
|
||||||
if(locationService != null)
|
if(locationService != null)
|
||||||
@@ -353,10 +355,7 @@ public class SolrLogger
|
|||||||
doc1.addField("longitude", location.longitude);
|
doc1.addField("longitude", location.longitude);
|
||||||
doc1.addField("isBot",isSpiderBot);
|
doc1.addField("isBot",isSpiderBot);
|
||||||
|
|
||||||
if(request.getHeader("User-Agent") != null)
|
|
||||||
{
|
|
||||||
doc1.addField("userAgent", request.getHeader("User-Agent"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +411,10 @@ public class SolrLogger
|
|||||||
log.error("Failed DNS Lookup for IP:" + ip);
|
log.error("Failed DNS Lookup for IP:" + ip);
|
||||||
log.debug(e.getMessage(),e);
|
log.debug(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
if(userAgent != null)
|
||||||
|
{
|
||||||
|
doc1.addField("userAgent", userAgent);
|
||||||
|
}
|
||||||
// Save the location information if valid, save the event without
|
// Save the location information if valid, save the event without
|
||||||
// location information if not valid
|
// location information if not valid
|
||||||
if(locationService != null)
|
if(locationService != null)
|
||||||
@@ -438,10 +440,7 @@ public class SolrLogger
|
|||||||
doc1.addField("longitude", location.longitude);
|
doc1.addField("longitude", location.longitude);
|
||||||
doc1.addField("isBot",isSpiderBot);
|
doc1.addField("isBot",isSpiderBot);
|
||||||
|
|
||||||
if(userAgent != null)
|
|
||||||
{
|
|
||||||
doc1.addField("userAgent", userAgent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user