Class SolrLoggerServiceImpl

  • All Implemented Interfaces:
    SolrLoggerService, org.springframework.beans.factory.InitializingBean

    public class SolrLoggerServiceImpl
    extends Object
    implements SolrLoggerService, org.springframework.beans.factory.InitializingBean
    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
    • Field Detail

      • solr

        protected org.apache.solr.client.solrj.SolrClient solr
      • locationService

        protected com.maxmind.geoip2.DatabaseReader locationService
      • useProxies

        protected boolean useProxies
      • bitstreamService

        @Autowired(required=true)
        protected BitstreamService bitstreamService
      • filterQuery

        protected String filterQuery
        String of IP and Ranges in IPTable as a Solr Query
    • Constructor Detail

      • SolrLoggerServiceImpl

        protected SolrLoggerServiceImpl()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • post

        public void post​(DSpaceObject dspaceObject,
                         javax.servlet.http.HttpServletRequest request,
                         EPerson currentUser)
        Description copied from interface: SolrLoggerService
        Old post method, use the new postview method instead !
        Specified by:
        post in interface SolrLoggerService
        Parameters:
        dspaceObject - the object used.
        request - the current request context.
        currentUser - the current session's user.
      • postView

        public void postView​(DSpaceObject dspaceObject,
                             javax.servlet.http.HttpServletRequest request,
                             EPerson currentUser)
        Description copied from interface: SolrLoggerService
        Store a usage event into Solr.
        Specified by:
        postView in interface SolrLoggerService
        Parameters:
        dspaceObject - the object used.
        request - the current request context.
        currentUser - the current session's user.
      • getCommonSolrDoc

        protected org.apache.solr.common.SolrInputDocument getCommonSolrDoc​(DSpaceObject dspaceObject,
                                                                            javax.servlet.http.HttpServletRequest request,
                                                                            EPerson currentUser)
                                                                     throws SQLException
        Returns a solr input document containing common information about the statistics regardless if we are logging a search or a view of a DSpace object
        Parameters:
        dspaceObject - the object used.
        request - the current request context.
        currentUser - the current session's user.
        Returns:
        a solr input document
        Throws:
        SQLException - in case of a database exception
      • storeParents

        public void storeParents​(org.apache.solr.common.SolrInputDocument doc1,
                                 DSpaceObject dso)
                          throws SQLException
        Description copied from interface: SolrLoggerService
        Method just used to log the parents.
        • Community log: owning comms.
        • Collection log: owning comms and their comms.
        • Item log: owning colls/comms.
        • Bitstream log: owning item/colls/comms.
        Specified by:
        storeParents in interface SolrLoggerService
        Parameters:
        doc1 - the current SolrInputDocument
        dso - the current dspace object we want to log
        Throws:
        SQLException - if database error ignore it
      • removeIndex

        public void removeIndex​(String query)
                         throws IOException,
                                org.apache.solr.client.solrj.SolrServerException
        Description copied from interface: SolrLoggerService
        Delete data from the index, as described by a query.
        Specified by:
        removeIndex in interface SolrLoggerService
        Parameters:
        query - description of the records to be deleted.
        Throws:
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
        org.apache.solr.client.solrj.SolrServerException - Exception from the Solr server to the solrj Java client.
      • queryFacetField

        public ObjectCount[] queryFacetField​(String query,
                                             String filterQuery,
                                             String facetField,
                                             int max,
                                             boolean showTotal,
                                             List<String> facetQueries)
                                      throws org.apache.solr.client.solrj.SolrServerException,
                                             IOException
        Description copied from interface: SolrLoggerService
        Query used to get values grouped by the given facet field.
        Specified by:
        queryFacetField in interface SolrLoggerService
        Parameters:
        query - the query to be used
        filterQuery - filter query
        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
        facetQueries - list of facet queries
        Returns:
        an array containing our results
        Throws:
        org.apache.solr.client.solrj.SolrServerException - Exception from the Solr server to the solrj Java client.
        IOException - passed through.
      • queryFacetDate

        public ObjectCount[] queryFacetDate​(String query,
                                            String filterQuery,
                                            int max,
                                            String dateType,
                                            String dateStart,
                                            String dateEnd,
                                            boolean showTotal,
                                            Context context)
                                     throws org.apache.solr.client.solrj.SolrServerException,
                                            IOException
        Description copied from interface: SolrLoggerService
        Query used to get values grouped by the date.
        Specified by:
        queryFacetDate in interface SolrLoggerService
        Parameters:
        query - the query to be used
        filterQuery - filter query
        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
        context - The relevant DSpace Context.
        Returns:
        and array containing our results
        Throws:
        org.apache.solr.client.solrj.SolrServerException - Exception from the Solr server to the solrj Java client.
        IOException - passed through.
      • getIgnoreSpiderIPs

        public String getIgnoreSpiderIPs()
        Description copied from interface: SolrLoggerService
        Returns in a filterQuery string all the ip addresses that should be ignored
        Specified by:
        getIgnoreSpiderIPs in interface SolrLoggerService
        Returns:
        a string query with ip addresses
      • optimizeSOLR

        public void optimizeSOLR()
        Description copied from interface: SolrLoggerService
        Maintenance to keep a SOLR index efficient. Note: This might take a long time.
        Specified by:
        optimizeSOLR in interface SolrLoggerService
      • createCore

        protected org.apache.solr.client.solrj.impl.HttpSolrClient createCore​(org.apache.solr.client.solrj.impl.HttpSolrClient solr,
                                                                              String coreName)
                                                                       throws IOException,
                                                                              org.apache.solr.client.solrj.SolrServerException
        Throws:
        IOException
        org.apache.solr.client.solrj.SolrServerException
      • getMultivaluedFieldNames

        public Set<String> getMultivaluedFieldNames()
                                             throws org.apache.solr.client.solrj.SolrServerException,
                                                    IOException
        Retrieves a list of all the multi valued fields in the solr core
        Returns:
        all fields tagged as multivalued
        Throws:
        org.apache.solr.client.solrj.SolrServerException - When getting the schema information from the SOLR core fails
        IOException - When connection to the SOLR server fails
      • addAdditionalSolrYearCores

        protected void addAdditionalSolrYearCores​(org.apache.solr.client.solrj.SolrQuery solrQuery)
      • initSolrYearCores

        protected void initSolrYearCores()