DS-4166 community feedback: remove multithreads indexing support

This commit is contained in:
Andrea Bollini
2019-03-28 09:02:58 +01:00
parent cc11f49556
commit 1252075ac9
4 changed files with 11 additions and 150 deletions

View File

@@ -7,15 +7,9 @@
*/
package org.dspace.discovery;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.apache.commons.cli.CommandLine;
@@ -30,7 +24,6 @@ import org.dspace.content.Community;
import org.dspace.content.Item;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.handle.factory.HandleServiceFactory;
@@ -89,11 +82,6 @@ public class IndexClient {
"add or update an Item, Collection or Community based on its handle")
.create("i"));
options.addOption(OptionBuilder.isRequired(false).hasArg(true)
.withDescription("update an Item, Collection or Community from index based on its handle, use with -f "
+ "to force clean")
.create("u"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
@@ -127,8 +115,6 @@ public class IndexClient {
options.addOption(OptionBuilder.isRequired(false).withDescription(
"optimize search core").create("o"));
options.addOption("e", "readfile", true, "Read the identifier from a file");
try {
line = new PosixParser().parse(options, args);
} catch (Exception e) {
@@ -172,47 +158,6 @@ public class IndexClient {
String itemUUID = line.getOptionValue("item_uuid");
Item item = ContentServiceFactory.getInstance().getItemService().find(context, UUID.fromString(itemUUID));
indexer.indexContent(context, item, line.hasOption("f"));
} else if (line.hasOption("u")) {
String optionValue = line.getOptionValue("u");
String[] identifiers = optionValue.split("\\s*,\\s*");
for (String id : identifiers) {
if (id.startsWith(ConfigurationManager.getProperty("handle.prefix")) || id.startsWith("123456789/")) {
IndexableObject dso = (IndexableObject) HandleServiceFactory.getInstance()
.getHandleService().resolveToObject(context, id);
indexer.indexContent(context, dso, line.hasOption("f"));
}
}
} else if (line.hasOption('e')) {
try {
String filename = line.getOptionValue('e');
FileInputStream fstream = new FileInputStream(filename);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// Read File Line By Line
UUID item_id = null;
List<UUID> ids = new ArrayList<UUID>();
while ((strLine = br.readLine()) != null) {
item_id = UUID.fromString(strLine.trim());
ids.add(item_id);
}
in.close();
int type = -1;
if (line.hasOption('t')) {
type = Integer.parseInt(line.getOptionValue("t"));
} else {
// force to item
type = Constants.ITEM;
}
indexer.updateIndex(context, ids, line.hasOption("f"), type);
} catch (Exception e) {
log.error("Error: " + e.getMessage());
}
} else if (line.hasOption('i')) {
final String handle = line.getOptionValue('i');
final IndexableObject dso = (IndexableObject) HandleServiceFactory.getInstance()