Program: 52179
Project: 52179
Buggy source:
/** 
 * When DSpace creates Default Group Names they are of a very specific format, for example: <li> COMMUNITY_[ID]_ADMIN <li> COLLECTION_[ID]_ADMIN <li> COLLECTION_[ID]_SUBMIT <li> COLLECTION_[ID]_WORKFLOW_STEP_# <p> Although these names work fine within DSpace, the DSpace internal ID (represented by [ID] above) becomes meaningless when content is exported outside of DSpace.  In order to make these Group names meaningful outside of DSpace, they must be translated into a different format: <li> COMMUNITY_[HANDLE]_ADMIN (e.g. COMMUNITY_hdl:123456789/10_ADMIN), etc. <p> This format replaces the internal ID with an external Handle identifier (which is expected to be more meaningful even when content is exported from DSpace). <p> This method prepares group names for export by replacing any found internal IDs with the appropriate external Handle identifier.  If the group name either doesn't have an embedded internal ID, or the corresponding Handle cannot be determined, then it is returned as is. <p> This method may be useful to any Crosswalks/Packagers which deal with import/export of DSpace Groups. <p> Also see the translateGroupNameForImport() method which does the opposite of this method.
 * @param relatedDso DSpaceObject associated with group
 * @param groupName Group's name
 * @return the group name, with any internal IDs translated to Handles
 */
public static String translateGroupNameForExport(Context context,String groupName) throws PackageException {
  if (!groupName.matches("String_Node_Str")) {
    return groupName;
  }
  String objType=groupName.substring(0,groupName.indexOf('_'));
  String tmpEndString=groupName.substring(groupName.indexOf('_') + 1);
  String objID=tmpEndString.substring(0,tmpEndString.indexOf('_'));
  String groupType=tmpEndString.substring(tmpEndString.indexOf('_') + 1);
  try {
    DSpaceObject dso=DSpaceObject.find(context,Constants.getTypeID(objType),Integer.parseInt(objID));
    if (dso == null) {
      log.warn("String_Node_Str" + groupName + "String_Node_Str"+ objID+ "String_Node_Str"+ objType+ "String_Node_Str");
      return groupName;
    }
    return objType + "String_Node_Str" + "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ groupType;
  }
 catch (  SQLException sqle) {
    throw new PackageException("String_Node_Str" + groupName + "String_Node_Str",sqle);
  }
}

Fixed version (ground truth):
/** 
 * When DSpace creates Default Group Names they are of a very specific format, for example: <li> COMMUNITY_[ID]_ADMIN <li> COLLECTION_[ID]_ADMIN <li> COLLECTION_[ID]_SUBMIT <li> COLLECTION_[ID]_WORKFLOW_STEP_# <p> Although these names work fine within DSpace, the DSpace internal ID (represented by [ID] above) becomes meaningless when content is exported outside of DSpace.  In order to make these Group names meaningful outside of DSpace, they must be translated into a different format: <li> COMMUNITY_[HANDLE]_ADMIN (e.g. COMMUNITY_hdl:123456789/10_ADMIN), etc. <p> This format replaces the internal ID with an external Handle identifier (which is expected to be more meaningful even when content is exported from DSpace). <p> This method prepares group names for export by replacing any found internal IDs with the appropriate external Handle identifier.  If the group name doesn't have an embedded internal ID, it is returned as is. If the group name contains an embedded internal ID, but the corresponding Handle cannot be determined, then null is returned (as the group name could not be translated). <p> This method may be useful to any Crosswalks/Packagers which deal with import/export of DSpace Groups. <p> Also see the translateGroupNameForImport() method which does the opposite of this method.
 * @param relatedDso DSpaceObject associated with group
 * @param groupName Group's name
 * @return the group name, with any internal IDs translated to Handles
 */
public static String translateGroupNameForExport(Context context,String groupName) throws PackageException {
  if (!groupName.matches("String_Node_Str")) {
    return groupName;
  }
  String objType=groupName.substring(0,groupName.indexOf('_'));
  String tmpEndString=groupName.substring(groupName.indexOf('_') + 1);
  String objID=tmpEndString.substring(0,tmpEndString.indexOf('_'));
  String groupType=tmpEndString.substring(tmpEndString.indexOf('_') + 1);
  try {
    DSpaceObject dso=DSpaceObject.find(context,Constants.getTypeID(objType),Integer.parseInt(objID));
    if (dso == null) {
      log.warn("String_Node_Str" + groupName + "String_Node_Str"+ objID+ "String_Node_Str"+ objType+ "String_Node_Str");
      return null;
    }
    return objType + "String_Node_Str" + "String_Node_Str"+ dso.getHandle()+ "String_Node_Str"+ groupType;
  }
 catch (  SQLException sqle) {
    throw new PackageException("String_Node_Str" + groupName + "String_Node_Str",sqle);
  }
}