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
      • 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.
      • postView

        public void postView​(DSpaceObject dspaceObject,
                             javax.servlet.http.HttpServletRequest request,
                             EPerson currentUser,
                             String referrer)
        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.
        referrer - the optional referrer.
      • 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
      • getCommonSolrDoc

        protected org.apache.solr.common.SolrInputDocument getCommonSolrDoc​(DSpaceObject dspaceObject,
                                                                            javax.servlet.http.HttpServletRequest request,
                                                                            EPerson currentUser,
                                                                            String referrer)
                                                                     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.
        referrer - the optional referrer.
        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.
      • update

        public void update​(String query,
                           String action,
                           List<String> fieldNames,
                           List<List<Object>> fieldValuesList,
                           boolean commit)
                    throws org.apache.solr.client.solrj.SolrServerException,
                           IOException
        Description copied from interface: SolrLoggerService
        Update the solr core.
        Specified by:
        update in interface SolrLoggerService
        Parameters:
        query - query indicating which documents to update
        action - the update action keyword
        fieldNames - the fields to update
        fieldValuesList - the values for the fields to update
        commit - whether to commit the changes
        Throws:
        org.apache.solr.client.solrj.SolrServerException
        IOException
      • query

        public void query​(String query,
                          int max,
                          int facetMinCount)
                   throws org.apache.solr.client.solrj.SolrServerException,
                          IOException
        Specified by:
        query in interface SolrLoggerService
        Throws:
        org.apache.solr.client.solrj.SolrServerException
        IOException
      • queryFacetField

        public ObjectCount[] queryFacetField​(String query,
                                             String filterQuery,
                                             String facetField,
                                             int max,
                                             boolean showTotal,
                                             List<String> facetQueries,
                                             int facetMinCount)
                                      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
        facetMinCount - Minimum count of results facet must have to return a result
        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,
                                            int facetMinCount)
                                     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.
        facetMinCount - Minimum count of results facet must have to return a result
        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.
      • query

        public org.apache.solr.client.solrj.response.QueryResponse query​(String query,
                                                                         String filterQuery,
                                                                         String facetField,
                                                                         int rows,
                                                                         int max,
                                                                         String dateType,
                                                                         String dateStart,
                                                                         String dateEnd,
                                                                         List<String> facetQueries,
                                                                         String sort,
                                                                         boolean ascending,
                                                                         int facetMinCount)
                                                                  throws org.apache.solr.client.solrj.SolrServerException,
                                                                         IOException
        Description copied from interface: SolrLoggerService
        Perform a solr query.
        Specified by:
        query in interface SolrLoggerService
        Parameters:
        query - the query to be used
        filterQuery - filter query
        facetField - field to facet the results by
        rows - the max number of results to return
        max - the max number of facets to return
        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
        facetQueries - list of facet queries
        sort - the sort field
        ascending - the sort direction (true: ascending)
        facetMinCount - Minimum count of results facet must have to return a result
        Throws:
        org.apache.solr.client.solrj.SolrServerException - Exception from the Solr server to the solrj Java client.
        IOException - passed through.
      • query

        public org.apache.solr.client.solrj.response.QueryResponse query​(String query,
                                                                         String filterQuery,
                                                                         String facetField,
                                                                         int rows,
                                                                         int max,
                                                                         String dateType,
                                                                         String dateStart,
                                                                         String dateEnd,
                                                                         List<String> facetQueries,
                                                                         String sort,
                                                                         boolean ascending,
                                                                         int facetMinCount,
                                                                         boolean defaultFilterQueries)
                                                                  throws org.apache.solr.client.solrj.SolrServerException,
                                                                         IOException
        Description copied from interface: SolrLoggerService
        Perform a solr query.
        Specified by:
        query in interface SolrLoggerService
        Parameters:
        query - the query to be used
        filterQuery - filter query
        facetField - field to facet the results by
        rows - the max number of results to return
        max - the max number of facets to return
        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
        facetQueries - list of facet queries
        sort - the sort field
        ascending - the sort direction (true: ascending)
        facetMinCount - Minimum count of results facet must have to return a result
        defaultFilterQueries - use the default filter queries
        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
      • 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()