Program: 51973
Project: 51973
Buggy source:
/** 
 * Add either the simple Ajax response document or the full document with header and full edit item form based on the mode parameter.  Mode parameter values are set in the Flowscipt and can be either 'ajax' or 'normal'.
 */
@SuppressWarnings("String_Node_Str") public void addBody(Body body) throws SQLException, WingException {
  UUID itemID=UUID.fromString(parameters.getParameter("String_Node_Str",null));
  Item item=itemService.find(context,itemID);
  java.util.List<MetadataValue> values=itemService.getMetadata(item,Item.ANY,Item.ANY,Item.ANY,Item.ANY);
  Collections.sort(values,new DCValueComparator());
  String baseURL=contextPath + "String_Node_Str" + knot.getId();
  Request request=ObjectModelHelper.getRequest(objectModel);
  String previousFieldID=request.getParameter("String_Node_Str");
  boolean editingTemplateItem=false;
  String templateCollectionID=parameters.getParameter("String_Node_Str",null);
  Collection templateCollection=templateCollectionID != null ? null : collectionService.find(context,UUID.fromString(templateCollectionID));
  if (templateCollection != null) {
    Item templateItem=templateCollection.getTemplateItem();
    if (templateItem != null && templateItem.getID() == itemID) {
      editingTemplateItem=true;
    }
  }
  Division main=body.addInteractiveDivision("String_Node_Str",contextPath + "String_Node_Str",Division.METHOD_POST,"String_Node_Str");
  if (editingTemplateItem) {
    main.setHead(T_template_head.parameterize(templateCollection.getName()));
  }
 else {
    main.setHead(T_option_head);
  }
  Collection owner=item.getOwningCollection();
  if (!editingTemplateItem) {
    List options=main.addList("String_Node_Str",List.TYPE_SIMPLE,"String_Node_Str");
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_status);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_bitstreams);
    options.addItem().addHighlight("String_Node_Str").addXref(baseURL + "String_Node_Str",T_option_metadata);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_view);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_curate);
  }
  List addForm=main.addList("String_Node_Str",List.TYPE_FORM);
  addForm.setHead(T_head1);
  Select addName=addForm.addItem().addSelect("String_Node_Str");
  addName.setLabel(T_name_label);
  java.util.List<MetadataField> fields=metadataFieldService.findAll(context);
  for (  MetadataField field : fields) {
    int fieldID=field.getFieldID();
    MetadataSchema schema=field.getMetadataSchema();
    String name=schema.getName() + "String_Node_Str" + field.getElement();
    if (field.getQualifier() != null) {
      name+="String_Node_Str" + field.getQualifier();
    }
    addName.addOption(fieldID,name);
  }
  if (previousFieldID != null) {
    addName.setOptionSelected(previousFieldID);
  }
  Composite addComposite=addForm.addItem().addComposite("String_Node_Str");
  addComposite.setLabel(T_value_label);
  TextArea addValue=addComposite.addTextArea("String_Node_Str");
  Text addLang=addComposite.addText("String_Node_Str");
  addValue.setSize(4,35);
  addLang.setLabel(T_lang_label);
  addLang.setSize(6);
  addForm.addItem().addButton("String_Node_Str").setValue(T_submit_add);
  main.addPara(T_para1);
  Para actions=main.addPara(null,"String_Node_Str");
  actions.addButton("String_Node_Str").setValue(T_submit_update);
  actions.addButton("String_Node_Str").setValue(T_submit_return);
  main.addHidden("String_Node_Str").setValue("String_Node_Str");
  int index=1;
  Table table=main.addTable("String_Node_Str",1,1);
  table.setHead(T_head2);
  Row header=table.addRow(Row.ROLE_HEADER);
  header.addCell().addContent(T_column1);
  header.addCell().addContent(T_column2);
  header.addCell().addContent(T_column3);
  header.addCell().addContent(T_column4);
  for (  MetadataValue value : values) {
    String name=value.getMetadataField().toString('_');
    Row row=table.addRow(name,Row.ROLE_DATA,"String_Node_Str");
    CheckBox remove=row.addCell().addCheckBox("String_Node_Str" + index);
    remove.setLabel("String_Node_Str");
    remove.addOption(index);
    Cell cell=row.addCell();
    cell.addContent(name.replaceAll("String_Node_Str","String_Node_Str"));
    cell.addHidden("String_Node_Str" + index).setValue(name);
    Cell mdCell=row.addCell();
    String fieldKey=metadataAuthorityService.makeFieldKey(value.getMetadataField().getMetadataSchema().getName(),value.getMetadataField().getElement(),value.getMetadataField().getQualifier());
    if (choiceAuthorityService.isChoicesConfigured(fieldKey) && Params.PRESENTATION_SELECT.equals(choiceAuthorityService.getPresentation(fieldKey))) {
      Select mdSelect=mdCell.addSelect("String_Node_Str" + index);
      mdSelect.setSize(1);
      Choices cs=choiceAuthorityService.getMatches(fieldKey,value.getValue(),owner,0,0,null);
      if (cs.defaultSelected < 0) {
        mdSelect.addOption(true,value.getValue(),value.getValue());
      }
      for (int i=0; i < cs.values.length; ++i) {
        mdSelect.addOption(i == cs.defaultSelected,cs.values[i].value,cs.values[i].label);
      }
    }
 else {
      TextArea mdValue=mdCell.addTextArea("String_Node_Str" + index);
      mdValue.setSize(4,35);
      mdValue.setValue(value.getValue());
      boolean isAuth=metadataAuthorityService.isAuthorityControlled(fieldKey);
      if (isAuth) {
        mdValue.setAuthorityControlled();
        mdValue.setAuthorityRequired(metadataAuthorityService.isAuthorityRequired(fieldKey));
        Value authValue=mdValue.setAuthorityValue((value.getAuthority() == null) ? "String_Node_Str" : value.getAuthority(),Choices.getConfidenceText(value.getConfidence()));
        Button unlock=authValue.addButton("String_Node_Str" + index,"String_Node_Str");
        unlock.setHelp(T_unlock);
      }
      if (choiceAuthorityService.isChoicesConfigured(fieldKey)) {
        mdValue.setChoices(fieldKey);
        if (Params.PRESENTATION_AUTHORLOOKUP.equals(choiceAuthorityService.getPresentation(fieldKey))) {
          mdValue.setChoicesPresentation(Params.PRESENTATION_AUTHORLOOKUP);
        }
 else {
          mdValue.setChoicesPresentation(Params.PRESENTATION_LOOKUP);
        }
        mdValue.setChoicesClosed(choiceAuthorityService.isClosed(fieldKey));
      }
    }
    Text mdLang=row.addCell().addText("String_Node_Str" + index);
    mdLang.setSize(6);
    mdLang.setValue(value.getLanguage());
    index++;
  }
  actions=main.addPara(null,"String_Node_Str");
  actions.addButton("String_Node_Str").setValue(T_submit_update);
  actions.addButton("String_Node_Str").setValue(T_submit_return);
  main.addHidden("String_Node_Str").setValue(knot.getId());
}

Fixed version (ground truth):
/** 
 * Add either the simple Ajax response document or the full document with header and full edit item form based on the mode parameter.  Mode parameter values are set in the Flowscipt and can be either 'ajax' or 'normal'.
 */
@SuppressWarnings("String_Node_Str") public void addBody(Body body) throws SQLException, WingException {
  UUID itemID=UUID.fromString(parameters.getParameter("String_Node_Str",null));
  Item item=itemService.find(context,itemID);
  java.util.List<MetadataValue> values=itemService.getMetadata(item,Item.ANY,Item.ANY,Item.ANY,Item.ANY);
  Collections.sort(values,new DCValueComparator());
  String baseURL=contextPath + "String_Node_Str" + knot.getId();
  Request request=ObjectModelHelper.getRequest(objectModel);
  String previousFieldID=request.getParameter("String_Node_Str");
  boolean editingTemplateItem=false;
  String templateCollectionID=parameters.getParameter("String_Node_Str",null);
  Collection templateCollection=templateCollectionID == null ? null : collectionService.find(context,UUID.fromString(templateCollectionID));
  if (templateCollection != null) {
    Item templateItem=templateCollection.getTemplateItem();
    if (templateItem != null && templateItem.getID() == itemID) {
      editingTemplateItem=true;
    }
  }
  Division main=body.addInteractiveDivision("String_Node_Str",contextPath + "String_Node_Str",Division.METHOD_POST,"String_Node_Str");
  if (templateCollection != null && editingTemplateItem) {
    main.setHead(T_template_head.parameterize(templateCollection.getName()));
  }
 else {
    main.setHead(T_option_head);
  }
  Collection owner=item.getOwningCollection();
  if (!editingTemplateItem) {
    List options=main.addList("String_Node_Str",List.TYPE_SIMPLE,"String_Node_Str");
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_status);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_bitstreams);
    options.addItem().addHighlight("String_Node_Str").addXref(baseURL + "String_Node_Str",T_option_metadata);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_view);
    options.addItem().addXref(baseURL + "String_Node_Str",T_option_curate);
  }
  List addForm=main.addList("String_Node_Str",List.TYPE_FORM);
  addForm.setHead(T_head1);
  Select addName=addForm.addItem().addSelect("String_Node_Str");
  addName.setLabel(T_name_label);
  java.util.List<MetadataField> fields=metadataFieldService.findAll(context);
  for (  MetadataField field : fields) {
    int fieldID=field.getFieldID();
    MetadataSchema schema=field.getMetadataSchema();
    String name=schema.getName() + "String_Node_Str" + field.getElement();
    if (field.getQualifier() != null) {
      name+="String_Node_Str" + field.getQualifier();
    }
    addName.addOption(fieldID,name);
  }
  if (previousFieldID != null) {
    addName.setOptionSelected(previousFieldID);
  }
  Composite addComposite=addForm.addItem().addComposite("String_Node_Str");
  addComposite.setLabel(T_value_label);
  TextArea addValue=addComposite.addTextArea("String_Node_Str");
  Text addLang=addComposite.addText("String_Node_Str");
  addValue.setSize(4,35);
  addLang.setLabel(T_lang_label);
  addLang.setSize(6);
  addForm.addItem().addButton("String_Node_Str").setValue(T_submit_add);
  main.addPara(T_para1);
  Para actions=main.addPara(null,"String_Node_Str");
  actions.addButton("String_Node_Str").setValue(T_submit_update);
  actions.addButton("String_Node_Str").setValue(T_submit_return);
  main.addHidden("String_Node_Str").setValue("String_Node_Str");
  int index=1;
  Table table=main.addTable("String_Node_Str",1,1);
  table.setHead(T_head2);
  Row header=table.addRow(Row.ROLE_HEADER);
  header.addCell().addContent(T_column1);
  header.addCell().addContent(T_column2);
  header.addCell().addContent(T_column3);
  header.addCell().addContent(T_column4);
  for (  MetadataValue value : values) {
    String name=value.getMetadataField().toString('_');
    Row row=table.addRow(name,Row.ROLE_DATA,"String_Node_Str");
    CheckBox remove=row.addCell().addCheckBox("String_Node_Str" + index);
    remove.setLabel("String_Node_Str");
    remove.addOption(index);
    Cell cell=row.addCell();
    cell.addContent(name.replaceAll("String_Node_Str","String_Node_Str"));
    cell.addHidden("String_Node_Str" + index).setValue(name);
    Cell mdCell=row.addCell();
    String fieldKey=metadataAuthorityService.makeFieldKey(value.getMetadataField().getMetadataSchema().getName(),value.getMetadataField().getElement(),value.getMetadataField().getQualifier());
    if (choiceAuthorityService.isChoicesConfigured(fieldKey) && Params.PRESENTATION_SELECT.equals(choiceAuthorityService.getPresentation(fieldKey))) {
      Select mdSelect=mdCell.addSelect("String_Node_Str" + index);
      mdSelect.setSize(1);
      Choices cs=choiceAuthorityService.getMatches(fieldKey,value.getValue(),owner,0,0,null);
      if (cs.defaultSelected < 0) {
        mdSelect.addOption(true,value.getValue(),value.getValue());
      }
      for (int i=0; i < cs.values.length; ++i) {
        mdSelect.addOption(i == cs.defaultSelected,cs.values[i].value,cs.values[i].label);
      }
    }
 else {
      TextArea mdValue=mdCell.addTextArea("String_Node_Str" + index);
      mdValue.setSize(4,35);
      mdValue.setValue(value.getValue());
      boolean isAuth=metadataAuthorityService.isAuthorityControlled(fieldKey);
      if (isAuth) {
        mdValue.setAuthorityControlled();
        mdValue.setAuthorityRequired(metadataAuthorityService.isAuthorityRequired(fieldKey));
        Value authValue=mdValue.setAuthorityValue((value.getAuthority() == null) ? "String_Node_Str" : value.getAuthority(),Choices.getConfidenceText(value.getConfidence()));
        Button unlock=authValue.addButton("String_Node_Str" + index,"String_Node_Str");
        unlock.setHelp(T_unlock);
      }
      if (choiceAuthorityService.isChoicesConfigured(fieldKey)) {
        mdValue.setChoices(fieldKey);
        if (Params.PRESENTATION_AUTHORLOOKUP.equals(choiceAuthorityService.getPresentation(fieldKey))) {
          mdValue.setChoicesPresentation(Params.PRESENTATION_AUTHORLOOKUP);
        }
 else {
          mdValue.setChoicesPresentation(Params.PRESENTATION_LOOKUP);
        }
        mdValue.setChoicesClosed(choiceAuthorityService.isClosed(fieldKey));
      }
    }
    Text mdLang=row.addCell().addText("String_Node_Str" + index);
    mdLang.setSize(6);
    mdLang.setValue(value.getLanguage());
    index++;
  }
  actions=main.addPara(null,"String_Node_Str");
  actions.addButton("String_Node_Str").setValue(T_submit_update);
  actions.addButton("String_Node_Str").setValue(T_submit_return);
  main.addHidden("String_Node_Str").setValue(knot.getId());
}