Program: 107389
Project: 107389
Buggy source:
@Override public List<DomainVO> searchForDomains(ListDomainsCmd cmd) throws PermissionDeniedException {
  Long domainId=cmd.getId();
  Account account=UserContext.current().getAccount();
  if (account != null) {
    if (domainId != null) {
      if (!_domainDao.isChildDomain(account.getDomainId(),domainId)) {
        throw new PermissionDeniedException("String_Node_Str" + domainId + "String_Node_Str");
      }
    }
 else {
      domainId=account.getDomainId();
    }
  }
  Filter searchFilter=new Filter(DomainVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  String domainName=cmd.getDomainName();
  Integer level=cmd.getLevel();
  Object keyword=cmd.getKeyword();
  SearchBuilder<DomainVO> sb=_domainDao.createSearchBuilder();
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getLevel(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPath(),SearchCriteria.Op.LIKE);
  SearchCriteria<DomainVO> sc=sb.create();
  if (keyword != null) {
    SearchCriteria<DomainVO> ssc=_domainDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (domainName != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + domainName + "String_Node_Str");
  }
  if (level != null) {
    sc.setParameters("String_Node_Str",level);
  }
  if ((domainName == null) && (level == null) && (domainId != null)) {
    DomainVO domain=_domainDao.findById(domainId);
    if (domain != null) {
      sc.setParameters("String_Node_Str",domain.getPath() + "String_Node_Str");
    }
  }
  return _domainDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<DomainVO> searchForDomains(ListDomainsCmd cmd) throws PermissionDeniedException {
  Long domainId=cmd.getId();
  Account account=UserContext.current().getAccount();
  if (account != null) {
    if (domainId != null) {
      if (!_domainDao.isChildDomain(account.getDomainId(),domainId)) {
        throw new PermissionDeniedException("String_Node_Str" + domainId + "String_Node_Str");
      }
    }
 else {
      domainId=account.getDomainId();
    }
  }
  Filter searchFilter=new Filter(DomainVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  String domainName=cmd.getDomainName();
  Integer level=cmd.getLevel();
  Object keyword=cmd.getKeyword();
  SearchBuilder<DomainVO> sb=_domainDao.createSearchBuilder();
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getLevel(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPath(),SearchCriteria.Op.LIKE);
  SearchCriteria<DomainVO> sc=sb.create();
  if (keyword != null) {
    SearchCriteria<DomainVO> ssc=_domainDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (domainName != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + domainName + "String_Node_Str");
  }
  if (level != null) {
    sc.setParameters("String_Node_Str",level);
  }
  if (domainId != null) {
    sc.setParameters("String_Node_Str",domainId);
  }
  return _domainDao.search(sc,searchFilter);
}