mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Make the browse indexing more robust to suspect data
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2595 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -50,6 +50,7 @@ import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
@@ -435,17 +436,29 @@ public class IndexBrowse
|
||||
{
|
||||
for (int x = 0; x < values.length; x++)
|
||||
{
|
||||
// get the normalised version of the value
|
||||
String nVal = OrderFormat.makeSortString(values[x].value, values[x].language, bis[i].getDataType());
|
||||
|
||||
Map sortMap = getSortValues(item, itemMDMap);
|
||||
|
||||
dao.insertIndex(bis[i].getTableName(), item.getID(), values[x].value, nVal, sortMap);
|
||||
|
||||
if (bis[i].isMetadataIndex())
|
||||
// Ensure that there is a value to index before inserting it
|
||||
if (StringUtils.isEmpty(values[x].value))
|
||||
{
|
||||
int distinctID = dao.getDistinctID(bis[i].getTableName(true, false, false), values[x].value, nVal);
|
||||
dao.createDistinctMapping(bis[i].getMapName(), item.getID(), distinctID);
|
||||
log.error("Null metadata value for item " + item.getID() + ", field: " +
|
||||
values[x].schema + "." +
|
||||
values[x].element +
|
||||
(values[x].qualifier == null ? "" : "." + values[x].qualifier));
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the normalised version of the value
|
||||
String nVal = OrderFormat.makeSortString(values[x].value, values[x].language, bis[i].getDataType());
|
||||
|
||||
// get all the normalised values for sorting
|
||||
Map sortMap = getSortValues(item, itemMDMap);
|
||||
|
||||
dao.insertIndex(bis[i].getTableName(), item.getID(), values[x].value, nVal, sortMap);
|
||||
|
||||
if (bis[i].isMetadataIndex())
|
||||
{
|
||||
int distinctID = dao.getDistinctID(bis[i].getTableName(true, false, false), values[x].value, nVal);
|
||||
dao.createDistinctMapping(bis[i].getMapName(), item.getID(), distinctID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -95,6 +95,10 @@ public class OrderFormat
|
||||
{
|
||||
OrderFormatDelegate delegate = null;
|
||||
|
||||
// If there is no value, return null
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// If a named index has been supplied
|
||||
if (type != null && type.length() > 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user