Program: 52477
Project: 52477
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();
  if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX)) {
    return STATUS_COMPLETE;
  }
  if (request.getParameter("String_Node_Str") != null) {
    if (buttonPressed.equals(CANCEL_EDIT_BUTTON)) {
      subInfo.setBitstream(null);
      return STATUS_EDIT_COMPLETE;
    }
 else {
      Bitstream b=Bitstream.find(context,Integer.parseInt(request.getParameter("String_Node_Str")));
      subInfo.setBitstream(b);
    }
  }
 else   if (buttonPressed.startsWith("String_Node_Str")) {
    String bitstreamID=buttonPressed.substring("String_Node_Str".length());
    Bitstream b=Bitstream.find(context,Integer.parseInt(bitstreamID));
    subInfo.setBitstream(b);
    return STATUS_EDIT_BITSTREAM;
  }
  if (buttonPressed.equalsIgnoreCase("String_Node_Str")) {
    if (request.getParameter("String_Node_Str") != null) {
      String[] removeIDs=request.getParameterValues("String_Node_Str");
      for (int i=0; i < removeIDs.length; i++) {
        int id=Integer.parseInt(removeIDs[i]);
        int status=processRemoveFile(context,item,id);
        if (status != STATUS_COMPLETE)         return status;
      }
      subInfo.setBitstream(null);
    }
  }
 else   if (buttonPressed.startsWith("String_Node_Str")) {
    int id=Integer.parseInt(buttonPressed.substring(14));
    int status=processRemoveFile(context,item,id);
    if (status != STATUS_COMPLETE)     return status;
    subInfo.setBitstream(null);
  }
  String contentType=request.getContentType();
  if (buttonPressed.equalsIgnoreCase(SUBMIT_UPLOAD_BUTTON)) {
    if ((contentType != null) && (contentType.indexOf("String_Node_Str") != -1)) {
      int status=processUploadFile(context,request,response,subInfo);
      if (status != STATUS_COMPLETE)       return status;
    }
  }
  String fileDescription=request.getParameter("String_Node_Str");
  if (fileDescription != null && fileDescription.length() > 0) {
    int status=processSaveFileDescription(context,request,response,subInfo);
    if (status != STATUS_COMPLETE)     return status;
  }
  int formatTypeID=Util.getIntParameter(request,"String_Node_Str");
  String formatDesc=request.getParameter("String_Node_Str");
  if (formatTypeID >= 0 || (formatDesc != null && formatDesc.length() > 0)) {
    int status=processSaveFileFormat(context,request,response,subInfo);
    if (status != STATUS_COMPLETE)     return status;
  }
  if (request.getParameter("String_Node_Str") != null) {
    Bundle[] bundles=item.getBundles("String_Node_Str");
    bundles[0].setPrimaryBitstreamID(new Integer(request.getParameter("String_Node_Str")).intValue());
    bundles[0].update();
  }
  boolean allowEmptyItems=(request.getParameter(SUBMIT_SKIP_BUTTON) != null);
  if (!allowEmptyItems) {
    Bundle[] bundles=item.getBundles("String_Node_Str");
    if (bundles.length == 0) {
      return STATUS_NO_FILES_ERROR;
    }
 else {
      Bitstream[] bitstreams=bundles[0].getBitstreams();
      if (bitstreams.length == 0) {
        return STATUS_NO_FILES_ERROR;
      }
    }
  }
  context.commit();
  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();
  if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX)) {
    return STATUS_COMPLETE;
  }
  if (request.getParameter("String_Node_Str") != null) {
    if (buttonPressed.equals(CANCEL_EDIT_BUTTON)) {
      subInfo.setBitstream(null);
      return STATUS_EDIT_COMPLETE;
    }
 else {
      Bitstream b=Bitstream.find(context,Integer.parseInt(request.getParameter("String_Node_Str")));
      subInfo.setBitstream(b);
    }
  }
 else   if (buttonPressed.startsWith("String_Node_Str")) {
    String bitstreamID=buttonPressed.substring("String_Node_Str".length());
    Bitstream b=Bitstream.find(context,Integer.parseInt(bitstreamID));
    subInfo.setBitstream(b);
    return STATUS_EDIT_BITSTREAM;
  }
  if (buttonPressed.equalsIgnoreCase("String_Node_Str")) {
    if (request.getParameter("String_Node_Str") != null) {
      String[] removeIDs=request.getParameterValues("String_Node_Str");
      for (int i=0; i < removeIDs.length; i++) {
        int id=Integer.parseInt(removeIDs[i]);
        int status=processRemoveFile(context,item,id);
        if (status != STATUS_COMPLETE)         return status;
      }
      subInfo.setBitstream(null);
    }
  }
 else   if (buttonPressed.startsWith("String_Node_Str")) {
    int id=Integer.parseInt(buttonPressed.substring(14));
    int status=processRemoveFile(context,item,id);
    if (status != STATUS_COMPLETE)     return status;
    subInfo.setBitstream(null);
  }
  String contentType=request.getContentType();
  if (buttonPressed.equalsIgnoreCase(SUBMIT_UPLOAD_BUTTON)) {
    if ((contentType != null) && (contentType.indexOf("String_Node_Str") != -1)) {
      int status=processUploadFile(context,request,response,subInfo);
      if (status != STATUS_COMPLETE)       return status;
    }
  }
  String fileDescription=request.getParameter("String_Node_Str");
  if (fileDescription != null && fileDescription.length() > 0) {
    int status=processSaveFileDescription(context,request,response,subInfo);
    if (status != STATUS_COMPLETE)     return status;
  }
  int formatTypeID=Util.getIntParameter(request,"String_Node_Str");
  String formatDesc=request.getParameter("String_Node_Str");
  if (formatTypeID >= 0 || (formatDesc != null && formatDesc.length() > 0)) {
    int status=processSaveFileFormat(context,request,response,subInfo);
    if (status != STATUS_COMPLETE)     return status;
  }
  if (request.getParameter("String_Node_Str") != null) {
    Bundle[] bundles=item.getBundles("String_Node_Str");
    bundles[0].setPrimaryBitstreamID(new Integer(request.getParameter("String_Node_Str")).intValue());
    bundles[0].update();
  }
  boolean fileRequired=ConfigurationManager.getBooleanProperty("String_Node_Str",true);
  if (fileRequired) {
    Bundle[] bundles=item.getBundles("String_Node_Str");
    if (bundles.length == 0) {
      return STATUS_NO_FILES_ERROR;
    }
 else {
      Bitstream[] bitstreams=bundles[0].getBitstreams();
      if (bitstreams.length == 0) {
        return STATUS_NO_FILES_ERROR;
      }
    }
  }
  context.commit();
  return STATUS_COMPLETE;
}