Program: 69542
Project: 69542
Buggy source:
/** 
 * @param ureq
 * @param cpRoot
 * @param showMenu
 * @param showNavigation Show the next/previous link
 * @param activateFirstPage
 * @param identPrefix In a course, set a unique prefix per node, if someone set 2x the same CPs in the course, the node identifiersof the CP elements must be different but predictable
 */
public CPDisplayController(UserRequest ureq,WindowControl wControl,VFSContainer rootContainer,boolean showMenu,boolean showNavigation,boolean activateFirstPage,boolean showPrint,DeliveryOptions deliveryOptions,String initialUri,OLATResourceable ores,String identPrefix){
  super(ureq,wControl);
  this.rootContainer=rootContainer;
  myContent=createVelocityContainer("String_Node_Str");
  if (!ureq.getUserSession().getRoles().isGuestOnly()) {
    SearchServiceUIFactory searchServiceUIFactory=(SearchServiceUIFactory)CoreSpringFactory.getBean(SearchServiceUIFactory.class);
    searchCtrl=searchServiceUIFactory.createInputController(ureq,wControl,DisplayOption.BUTTON,null);
    myContent.put("String_Node_Str",searchCtrl.getInitialComponent());
    listenTo(searchCtrl);
  }
  cpContentCtr=new IFrameDisplayController(ureq,getWindowControl(),rootContainer,null,ores,deliveryOptions,false);
  cpContentCtr.setAllowDownload(true);
  listenTo(cpContentCtr);
  myContent.put("String_Node_Str",cpContentCtr.getInitialComponent());
  myContent.contextPut("String_Node_Str",Boolean.TRUE);
  VFSItem mani=rootContainer.resolve("String_Node_Str");
  if (mani == null || !(mani instanceof VFSLeaf)) {
    showError("String_Node_Str");
    return;
  }
  try {
    ctm=new CPManifestTreeModel((VFSLeaf)mani,identPrefix);
  }
 catch (  IOException e) {
    showError("String_Node_Str");
    return;
  }
  if (showMenu) {
    cpTree=new MenuTree("String_Node_Str");
    cpTree.setTreeModel(ctm);
    cpTree.addListener(this);
  }
  if (showPrint) {
    printLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    printLink.setCustomDisplayText("String_Node_Str");
    printLink.setIconLeftCSS("String_Node_Str");
    printLink.setCustomEnabledLinkCSS("String_Node_Str");
    printLink.setTitle(translate("String_Node_Str"));
    String themeBaseUri=wControl.getWindowBackOffice().getWindow().getGuiTheme().getBaseURI();
    printMapper=new CPPrintMapper(ctm,rootContainer,themeBaseUri);
    mapperBaseURL=registerMapper(ureq,printMapper);
    printMapper.setBaseUri(mapperBaseURL);
  }
  if (showNavigation && ctm.getRootNode().getChildCount() > 0) {
    nextLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    nextLink.setCustomDisplayText("String_Node_Str");
    nextLink.setIconLeftCSS("String_Node_Str");
    nextLink.setCustomEnabledLinkCSS("String_Node_Str");
    nextLink.setTitle(translate("String_Node_Str"));
    previousLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    previousLink.setCustomDisplayText("String_Node_Str");
    previousLink.setIconLeftCSS("String_Node_Str");
    previousLink.setCustomEnabledLinkCSS("String_Node_Str");
    previousLink.setTitle(translate("String_Node_Str"));
    myContent.put("String_Node_Str",nextLink);
    myContent.put("String_Node_Str",previousLink);
  }
  LoggingResourceable nodeInfo=null;
  if (activateFirstPage) {
    TreeNode node=ctm.getRootNode();
    if (node == null)     throw new OLATRuntimeException(CPDisplayController.class,"String_Node_Str" + rootContainer,null);
    while (node != null && !node.isAccessible()) {
      if (node.getChildCount() > 0) {
        node=(TreeNode)node.getChildAt(0);
      }
 else       node=null;
    }
    if (node != null) {
      String nodeUri=(String)node.getUserObject();
      if (cpContentCtr != null)       cpContentCtr.setCurrentURI(nodeUri);
      if (cpComponent != null)       cpComponent.setCurrentURI(nodeUri);
      if (showMenu)       cpTree.setSelectedNodeId(node.getIdent());
      selNodeId=node.getIdent();
      nodeInfo=LoggingResourceable.wrapCpNode(nodeUri);
      updateNextPreviousLink(node);
      if (node.getUserObject() != null) {
        String identifierRes=(String)node.getUserObject();
        OLATResourceable pOres=OresHelper.createOLATResourceableInstanceWithoutCheck("String_Node_Str" + identifierRes,0l);
        addToHistory(ureq,pOres,null);
      }
    }
  }
 else   if (initialUri != null) {
    if (cpContentCtr != null)     cpContentCtr.setCurrentURI(initialUri);
    if (cpComponent != null)     cpComponent.setCurrentURI(initialUri);
    TreeNode newNode=ctm.lookupTreeNodeByHref(initialUri);
    if (newNode != null) {
      if (cpTree != null) {
        cpTree.setSelectedNodeId(newNode.getIdent());
      }
 else {
        selNodeId=newNode.getIdent();
      }
      updateNextPreviousLink(newNode);
      if (newNode.getUserObject() != null) {
        String identifierRes=(String)newNode.getUserObject();
        Long id=Long.parseLong(newNode.getIdent());
        OLATResourceable pOres=OresHelper.createOLATResourceableInstanceWithoutCheck("String_Node_Str" + identifierRes,id);
        addToHistory(ureq,pOres,null);
      }
    }
    nodeInfo=LoggingResourceable.wrapCpNode(initialUri);
  }
  if (ores != null && nodeInfo != null && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
    addLoggingResourceable(LoggingResourceable.wrap(ores,OlatResourceableType.cp));
    ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN,getClass(),nodeInfo);
  }
  putInitialPanel(myContent);
}

Fixed version (ground truth):
/** 
 * @param ureq
 * @param cpRoot
 * @param showMenu
 * @param showNavigation Show the next/previous link
 * @param activateFirstPage
 * @param identPrefix In a course, set a unique prefix per node, if someone set 2x the same CPs in the course, the node identifiersof the CP elements must be different but predictable
 */
public CPDisplayController(UserRequest ureq,WindowControl wControl,VFSContainer rootContainer,boolean showMenu,boolean showNavigation,boolean activateFirstPage,boolean showPrint,DeliveryOptions deliveryOptions,String initialUri,OLATResourceable ores,String identPrefix){
  super(ureq,wControl);
  this.rootContainer=rootContainer;
  myContent=createVelocityContainer("String_Node_Str");
  if (!ureq.getUserSession().getRoles().isGuestOnly()) {
    SearchServiceUIFactory searchServiceUIFactory=(SearchServiceUIFactory)CoreSpringFactory.getBean(SearchServiceUIFactory.class);
    searchCtrl=searchServiceUIFactory.createInputController(ureq,wControl,DisplayOption.BUTTON,null);
    myContent.put("String_Node_Str",searchCtrl.getInitialComponent());
    listenTo(searchCtrl);
  }
  cpContentCtr=new IFrameDisplayController(ureq,getWindowControl(),rootContainer,null,ores,deliveryOptions,true);
  cpContentCtr.setAllowDownload(true);
  listenTo(cpContentCtr);
  myContent.put("String_Node_Str",cpContentCtr.getInitialComponent());
  myContent.contextPut("String_Node_Str",Boolean.TRUE);
  VFSItem mani=rootContainer.resolve("String_Node_Str");
  if (mani == null || !(mani instanceof VFSLeaf)) {
    showError("String_Node_Str");
    return;
  }
  try {
    ctm=new CPManifestTreeModel((VFSLeaf)mani,identPrefix);
  }
 catch (  IOException e) {
    showError("String_Node_Str");
    return;
  }
  if (showMenu) {
    cpTree=new MenuTree("String_Node_Str");
    cpTree.setTreeModel(ctm);
    cpTree.addListener(this);
  }
  if (showPrint) {
    printLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    printLink.setCustomDisplayText("String_Node_Str");
    printLink.setIconLeftCSS("String_Node_Str");
    printLink.setCustomEnabledLinkCSS("String_Node_Str");
    printLink.setTitle(translate("String_Node_Str"));
    String themeBaseUri=wControl.getWindowBackOffice().getWindow().getGuiTheme().getBaseURI();
    printMapper=new CPPrintMapper(ctm,rootContainer,themeBaseUri);
    mapperBaseURL=registerMapper(ureq,printMapper);
    printMapper.setBaseUri(mapperBaseURL);
  }
  if (showNavigation && ctm.getRootNode().getChildCount() > 0) {
    nextLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    nextLink.setCustomDisplayText("String_Node_Str");
    nextLink.setIconLeftCSS("String_Node_Str");
    nextLink.setCustomEnabledLinkCSS("String_Node_Str");
    nextLink.setTitle(translate("String_Node_Str"));
    previousLink=LinkFactory.createCustomLink("String_Node_Str","String_Node_Str",null,Link.LINK + Link.NONTRANSLATED,myContent,this);
    previousLink.setCustomDisplayText("String_Node_Str");
    previousLink.setIconLeftCSS("String_Node_Str");
    previousLink.setCustomEnabledLinkCSS("String_Node_Str");
    previousLink.setTitle(translate("String_Node_Str"));
    myContent.put("String_Node_Str",nextLink);
    myContent.put("String_Node_Str",previousLink);
  }
  LoggingResourceable nodeInfo=null;
  if (activateFirstPage) {
    TreeNode node=ctm.getRootNode();
    if (node == null)     throw new OLATRuntimeException(CPDisplayController.class,"String_Node_Str" + rootContainer,null);
    while (node != null && !node.isAccessible()) {
      if (node.getChildCount() > 0) {
        node=(TreeNode)node.getChildAt(0);
      }
 else       node=null;
    }
    if (node != null) {
      String nodeUri=(String)node.getUserObject();
      if (cpContentCtr != null)       cpContentCtr.setCurrentURI(nodeUri);
      if (cpComponent != null)       cpComponent.setCurrentURI(nodeUri);
      if (showMenu)       cpTree.setSelectedNodeId(node.getIdent());
      selNodeId=node.getIdent();
      nodeInfo=LoggingResourceable.wrapCpNode(nodeUri);
      updateNextPreviousLink(node);
      if (node.getUserObject() != null) {
        String identifierRes=(String)node.getUserObject();
        OLATResourceable pOres=OresHelper.createOLATResourceableInstanceWithoutCheck("String_Node_Str" + identifierRes,0l);
        addToHistory(ureq,pOres,null);
      }
    }
  }
 else   if (initialUri != null) {
    if (cpContentCtr != null)     cpContentCtr.setCurrentURI(initialUri);
    if (cpComponent != null)     cpComponent.setCurrentURI(initialUri);
    TreeNode newNode=ctm.lookupTreeNodeByHref(initialUri);
    if (newNode != null) {
      if (cpTree != null) {
        cpTree.setSelectedNodeId(newNode.getIdent());
      }
 else {
        selNodeId=newNode.getIdent();
      }
      updateNextPreviousLink(newNode);
      if (newNode.getUserObject() != null) {
        String identifierRes=(String)newNode.getUserObject();
        Long id=Long.parseLong(newNode.getIdent());
        OLATResourceable pOres=OresHelper.createOLATResourceableInstanceWithoutCheck("String_Node_Str" + identifierRes,id);
        addToHistory(ureq,pOres,null);
      }
    }
    nodeInfo=LoggingResourceable.wrapCpNode(initialUri);
  }
  if (ores != null && nodeInfo != null && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
    addLoggingResourceable(LoggingResourceable.wrap(ores,OlatResourceableType.cp));
    ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN,getClass(),nodeInfo);
  }
  putInitialPanel(myContent);
}