Program: 52239
Project: 52239
Buggy source:
/** 
 * Edit an eperson's metadata, the email address, first name, and last name are all required. The user's email address can be updated but it must remain unique, if the email address allready exists then the an error is produced.
 * @param context The current DSpace context
 * @param request The HTTP request parameters
 * @param objectModel Cocoon's object model
 * @param epersonID The unique id of the eperson being edited.
 * @return A process result's object.
 */
public static FlowResult processEditEPerson(Context context,Request request,Map ObjectModel,int epersonID) throws SQLException, AuthorizeException {
  FlowResult result=new FlowResult();
  result.setContinue(false);
  String email=request.getParameter("String_Node_Str");
  String first=request.getParameter("String_Node_Str");
  String last=request.getParameter("String_Node_Str");
  String phone=request.getParameter("String_Node_Str");
  boolean login=(request.getParameter("String_Node_Str") != null) ? true : false;
  boolean certificate=(request.getParameter("String_Node_Str") != null) ? true : false;
  if (email.length() == 0)   result.addError("String_Node_Str");
  if (first.length() == 0)   result.addError("String_Node_Str");
  if (last.length() == 0)   result.addError("String_Node_Str");
  if (result.getErrors() == null) {
    EPerson personModified=EPerson.find(context,epersonID);
    if (personModified.getEmail() != email) {
      EPerson potentialDupicate=EPerson.findByEmail(context,email);
      if (potentialDupicate == null) {
        personModified.setEmail(email);
      }
 else       if (potentialDupicate != personModified) {
        result.addError("String_Node_Str");
        return result;
      }
    }
    if (personModified.getFirstName() != first) {
      personModified.setFirstName(first);
    }
    if (personModified.getLastName() != last) {
      personModified.setLastName(last);
    }
    if (personModified.getMetadata("String_Node_Str") != phone) {
      personModified.setMetadata("String_Node_Str",phone);
    }
    personModified.setCanLogIn(login);
    personModified.setRequireCertificate(certificate);
    personModified.update();
    context.commit();
    result.setContinue(true);
    result.setOutcome(true);
    result.setMessage(T_edit_eperson_success_notice);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Edit an eperson's metadata, the email address, first name, and last name are all required. The user's email address can be updated but it must remain unique, if the email address allready exists then the an error is produced.
 * @param context The current DSpace context
 * @param request The HTTP request parameters
 * @param objectModel Cocoon's object model
 * @param epersonID The unique id of the eperson being edited.
 * @return A process result's object.
 */
public static FlowResult processEditEPerson(Context context,Request request,Map ObjectModel,int epersonID) throws SQLException, AuthorizeException {
  FlowResult result=new FlowResult();
  result.setContinue(false);
  String email=request.getParameter("String_Node_Str");
  String first=request.getParameter("String_Node_Str");
  String last=request.getParameter("String_Node_Str");
  String phone=request.getParameter("String_Node_Str");
  boolean login=(request.getParameter("String_Node_Str") != null) ? true : false;
  boolean certificate=(request.getParameter("String_Node_Str") != null) ? true : false;
  if (email.length() == 0)   result.addError("String_Node_Str");
  if (first.length() == 0)   result.addError("String_Node_Str");
  if (last.length() == 0)   result.addError("String_Node_Str");
  if (result.getErrors() == null) {
    EPerson personModified=EPerson.find(context,epersonID);
    if (!personModified.getEmail().equals(email)) {
      EPerson potentialDupicate=EPerson.findByEmail(context,email);
      if (potentialDupicate == null) {
        personModified.setEmail(email);
      }
 else       if (potentialDupicate != personModified) {
        result.addError("String_Node_Str");
        return result;
      }
    }
    if (!personModified.getFirstName().equals(first)) {
      personModified.setFirstName(first);
    }
    if (!personModified.getLastName().equals(last)) {
      personModified.setLastName(last);
    }
    if (!personModified.getMetadata("String_Node_Str").equals(phone)) {
      personModified.setMetadata("String_Node_Str",phone);
    }
    personModified.setCanLogIn(login);
    personModified.setRequireCertificate(certificate);
    personModified.update();
    context.commit();
    result.setContinue(true);
    result.setOutcome(true);
    result.setMessage(T_edit_eperson_success_notice);
  }
  return result;
}