Program: 69301
Project: 69301
Buggy source:
protected void publishToCatalog(String choiceValue,List<CategoryLabel> labels){
  CoursePropertyManager cpm=course.getCourseEnvironment().getCoursePropertyManager();
  CourseNode rootNode=course.getRunStructure().getRootNode();
  Property prop=cpm.findCourseNodeProperty(rootNode,null,null,"String_Node_Str");
  if (prop == null) {
    prop=cpm.createCourseNodePropertyInstance(rootNode,null,null,"String_Node_Str",null,null,choiceValue,null);
    cpm.saveProperty(prop);
  }
 else {
    prop.setStringValue(choiceValue);
    cpm.updateProperty(prop);
  }
  if ("String_Node_Str".equals(choiceValue) && labels != null) {
    CatalogManager cm=CoreSpringFactory.getImpl(CatalogManager.class);
    List<CatalogEntry> refParentCategories=cm.getCatalogCategoriesFor(repositoryEntry);
    a_a:     for (    CategoryLabel label : labels) {
      CatalogEntry category=label.getCategory();
      CatalogEntry parentCategory=label.getParentCategory();
      if (label.isDeleted()) {
        if (category.getKey() != null) {
          List<CatalogEntry> children=cm.getChildrenOf(category);
          for (          CatalogEntry child : children) {
            if (child.getRepositoryEntry() != null && child.getRepositoryEntry().equalsByPersistableKey(repositoryEntry)) {
              cm.deleteCatalogEntry(child);
            }
          }
        }
      }
 else       if (category.getKey() == null) {
        for (Iterator<CatalogEntry> refIt=refParentCategories.iterator(); refIt.hasNext(); ) {
          CatalogEntry refParentCategory=refIt.next();
          if (refParentCategory.equalsByPersistableKey(parentCategory)) {
            refIt.remove();
            break a_a;
          }
        }
        category.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
        cm.addCatalogEntry(parentCategory,category);
      }
 else {
        for (Iterator<CatalogEntry> refIt=refParentCategories.iterator(); refIt.hasNext(); ) {
          CatalogEntry refParentCategory=refIt.next();
          if (refParentCategory.equalsByPersistableKey(category)) {
            refIt.remove();
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void publishToCatalog(String choiceValue,List<CategoryLabel> labels){
  CoursePropertyManager cpm=course.getCourseEnvironment().getCoursePropertyManager();
  CourseNode rootNode=course.getRunStructure().getRootNode();
  Property prop=cpm.findCourseNodeProperty(rootNode,null,null,"String_Node_Str");
  if (prop == null) {
    prop=cpm.createCourseNodePropertyInstance(rootNode,null,null,"String_Node_Str",null,null,choiceValue,null);
    cpm.saveProperty(prop);
  }
 else {
    prop.setStringValue(choiceValue);
    cpm.updateProperty(prop);
  }
  CatalogManager cm=CoreSpringFactory.getImpl(CatalogManager.class);
  List<CatalogEntry> refParentCategories=cm.getCatalogCategoriesFor(repositoryEntry);
  a_a:   for (  CategoryLabel label : labels) {
    CatalogEntry category=label.getCategory();
    CatalogEntry parentCategory=label.getParentCategory();
    if (label.isDeleted()) {
      if (category.getKey() != null) {
        List<CatalogEntry> children=cm.getChildrenOf(category);
        for (        CatalogEntry child : children) {
          if (child.getRepositoryEntry() != null && child.getRepositoryEntry().equalsByPersistableKey(repositoryEntry)) {
            cm.deleteCatalogEntry(child);
          }
        }
      }
    }
 else     if (category.getKey() == null) {
      for (Iterator<CatalogEntry> refIt=refParentCategories.iterator(); refIt.hasNext(); ) {
        CatalogEntry refParentCategory=refIt.next();
        if (refParentCategory.equalsByPersistableKey(parentCategory)) {
          refIt.remove();
          break a_a;
        }
      }
      category.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
      cm.addCatalogEntry(parentCategory,category);
    }
 else {
      for (Iterator<CatalogEntry> refIt=refParentCategories.iterator(); refIt.hasNext(); ) {
        CatalogEntry refParentCategory=refIt.next();
        if (refParentCategory.equalsByPersistableKey(category)) {
          refIt.remove();
        }
      }
    }
  }
}