Program: 135780
Project: 135780
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);
  if (Validator.isNull(path) || path.equals(ContentTargetingPath.VIEW) || path.equals(ContentTargetingPath.VIEW_CAMPAIGNS_RESOURCES)|| path.equals(ContentTargetingPath.VIEW_USER_SEGMENTS_RESOURCES)) {
    template.put("String_Node_Str",staticModels.get("String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",new RowChecker(portletResponse));
    String keywords=ParamUtil.getString(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",new CampaignSearchContainerIterator(themeDisplay.getSiteGroupIdOrLiveGroupId(),keywords));
    template.put("String_Node_Str",new UserSegmentSearchContainerIterator(themeDisplay.getSiteGroupIdOrLiveGroupId(),keywords));
    template.put("String_Node_Str",UsedUserSegmentException.class);
  }
 else   if (path.equals(ContentTargetingPath.EDIT_CAMPAIGN)) {
    long campaignId=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",campaignId);
    int priority=1;
    long userSegmentId=-1;
    if (campaignId > 0) {
      Campaign campaign=_campaignLocalService.getCampaign(campaignId);
      template.put("String_Node_Str",campaign);
      List<UserSegment> campaignUserSegments=_userSegmentLocalService.getCampaignUserSegments(campaignId);
      priority=campaign.getPriority();
      if ((campaignUserSegments != null) && !campaignUserSegments.isEmpty()) {
        UserSegment campaignUserSegment=campaignUserSegments.get(0);
        userSegmentId=campaignUserSegment.getUserSegmentId();
      }
    }
    template.put("String_Node_Str",priority);
    template.put("String_Node_Str",userSegmentId);
    long[] groupIds=ContentTargetingUtil.getAncestorsAndCurrentGroupIds(themeDisplay.getScopeGroupId());
    List<UserSegment> userSegments=_userSegmentService.getUserSegments(groupIds);
    template.put("String_Node_Str",userSegments);
    template.put("String_Node_Str",_trackingActionsRegistry);
    Map<String,TrackingAction> trackingActions=_trackingActionsRegistry.getTrackingActions();
    boolean isolated=themeDisplay.isIsolated();
    try {
      themeDisplay.setIsolated(true);
      template.put("String_Node_Str",trackingActions.values());
      if (campaignId > 0) {
        List<TrackingActionInstance> instances=_trackingActionInstanceService.getTrackingActionInstances(campaignId);
        template.put("String_Node_Str",instances);
        List<TrackingActionTemplate> addedTrackingActionTemplates=new ArrayList<TrackingActionTemplate>();
        for (        TrackingActionInstance instance : instances) {
          TrackingAction trackingAction=_trackingActionsRegistry.getTrackingAction(instance.getTrackingActionKey());
          TrackingActionTemplate trackingActionTemplate=new TrackingActionTemplate();
          String html=trackingAction.getFormHTML(instance,_cloneTemplateContext(template));
          trackingActionTemplate.setInstanceId(instance.getTrackingActionInstanceId());
          trackingActionTemplate.setTrackingAction(trackingAction);
          trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
          addedTrackingActionTemplates.add(trackingActionTemplate);
        }
        template.put("String_Node_Str",addedTrackingActionTemplates);
      }
      List<TrackingActionTemplate> trackingActionTemplates=new ArrayList<TrackingActionTemplate>();
      for (      TrackingAction trackingAction : trackingActions.values()) {
        TrackingActionTemplate trackingActionTemplate=new TrackingActionTemplate();
        String html=trackingAction.getFormHTML(null,_cloneTemplateContext(template));
        trackingActionTemplate.setTrackingAction(trackingAction);
        trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
        trackingActionTemplates.add(trackingActionTemplate);
      }
      template.put("String_Node_Str",trackingActionTemplates);
    }
  finally {
      themeDisplay.setIsolated(isolated);
    }
  }
 else   if (path.equals(ContentTargetingPath.EDIT_USER_SEGMENT)) {
    long userSegmentId=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",userSegmentId);
    template.put("String_Node_Str",_rulesRegistry);
    Map<String,Rule> rules=_rulesRegistry.getRules();
    boolean isolated=themeDisplay.isIsolated();
    try {
      themeDisplay.setIsolated(true);
      template.put("String_Node_Str",rules.values());
      if (userSegmentId > 0) {
        List<RuleInstance> ruleInstances=_ruleInstanceService.getRuleInstances(userSegmentId);
        template.put("String_Node_Str",ruleInstances);
        List<RuleTemplate> addedRuleTemplates=new ArrayList<RuleTemplate>();
        for (        RuleInstance ruleInstance : ruleInstances) {
          Rule rule=_rulesRegistry.getRule(ruleInstance.getRuleKey());
          RuleTemplate ruleTemplate=new RuleTemplate();
          String html=rule.getFormHTML(ruleInstance,_cloneTemplateContext(template));
          ruleTemplate.setInstanceId(ruleInstance.getRuleInstanceId());
          ruleTemplate.setRule(rule);
          ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
          addedRuleTemplates.add(ruleTemplate);
        }
        template.put("String_Node_Str",addedRuleTemplates);
        UserSegment userSegment=_userSegmentLocalService.getUserSegment(userSegmentId);
        template.put("String_Node_Str",userSegment);
      }
      List<RuleTemplate> ruleTemplates=new ArrayList<RuleTemplate>();
      for (      Rule rule : rules.values()) {
        RuleTemplate ruleTemplate=new RuleTemplate();
        String html=rule.getFormHTML(null,_cloneTemplateContext(template));
        ruleTemplate.setRule(rule);
        ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
        ruleTemplates.add(ruleTemplate);
      }
      template.put("String_Node_Str",ruleTemplates);
    }
  finally {
      themeDisplay.setIsolated(isolated);
    }
  }
 else   if (path.equals(ContentTargetingPath.VIEW_REPORT) || path.equals(ContentTargetingPath.VIEW_REPORTS)) {
    String className=ParamUtil.getString(portletRequest,"String_Node_Str");
    long classPK=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",className);
    template.put("String_Node_Str",classPK);
    if (path.equals(ContentTargetingPath.VIEW_REPORT)) {
      String reportKey=ParamUtil.getString(portletRequest,"String_Node_Str");
      Report report=_reportsRegistry.getReport(reportKey);
      template.put("String_Node_Str",report);
      template.put("String_Node_Str",report.getHTML(_cloneTemplateContext(template)));
    }
    if (path.equals(ContentTargetingPath.VIEW_REPORTS)) {
      String title="String_Node_Str";
      if (className.equals(Campaign.class.getName())) {
        Campaign campaign=_campaignLocalService.getCampaign(classPK);
        title=LanguageUtil.format(themeDisplay.getLocale(),"String_Node_Str",campaign.getName(themeDisplay.getLocale()));
      }
 else       if (className.equals(UserSegment.class.getName())) {
        UserSegment userSegment=_userSegmentLocalService.getUserSegment(classPK);
        title=LanguageUtil.format(themeDisplay.getLocale(),"String_Node_Str",userSegment.getName(themeDisplay.getLocale()),false);
      }
      template.put("String_Node_Str",title);
      template.put("String_Node_Str",new ReportSearchContainerIterator(themeDisplay.getScopeGroupId(),null,className));
    }
  }
}

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);
  if (Validator.isNull(path) || path.equals(ContentTargetingPath.VIEW) || path.equals(ContentTargetingPath.VIEW_CAMPAIGNS_RESOURCES)|| path.equals(ContentTargetingPath.VIEW_USER_SEGMENTS_RESOURCES)) {
    template.put("String_Node_Str",staticModels.get("String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",staticModels.get("String_Node_Str" + "String_Node_Str"));
    template.put("String_Node_Str",new RowChecker(portletResponse));
    String keywords=ParamUtil.getString(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",new CampaignSearchContainerIterator(themeDisplay.getSiteGroupIdOrLiveGroupId(),keywords));
    template.put("String_Node_Str",new UserSegmentSearchContainerIterator(themeDisplay.getSiteGroupIdOrLiveGroupId(),keywords));
    template.put("String_Node_Str",UsedUserSegmentException.class);
  }
 else   if (path.equals(ContentTargetingPath.EDIT_CAMPAIGN)) {
    long campaignId=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",campaignId);
    int priority=1;
    long userSegmentId=-1;
    if (campaignId > 0) {
      Campaign campaign=_campaignLocalService.getCampaign(campaignId);
      template.put("String_Node_Str",campaign);
      List<UserSegment> campaignUserSegments=_userSegmentLocalService.getCampaignUserSegments(campaignId);
      priority=campaign.getPriority();
      if ((campaignUserSegments != null) && !campaignUserSegments.isEmpty()) {
        UserSegment campaignUserSegment=campaignUserSegments.get(0);
        userSegmentId=campaignUserSegment.getUserSegmentId();
      }
    }
    template.put("String_Node_Str",priority);
    template.put("String_Node_Str",userSegmentId);
    long[] groupIds=ContentTargetingUtil.getAncestorsAndCurrentGroupIds(themeDisplay.getScopeGroupId());
    List<UserSegment> userSegments=_userSegmentService.getUserSegments(groupIds);
    template.put("String_Node_Str",userSegments);
    template.put("String_Node_Str",_trackingActionsRegistry);
    Map<String,TrackingAction> trackingActions=_trackingActionsRegistry.getTrackingActions();
    boolean isolated=themeDisplay.isIsolated();
    try {
      themeDisplay.setIsolated(true);
      template.put("String_Node_Str",trackingActions.values());
      if (campaignId > 0) {
        List<TrackingActionInstance> instances=_trackingActionInstanceService.getTrackingActionInstances(campaignId);
        template.put("String_Node_Str",instances);
        List<TrackingActionTemplate> addedTrackingActionTemplates=new ArrayList<TrackingActionTemplate>();
        for (        TrackingActionInstance instance : instances) {
          TrackingAction trackingAction=_trackingActionsRegistry.getTrackingAction(instance.getTrackingActionKey());
          TrackingActionTemplate trackingActionTemplate=new TrackingActionTemplate();
          String html=trackingAction.getFormHTML(instance,_cloneTemplateContext(template));
          trackingActionTemplate.setInstanceId(instance.getTrackingActionInstanceId());
          trackingActionTemplate.setTrackingAction(trackingAction);
          trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
          addedTrackingActionTemplates.add(trackingActionTemplate);
        }
        template.put("String_Node_Str",addedTrackingActionTemplates);
      }
      List<TrackingActionTemplate> trackingActionTemplates=new ArrayList<TrackingActionTemplate>();
      for (      TrackingAction trackingAction : trackingActions.values()) {
        TrackingActionTemplate trackingActionTemplate=new TrackingActionTemplate();
        String html=trackingAction.getFormHTML(null,_cloneTemplateContext(template));
        trackingActionTemplate.setTrackingAction(trackingAction);
        trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
        trackingActionTemplates.add(trackingActionTemplate);
      }
      template.put("String_Node_Str",trackingActionTemplates);
    }
  finally {
      themeDisplay.setIsolated(isolated);
    }
  }
 else   if (path.equals(ContentTargetingPath.EDIT_USER_SEGMENT)) {
    long userSegmentId=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",userSegmentId);
    template.put("String_Node_Str",_rulesRegistry);
    Map<String,Rule> rules=_rulesRegistry.getRules();
    boolean isolated=themeDisplay.isIsolated();
    try {
      themeDisplay.setIsolated(true);
      template.put("String_Node_Str",rules.values());
      if (userSegmentId > 0) {
        List<RuleInstance> ruleInstances=_ruleInstanceService.getRuleInstances(userSegmentId);
        template.put("String_Node_Str",ruleInstances);
        List<RuleTemplate> addedRuleTemplates=new ArrayList<RuleTemplate>();
        for (        RuleInstance ruleInstance : ruleInstances) {
          Rule rule=_rulesRegistry.getRule(ruleInstance.getRuleKey());
          RuleTemplate ruleTemplate=new RuleTemplate();
          String html=rule.getFormHTML(ruleInstance,_cloneTemplateContext(template));
          ruleTemplate.setInstanceId(ruleInstance.getRuleInstanceId());
          ruleTemplate.setRule(rule);
          ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
          addedRuleTemplates.add(ruleTemplate);
        }
        template.put("String_Node_Str",addedRuleTemplates);
        UserSegment userSegment=_userSegmentLocalService.getUserSegment(userSegmentId);
        template.put("String_Node_Str",userSegment);
      }
      List<RuleTemplate> ruleTemplates=new ArrayList<RuleTemplate>();
      for (      Rule rule : rules.values()) {
        RuleTemplate ruleTemplate=new RuleTemplate();
        String html=rule.getFormHTML(null,_cloneTemplateContext(template));
        ruleTemplate.setRule(rule);
        ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html));
        ruleTemplates.add(ruleTemplate);
      }
      template.put("String_Node_Str",ruleTemplates);
    }
  finally {
      themeDisplay.setIsolated(isolated);
    }
  }
 else   if (path.equals(ContentTargetingPath.VIEW_REPORT) || path.equals(ContentTargetingPath.VIEW_REPORTS)) {
    String className=ParamUtil.getString(portletRequest,"String_Node_Str");
    long classPK=ParamUtil.getLong(portletRequest,"String_Node_Str");
    template.put("String_Node_Str",className);
    template.put("String_Node_Str",classPK);
    if (path.equals(ContentTargetingPath.VIEW_REPORT)) {
      String reportKey=ParamUtil.getString(portletRequest,"String_Node_Str");
      Report report=_reportsRegistry.getReport(reportKey);
      template.put("String_Node_Str",report);
      template.put("String_Node_Str",report.getHTML(_cloneTemplateContext(template)));
    }
    if (path.equals(ContentTargetingPath.VIEW_REPORTS)) {
      PortletConfig portletConfig=(PortletConfig)portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
      String title="String_Node_Str";
      if (className.equals(Campaign.class.getName())) {
        Campaign campaign=_campaignLocalService.getCampaign(classPK);
        title=LanguageUtil.format(portletConfig,themeDisplay.getLocale(),"String_Node_Str",campaign.getName(themeDisplay.getLocale()));
      }
 else       if (className.equals(UserSegment.class.getName())) {
        UserSegment userSegment=_userSegmentLocalService.getUserSegment(classPK);
        title=LanguageUtil.format(portletConfig,themeDisplay.getLocale(),"String_Node_Str",userSegment.getName(themeDisplay.getLocale()),false);
      }
      template.put("String_Node_Str",title);
      template.put("String_Node_Str",new ReportSearchContainerIterator(themeDisplay.getScopeGroupId(),null,className));
    }
  }
}