Program: 135777
Project: 135777
Buggy source:
protected void populateViewContext(String path,PortletRequest portletRequest,PortletResponse portletResponse,Template template,TemplateHashModel staticModels) throws Exception {
  ThemeDisplay themeDisplay=(ThemeDisplay)portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
  PortletPreferences portletPreferences=portletRequest.getPreferences();
  long assetEntryIdDefault=GetterUtil.getLong(portletPreferences.getValue("String_Node_Str",null));
  boolean contentDefaultValue=GetterUtil.getBoolean(portletPreferences.getValue("String_Node_Str",null));
  populatePortletDisplayTemplateContext(template,portletPreferences,themeDisplay.getScopeGroupId(),"String_Node_Str");
  if (Validator.isNull(path) || path.equals(UserSegmentContentDisplayPath.VIEW)) {
    template.put("String_Node_Str",showPreview(themeDisplay));
    template.put("String_Node_Str",contentDefaultValue);
    List<QueryRule> userSegmentQueryRules=UserSegmentQueryRuleUtil.getUserSegmentQueryRules(portletPreferences,themeDisplay.getLocale());
    template.put("String_Node_Str",userSegmentQueryRules);
    QueryRule queryRule=null;
    long[] userSegmentIds=(long[])portletRequest.getAttribute(WebKeys.USER_SEGMENT_IDS);
    if (userSegmentIds != null) {
      long[] userSegmentAssetCategoryIds=ContentTargetingUtil.getAssetCategoryIds(userSegmentIds);
      queryRule=UserSegmentQueryRuleUtil.match(userSegmentAssetCategoryIds,userSegmentQueryRules);
      template.put("String_Node_Str",queryRule);
    }
    template.put("String_Node_Str",userSegmentQueryRules.indexOf(queryRule));
    List<AssetEntry> results=new ArrayList<AssetEntry>();
    if ((queryRule != null) && (queryRule.getAssetEntry() != null)) {
      results.add(queryRule.getAssetEntry());
      queryRule.setAssetAttributes(portletRequest);
    }
 else {
      portletRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY,Boolean.TRUE);
    }
    template.put("String_Node_Str",LiferayWindowState.POP_UP);
    populatePortletDisplayTemplateViewContext(template,portletRequest,themeDisplay,results,userSegmentQueryRules);
  }
 else   if (path.equals(UserSegmentContentDisplayPath.EDIT_QUERY_RULE) || path.equals(UserSegmentContentDisplayPath.CONFIGURATION)) {
    template.put("String_Node_Str",getSelectableAssetRendererFactories(themeDisplay.getCompanyId()));
    String assetImageDefault=StringPool.BLANK;
    String assetTitleDefault=StringPool.BLANK;
    String assetTypeDefault=StringPool.BLANK;
    if (assetEntryIdDefault > 0) {
      AssetEntry assetEntry=AssetEntryLocalServiceUtil.fetchAssetEntry(assetEntryIdDefault);
      AssetRendererFactory assetRendererFactory=AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(assetEntry.getClassName());
      AssetRenderer assetRenderer=assetRendererFactory.getAssetRenderer(assetEntry.getClassPK());
      assetImageDefault=assetRenderer.getThumbnailPath(portletRequest);
      assetTitleDefault=assetRenderer.getTitle(themeDisplay.getLocale());
      assetTypeDefault=assetRendererFactory.getTypeName(themeDisplay.getLocale(),true);
    }
    template.put("String_Node_Str",assetEntryIdDefault);
    template.put("String_Node_Str",assetImageDefault);
    template.put("String_Node_Str",assetTitleDefault);
    template.put("String_Node_Str",assetTypeDefault);
    template.put("String_Node_Str",contentDefaultValue);
    template.put("String_Node_Str",LiferayWindowState.EXCLUSIVE);
    template.put("String_Node_Str",portletPreferences);
    int[] queryRulesIndexes=GetterUtil.getIntegerValues(portletPreferences.getValues("String_Node_Str",null),new int[]{0});
    template.put("String_Node_Str",queryRulesIndexes);
    template.put("String_Node_Str",staticModels.get(UserSegmentQueryRuleUtil.class.getName()));
    template.put("String_Node_Str",staticModels.get(UserSegmentContentDisplayUtil.class.getName()));
    ServiceContext serviceContext=new ServiceContext();
    serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
    long[] vocabularyGroupIds=new long[1];
    long[] vocabularyIds=new long[1];
    if (themeDisplay.getScopeGroupId() == themeDisplay.getCompanyGroupId()) {
      vocabularyGroupIds[0]=themeDisplay.getCompanyGroupId();
      vocabularyIds[0]=UserSegmentUtil.getAssetVocabularyId(themeDisplay.getUserId(),serviceContext);
    }
 else {
      vocabularyGroupIds=ContentTargetingUtil.getAncestorsAndCurrentGroupIds(themeDisplay.getSiteGroupId());
      vocabularyIds=UserSegmentUtil.getAssetVocabularyIds(vocabularyGroupIds);
    }
    template.put("String_Node_Str",StringUtil.merge(vocabularyGroupIds));
    template.put("String_Node_Str",StringUtil.merge(vocabularyIds));
  }
}

Fixed version (ground truth):
protected void populateViewContext(String path,PortletRequest portletRequest,PortletResponse portletResponse,Template template,TemplateHashModel staticModels) throws Exception {
  ThemeDisplay themeDisplay=(ThemeDisplay)portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
  PortletPreferences portletPreferences=portletRequest.getPreferences();
  long assetEntryIdDefault=GetterUtil.getLong(portletPreferences.getValue("String_Node_Str",null));
  boolean contentDefaultValue=GetterUtil.getBoolean(portletPreferences.getValue("String_Node_Str",null));
  populatePortletDisplayTemplateContext(template,portletPreferences,themeDisplay.getScopeGroupId(),"String_Node_Str");
  if (Validator.isNull(path) || path.equals(UserSegmentContentDisplayPath.VIEW)) {
    template.put("String_Node_Str",showPreview(themeDisplay));
    template.put("String_Node_Str",contentDefaultValue);
    List<QueryRule> userSegmentQueryRules=UserSegmentQueryRuleUtil.getUserSegmentQueryRules(portletPreferences,themeDisplay.getLocale());
    template.put("String_Node_Str",userSegmentQueryRules);
    QueryRule queryRule=userSegmentQueryRules.get(0);
    long[] userSegmentIds=(long[])portletRequest.getAttribute(WebKeys.USER_SEGMENT_IDS);
    if (userSegmentIds != null) {
      long[] userSegmentAssetCategoryIds=ContentTargetingUtil.getAssetCategoryIds(userSegmentIds);
      queryRule=UserSegmentQueryRuleUtil.match(userSegmentAssetCategoryIds,userSegmentQueryRules);
    }
    template.put("String_Node_Str",queryRule);
    template.put("String_Node_Str",userSegmentQueryRules.indexOf(queryRule));
    List<AssetEntry> results=new ArrayList<AssetEntry>();
    if ((queryRule != null) && (queryRule.getAssetEntry() != null)) {
      results.add(queryRule.getAssetEntry());
      queryRule.setAssetAttributes(portletRequest);
    }
 else {
      portletRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY,Boolean.TRUE);
    }
    template.put("String_Node_Str",LiferayWindowState.POP_UP);
    populatePortletDisplayTemplateViewContext(template,portletRequest,themeDisplay,results,userSegmentQueryRules);
  }
 else   if (path.equals(UserSegmentContentDisplayPath.EDIT_QUERY_RULE) || path.equals(UserSegmentContentDisplayPath.CONFIGURATION)) {
    template.put("String_Node_Str",getSelectableAssetRendererFactories(themeDisplay.getCompanyId()));
    String assetImageDefault=StringPool.BLANK;
    String assetTitleDefault=StringPool.BLANK;
    String assetTypeDefault=StringPool.BLANK;
    if (assetEntryIdDefault > 0) {
      AssetEntry assetEntry=AssetEntryLocalServiceUtil.fetchAssetEntry(assetEntryIdDefault);
      AssetRendererFactory assetRendererFactory=AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(assetEntry.getClassName());
      AssetRenderer assetRenderer=assetRendererFactory.getAssetRenderer(assetEntry.getClassPK());
      assetImageDefault=assetRenderer.getThumbnailPath(portletRequest);
      assetTitleDefault=assetRenderer.getTitle(themeDisplay.getLocale());
      assetTypeDefault=assetRendererFactory.getTypeName(themeDisplay.getLocale(),true);
    }
    template.put("String_Node_Str",assetEntryIdDefault);
    template.put("String_Node_Str",assetImageDefault);
    template.put("String_Node_Str",assetTitleDefault);
    template.put("String_Node_Str",assetTypeDefault);
    template.put("String_Node_Str",contentDefaultValue);
    template.put("String_Node_Str",LiferayWindowState.EXCLUSIVE);
    template.put("String_Node_Str",portletPreferences);
    int[] queryRulesIndexes=GetterUtil.getIntegerValues(portletPreferences.getValues("String_Node_Str",null),new int[]{0});
    template.put("String_Node_Str",queryRulesIndexes);
    template.put("String_Node_Str",staticModels.get(UserSegmentQueryRuleUtil.class.getName()));
    template.put("String_Node_Str",staticModels.get(UserSegmentContentDisplayUtil.class.getName()));
    ServiceContext serviceContext=new ServiceContext();
    serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
    long[] vocabularyGroupIds=new long[1];
    long[] vocabularyIds=new long[1];
    if (themeDisplay.getScopeGroupId() == themeDisplay.getCompanyGroupId()) {
      vocabularyGroupIds[0]=themeDisplay.getCompanyGroupId();
      vocabularyIds[0]=UserSegmentUtil.getAssetVocabularyId(themeDisplay.getUserId(),serviceContext);
    }
 else {
      vocabularyGroupIds=ContentTargetingUtil.getAncestorsAndCurrentGroupIds(themeDisplay.getSiteGroupId());
      vocabularyIds=UserSegmentUtil.getAssetVocabularyIds(vocabularyGroupIds);
    }
    template.put("String_Node_Str",StringUtil.merge(vocabularyGroupIds));
    template.put("String_Node_Str",StringUtil.merge(vocabularyIds));
  }
}