Program: 3604
Project: 3604
Buggy source:
/** 
 * This method should be called whenever an item is added.
 * @param context The current DSpace context
 * @param item The item which has been added
 * @exception SQLException If a database error occurs
 */
public static void itemAdded(Context context,Item item) throws SQLException {
  Map table2dc=new HashMap();
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str",null,Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str",Item.ANY,Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str","String_Node_Str",Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str","String_Node_Str",Item.ANY));
  for (Iterator iterator=table2dc.keySet().iterator(); iterator.hasNext(); ) {
    String table=(String)iterator.next();
    DCValue[] dc=(DCValue[])table2dc.get(table);
    for (int i=0; i < dc.length; i++) {
      TableRow row=DatabaseManager.create(context,table);
      row.setColumn("String_Node_Str",item.getID());
      String value=dc[i].value;
      if ("String_Node_Str".equals(table))       row.setColumn("String_Node_Str",value);
 else       if ("String_Node_Str".equals(table))       row.setColumn("String_Node_Str",value);
 else       if ("String_Node_Str".equals(table)) {
        row.setColumn("String_Node_Str",value);
        row.setColumn("String_Node_Str",value.toLowerCase());
      }
 else       if ("String_Node_Str".equals(table)) {
        String title=NormalizedTitle.normalize(value,dc[i].language);
        row.setColumn("String_Node_Str",value);
        row.setColumn("String_Node_Str",title.toLowerCase());
      }
      DatabaseManager.update(context,row);
    }
  }
}

Fixed version (ground truth):
/** 
 * This method should be called whenever an item is added.
 * @param context The current DSpace context
 * @param item The item which has been added
 * @exception SQLException If a database error occurs
 */
public static void itemAdded(Context context,Item item) throws SQLException {
  Community[] parents=item.getCommunities();
  for (int j=0; j < parents.length; j++) {
    TableRow row=DatabaseManager.create(context,"String_Node_Str");
    row.setColumn("String_Node_Str",item.getID());
    row.setColumn("String_Node_Str",parents[j].getID());
    DatabaseManager.update(context,row);
  }
  Map table2dc=new HashMap();
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str",null,Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str",Item.ANY,Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str","String_Node_Str",Item.ANY));
  table2dc.put("String_Node_Str",item.getDC("String_Node_Str","String_Node_Str",Item.ANY));
  for (Iterator iterator=table2dc.keySet().iterator(); iterator.hasNext(); ) {
    String table=(String)iterator.next();
    DCValue[] dc=(DCValue[])table2dc.get(table);
    for (int i=0; i < dc.length; i++) {
      TableRow row=DatabaseManager.create(context,table);
      row.setColumn("String_Node_Str",item.getID());
      String value=dc[i].value;
      if ("String_Node_Str".equals(table))       row.setColumn("String_Node_Str",value);
 else       if ("String_Node_Str".equals(table))       row.setColumn("String_Node_Str",value);
 else       if ("String_Node_Str".equals(table)) {
        row.setColumn("String_Node_Str",value);
        row.setColumn("String_Node_Str",value.toLowerCase());
      }
 else       if ("String_Node_Str".equals(table)) {
        String title=NormalizedTitle.normalize(value,dc[i].language);
        row.setColumn("String_Node_Str",value);
        row.setColumn("String_Node_Str",title.toLowerCase());
      }
      DatabaseManager.update(context,row);
    }
  }
}