Program: 107118
Project: 107118
Buggy source:
@Override public List<ServiceOfferingVO> searchForServiceOfferings(ListServiceOfferingsCmd cmd){
  Filter searchFilter=new Filter(ServiceOfferingVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchCriteria<ServiceOfferingVO> sc=_offeringsDao.createSearchCriteria();
  Account account=UserContext.current().getCaller();
  Object name=cmd.getServiceOfferingName();
  Object id=cmd.getId();
  Object keyword=cmd.getKeyword();
  Long vmId=cmd.getVirtualMachineId();
  Long domainId=cmd.getDomainId();
  if (domainId != null) {
    if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
      return _offeringsDao.findServiceOfferingByDomainId(domainId);
    }
 else {
      if (isPermissible(account.getDomainId(),domainId)) {
        return _offeringsDao.findServiceOfferingByDomainId(domainId);
      }
 else {
        throw new PermissionDeniedException("String_Node_Str" + account.getAccountName() + "String_Node_Str");
      }
    }
  }
  if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
    return searchServiceOfferingsInternal(account,name,id,vmId,keyword,searchFilter);
  }
  if (keyword != null) {
    SearchCriteria<ServiceOfferingVO> ssc=_offeringsDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
 else   if (vmId != null) {
    UserVmVO vmInstance=_userVmDao.findById(vmId);
    if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
      throw new InvalidParameterValueException("String_Node_Str" + vmId);
    }
    if ((account != null) && !isAdmin(account.getType())) {
      if (account.getId() != vmInstance.getAccountId()) {
        throw new PermissionDeniedException("String_Node_Str" + vmId + "String_Node_Str");
      }
    }
    ServiceOfferingVO offering=_offeringsDao.findById(vmInstance.getServiceOfferingId());
    sc.addAnd("String_Node_Str",SearchCriteria.Op.NEQ,offering.getId());
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getUseLocalStorage());
  }
  if (id != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,id);
  }
  if (name != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
  }
  sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,false);
  return _offeringsDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<ServiceOfferingVO> searchForServiceOfferings(ListServiceOfferingsCmd cmd){
  Filter searchFilter=new Filter(ServiceOfferingVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchCriteria<ServiceOfferingVO> sc=_offeringsDao.createSearchCriteria();
  Account account=UserContext.current().getCaller();
  Object name=cmd.getServiceOfferingName();
  Object id=cmd.getId();
  Object keyword=cmd.getKeyword();
  Long vmId=cmd.getVirtualMachineId();
  Long domainId=cmd.getDomainId();
  if (domainId != null) {
    if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
      return _offeringsDao.findServiceOfferingByDomainId(domainId);
    }
 else {
      if (isPermissible(account.getDomainId(),domainId)) {
        return _offeringsDao.findServiceOfferingByDomainId(domainId);
      }
 else {
        throw new PermissionDeniedException("String_Node_Str" + account.getAccountName() + "String_Node_Str");
      }
    }
  }
  if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
    return searchServiceOfferingsInternal(account,name,id,vmId,keyword,searchFilter);
  }
  if (keyword != null) {
    SearchCriteria<ServiceOfferingVO> ssc=_offeringsDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
 else   if (vmId != null) {
    UserVmVO vmInstance=_userVmDao.findById(vmId);
    if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
      throw new InvalidParameterValueException("String_Node_Str" + vmId);
    }
    if ((account != null) && !isAdmin(account.getType())) {
      if (account.getId() != vmInstance.getAccountId()) {
        throw new PermissionDeniedException("String_Node_Str" + vmId + "String_Node_Str");
      }
    }
    ServiceOfferingVO offering=_offeringsDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
    sc.addAnd("String_Node_Str",SearchCriteria.Op.NEQ,offering.getId());
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getUseLocalStorage());
  }
  if (id != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,id);
  }
  if (name != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
  }
  sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,false);
  return _offeringsDao.search(sc,searchFilter);
}