Program: 52556
Project: 52556
Buggy source:
/** 
 * Process input from the edit item form
 * @param context   DSpace context
 * @param request   the HTTP request containing posted info
 * @param response  the HTTP response
 * @param item      the item
 */
private void processUpdateItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item) throws ServletException, IOException, SQLException, AuthorizeException {
  String button=UIUtil.getSubmitButton(request,"String_Node_Str");
  item.clearDC(Item.ANY,Item.ANY,Item.ANY);
  Enumeration unsortedParamNames=request.getParameterNames();
  List sortedParamNames=new LinkedList();
  while (unsortedParamNames.hasMoreElements()) {
    sortedParamNames.add(unsortedParamNames.nextElement());
  }
  Collections.sort(sortedParamNames);
  Iterator iterator=sortedParamNames.iterator();
  while (iterator.hasNext()) {
    String p=(String)iterator.next();
    if (p.startsWith("String_Node_Str")) {
      StringTokenizer st=new StringTokenizer(p,"String_Node_Str");
      st.nextToken();
      String element=st.nextToken();
      String qualifier=null;
      if (st.countTokens() == 2) {
        qualifier=st.nextToken();
      }
      String sequenceNumber=st.nextToken();
      String key=element;
      if (qualifier != null) {
        key=element + "String_Node_Str" + qualifier;
      }
      String language=request.getParameter("String_Node_Str" + key + "String_Node_Str"+ sequenceNumber);
      if (language != null && language.equals("String_Node_Str")) {
        language=null;
      }
      String value=request.getParameter(p).trim();
      if (value.equals("String_Node_Str") || !button.equals("String_Node_Str" + key + "String_Node_Str"+ sequenceNumber)) {
        item.addDC(element,qualifier,language,value);
      }
    }
 else     if (p.startsWith("String_Node_Str")) {
      StringTokenizer st=new StringTokenizer(p,"String_Node_Str");
      st.nextToken();
      st.nextToken();
      int bundleID=Integer.parseInt(st.nextToken());
      int bitstreamID=Integer.parseInt(st.nextToken());
      Bundle bundle=Bundle.find(context,bundleID);
      Bitstream bitstream=Bitstream.find(context,bitstreamID);
      String key=String.valueOf(bundleID) + "String_Node_Str" + bitstreamID;
      if (button.equals("String_Node_Str" + key)) {
        bundle.removeBitstream(bitstream);
        if (bundle.getBitstreams().length == 0) {
          item.removeBundle(bundle);
        }
      }
 else {
        String name=request.getParameter(p);
        String source=request.getParameter("String_Node_Str" + key);
        String desc=request.getParameter("String_Node_Str" + key);
        int formatID=UIUtil.getIntParameter(request,"String_Node_Str" + key);
        String userFormatDesc=request.getParameter("String_Node_Str" + key);
        int primaryBitstreamID=UIUtil.getIntParameter(request,bundleID + "String_Node_Str");
        if (source.equals("String_Node_Str"))         source=null;
        if (desc.equals("String_Node_Str"))         desc=null;
        if (userFormatDesc.equals("String_Node_Str"))         userFormatDesc=null;
        bitstream.setName(name);
        bitstream.setSource(source);
        bitstream.setDescription(desc);
        bitstream.setFormat(BitstreamFormat.find(context,formatID));
        bundle.setPrimaryBitstreamID(primaryBitstreamID);
        if (userFormatDesc != null) {
          bitstream.setUserFormatDescription(userFormatDesc);
        }
        bitstream.update();
        bundle.update();
      }
    }
  }
  item.update();
  if (button.equals("String_Node_Str")) {
    int dcTypeID=UIUtil.getIntParameter(request,"String_Node_Str");
    String value=request.getParameter("String_Node_Str").trim();
    String lang=request.getParameter("String_Node_Str");
    if (lang.equals("String_Node_Str"))     lang=null;
    DCType dcType=DCType.find(context,dcTypeID);
    item.addDC(dcType.getElement(),dcType.getQualifier(),lang,value);
    item.update();
  }
  if (button.equals("String_Node_Str")) {
    request.setAttribute("String_Node_Str",item);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
 else {
    showEditForm(context,request,response,item);
  }
  context.complete();
}

Fixed version (ground truth):
/** 
 * Process input from the edit item form
 * @param context   DSpace context
 * @param request   the HTTP request containing posted info
 * @param response  the HTTP response
 * @param item      the item
 */
private void processUpdateItem(Context context,HttpServletRequest request,HttpServletResponse response,Item item) throws ServletException, IOException, SQLException, AuthorizeException {
  String button=UIUtil.getSubmitButton(request,"String_Node_Str");
  item.clearDC(Item.ANY,Item.ANY,Item.ANY);
  Enumeration unsortedParamNames=request.getParameterNames();
  List sortedParamNames=new LinkedList();
  while (unsortedParamNames.hasMoreElements()) {
    sortedParamNames.add(unsortedParamNames.nextElement());
  }
  Collections.sort(sortedParamNames);
  Iterator iterator=sortedParamNames.iterator();
  while (iterator.hasNext()) {
    String p=(String)iterator.next();
    if (p.startsWith("String_Node_Str")) {
      StringTokenizer st=new StringTokenizer(p,"String_Node_Str");
      st.nextToken();
      String element=st.nextToken();
      String qualifier=null;
      if (st.countTokens() == 2) {
        qualifier=st.nextToken();
      }
      String sequenceNumber=st.nextToken();
      String key=element;
      if (qualifier != null) {
        key=element + "String_Node_Str" + qualifier;
      }
      String language=request.getParameter("String_Node_Str" + key + "String_Node_Str"+ sequenceNumber);
      if (language != null && language.equals("String_Node_Str")) {
        language=null;
      }
      String value=request.getParameter(p).trim();
      if (value.equals("String_Node_Str") || !button.equals("String_Node_Str" + key + "String_Node_Str"+ sequenceNumber)) {
        item.addDC(element,qualifier,language,value);
      }
    }
 else     if (p.startsWith("String_Node_Str")) {
      StringTokenizer st=new StringTokenizer(p,"String_Node_Str");
      st.nextToken();
      st.nextToken();
      int bundleID=Integer.parseInt(st.nextToken());
      int bitstreamID=Integer.parseInt(st.nextToken());
      Bundle bundle=Bundle.find(context,bundleID);
      Bitstream bitstream=Bitstream.find(context,bitstreamID);
      String key=String.valueOf(bundleID) + "String_Node_Str" + bitstreamID;
      if (button.equals("String_Node_Str" + key)) {
        bundle.removeBitstream(bitstream);
        if (bundle.getBitstreams().length == 0) {
          item.removeBundle(bundle);
        }
      }
 else {
        String name=request.getParameter(p);
        String source=request.getParameter("String_Node_Str" + key);
        String desc=request.getParameter("String_Node_Str" + key);
        int formatID=UIUtil.getIntParameter(request,"String_Node_Str" + key);
        String userFormatDesc=request.getParameter("String_Node_Str" + key);
        int primaryBitstreamID=UIUtil.getIntParameter(request,bundleID + "String_Node_Str");
        if (source.equals("String_Node_Str"))         source=null;
        if (desc.equals("String_Node_Str"))         desc=null;
        if (userFormatDesc.equals("String_Node_Str"))         userFormatDesc=null;
        bitstream.setName(name);
        bitstream.setSource(source);
        bitstream.setDescription(desc);
        bitstream.setFormat(BitstreamFormat.find(context,formatID));
        if (primaryBitstreamID > 0) {
          bundle.setPrimaryBitstreamID(primaryBitstreamID);
        }
        if (userFormatDesc != null) {
          bitstream.setUserFormatDescription(userFormatDesc);
        }
        bitstream.update();
        bundle.update();
      }
    }
  }
  item.update();
  if (button.equals("String_Node_Str")) {
    int dcTypeID=UIUtil.getIntParameter(request,"String_Node_Str");
    String value=request.getParameter("String_Node_Str").trim();
    String lang=request.getParameter("String_Node_Str");
    if (lang.equals("String_Node_Str"))     lang=null;
    DCType dcType=DCType.find(context,dcTypeID);
    item.addDC(dcType.getElement(),dcType.getQualifier(),lang,value);
    item.update();
  }
  if (button.equals("String_Node_Str")) {
    request.setAttribute("String_Node_Str",item);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
 else {
    showEditForm(context,request,response,item);
  }
  context.complete();
}