throws BrowseException
{
try
{
boolean rowUpdated = false;
TableRow row = DatabaseManager.findByUnique(context, table, "item_id", itemID);
// If the item does not exist in the table, return that it couldn't be found
if (row == null)
return false;
// Iterate through all the sort values
Iterator itra = sortCols.keySet().iterator();
while (itra.hasNext())
{
Integer key = (Integer) itra.next();
// Generate the appropriate column name
String column = "sort_" + key.toString();
// Create the value that will be written in to the column
String newValue = utils.truncateSortValue( (String) sortCols.get(key) );
// Check the column exists - if it doesn't, something has gone seriously wrong
if (!row.hasColumn(column))
throw new BrowseException("Column '" + column + "' does not exist in table " + table);
// Get the existing value from the column
String oldValue = row.getStringColumn(column);
// If the new value differs from the old value, update the column and flag that the row has changed
if (oldValue != null && !oldValue.equals(newValue))
{
row.setColumn(column, newValue);
rowUpdated = true;
}
else if (newValue != null && !newValue.equals(oldValue))
{
row.setColumn(column, newValue);
rowUpdated = true;
}
}
// We've updated the row, so save it back to the database