Package org.dspace.app.util
Class OpenSearchServiceImpl
java.lang.Object
org.dspace.app.util.OpenSearchServiceImpl
- All Implemented Interfaces:
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigurationServiceprotected HandleServiceprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringGet base search service URL (websvc.opensearch.svccontext)protected StringGet base search UI URL (websvc.opensearch.uicontext)getContentType(String format) Returns a mime-type associated with passed formatgetDescription(String scope) Returns OpenSearch Servic Document as a stringgetDescriptionDoc(String scope) Returns the OpenSearch service document appropriate for given scopeReturns list of supported formatsintGet base search UI URL (websvc.opensearch.max_num_of_items_per_request)protected SyndicationFeedgetResults(Context context, String format, String query, int totalResults, int start, int pageSize, IndexableObject scope, List<IndexableObject> results) getResultsDoc(Context context, String format, String query, int totalResults, int start, int pageSize, IndexableObject scope, List<IndexableObject> results) Returns a formatted set of search results as a documentgetResultsString(Context context, String format, String query, int totalResults, int start, int pageSize, IndexableObject scope, List<IndexableObject> results) Returns a formatted set of search results as a stringprotected org.jdom2.DocumentgetServiceDocument(String scope) Returns as a document the OpenSearch service documentbooleanDetermine if the module is activeprotected DocumentjDomToW3(org.jdom2.Document jdomDoc) Converts a JDOM document to a W3C oneprotected com.rometools.modules.opensearch.OpenSearchModuleopenSearchMarkup(String query, int totalResults, int start, int pageSize) resolveScope(Context context, String scope)
-
Field Details
-
osNs
- See Also:
-
configurationService
-
handleService
-
-
Constructor Details
-
OpenSearchServiceImpl
protected OpenSearchServiceImpl()
-
-
Method Details
-
getFormats
Description copied from interface:OpenSearchServiceReturns list of supported formats- Specified by:
getFormatsin interfaceOpenSearchService- Returns:
- list of format names - 'rss', 'atom' or 'html'
-
isEnabled
public boolean isEnabled()Description copied from interface:OpenSearchServiceDetermine if the module is active- Specified by:
isEnabledin interfaceOpenSearchService- Returns:
- boolean indicator if the OpenSearch module is enabled or not
-
getBaseSearchServiceURL
Get base search service URL (websvc.opensearch.svccontext) -
getBaseSearchUIURL
Get base search UI URL (websvc.opensearch.uicontext) -
getMaxNumOfItemsPerRequest
public int getMaxNumOfItemsPerRequest()Get base search UI URL (websvc.opensearch.max_num_of_items_per_request)- Specified by:
getMaxNumOfItemsPerRequestin interfaceOpenSearchService- Returns:
- the maximum number of items allowed per request
-
getContentType
Description copied from interface:OpenSearchServiceReturns a mime-type associated with passed format- Specified by:
getContentTypein interfaceOpenSearchService- Parameters:
format- the results document format (rss, atom, html)- Returns:
- content-type mime-type
-
getDescriptionDoc
Description copied from interface:OpenSearchServiceReturns the OpenSearch service document appropriate for given scope- Specified by:
getDescriptionDocin interfaceOpenSearchService- Parameters:
scope- - null for entire repository, or handle or community or collection- Returns:
- document the service document
- Throws:
IOException- if IO error
-
getDescription
Description copied from interface:OpenSearchServiceReturns OpenSearch Servic Document as a string- Specified by:
getDescriptionin interfaceOpenSearchService- 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) throws IOException Description copied from interface:OpenSearchServiceReturns a formatted set of search results as a string- Specified by:
getResultsStringin interfaceOpenSearchService- Parameters:
context- DSpace Contextformat- results format - html, rss or atomquery- - the search querytotalResults- - the hit countstart- - start result indexpageSize- - page sizescope- - search scope, null or the community/collectionresults- the retrieved DSpace objects satisfying search- 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) throws IOException Description copied from interface:OpenSearchServiceReturns a formatted set of search results as a document- Specified by:
getResultsDocin interfaceOpenSearchService- Parameters:
context- DSpace Contextformat- results format - html, rss or atomquery- - the search querytotalResults- - the hit countstart- - start result indexpageSize- - page sizescope- - search scope, null or the community/collectionresults- the retrieved DSpace objects satisfying search- Returns:
- formatted search results
- Throws:
IOException- if IO error
-
getResults
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start, int pageSize, IndexableObject scope, List<IndexableObject> results) -
openSearchMarkup
protected com.rometools.modules.opensearch.OpenSearchModule openSearchMarkup(String query, int totalResults, int start, int pageSize) -
getServiceDocument
Returns as a document the OpenSearch service document- Parameters:
scope- - null for the entire repository, or a collection/community handle- Returns:
- Service Document
-
jDomToW3
Converts a JDOM document to a W3C one- Parameters:
jdomDoc- jDOM document to convert- Returns:
- W3C Document object
- Throws:
IOException- if IO error
-
resolveScope
- Specified by:
resolveScopein interfaceOpenSearchService- Throws:
SQLException
-