Program: 69543
Project: 69543
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.setIconLeftCSS("String_Node_Str");
        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);
    }
    RepositoryEntryStatistics statistics=entry.getStatistics();
    if (repositoryModule.isRatingEnabled()) {
      Integer myRating;
      if (row == null) {
        myRating=userRatingsDao.getRatingValue(getIdentity(),entry,null);
      }
 else {
        myRating=row.getMyRating();
      }
      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);
    }
    if (repositoryModule.isCommentEnabled()) {
      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);
    }
    boolean isMember=repositoryService.isMember(getIdentity(),entry);
    List<Long> authorKeys=repositoryService.getAuthors(entry);
    boolean isAuthor=false;
    if (isMember) {
      isAuthor=authorKeys.contains(getIdentity().getKey());
      layoutCont.contextPut("String_Node_Str",new Boolean(isAuthor));
    }
    Roles roles=ureq.getUserSession().getRoles();
    layoutCont.contextPut("String_Node_Str",roles);
    String accessI18n=null;
    List<PriceMethod> types=new ArrayList<PriceMethod>();
    if (entry.isMembersOnly()) {
      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(),isMember,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=guestOnly ? translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName())) : 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");
        if (guestOnly) {
          if (entry.getAccess() == RepositoryEntry.ACC_USERS_GUESTS) {
            startLink.setVisible(true);
          }
 else {
            startLink.setVisible(false);
          }
        }
 else {
          startLink.setVisible(true);
        }
      }
 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.setVisible(!guestOnly);
      }
      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.setIconLeftCSS("String_Node_Str");
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);
Long courseResId=entry.getOlatResource().getResourceableId();
Date recentLaunch=userCourseInfosManager.getRecentLaunchDate(courseResId,getIdentity());
layoutCont.contextPut("String_Node_Str",recentLaunch);
String numUsers;
OLATResourceable ores=entry.getOlatResource();
int cnt=0;
OLATResourceable courseRunOres=OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN,courseResId);
if (ores != null) cnt=coordinatorManager.getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres);
numUsers=String.valueOf(cnt);
layoutCont.contextPut("String_Node_Str",numUsers);
if (isAuthor || roles.isOLATAdmin() || roles.isInstitutionalResourceManager()) {
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);
Boolean guestAllowed=(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS && loginModule.isGuestLoginLinksEnabled()) ? Boolean.TRUE : Boolean.FALSE;
layoutCont.contextPut("String_Node_Str",guestAllowed);
List<String> authorLinkNames=new ArrayList<String>(authorKeys.size());
Map<Long,String> authorNames=userManager.getUserDisplayNamesByKey(authorKeys);
int counter=0;
for (Map.Entry<Long,String> author : authorNames.entrySet()) {
Long authorKey=author.getKey();
String authorName=author.getValue();
FormLink authorLink=uifactory.addFormLink("String_Node_Str" + ++counter,"String_Node_Str",authorName,null,formLayout,Link.NONTRANSLATED | Link.LINK);
authorLink.setUserObject(authorKey);
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.setIconLeftCSS("String_Node_Str");
        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);
    }
    RepositoryEntryStatistics statistics=entry.getStatistics();
    if (repositoryModule.isRatingEnabled()) {
      Integer myRating;
      if (row == null) {
        myRating=userRatingsDao.getRatingValue(getIdentity(),entry,null);
      }
 else {
        myRating=row.getMyRating();
      }
      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);
    }
    if (repositoryModule.isCommentEnabled()) {
      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);
    }
    boolean isMember=repositoryService.isMember(getIdentity(),entry);
    List<Long> authorKeys=repositoryService.getAuthors(entry);
    boolean isAuthor=false;
    if (isMember) {
      isAuthor=authorKeys.contains(getIdentity().getKey());
      layoutCont.contextPut("String_Node_Str",new Boolean(isAuthor));
    }
    Roles roles=ureq.getUserSession().getRoles();
    layoutCont.contextPut("String_Node_Str",roles);
    String accessI18n=null;
    List<PriceMethod> types=new ArrayList<PriceMethod>();
    if (entry.isMembersOnly()) {
      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(),isMember,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=guestOnly ? translate("String_Node_Str",translate(entry.getOlatResource().getResourceableTypeName())) : 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");
        if (guestOnly) {
          if (entry.getAccess() == RepositoryEntry.ACC_USERS_GUESTS) {
            startLink.setVisible(true);
          }
 else {
            startLink.setVisible(false);
          }
        }
 else {
          startLink.setVisible(true);
        }
      }
 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.setElementCssClass("String_Node_Str");
        startLink.setVisible(!guestOnly);
      }
      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.setIconLeftCSS("String_Node_Str");
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);
Long courseResId=entry.getOlatResource().getResourceableId();
Date recentLaunch=userCourseInfosManager.getRecentLaunchDate(courseResId,getIdentity());
layoutCont.contextPut("String_Node_Str",recentLaunch);
String numUsers;
OLATResourceable ores=entry.getOlatResource();
int cnt=0;
OLATResourceable courseRunOres=OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN,courseResId);
if (ores != null) cnt=coordinatorManager.getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres);
numUsers=String.valueOf(cnt);
layoutCont.contextPut("String_Node_Str",numUsers);
if (isAuthor || roles.isOLATAdmin() || roles.isInstitutionalResourceManager()) {
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);
Boolean guestAllowed=(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS && loginModule.isGuestLoginLinksEnabled()) ? Boolean.TRUE : Boolean.FALSE;
layoutCont.contextPut("String_Node_Str",guestAllowed);
List<String> authorLinkNames=new ArrayList<String>(authorKeys.size());
Map<Long,String> authorNames=userManager.getUserDisplayNamesByKey(authorKeys);
int counter=0;
for (Map.Entry<Long,String> author : authorNames.entrySet()) {
Long authorKey=author.getKey();
String authorName=author.getValue();
FormLink authorLink=uifactory.addFormLink("String_Node_Str" + ++counter,"String_Node_Str",authorName,null,formLayout,Link.NONTRANSLATED | Link.LINK);
authorLink.setUserObject(authorKey);
authorLinkNames.add(authorLink.getComponent().getComponentName());
}
layoutCont.contextPut("String_Node_Str",authorLinkNames);
}
}