Program: 3313
Project: 3313
Buggy source:
/** 
 * Do any processing of the information input by the user, and/or perform step processing (if no user interaction required) <P> It is this method's job to save any data to the underlying database, as necessary, and return error messages (if any) which can then be processed by the appropriate user interface (JSP-UI or XML-UI) <P> NOTE: If this step is a non-interactive step (i.e. requires no UI), then it should perform *all* of its processing in this method!
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return Status or error flag which will be processed bydoPostProcessing() below! (if STATUS_COMPLETE or 0 is returned, no errors occurred!)
 */
public int doProcessing(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  String buttonPressed=Util.getSubmitButton(request,NEXT_BUTTON);
  Item item=subInfo.getSubmissionItem().getItem();
  int currentPage=getCurrentPage(request);
  Collection c=subInfo.getSubmissionItem().getCollection();
  DCInput[] inputs=inputsReader.getInputs(c.getHandle()).getPageRows(currentPage - 1,subInfo.getSubmissionItem().hasMultipleTitles(),subInfo.getSubmissionItem().isPublishedBefore());
  for (int i=0; i < inputs.length; i++) {
    String qualifier=inputs[i].getQualifier();
    if (qualifier == null && inputs[i].getInputType().equals("String_Node_Str")) {
      qualifier=Item.ANY;
    }
    item.clearMetadata(inputs[i].getSchema(),inputs[i].getElement(),qualifier,Item.ANY);
  }
  String fieldName;
  boolean moreInput=false;
  for (int j=0; j < inputs.length; j++) {
    String element=inputs[j].getElement();
    String qualifier=inputs[j].getQualifier();
    String schema=inputs[j].getSchema();
    if (qualifier != null && !qualifier.equals(Item.ANY)) {
      fieldName=schema + "String_Node_Str" + element+ '_'+ qualifier;
    }
 else {
      fieldName=schema + "String_Node_Str" + element;
    }
    String inputType=inputs[j].getInputType();
    if (inputType.equals("String_Node_Str")) {
      readNames(request,item,schema,element,qualifier,inputs[j].getRepeatable());
    }
 else     if (inputType.equals("String_Node_Str")) {
      readDate(request,item,schema,element,qualifier);
    }
 else     if (inputType.equals("String_Node_Str")) {
      readSeriesNumbers(request,item,schema,element,qualifier,inputs[j].getRepeatable());
    }
 else     if (inputType.equals("String_Node_Str")) {
      List quals=getRepeatedParameter(request,schema + "String_Node_Str" + element,schema + "String_Node_Str" + element+ "String_Node_Str");
      List vals=getRepeatedParameter(request,schema + "String_Node_Str" + element,schema + "String_Node_Str" + element+ "String_Node_Str");
      for (int z=0; z < vals.size(); z++) {
        String thisQual=(String)quals.get(z);
        if ("String_Node_Str".equals(thisQual)) {
          thisQual=null;
        }
        String thisVal=(String)vals.get(z);
        if (!buttonPressed.equals("String_Node_Str" + schema + "String_Node_Str"+ element+ "String_Node_Str"+ z) && !thisVal.equals("String_Node_Str")) {
          item.addMetadata(schema,element,thisQual,null,thisVal);
        }
      }
    }
 else     if (inputType.equals("String_Node_Str") || inputType.equals("String_Node_Str")) {
      String[] vals=request.getParameterValues(fieldName);
      if (vals != null) {
        for (int z=0; z < vals.length; z++) {
          if (!vals[z].equals("String_Node_Str")) {
            item.addMetadata(schema,element,qualifier,LANGUAGE_QUALIFIER,vals[z]);
          }
        }
      }
    }
 else     if ((inputType.equals("String_Node_Str")) || (inputType.equals("String_Node_Str")) || (inputType.equals("String_Node_Str"))) {
      readText(request,item,schema,element,qualifier,inputs[j].getRepeatable(),LANGUAGE_QUALIFIER);
    }
 else {
      throw new ServletException("String_Node_Str" + fieldName + "String_Node_Str"+ inputType);
    }
    if (!moreInput && buttonPressed.equals("String_Node_Str" + fieldName + "String_Node_Str")) {
      subInfo.setMoreBoxesFor(fieldName);
      subInfo.setJumpToField(fieldName);
      moreInput=true;
    }
  }
  clearErrorFields(request);
  for (int i=0; i < inputs.length; i++) {
    DCValue[] values=item.getMetadata(inputs[i].getSchema(),inputs[i].getElement(),inputs[i].getQualifier(),Item.ANY);
    if (inputs[i].isRequired() && values.length == 0) {
      addErrorField(request,getFieldName(inputs[i]));
    }
  }
  subInfo.getSubmissionItem().update();
  context.commit();
  if (moreInput) {
    return STATUS_MORE_INPUT_REQUESTED;
  }
 else   if (getErrorFields(request) != null && getErrorFields(request).size() > 0) {
    return STATUS_MISSING_REQUIRED_FIELDS;
  }
  return STATUS_COMPLETE;
}

Fixed version (ground truth):
/** 
 * Do any processing of the information input by the user, and/or perform step processing (if no user interaction required) <P> It is this method's job to save any data to the underlying database, as necessary, and return error messages (if any) which can then be processed by the appropriate user interface (JSP-UI or XML-UI) <P> NOTE: If this step is a non-interactive step (i.e. requires no UI), then it should perform *all* of its processing in this method!
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return Status or error flag which will be processed bydoPostProcessing() below! (if STATUS_COMPLETE or 0 is returned, no errors occurred!)
 */
public int doProcessing(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  String buttonPressed=Util.getSubmitButton(request,NEXT_BUTTON);
  Item item=subInfo.getSubmissionItem().getItem();
  int currentPage=getCurrentPage(request);
  Collection c=subInfo.getSubmissionItem().getCollection();
  DCInput[] inputs=inputsReader.getInputs(c.getHandle()).getPageRows(currentPage - 1,subInfo.getSubmissionItem().hasMultipleTitles(),subInfo.getSubmissionItem().isPublishedBefore());
  for (int i=0; i < inputs.length; i++) {
    String qualifier=inputs[i].getQualifier();
    if (qualifier == null && inputs[i].getInputType().equals("String_Node_Str")) {
      qualifier=Item.ANY;
    }
    item.clearMetadata(inputs[i].getSchema(),inputs[i].getElement(),qualifier,Item.ANY);
  }
  String fieldName;
  boolean moreInput=false;
  for (int j=0; j < inputs.length; j++) {
    String element=inputs[j].getElement();
    String qualifier=inputs[j].getQualifier();
    String schema=inputs[j].getSchema();
    if (qualifier != null && !qualifier.equals(Item.ANY)) {
      fieldName=schema + "String_Node_Str" + element+ '_'+ qualifier;
    }
 else {
      fieldName=schema + "String_Node_Str" + element;
    }
    String inputType=inputs[j].getInputType();
    if (inputType.equals("String_Node_Str")) {
      readNames(request,item,schema,element,qualifier,inputs[j].getRepeatable());
    }
 else     if (inputType.equals("String_Node_Str")) {
      readDate(request,item,schema,element,qualifier);
    }
 else     if (inputType.equals("String_Node_Str")) {
      readSeriesNumbers(request,item,schema,element,qualifier,inputs[j].getRepeatable());
    }
 else     if (inputType.equals("String_Node_Str")) {
      List quals=getRepeatedParameter(request,schema + "String_Node_Str" + element,schema + "String_Node_Str" + element+ "String_Node_Str");
      List vals=getRepeatedParameter(request,schema + "String_Node_Str" + element,schema + "String_Node_Str" + element+ "String_Node_Str");
      for (int z=0; z < vals.size(); z++) {
        String thisQual=(String)quals.get(z);
        if ("String_Node_Str".equals(thisQual)) {
          thisQual=null;
        }
        String thisVal=(String)vals.get(z);
        if (!buttonPressed.equals("String_Node_Str" + schema + "String_Node_Str"+ element+ "String_Node_Str"+ z) && !thisVal.equals("String_Node_Str")) {
          item.addMetadata(schema,element,thisQual,null,thisVal);
        }
      }
    }
 else     if (inputType.equals("String_Node_Str") || inputType.equals("String_Node_Str")) {
      String[] vals=request.getParameterValues(fieldName);
      if (vals != null) {
        for (int z=0; z < vals.length; z++) {
          if (!vals[z].equals("String_Node_Str")) {
            item.addMetadata(schema,element,qualifier,LANGUAGE_QUALIFIER,vals[z]);
          }
        }
      }
    }
 else     if ((inputType.equals("String_Node_Str")) || (inputType.equals("String_Node_Str")) || (inputType.equals("String_Node_Str"))) {
      readText(request,item,schema,element,qualifier,inputs[j].getRepeatable(),LANGUAGE_QUALIFIER);
    }
 else {
      throw new ServletException("String_Node_Str" + fieldName + "String_Node_Str"+ inputType);
    }
    if (!moreInput && buttonPressed.equals("String_Node_Str" + fieldName + "String_Node_Str")) {
      subInfo.setMoreBoxesFor(fieldName);
      subInfo.setJumpToField(fieldName);
      moreInput=true;
    }
  }
  if (buttonPressed.equals(NEXT_BUTTON) || buttonPressed.startsWith(PROGRESS_BAR_PREFIX)) {
    clearErrorFields(request);
    for (int i=0; i < inputs.length; i++) {
      DCValue[] values=item.getMetadata(inputs[i].getSchema(),inputs[i].getElement(),inputs[i].getQualifier(),Item.ANY);
      if (inputs[i].isRequired() && values.length == 0) {
        addErrorField(request,getFieldName(inputs[i]));
      }
    }
  }
  subInfo.getSubmissionItem().update();
  context.commit();
  if (moreInput) {
    return STATUS_MORE_INPUT_REQUESTED;
  }
 else   if (getErrorFields(request) != null && getErrorFields(request).size() > 0) {
    return STATUS_MISSING_REQUIRED_FIELDS;
  }
  return STATUS_COMPLETE;
}