org.dspace.statistics
Class SolrLogger

java.lang.Object
  extended by org.dspace.statistics.SolrLogger

public class SolrLogger
extends Object

Static holder for a HttpSolrClient connection pool to issue usage logging events to Solr from DSpace libraries, and some static query composers.

Author:
ben at atmire.com, kevinvandevelde at atmire.com, mdiggory at atmire.com

Nested Class Summary
static class SolrLogger.ResultProcessor
           
 
Field Summary
static String DATE_FORMAT_8601
           
static String DATE_FORMAT_DCDATE
           
 
Constructor Summary
SolrLogger()
           
 
Method Summary
static void deleteIP(String ip)
           
static void deleteRobotsByIP()
           
static void deleteRobotsByIsBotFlag()
           
static String getIgnoreSpiderIPs()
          Returns in a filterQuery string all the ip addresses that should be ignored
static Map<String,String> getMetadataStorageInfo()
           
static boolean isUseProxies()
           
static void markRobotByUserAgent(String agent)
           
static void markRobotsByIP()
           
static void optimizeSOLR()
          Maintenance to keep a SOLR index efficient.
static void post(DSpaceObject dspaceObject, javax.servlet.http.HttpServletRequest request, EPerson currentUser)
          Store a usage event into Solr.
static void query(String query, int max)
           
static ObjectCount[] queryFacetDate(String query, String filterQuery, int max, String dateType, String dateStart, String dateEnd, boolean showTotal)
          Query used to get values grouped by the date.
static ObjectCount[] queryFacetField(String query, String filterQuery, String facetField, int max, boolean showTotal, List<String> facetQueries)
          Query used to get values grouped by the given facet field.
static Map<String,Integer> queryFacetQuery(String query, String filterQuery, List<String> facetQueries)
           
static Map<String,List<String>> queryField(String query, List oldFieldVals, String field)
           
static ObjectCount queryTotal(String query, String filterQuery)
           
static void removeIndex(String query)
          Delete data from the index, as described by a query.
static void storeParents(org.apache.solr.common.SolrInputDocument doc1, DSpaceObject dso)
          Method just used to log the parents.
static void update(String query, String action, List<String> fieldNames, List<List<Object>> fieldValuesList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT_8601

public static final String DATE_FORMAT_8601
See Also:
Constant Field Values

DATE_FORMAT_DCDATE

public static final String DATE_FORMAT_DCDATE
See Also:
Constant Field Values
Constructor Detail

SolrLogger

public SolrLogger()
Method Detail

post

public static void post(DSpaceObject dspaceObject,
                        javax.servlet.http.HttpServletRequest request,
                        EPerson currentUser)
Store a usage event into Solr.

Parameters:
dspaceObject - the object used.
request - the current request context.
currentUser - the current session's user.

getMetadataStorageInfo

public static Map<String,String> getMetadataStorageInfo()

storeParents

public static void storeParents(org.apache.solr.common.SolrInputDocument doc1,
                                DSpaceObject dso)
                         throws SQLException
Method just used to log the parents.

Parameters:
doc1 - the current SolrInputDocument
dso - the current dspace object we want to log
Throws:
SQLException - ignore it

isUseProxies

public static boolean isUseProxies()

removeIndex

public static void removeIndex(String query)
                        throws IOException,
                               org.apache.solr.client.solrj.SolrServerException
Delete data from the index, as described by a query.

Parameters:
query - description of the records to be deleted.
Throws:
IOException
org.apache.solr.client.solrj.SolrServerException

queryField

public static Map<String,List<String>> queryField(String query,
                                                  List oldFieldVals,
                                                  String field)

markRobotsByIP

public static void markRobotsByIP()

markRobotByUserAgent

public static void markRobotByUserAgent(String agent)

deleteRobotsByIsBotFlag

public static void deleteRobotsByIsBotFlag()

deleteIP

public static void deleteIP(String ip)

deleteRobotsByIP

public static void deleteRobotsByIP()

update

public static void update(String query,
                          String action,
                          List<String> fieldNames,
                          List<List<Object>> fieldValuesList)
                   throws org.apache.solr.client.solrj.SolrServerException,
                          IOException
Throws:
org.apache.solr.client.solrj.SolrServerException
IOException

query

public static void query(String query,
                         int max)
                  throws org.apache.solr.client.solrj.SolrServerException
Throws:
org.apache.solr.client.solrj.SolrServerException

queryFacetField

public static ObjectCount[] queryFacetField(String query,
                                            String filterQuery,
                                            String facetField,
                                            int max,
                                            boolean showTotal,
                                            List<String> facetQueries)
                                     throws org.apache.solr.client.solrj.SolrServerException
Query used to get values grouped by the given facet field.

Parameters:
query - the query to be used
facetField - the facet field on which to group our values
max - the max number of values given back (in case of 10 the top 10 will be given)
showTotal - a boolean determining whether the total amount should be given back as the last element of the array
Returns:
an array containing our results
Throws:
org.apache.solr.client.solrj.SolrServerException - ...

queryFacetDate

public static ObjectCount[] queryFacetDate(String query,
                                           String filterQuery,
                                           int max,
                                           String dateType,
                                           String dateStart,
                                           String dateEnd,
                                           boolean showTotal)
                                    throws org.apache.solr.client.solrj.SolrServerException
Query used to get values grouped by the date.

Parameters:
query - the query to be used
max - the max number of values given back (in case of 10 the top 10 will be given)
dateType - the type to be used (example: DAY, MONTH, YEAR)
dateStart - the start date Format:(-3, -2, ..) the date is calculated relatively on today
dateEnd - the end date stop Format (-2, +1, ..) the date is calculated relatively on today
showTotal - a boolean determining whether the total amount should be given back as the last element of the array
Returns:
and array containing our results
Throws:
org.apache.solr.client.solrj.SolrServerException - ...

queryFacetQuery

public static Map<String,Integer> queryFacetQuery(String query,
                                                  String filterQuery,
                                                  List<String> facetQueries)
                                           throws org.apache.solr.client.solrj.SolrServerException
Throws:
org.apache.solr.client.solrj.SolrServerException

queryTotal

public static ObjectCount queryTotal(String query,
                                     String filterQuery)
                              throws org.apache.solr.client.solrj.SolrServerException
Throws:
org.apache.solr.client.solrj.SolrServerException

getIgnoreSpiderIPs

public static String getIgnoreSpiderIPs()
Returns in a filterQuery string all the ip addresses that should be ignored

Returns:
a string query with ip addresses

optimizeSOLR

public static void optimizeSOLR()
Maintenance to keep a SOLR index efficient. Note: This might take a long time.



Copyright © 2011 DuraSpace. All Rights Reserved.