Program: 69591
Project: 69591
Buggy source:
@Override protected void initForm(FormItemContainer formLayout,Controller listener,UserRequest ureq){
  int cmpcount=0;
  if (formLayout instanceof FormLayoutContainer) {
    FormLayoutContainer layoutCont=(FormLayoutContainer)formLayout;
    layoutCont.contextPut("String_Node_Str",entry);
    layoutCont.contextPut("String_Node_Str",new Boolean(guestOnly));
    String cssClass=RepositoyUIFactory.getIconCssClass(entry);
    layoutCont.contextPut("String_Node_Str",cssClass);
    RepositoryHandler handler=RepositoryHandlerFactory.getInstance().getRepositoryHandler(entry);
    VFSContainer mediaContainer=handler.getMediaContainer(entry);
    if (mediaContainer != null) {
      baseUrl=registerMapper(ureq,new VFSContainerMapper(mediaContainer.getParentContainer()));
    }
    setText(entry.getDescription(),"String_Node_Str",layoutCont);
    setText(entry.getRequirements(),"String_Node_Str",layoutCont);
    setText(entry.getObjectives(),"String_Node_Str",layoutCont);
    setText(entry.getCredits(),"String_Node_Str",layoutCont);
    VFSLeaf movie=repositoryService.getIntroductionMovie(entry);
    VFSLeaf image=repositoryService.getIntroductionImage(entry);
    if (image != null || movie != null) {
      ImageComponent ic=new ImageComponent(ureq.getUserSession(),"String_Node_Str");
      if (movie != null) {
        ic.setMedia(movie);
        ic.setMaxWithAndHeightToFitWithin(500,300);
        if (image != null) {
          ic.setPoster(image);
        }
      }
 else {
        ic.setMedia(image);
        ic.setMaxWithAndHeightToFitWithin(500,300);
      }
      layoutCont.put("String_Node_Str",ic);
    }
    if (repositoryModule.isCatalogEnabled()) {
      List<CatalogEntry> categories=catalogManager.getCatalogEntriesReferencing(entry);
      List<String> categoriesLink=new ArrayList<>(categories.size());
      for (      CatalogEntry category : categories) {
        String id="String_Node_Str" + ++cmpcount;
        String title=category.getParent().getName();
        FormLink catLink=uifactory.addFormLink(id,"String_Node_Str",title,null,layoutCont,Link.LINK | Link.NONTRANSLATED);
        catLink.setUserObject(category.getKey());
        categoriesLink.add(id);
      }
      layoutCont.contextPut("String_Node_Str",categoriesLink);
    }
    if (!guestOnly) {
      boolean marked;
      if (row == null) {
        marked=markManager.isMarked(entry,getIdentity(),null);
      }
 else {
        marked=row.isMarked();
      }
      markLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",marked ? "String_Node_Str" : "String_Node_Str",null,layoutCont,Link.LINK);
      markLink.setElementCssClass("String_Node_Str");
      markLink.setIconLeftCSS(marked ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
    }
    Integer myRating;
    if (row == null) {
      myRating=userRatingsDao.getRatingValue(getIdentity(),entry,null);
    }
 else {
      myRating=row.getMyRating();
    }
    RepositoryEntryStatistics statistics=entry.getStatistics();
    Double averageRating=statistics.getRating();
    long numOfRatings=statistics.getNumOfRatings();
    float ratingValue=myRating == null ? 0f : myRating.floatValue();
    float averageRatingValue=averageRating == null ? 0f : averageRating.floatValue();
    ratingEl=new RatingWithAverageFormItem("String_Node_Str",ratingValue,averageRatingValue,5,numOfRatings);
    ratingEl.setEnabled(!guestOnly);
    layoutCont.add("String_Node_Str",ratingEl);
    long numOfComments=statistics.getNumOfComments();
    String title="String_Node_Str" + numOfComments + "String_Node_Str";
    commentsLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",title,null,layoutCont,Link.NONTRANSLATED);
    commentsLink.setCustomEnabledLinkCSS("String_Node_Str");
    String css=numOfComments > 0 ? "String_Node_Str" : "String_Node_Str";
    commentsLink.setIconLeftCSS(css);
    List<String> roles=repositoryService.getRoles(getIdentity(),entry);
    boolean isMember=roles.contains(GroupRoles.owner.name()) || roles.contains(GroupRoles.coach.name()) || roles.contains(GroupRoles.participant.name());
    if (isMember) {
      Boolean isAuthor=Boolean.valueOf(roles.contains(GroupRoles.owner));
      layoutCont.contextPut("String_Node_Str",isAuthor);
    }
    layoutCont.contextPut("String_Node_Str",ureq.getUserSession().getRoles());
    String accessI18n=null;
    List<PriceMethod> types=new ArrayList<PriceMethod>();
    if (entry.isMembersOnly()) {
      types.add(new PriceMethod("String_Node_Str","String_Node_Str",translate("String_Node_Str")));
      if (isMember) {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setElementCssClass("String_Node_Str");
        startLink.setIconRightCSS("String_Node_Str");
        startLink.setPrimary(true);
      }
      accessI18n=translate("String_Node_Str");
    }
 else {
      AccessResult acResult=acService.isAccessible(entry,getIdentity(),false);
      if (acResult.isAccessible()) {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setElementCssClass("String_Node_Str");
      }
 else       if (acResult.getAvailableMethods().size() > 0) {
        for (        OfferAccess access : acResult.getAvailableMethods()) {
          AccessMethod method=access.getMethod();
          String type=(method.getMethodCssClass() + "String_Node_Str").intern();
          Price p=access.getOffer().getPrice();
          String price=p == null || p.isEmpty() ? "String_Node_Str" : PriceFormat.fullFormat(p);
          AccessMethodHandler amh=acModule.getAccessMethodHandler(method.getType());
          String displayName=amh.getMethodName(getLocale());
          types.add(new PriceMethod(price,type,displayName));
        }
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setCustomEnabledLinkCSS("String_Node_Str");
        startLink.setElementCssClass("String_Node_Str");
      }
 else {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setEnabled(false);
        startLink.setElementCssClass("String_Node_Str");
      }
      startLink.setIconRightCSS("String_Node_Str");
      startLink.setPrimary(true);
switch (entry.getAccess()) {
case 0:
        accessI18n="String_Node_Str";
      break;
case 1:
    accessI18n=translate("String_Node_Str");
  break;
case 2:
accessI18n=translate("String_Node_Str");
break;
case 3:
accessI18n=translate("String_Node_Str");
break;
case 4:
accessI18n=translate("String_Node_Str");
break;
}
}
layoutCont.contextPut("String_Node_Str",accessI18n);
if (!types.isEmpty()) {
layoutCont.contextPut("String_Node_Str",types);
}
if (isMember) {
SearchBusinessGroupParams params=new SearchBusinessGroupParams(getIdentity(),true,true);
List<BusinessGroup> groups=businessGroupService.findBusinessGroups(params,entry,0,-1);
List<String> groupLinkNames=new ArrayList<>(groups.size());
for (BusinessGroup group : groups) {
String groupLinkName="String_Node_Str" + ++cmpcount;
FormLink link=uifactory.addFormLink(groupLinkName,"String_Node_Str",group.getName(),null,layoutCont,Link.LINK | Link.NONTRANSLATED);
link.setUserObject(group.getKey());
groupLinkNames.add(groupLinkName);
}
layoutCont.contextPut("String_Node_Str",groupLinkNames);
}
boolean passed=false;
boolean failed=false;
String score=null;
if (row != null) {
passed=row.isPassed();
failed=row.isFailed();
score=row.getScore();
}
 else {
UserEfficiencyStatement statement=effManager.getUserEfficiencyStatementLight(entry.getKey(),getIdentity());
if (statement != null) {
Boolean p=statement.getPassed();
if (p != null) {
passed=p.booleanValue();
failed=!p.booleanValue();
}
Float scoreVal=statement.getScore();
if (scoreVal != null) {
score=AssessmentHelper.getRoundedScore(scoreVal);
}
}
}
layoutCont.contextPut("String_Node_Str",passed);
layoutCont.contextPut("String_Node_Str",failed);
layoutCont.contextPut("String_Node_Str",score);
Date recentLaunch=null;
if (row != null) {
recentLaunch=row.getRecentLaunch();
}
 else {
Long courseResId=entry.getOlatResource().getResourceableId();
UserCourseInformations infos=userCourseInfosManager.getUserCourseInformations(courseResId,getIdentity());
if (infos != null) {
recentLaunch=infos.getRecentLaunch();
}
}
layoutCont.contextPut("String_Node_Str",recentLaunch);
String numUsers;
OLATResourceable ores=entry.getOlatResource();
int cnt=0;
OLATResourceable courseRunOres=OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN,entry.getOlatResource().getResourceableId());
if (ores != null) cnt=coordinatorManager.getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres);
numUsers=String.valueOf(cnt);
layoutCont.contextPut("String_Node_Str",numUsers);
String referenceDetails=referenceManager.getReferencesToSummary(entry.getOlatResource(),getLocale());
if (referenceDetails != null) {
layoutCont.contextPut("String_Node_Str",referenceDetails);
}
String url=Settings.getServerContextPathURI() + "String_Node_Str" + entry.getKey();
layoutCont.contextPut("String_Node_Str",url);
layoutCont.contextPut("String_Node_Str",(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS ? Boolean.TRUE : Boolean.FALSE));
List<Identity> authors=repositoryService.getMembers(entry,GroupRoles.owner.name());
List<String> authorLinkNames=new ArrayList<String>(authors.size());
int counter=0;
for (Identity author : authors) {
String authorName=userManager.getUserDisplayName(author);
FormLink authorLink=uifactory.addFormLink("String_Node_Str" + counter,"String_Node_Str",authorName,null,formLayout,Link.NONTRANSLATED | Link.LINK);
authorLink.setUserObject(author.getKey());
authorLinkNames.add(authorLink.getComponent().getComponentName());
}
layoutCont.contextPut("String_Node_Str",authorLinkNames);
}
}

Fixed version (ground truth):
@Override protected void initForm(FormItemContainer formLayout,Controller listener,UserRequest ureq){
  int cmpcount=0;
  if (formLayout instanceof FormLayoutContainer) {
    FormLayoutContainer layoutCont=(FormLayoutContainer)formLayout;
    layoutCont.contextPut("String_Node_Str",entry);
    layoutCont.contextPut("String_Node_Str",new Boolean(guestOnly));
    String cssClass=RepositoyUIFactory.getIconCssClass(entry);
    layoutCont.contextPut("String_Node_Str",cssClass);
    RepositoryHandler handler=RepositoryHandlerFactory.getInstance().getRepositoryHandler(entry);
    VFSContainer mediaContainer=handler.getMediaContainer(entry);
    if (mediaContainer != null) {
      baseUrl=registerMapper(ureq,new VFSContainerMapper(mediaContainer.getParentContainer()));
    }
    setText(entry.getDescription(),"String_Node_Str",layoutCont);
    setText(entry.getRequirements(),"String_Node_Str",layoutCont);
    setText(entry.getObjectives(),"String_Node_Str",layoutCont);
    setText(entry.getCredits(),"String_Node_Str",layoutCont);
    VFSLeaf movie=repositoryService.getIntroductionMovie(entry);
    VFSLeaf image=repositoryService.getIntroductionImage(entry);
    if (image != null || movie != null) {
      ImageComponent ic=new ImageComponent(ureq.getUserSession(),"String_Node_Str");
      if (movie != null) {
        ic.setMedia(movie);
        ic.setMaxWithAndHeightToFitWithin(500,300);
        if (image != null) {
          ic.setPoster(image);
        }
      }
 else {
        ic.setMedia(image);
        ic.setMaxWithAndHeightToFitWithin(500,300);
      }
      layoutCont.put("String_Node_Str",ic);
    }
    if (repositoryModule.isCatalogEnabled()) {
      List<CatalogEntry> categories=catalogManager.getCatalogEntriesReferencing(entry);
      List<String> categoriesLink=new ArrayList<>(categories.size());
      for (      CatalogEntry category : categories) {
        String id="String_Node_Str" + ++cmpcount;
        String title=category.getParent().getName();
        FormLink catLink=uifactory.addFormLink(id,"String_Node_Str",title,null,layoutCont,Link.LINK | Link.NONTRANSLATED);
        catLink.setUserObject(category.getKey());
        categoriesLink.add(id);
      }
      layoutCont.contextPut("String_Node_Str",categoriesLink);
    }
    if (!guestOnly) {
      boolean marked;
      if (row == null) {
        marked=markManager.isMarked(entry,getIdentity(),null);
      }
 else {
        marked=row.isMarked();
      }
      markLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",marked ? "String_Node_Str" : "String_Node_Str",null,layoutCont,Link.LINK);
      markLink.setElementCssClass("String_Node_Str");
      markLink.setIconLeftCSS(marked ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
    }
    Integer myRating;
    if (row == null) {
      myRating=userRatingsDao.getRatingValue(getIdentity(),entry,null);
    }
 else {
      myRating=row.getMyRating();
    }
    RepositoryEntryStatistics statistics=entry.getStatistics();
    Double averageRating=statistics.getRating();
    long numOfRatings=statistics.getNumOfRatings();
    float ratingValue=myRating == null ? 0f : myRating.floatValue();
    float averageRatingValue=averageRating == null ? 0f : averageRating.floatValue();
    ratingEl=new RatingWithAverageFormItem("String_Node_Str",ratingValue,averageRatingValue,5,numOfRatings);
    ratingEl.setEnabled(!guestOnly);
    layoutCont.add("String_Node_Str",ratingEl);
    long numOfComments=statistics.getNumOfComments();
    String title="String_Node_Str" + numOfComments + "String_Node_Str";
    commentsLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",title,null,layoutCont,Link.NONTRANSLATED);
    commentsLink.setCustomEnabledLinkCSS("String_Node_Str");
    String css=numOfComments > 0 ? "String_Node_Str" : "String_Node_Str";
    commentsLink.setIconLeftCSS(css);
    List<String> roles=repositoryService.getRoles(getIdentity(),entry);
    boolean isMember=roles.contains(GroupRoles.owner.name()) || roles.contains(GroupRoles.coach.name()) || roles.contains(GroupRoles.participant.name());
    if (isMember) {
      Boolean isAuthor=Boolean.valueOf(roles.contains(GroupRoles.owner.name()));
      layoutCont.contextPut("String_Node_Str",isAuthor);
    }
    layoutCont.contextPut("String_Node_Str",ureq.getUserSession().getRoles());
    String accessI18n=null;
    List<PriceMethod> types=new ArrayList<PriceMethod>();
    if (entry.isMembersOnly()) {
      types.add(new PriceMethod("String_Node_Str","String_Node_Str",translate("String_Node_Str")));
      if (isMember) {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setElementCssClass("String_Node_Str");
        startLink.setIconRightCSS("String_Node_Str");
        startLink.setPrimary(true);
      }
      accessI18n=translate("String_Node_Str");
    }
 else {
      AccessResult acResult=acService.isAccessible(entry,getIdentity(),false);
      if (acResult.isAccessible()) {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setElementCssClass("String_Node_Str");
      }
 else       if (acResult.getAvailableMethods().size() > 0) {
        for (        OfferAccess access : acResult.getAvailableMethods()) {
          AccessMethod method=access.getMethod();
          String type=(method.getMethodCssClass() + "String_Node_Str").intern();
          Price p=access.getOffer().getPrice();
          String price=p == null || p.isEmpty() ? "String_Node_Str" : PriceFormat.fullFormat(p);
          AccessMethodHandler amh=acModule.getAccessMethodHandler(method.getType());
          String displayName=amh.getMethodName(getLocale());
          types.add(new PriceMethod(price,type,displayName));
        }
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setCustomEnabledLinkCSS("String_Node_Str");
        startLink.setElementCssClass("String_Node_Str");
      }
 else {
        String linkText=translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName()));
        startLink=uifactory.addFormLink("String_Node_Str","String_Node_Str",linkText,null,layoutCont,Link.BUTTON + Link.NONTRANSLATED);
        startLink.setEnabled(false);
        startLink.setElementCssClass("String_Node_Str");
      }
      startLink.setIconRightCSS("String_Node_Str");
      startLink.setPrimary(true);
switch (entry.getAccess()) {
case 0:
        accessI18n="String_Node_Str";
      break;
case 1:
    accessI18n=translate("String_Node_Str");
  break;
case 2:
accessI18n=translate("String_Node_Str");
break;
case 3:
accessI18n=translate("String_Node_Str");
break;
case 4:
accessI18n=translate("String_Node_Str");
break;
}
}
layoutCont.contextPut("String_Node_Str",accessI18n);
if (!types.isEmpty()) {
layoutCont.contextPut("String_Node_Str",types);
}
if (isMember) {
SearchBusinessGroupParams params=new SearchBusinessGroupParams(getIdentity(),true,true);
List<BusinessGroup> groups=businessGroupService.findBusinessGroups(params,entry,0,-1);
List<String> groupLinkNames=new ArrayList<>(groups.size());
for (BusinessGroup group : groups) {
String groupLinkName="String_Node_Str" + ++cmpcount;
FormLink link=uifactory.addFormLink(groupLinkName,"String_Node_Str",group.getName(),null,layoutCont,Link.LINK | Link.NONTRANSLATED);
link.setUserObject(group.getKey());
groupLinkNames.add(groupLinkName);
}
layoutCont.contextPut("String_Node_Str",groupLinkNames);
}
boolean passed=false;
boolean failed=false;
String score=null;
if (row != null) {
passed=row.isPassed();
failed=row.isFailed();
score=row.getScore();
}
 else {
UserEfficiencyStatement statement=effManager.getUserEfficiencyStatementLight(entry.getKey(),getIdentity());
if (statement != null) {
Boolean p=statement.getPassed();
if (p != null) {
passed=p.booleanValue();
failed=!p.booleanValue();
}
Float scoreVal=statement.getScore();
if (scoreVal != null) {
score=AssessmentHelper.getRoundedScore(scoreVal);
}
}
}
layoutCont.contextPut("String_Node_Str",passed);
layoutCont.contextPut("String_Node_Str",failed);
layoutCont.contextPut("String_Node_Str",score);
Date recentLaunch=null;
if (row != null) {
recentLaunch=row.getRecentLaunch();
}
 else {
Long courseResId=entry.getOlatResource().getResourceableId();
UserCourseInformations infos=userCourseInfosManager.getUserCourseInformations(courseResId,getIdentity());
if (infos != null) {
recentLaunch=infos.getRecentLaunch();
}
}
layoutCont.contextPut("String_Node_Str",recentLaunch);
String numUsers;
OLATResourceable ores=entry.getOlatResource();
int cnt=0;
OLATResourceable courseRunOres=OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN,entry.getOlatResource().getResourceableId());
if (ores != null) cnt=coordinatorManager.getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres);
numUsers=String.valueOf(cnt);
layoutCont.contextPut("String_Node_Str",numUsers);
String referenceDetails=referenceManager.getReferencesToSummary(entry.getOlatResource(),getLocale());
if (referenceDetails != null) {
layoutCont.contextPut("String_Node_Str",referenceDetails);
}
String url=Settings.getServerContextPathURI() + "String_Node_Str" + entry.getKey();
layoutCont.contextPut("String_Node_Str",url);
layoutCont.contextPut("String_Node_Str",(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS ? Boolean.TRUE : Boolean.FALSE));
List<Identity> authors=repositoryService.getMembers(entry,GroupRoles.owner.name());
List<String> authorLinkNames=new ArrayList<String>(authors.size());
int counter=0;
for (Identity author : authors) {
String authorName=userManager.getUserDisplayName(author);
FormLink authorLink=uifactory.addFormLink("String_Node_Str" + counter,"String_Node_Str",authorName,null,formLayout,Link.NONTRANSLATED | Link.LINK);
authorLink.setUserObject(author.getKey());
authorLinkNames.add(authorLink.getComponent().getComponentName());
}
layoutCont.contextPut("String_Node_Str",authorLinkNames);
}
}