mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-2160] [DS-2187] Remove non-nested usages of DSIndexer and some easy non-nested usages of DSQuery
DSIndexer dependency (outside org.dspace.search) removal: (complete) ==== Removed (unused) java class import from MediaFilter Removed ItemImport DSIndexer.setBatchProcessingMode references, removed java class import Removed FlyWay allback to DatabaseLegacyReindexer, removed DatabaseLegacyReindexer class DSQuery dependency (outside org.dspace.search) removal: (WIP) ==== Removed org.dspace.app.webui.search.LuceneRequestProcessor and dependencies/imports in: - its reference in dspace.cfg, JSPUI Discovery section, updated comments to reflect removal - (unused) class import in org.dspace.app.webui.servlet.AdvancedSearchServlet - (unused) class import in org.dspace.app.webui.servlet.OpenSearchServlet - (unused) class import in org.dspace.app.webui.servlet.SimpleSearchServlet - (unused) class import in org.dspace.app.webui.servlet.admin.ItemMapServlet Removed org.dspace.xmlui.aspect.adminstrative.mapper.LuceneSearchRequestProcessor and its reference in dspace.cfg, XMLUI Discovery section, updated comments to reflect removal. Notes: org.dspace.app.webui.search now only contains SearchRequestProcessor and SearchProcessorException. SearchReqeuestProcessor is now only implemented by org.dspace.app.webui.discovery.DiscoverySearchRequestProcessor. Would it make sense to move these classes into org.dspace.app.webui.discovery and refactor references to SearchProcessorException accordingly? Or is it safer for unknown customisations to leave as is? org.dspace.app.xmlui.opensearch.DiscoveryOpenSearchGenerator and org.dspace.app.xmlui.opensearch.StandardOpenSearchGenerator had their summary comments mixed up - I swapped these back around. No removal of StandardOpenSearchGenerator yet, needs closer inspection of usage in sitemap, pattern mapping etc.
This commit is contained in:
@@ -1,189 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.storage.rdbms;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.dspace.browse.IndexBrowse;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.search.DSIndexer;
|
||||
import org.flywaydb.core.api.MigrationInfo;
|
||||
import org.flywaydb.core.api.callback.FlywayCallback;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This is a FlywayCallback class which automatically reindexes Database
|
||||
* contents into your Legacy search/browse engine of choice. It is NOT needed
|
||||
* for Solr, but is necessary for Lucene / RDBMS indexes.
|
||||
* <P>
|
||||
* Reindexing is performed AFTER any database migration or repair. This
|
||||
* ensures that your search/browse indexes are auto-updated post-upgrade.
|
||||
*
|
||||
* @author Tim Donohue
|
||||
*/
|
||||
public class DatabaseLegacyReindexer implements FlywayCallback
|
||||
{
|
||||
/** logging category */
|
||||
private static final Logger log = LoggerFactory.getLogger(DatabaseLegacyReindexer.class);
|
||||
|
||||
/**
|
||||
* Method to actually reindex all database contents. This method is "smart"
|
||||
* in that it determines which indexing consumer(s) you have enabled,
|
||||
* and then ensures each is reindexed appropriately.
|
||||
* <P>
|
||||
* NOTE: However, because Solr is never running when the Database is initialized,
|
||||
* this reindexer only really works for Lucene / DBMS. Once those are obsolete,
|
||||
* this can be safely removed, along with the reference to it in
|
||||
* DatabaseUtils.setupFlyway()
|
||||
*/
|
||||
private void reindex()
|
||||
{
|
||||
Context context = null;
|
||||
try
|
||||
{
|
||||
context = new Context();
|
||||
|
||||
// What indexing consumer(s) are configured in this DSpace?
|
||||
// TODO: This really should use the ConfigurationService, BUT for
|
||||
// some reason the DSpace Kernel is often not yet initialized at this point
|
||||
String consumers = ConfigurationManager.getProperty("event.dispatcher.default.consumers");
|
||||
if(consumers==null)
|
||||
consumers = "";
|
||||
List<String> consumerList = Arrays.asList(consumers.split("\\s*,\\s*"));
|
||||
|
||||
// If Discovery indexing is enabled
|
||||
if (consumerList.contains("discovery"))
|
||||
{
|
||||
// Do nothing
|
||||
// Because Solr is normally not running when the DatabaseManager initializes,
|
||||
// Discovery autoindexing takes place in DatabaseUtils.checkReindexDiscovery(),
|
||||
// which is automatically called when Discovery initializes.
|
||||
}
|
||||
|
||||
// If Lucene indexing is enabled
|
||||
if (consumerList.contains("search"))
|
||||
{
|
||||
log.info("Reindexing all content in Lucene search engine");
|
||||
// Clean and update Lucene index
|
||||
DSIndexer.cleanIndex(context);
|
||||
DSIndexer.updateIndex(context, true);
|
||||
log.info("Reindexing is complete");
|
||||
}
|
||||
|
||||
// If traditional DBMS browse indexing is enabled
|
||||
if (consumerList.contains("browse"))
|
||||
{
|
||||
log.info("Reindexing all content in DBMS Browse tables");
|
||||
// Rebuild browse tables to perform a full index
|
||||
// (recreating tables as needed)
|
||||
IndexBrowse indexer = new IndexBrowse(context);
|
||||
indexer.setRebuild(true);
|
||||
indexer.setExecute(true);
|
||||
indexer.initBrowse();
|
||||
// Since the browse index is in the DB, we must commit & close context
|
||||
context.complete();
|
||||
log.info("Reindexing is complete");
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.error("Error attempting to reindex all contents for search/browse. You may need to manually reindex Lucene or DBMS", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clean up our context, if it still exists & it was never completed
|
||||
if(context!=null && context.isValid())
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeClean(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterClean(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMigrate(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterMigrate(Connection connection) {
|
||||
reindex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachMigrate(Connection connection, MigrationInfo migrationInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEachMigrate(Connection connection, MigrationInfo migrationInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeValidate(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterValidate(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeInit(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterInit(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeBaseline(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBaseline(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRepair(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRepair(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeInfo(Connection connection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterInfo(Connection connection) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.app.xmlui.aspect.administrative.mapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.HandleServiceImpl;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.search.DSQuery;
|
||||
import org.dspace.search.QueryArgs;
|
||||
import org.dspace.search.QueryResults;
|
||||
|
||||
/**
|
||||
* Search using built-in Lucene index provider.
|
||||
*
|
||||
* @author mwood
|
||||
*/
|
||||
public class LuceneSearchRequestProcessor
|
||||
implements SearchRequestProcessor
|
||||
{
|
||||
protected HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
|
||||
@Override
|
||||
public List<DSpaceObject> doItemMapSearch(Context context, String query, Collection collection)
|
||||
throws IOException, SQLException
|
||||
{
|
||||
QueryArgs queryArgs = new QueryArgs();
|
||||
queryArgs.setQuery(query);
|
||||
queryArgs.setPageSize(Integer.MAX_VALUE);
|
||||
QueryResults results = DSQuery.doQuery(context, queryArgs);
|
||||
|
||||
results.getHitHandles();
|
||||
List<DSpaceObject> dsos = new ArrayList<DSpaceObject>();
|
||||
for (String handle : results.getHitHandles())
|
||||
dsos.add(handleService.resolveToObject(context, handle));
|
||||
|
||||
return dsos;
|
||||
}
|
||||
}
|
@@ -37,7 +37,8 @@ import org.xml.sax.SAXException;
|
||||
* Generate an OpenSearch compliant search results document for DSpace, either scoped by a collection,
|
||||
* a community or the whole repository.
|
||||
*
|
||||
* This class implements the generate() method in order to issue a search using the PostgreSQL indexes.
|
||||
* This class implements the generate() method in order to issue a search using the Discovery search service
|
||||
* (Solr based search)
|
||||
* Search params are parsed by AbstractOpenSearchGenerator class.
|
||||
|
||||
* I18N: Feed's are internationalized, meaning that they may contain references
|
||||
|
@@ -33,10 +33,9 @@ import org.xml.sax.SAXException;
|
||||
* Generate an OpenSearch compliant search results document for DSpace, either scoped by a collection,
|
||||
* a community or the whole repository.
|
||||
*
|
||||
* This class implements the generate() method in order to issue a search using the Discovery search service
|
||||
* (Solr based search)
|
||||
* This class implements the generate() method in order to issue a search using the PostgreSQL indexes.
|
||||
* Search params are parsed by AbstractOpenSearchGenerator class.
|
||||
|
||||
*
|
||||
* I18N: Feed's are internationalized, meaning that they may contain references
|
||||
* to messages contained in the global messages.xml file using cocoon's i18n
|
||||
* schema. However the library used to build the feeds does not understand
|
||||
|
@@ -1306,22 +1306,18 @@ recent.submissions.count = 0
|
||||
# org.dspace.app.webui.components.CollectionItemList
|
||||
|
||||
#### JSPUI Discovery (extra Discovery setting that applies only to JSPUI) ####
|
||||
# uncomment the following configuration if you want to restore the legacy Lucene
|
||||
# search provider with JSPUI (be sure to re-enable also the search consumer)
|
||||
# plugin.single.org.dspace.app.webui.search.SearchRequestProcessor = \
|
||||
# org.dspace.app.webui.search.LuceneSearchRequestProcessor
|
||||
#
|
||||
# default since DSpace 4.0 is to use the Discovery search provider
|
||||
# The legacy JSPUI Lucene search provider deprecated in DSpace 4.0
|
||||
# (org.dspace.app.webui.search.LuceneSearchRequestProcessor) has been removed
|
||||
# in DSpace 6.0.
|
||||
# The default since DSpace 4.0 is to use the Discovery search provider
|
||||
plugin.single.org.dspace.app.webui.search.SearchRequestProcessor = \
|
||||
org.dspace.app.webui.discovery.DiscoverySearchRequestProcessor
|
||||
|
||||
#### XMLUI Discovery (extra Discovery setting that applies only to XMLUI) ####
|
||||
# uncomment the following configuration if you want to restore the legacy Lucene
|
||||
# search provider with XMLUI (be sure to re-enable also the search consumer)
|
||||
# plugin.single.org.dspace.app.xmlui.aspect.administrative.mapper.SearchRequestProcessor = \
|
||||
# org.dspace.app.xmlui.aspect.administrative.mapper.LuceneSearchRequestProcessor
|
||||
#
|
||||
# default since DSpace 4.0 is to use the Discovery search provider
|
||||
# The legacy XMLUI Lucene search provider deprecated in DSpace 4.0
|
||||
# (org.dspace.app.xmlui.aspect.administrative.mapper.LuceneSearchRequestProcessor)
|
||||
# has been removed in DSpace 6.0.
|
||||
# The default since DSpace 4.0 is to use the Discovery search provider
|
||||
plugin.single.org.dspace.app.xmlui.aspect.administrative.mapper.SearchRequestProcessor = \
|
||||
org.dspace.app.xmlui.aspect.administrative.mapper.DiscoverySearchRequestProcessor
|
||||
|
||||
|
Reference in New Issue
Block a user