Class OpenSearchServiceImpl

  • All Implemented Interfaces:
    OpenSearchService

    public class OpenSearchServiceImpl
    extends Object
    implements OpenSearchService
    Utility Class with static methods for producing OpenSearch-compliant search results, and the OpenSearch description document.

    OpenSearch is a specification for describing and advertising search-engines and their result formats. Commonly, RSS and Atom formats are used, which the current implementation supports, as is HTML (used directly in browsers). NB: this is baseline OpenSearch, no extensions currently supported.

    The value of the "scope" parameter should either be absent (which means no scope restriction), or the handle of a community or collection.

    Author:
    Richard Rodgers
    • Constructor Detail

      • OpenSearchServiceImpl

        protected OpenSearchServiceImpl()
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Description copied from interface: OpenSearchService
        Determine if the module is active
        Specified by:
        isEnabled in interface OpenSearchService
        Returns:
        boolean indicator if the OpenSearch module is enabled or not
      • getBaseSearchServiceURL

        protected String getBaseSearchServiceURL()
        Get base search service URL (websvc.opensearch.svccontext)
      • getBaseSearchUIURL

        protected String getBaseSearchUIURL()
        Get base search UI URL (websvc.opensearch.uicontext)
      • getContentType

        public String getContentType​(String format)
        Description copied from interface: OpenSearchService
        Returns a mime-type associated with passed format
        Specified by:
        getContentType in interface OpenSearchService
        Parameters:
        format - the results document format (rss, atom, html)
        Returns:
        content-type mime-type
      • getDescriptionDoc

        public Document getDescriptionDoc​(String scope)
                                   throws IOException
        Description copied from interface: OpenSearchService
        Returns the OpenSearch service document appropriate for given scope
        Specified by:
        getDescriptionDoc in interface OpenSearchService
        Parameters:
        scope - - null for entire repository, or handle or community or collection
        Returns:
        document the service document
        Throws:
        IOException - if IO error
      • getDescription

        public String getDescription​(String scope)
        Description copied from interface: OpenSearchService
        Returns OpenSearch Servic Document as a string
        Specified by:
        getDescription in interface OpenSearchService
        Parameters:
        scope - - null for entire repository, or handle or community or collection
        Returns:
        service document as a string
      • getResultsString

        public String getResultsString​(Context context,
                                       String format,
                                       String query,
                                       int totalResults,
                                       int start,
                                       int pageSize,
                                       IndexableObject scope,
                                       List<IndexableObject> results,
                                       Map<String,​String> labels)
                                throws IOException
        Description copied from interface: OpenSearchService
        Returns a formatted set of search results as a string
        Specified by:
        getResultsString in interface OpenSearchService
        Parameters:
        context - DSpace Context
        format - results format - html, rss or atom
        query - - the search query
        totalResults - - the hit count
        start - - start result index
        pageSize - - page size
        scope - - search scope, null or the community/collection
        results - the retreived DSpace objects satisfying search
        labels - labels to apply - format specific
        Returns:
        formatted search results
        Throws:
        IOException - if IO error
      • getResultsDoc

        public Document getResultsDoc​(Context context,
                                      String format,
                                      String query,
                                      int totalResults,
                                      int start,
                                      int pageSize,
                                      IndexableObject scope,
                                      List<IndexableObject> results,
                                      Map<String,​String> labels)
                               throws IOException
        Description copied from interface: OpenSearchService
        Returns a formatted set of search results as a document
        Specified by:
        getResultsDoc in interface OpenSearchService
        Parameters:
        context - DSpace Context
        format - results format - html, rss or atom
        query - - the search query
        totalResults - - the hit count
        start - - start result index
        pageSize - - page size
        scope - - search scope, null or the community/collection
        results - the retreived DSpace objects satisfying search
        labels - labels to apply - format specific
        Returns:
        formatted search results
        Throws:
        IOException - if IO error
      • openSearchMarkup

        protected com.sun.syndication.feed.module.opensearch.OpenSearchModule openSearchMarkup​(String query,
                                                                                               int totalResults,
                                                                                               int start,
                                                                                               int pageSize)
      • getServiceDocument

        protected org.jdom.Document getServiceDocument​(String scope)
        Returns as a document the OpenSearch service document
        Parameters:
        scope - - null for the entire repository, or a collection/community handle
        Returns:
        Service Document
      • jDomToW3

        protected Document jDomToW3​(org.jdom.Document jdomDoc)
                             throws IOException
        Converts a JDOM document to a W3C one
        Parameters:
        jdomDoc - jDOM document to convert
        Returns:
        W3C Document object
        Throws:
        IOException - if IO error