Program: 89548
Project: 89548
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();
  Boolean issystem=cmd.getIsSystem();
  String vm_type_str=cmd.getSystemVmType();
  if (domainId != null) {
    if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
      if (account.getDomainId() != 1 && issystem) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      return _offeringsDao.findSystemOffering(domainId,issystem,vm_type_str);
    }
 else {
      if (issystem) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      if (isPermissible(account.getDomainId(),domainId)) {
        return _offeringsDao.findSystemOffering(domainId,false,vm_type_str);
      }
 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) || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
    if (issystem) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    return searchServiceOfferingsInternal(account,name,id,vmId,keyword,searchFilter);
  }
  if (account.getDomainId() != 1 && issystem) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  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");
  }
  if (vm_type_str != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,vm_type_str);
  }
  sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,issystem);
  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 caller=UserContext.current().getCaller();
  Object name=cmd.getServiceOfferingName();
  Object id=cmd.getId();
  Object keyword=cmd.getKeyword();
  Long vmId=cmd.getVirtualMachineId();
  Long domainId=cmd.getDomainId();
  Boolean isSystem=cmd.getIsSystem();
  String vm_type_str=cmd.getSystemVmType();
  if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && isSystem) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (domainId != null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
    if (!isPermissible(caller.getDomainId(),domainId)) {
      throw new PermissionDeniedException("String_Node_Str" + caller.getAccountName() + "String_Node_Str");
    }
  }
  if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
    if (isSystem) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    return searchServiceOfferingsInternal(caller,name,id,vmId,keyword,searchFilter);
  }
  if (caller.getDomainId() != 1 && isSystem) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  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 ((caller != null) && !isAdmin(caller.getType())) {
      if (caller.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 (isSystem != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,isSystem);
  }
  if (name != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
  }
  if (domainId != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainId);
  }
  if (vm_type_str != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,vm_type_str);
  }
  sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,isSystem);
  return _offeringsDao.search(sc,searchFilter);
}