Program: 3268
Project: 3268
Buggy source:
/** 
 * Ingest a List of XML elements <P> This method creates new DSpace Policies based on the parsed METSRights XML contents. These Policies assign permissions to DSpace Groups or EPeople. <P> NOTE: This crosswalk will NOT create missing DSpace Groups or EPeople. Therefore, it is recommended to use this METSRightsCrosswalk in conjunction with another Crosswalk which can create/restore missing Groups or EPeople (e.g. RoleCrosswalk).
 * @param context
 * @param dso
 * @param metadata
 * @throws CrosswalkException
 * @throws IOException
 * @throws SQLException
 * @throws AuthorizeException
 * @see RoleCrosswalk
 */
@Override public void ingest(Context context,DSpaceObject dso,List ml) throws CrosswalkException, IOException, SQLException, AuthorizeException {
  if (dso.getType() == Constants.SITE)   throw new CrosswalkObjectNotSupported("String_Node_Str");
  if (!ml.isEmpty())   AuthorizeManager.removeAllPolicies(context,dso);
  Iterator mi=ml.iterator();
  while (mi.hasNext()) {
    Element element=(Element)mi.next();
    if (element.getName().equals("String_Node_Str"))     ingest(context,dso,element.getChildren());
 else     if (element.getName().equals("String_Node_Str")) {
      String contextClass=element.getAttributeValue("String_Node_Str");
      Element permsElement=element.getChild("String_Node_Str",METSRights_NS);
      if (contextClass.equals(ANONYMOUS_CONTEXTCLASS)) {
        Group anonGroup=Group.find(context,0);
        if (anonGroup == null)         throw new CrosswalkInternalException("String_Node_Str");
        assignPermissions(context,dso,anonGroup,permsElement);
      }
 else       if (contextClass.equals(ADMIN_CONTEXTCLASS)) {
        Group adminGroup=Group.find(context,1);
        if (adminGroup == null)         throw new CrosswalkInternalException("String_Node_Str");
        assignPermissions(context,dso,adminGroup,permsElement);
      }
 else       if (contextClass.equals(GROUP_CONTEXTCLASS)) {
        try {
          String groupName=element.getChildTextTrim("String_Node_Str",METSRights_NS);
          groupName=PackageUtils.crosswalkDefaultGroupName(context,groupName);
          Group group=Group.findByName(context,groupName);
          if (group == null) {
            throw new CrosswalkInternalException("String_Node_Str" + "String_Node_Str" + Constants.typeText[dso.getType()] + "String_Node_Str"+ "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ "String_Node_Str"+ dso.getID()+ "String_Node_Str"+ groupName+ "String_Node_Str"+ "String_Node_Str");
          }
          assignPermissions(context,dso,group,permsElement);
        }
 catch (        PackageException pe) {
          throw new CrosswalkException(pe);
        }
      }
 else       if (contextClass.equals(PERSON_CONTEXTCLASS)) {
        String personEmail=element.getChildTextTrim("String_Node_Str",METSRights_NS);
        EPerson person=EPerson.findByEmail(context,personEmail);
        if (person == null)         person=EPerson.findByNetid(context,personEmail);
        if (person == null) {
          throw new CrosswalkInternalException("String_Node_Str" + "String_Node_Str" + Constants.typeText[dso.getType()] + "String_Node_Str"+ "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ "String_Node_Str"+ dso.getID()+ "String_Node_Str"+ personEmail+ "String_Node_Str"+ "String_Node_Str");
        }
        assignPermissions(context,dso,person,permsElement);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Ingest a List of XML elements <P> This method creates new DSpace Policies based on the parsed METSRights XML contents. These Policies assign permissions to DSpace Groups or EPeople. <P> NOTE: This crosswalk will NOT create missing DSpace Groups or EPeople. Therefore, it is recommended to use this METSRightsCrosswalk in conjunction with another Crosswalk which can create/restore missing Groups or EPeople (e.g. RoleCrosswalk).
 * @param context
 * @param dso
 * @param metadata
 * @throws CrosswalkException
 * @throws IOException
 * @throws SQLException
 * @throws AuthorizeException
 * @see RoleCrosswalk
 */
@Override public void ingest(Context context,DSpaceObject dso,List ml) throws CrosswalkException, IOException, SQLException, AuthorizeException {
  if (dso.getType() == Constants.SITE)   throw new CrosswalkObjectNotSupported("String_Node_Str");
  if (!ml.isEmpty())   AuthorizeManager.removeAllPolicies(context,dso);
  Iterator mi=ml.iterator();
  while (mi.hasNext()) {
    Element element=(Element)mi.next();
    if (element.getName().equals("String_Node_Str"))     ingest(context,dso,element.getChildren());
 else     if (element.getName().equals("String_Node_Str")) {
      String contextClass=element.getAttributeValue("String_Node_Str");
      Element permsElement=element.getChild("String_Node_Str",METSRights_NS);
      if (contextClass.equals(ANONYMOUS_CONTEXTCLASS)) {
        Group anonGroup=Group.find(context,0);
        if (anonGroup == null)         throw new CrosswalkInternalException("String_Node_Str");
        assignPermissions(context,dso,anonGroup,permsElement);
      }
 else       if (contextClass.equals(ADMIN_CONTEXTCLASS)) {
        Group adminGroup=Group.find(context,1);
        if (adminGroup == null)         throw new CrosswalkInternalException("String_Node_Str");
        assignPermissions(context,dso,adminGroup,permsElement);
      }
 else       if (contextClass.equals(GROUP_CONTEXTCLASS)) {
        try {
          String groupName=element.getChildTextTrim("String_Node_Str",METSRights_NS);
          groupName=PackageUtils.translateGroupNameForImport(context,groupName);
          Group group=Group.findByName(context,groupName);
          if (group == null) {
            throw new CrosswalkInternalException("String_Node_Str" + "String_Node_Str" + Constants.typeText[dso.getType()] + "String_Node_Str"+ "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ "String_Node_Str"+ dso.getID()+ "String_Node_Str"+ groupName+ "String_Node_Str"+ "String_Node_Str");
          }
          assignPermissions(context,dso,group,permsElement);
        }
 catch (        PackageException pe) {
          throw new CrosswalkException(pe);
        }
      }
 else       if (contextClass.equals(PERSON_CONTEXTCLASS)) {
        String personEmail=element.getChildTextTrim("String_Node_Str",METSRights_NS);
        EPerson person=EPerson.findByEmail(context,personEmail);
        if (person == null)         person=EPerson.findByNetid(context,personEmail);
        if (person == null) {
          throw new CrosswalkInternalException("String_Node_Str" + "String_Node_Str" + Constants.typeText[dso.getType()] + "String_Node_Str"+ "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ "String_Node_Str"+ dso.getID()+ "String_Node_Str"+ personEmail+ "String_Node_Str"+ "String_Node_Str");
        }
        assignPermissions(context,dso,person,permsElement);
      }
    }
  }
}