Program: 106560
Project: 106560
Buggy source:
@Override public List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd){
  Long volumeId=cmd.getVolumeId();
  String name=cmd.getSnapshotName();
  Long id=cmd.getId();
  String keyword=cmd.getKeyword();
  String snapshotTypeStr=cmd.getSnapshotType();
  String intervalTypeStr=cmd.getIntervalType();
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (volumeId != null) {
    VolumeVO volume=_volsDao.findById(volumeId);
    if (volume != null) {
      _accountMgr.checkAccess(UserContext.current().getCaller(),null,true,volume);
    }
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,id,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll());
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter searchFilter=new Filter(SnapshotVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<SnapshotVO> sb=_snapshotDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getStatus(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getVolumeId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getsnapshotType(),SearchCriteria.Op.IN);
  sb.and("String_Node_Str",sb.entity().getsnapshotType(),SearchCriteria.Op.NEQ);
  SearchCriteria<SnapshotVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (volumeId != null) {
    sc.setParameters("String_Node_Str",volumeId);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + name + "String_Node_Str");
  }
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (keyword != null) {
    SearchCriteria<SnapshotVO> ssc=_snapshotDao.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 (snapshotTypeStr != null) {
    Type snapshotType=SnapshotVO.getSnapshotType((String)snapshotTypeStr);
    if (snapshotType == null) {
      throw new InvalidParameterValueException("String_Node_Str" + snapshotTypeStr);
    }
    if (snapshotType == Type.RECURRING) {
      sc.setParameters("String_Node_Str",Type.HOURLY.ordinal(),Type.DAILY.ordinal(),Type.WEEKLY.ordinal(),Type.MONTHLY.ordinal());
    }
 else {
      sc.setParameters("String_Node_Str",snapshotType.ordinal());
    }
  }
 else   if (intervalTypeStr != null && volumeId != null) {
    Type type=SnapshotVO.getSnapshotType((String)intervalTypeStr);
    if (type == null) {
      throw new InvalidParameterValueException("String_Node_Str" + intervalTypeStr);
    }
    sc.setParameters("String_Node_Str",type.ordinal());
  }
 else {
    sc.setParameters("String_Node_Str",Snapshot.Type.TEMPLATE.ordinal());
  }
  return _snapshotDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd){
  Long volumeId=cmd.getVolumeId();
  String name=cmd.getSnapshotName();
  Long id=cmd.getId();
  String keyword=cmd.getKeyword();
  String snapshotTypeStr=cmd.getSnapshotType();
  String intervalTypeStr=cmd.getIntervalType();
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (volumeId != null) {
    VolumeVO volume=_volsDao.findById(volumeId);
    if (volume != null) {
      _accountMgr.checkAccess(UserContext.current().getCaller(),null,true,volume);
    }
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,id,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll(),false);
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter searchFilter=new Filter(SnapshotVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<SnapshotVO> sb=_snapshotDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getStatus(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getVolumeId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getsnapshotType(),SearchCriteria.Op.IN);
  sb.and("String_Node_Str",sb.entity().getsnapshotType(),SearchCriteria.Op.NEQ);
  SearchCriteria<SnapshotVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (volumeId != null) {
    sc.setParameters("String_Node_Str",volumeId);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + name + "String_Node_Str");
  }
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (keyword != null) {
    SearchCriteria<SnapshotVO> ssc=_snapshotDao.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 (snapshotTypeStr != null) {
    Type snapshotType=SnapshotVO.getSnapshotType((String)snapshotTypeStr);
    if (snapshotType == null) {
      throw new InvalidParameterValueException("String_Node_Str" + snapshotTypeStr);
    }
    if (snapshotType == Type.RECURRING) {
      sc.setParameters("String_Node_Str",Type.HOURLY.ordinal(),Type.DAILY.ordinal(),Type.WEEKLY.ordinal(),Type.MONTHLY.ordinal());
    }
 else {
      sc.setParameters("String_Node_Str",snapshotType.ordinal());
    }
  }
 else   if (intervalTypeStr != null && volumeId != null) {
    Type type=SnapshotVO.getSnapshotType((String)intervalTypeStr);
    if (type == null) {
      throw new InvalidParameterValueException("String_Node_Str" + intervalTypeStr);
    }
    sc.setParameters("String_Node_Str",type.ordinal());
  }
 else {
    sc.setParameters("String_Node_Str",Snapshot.Type.TEMPLATE.ordinal());
  }
  return _snapshotDao.search(sc,searchFilter);
}