Program: 52207
Project: 52207
Buggy source:
/** 
 * Actually Disseminate into METSRights schema.  This method locates all DSpace policies (permissions) for the provided object, and translates them into METSRights PermissionTypes.
 * @param dso DSpace Object
 * @return XML Element corresponding to the new <RightsDeclarationMD> translation
 * @throws CrosswalkException
 * @throws IOException
 * @throws SQLException
 * @throws AuthorizeException
 */
@Override public Element disseminateElement(DSpaceObject dso) throws CrosswalkException, IOException, SQLException, AuthorizeException {
  if (dso == null)   return null;
 else   if (dso.getType() == Constants.SITE)   throw new CrosswalkObjectNotSupported("String_Node_Str");
  Element rightsMD=new Element("String_Node_Str",METSRights_NS);
  rightsMD.setAttribute("String_Node_Str","String_Node_Str");
  Context context=new Context();
  List<ResourcePolicy> policies=AuthorizeManager.getPolicies(context,dso);
  for (  ResourcePolicy policy : policies) {
    Group group=policy.getGroup();
    EPerson person=policy.getEPerson();
    Element rightsContext=new Element("String_Node_Str",METSRights_NS);
    rightsMD.addContent(rightsContext);
    if (group != null) {
      String contextClass=GROUP_CONTEXTCLASS;
      if (group.getID() == 0)       contextClass=ANONYMOUS_CONTEXTCLASS;
 else       if (group.getID() == 1)       contextClass=ADMIN_CONTEXTCLASS;
      rightsContext.setAttribute("String_Node_Str",contextClass);
      if (contextClass.equals(GROUP_CONTEXTCLASS)) {
        try {
          Element rightsUser=new Element("String_Node_Str",METSRights_NS);
          rightsUser.setAttribute("String_Node_Str",GROUP_USERTYPE);
          rightsUser.addContent(PackageUtils.crosswalkDefaultGroupName(context,group.getName()));
          rightsContext.addContent(rightsUser);
        }
 catch (        PackageException pe) {
          throw new CrosswalkException(pe);
        }
      }
    }
 else     if (person != null) {
      rightsContext.setAttribute("String_Node_Str",PERSON_CONTEXTCLASS);
      Element rightsUser=new Element("String_Node_Str",METSRights_NS);
      rightsUser.setAttribute("String_Node_Str",PERSON_USERTYPE);
      rightsUser.addContent(person.getEmail());
      rightsContext.addContent(rightsUser);
    }
    Element rightsPerm=translatePermissions(policy);
    rightsContext.addContent(rightsPerm);
  }
  context.complete();
  return rightsMD;
}

Fixed version (ground truth):
/** 
 * Actually Disseminate into METSRights schema.  This method locates all DSpace policies (permissions) for the provided object, and translates them into METSRights PermissionTypes.
 * @param dso DSpace Object
 * @return XML Element corresponding to the new <RightsDeclarationMD> translation
 * @throws CrosswalkException
 * @throws IOException
 * @throws SQLException
 * @throws AuthorizeException
 */
@Override public Element disseminateElement(DSpaceObject dso) throws CrosswalkException, IOException, SQLException, AuthorizeException {
  if (dso == null)   return null;
 else   if (dso.getType() == Constants.SITE)   throw new CrosswalkObjectNotSupported("String_Node_Str");
  Element rightsMD=new Element("String_Node_Str",METSRights_NS);
  rightsMD.setAttribute("String_Node_Str","String_Node_Str");
  Context context=new Context();
  List<ResourcePolicy> policies=AuthorizeManager.getPolicies(context,dso);
  for (  ResourcePolicy policy : policies) {
    Group group=policy.getGroup();
    EPerson person=policy.getEPerson();
    Element rightsContext=new Element("String_Node_Str",METSRights_NS);
    rightsMD.addContent(rightsContext);
    if (group != null) {
      String contextClass=GROUP_CONTEXTCLASS;
      if (group.getID() == 0)       contextClass=ANONYMOUS_CONTEXTCLASS;
 else       if (group.getID() == 1)       contextClass=ADMIN_CONTEXTCLASS;
      rightsContext.setAttribute("String_Node_Str",contextClass);
      if (contextClass.equals(GROUP_CONTEXTCLASS)) {
        try {
          Element rightsUser=new Element("String_Node_Str",METSRights_NS);
          rightsUser.setAttribute("String_Node_Str",GROUP_USERTYPE);
          rightsUser.addContent(PackageUtils.translateGroupNameForExport(context,group.getName()));
          rightsContext.addContent(rightsUser);
        }
 catch (        PackageException pe) {
          throw new CrosswalkException(pe);
        }
      }
    }
 else     if (person != null) {
      rightsContext.setAttribute("String_Node_Str",PERSON_CONTEXTCLASS);
      Element rightsUser=new Element("String_Node_Str",METSRights_NS);
      rightsUser.setAttribute("String_Node_Str",PERSON_USERTYPE);
      rightsUser.addContent(person.getEmail());
      rightsContext.addContent(rightsUser);
    }
    Element rightsPerm=translatePermissions(policy);
    rightsContext.addContent(rightsPerm);
  }
  context.complete();
  return rightsMD;
}