javadoc (doclint) and whitespace fixes

includes whitespace fixes as per Coding Conventions
This commit is contained in:
Ivan Masár
2016-10-31 14:34:27 +01:00
parent db1641cfa9
commit 269af71afb
384 changed files with 24482 additions and 20843 deletions

View File

@@ -41,12 +41,15 @@ public class IndexClient {
* from the whole index
*
* @param args the command-line arguments, none used
* @throws java.io.IOException
* @throws SQLException if database error
*
* @throws SQLException
* An exception that provides information on a database access error or other errors.
* @throws IOException
* A general class of exceptions produced by failed or interrupted I/O operations.
* @throws SearchServiceException if something went wrong with querying the solr server
*/
public static void main(String[] args) throws SQLException, IOException, SearchServiceException {
public static void main(String[] args)
throws SQLException, IOException, SearchServiceException
{
Context context = new Context();
context.turnOffAuthorisationSystem();
@@ -55,46 +58,49 @@ public class IndexClient {
HelpFormatter formatter = new HelpFormatter();
CommandLine line = null;
options
.addOption(OptionBuilder
.withArgName("handle to remove")
.hasArg(true)
.withDescription(
"remove an Item, Collection or Community from index based on its handle")
.create("r"));
options.addOption(OptionBuilder
.withArgName("handle to remove")
.hasArg(true)
.withDescription(
"remove an Item, Collection or Community from index based on its handle")
.create("r"));
options
.addOption(OptionBuilder
.withArgName("handle to add or update")
.hasArg(true)
.withDescription(
"add or update an Item, Collection or Community based on its handle")
.create("i"));
options.addOption(OptionBuilder
.withArgName("handle to add or update")
.hasArg(true)
.withDescription(
"add or update an Item, Collection or Community based on its handle")
.create("i"));
options
.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"clean existing index removing any documents that no longer exist in the db")
.create("c"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"clean existing index removing any documents that no longer exist in the db")
.create("c"));
options.addOption(OptionBuilder.isRequired(false).withDescription(
"(re)build index, wiping out current one if it exists").create(
"b"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"(re)build index, wiping out current one if it exists")
.create("b"));
options.addOption(OptionBuilder.isRequired(false).withDescription(
"Rebuild the spellchecker, can be combined with -b and -f.").create(
"s"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"Rebuild the spellchecker, can be combined with -b and -f.")
.create("s"));
options
.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"if updating existing index, force each handle to be reindexed even if uptodate")
.create("f"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"if updating existing index, force each handle to be reindexed even if uptodate")
.create("f"));
options.addOption(OptionBuilder.isRequired(false).withDescription(
"print this help message").create("h"));
options.addOption(OptionBuilder
.isRequired(false)
.withDescription(
"print this help message")
.create("h"));
options.addOption(OptionBuilder.isRequired(false).withDescription(
"optimize search core").create("o"));
@@ -118,7 +124,10 @@ public class IndexClient {
* new DSpace.getServiceManager().getServiceByName("org.dspace.discovery.SolrIndexer");
*/
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(
IndexingService.class.getName(),
IndexingService.class
);
if (line.hasOption("r")) {
log.info("Removing " + line.getOptionValue("r") + " from Index");
@@ -133,9 +142,9 @@ public class IndexClient {
} else if (line.hasOption("o")) {
log.info("Optimizing search core.");
indexer.optimize();
} else if(line.hasOption('s')) {
} else if (line.hasOption('s')) {
checkRebuildSpellCheck(line, indexer);
} else if(line.hasOption('i')) {
} else if (line.hasOption('i')) {
final String handle = line.getOptionValue('i');
final DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, handle);
if (dso == null) {
@@ -156,15 +165,31 @@ public class IndexClient {
}
log.info("Done with indexing");
}
}
/**
* Indexes the given object and all children, if applicable.
*
* @param indexingService
*
* @param itemService
*
* @param context
* The relevant DSpace Context.
* @param dso
* DSpace object to index recursively
* @throws IOException
* A general class of exceptions produced by failed or interrupted I/O operations.
* @throws SearchServiceException in case of a solr exception
* @throws SQLException
* An exception that provides information on a database access error or other errors.
*/
private static long indexAll(final IndexingService indexingService,
final ItemService itemService,
final Context context,
final DSpaceObject dso) throws IOException, SearchServiceException, SQLException {
final DSpaceObject dso)
throws IOException, SearchServiceException, SQLException
{
long count = 0;
indexingService.indexContent(context, dso, true, true);
@@ -194,11 +219,27 @@ public class IndexClient {
/**
* Indexes all items in the given collection.
*
* @param indexingService
*
* @param itemService
*
* @param context
* The relevant DSpace Context.
* @param collection
* collection to index
* @throws IOException
* A general class of exceptions produced by failed or interrupted I/O operations.
* @throws SearchServiceException in case of a solr exception
* @throws SQLException
* An exception that provides information on a database access error or other errors.
*/
private static long indexItems(final IndexingService indexingService,
final ItemService itemService,
final Context context,
final Collection collection) throws IOException, SearchServiceException, SQLException {
final Collection collection)
throws IOException, SearchServiceException, SQLException
{
long count = 0;
final Iterator<Item> itemIterator = itemService.findByCollection(context, collection);
@@ -220,10 +261,12 @@ public class IndexClient {
* @param indexer the solr indexer
* @throws SearchServiceException in case of a solr exception
*/
protected static void checkRebuildSpellCheck(CommandLine line, IndexingService indexer) throws SearchServiceException {
protected static void checkRebuildSpellCheck(CommandLine line, IndexingService indexer)
throws SearchServiceException
{
if (line.hasOption("s")) {
log.info("Rebuilding spell checker.");
indexer.buildSpellCheck();
}
}
}
}