Source:
public RepoObject getObject(String bucketName, String key, Integer version, String versionChecksum, String tag, boolean searchInDeleted, boolean searchInPurged) throws SQLException { PreparedStatement p = null; ResultSet result = null; try { StringBuilder query = new StringBuilder(); query.append("SELECT * FROM objects a, buckets b WHERE a.bucketId = b.bucketId AND b.bucketName=? AND objKey=?"); if (version != null){ query.append(" AND versionNumber=?"); } if (versionChecksum != null){ query.append(" AND versionChecksum=?"); } if (tag != null){ query.append(" AND tag=?"); } if (!searchInDeleted && !searchInPurged){ query.append(" AND status=?"); } if ((!searchInDeleted && searchInPurged) || (searchInDeleted && !searchInPurged)){ query.append(" AND status in (?,?)"); } query.append(" ORDER BY a.creationDate DESC LIMIT 1"); p = connectionLocal.get().prepareStatement(query.toString()); p.setString(1, bucketName); p.setString(2, key); int i = 3; if (version != null){ p.setInt(i++, version); } if (versionChecksum != null){ p.setString(i++, versionChecksum); } if (tag != null){ p.setString(i++, tag); } if (!searchInDeleted && !searchInPurged) p.setInt(i++, Status.USED.getValue()); if (searchInDeleted && !searchInPurged){ p.setInt(i++, Status.USED.getValue()); p.setInt(i++, Status.DELETED.getValue()); } if (!searchInDeleted && searchInPurged){ p.setInt(i++, Status.USED.getValue()); p.setInt(i++, Status.PURGED.getValue()); } result = p.executeQuery(); if (result.next()) { RepoObject repoObject = mapObjectRow(result); return repoObject; } else return null; } finally { closeDbStuff(result, p); } }

Target:
public RepoObject getObject(String bucketName, String key, Integer version, String versionChecksum, String tag, boolean searchInDeleted, boolean searchInPurged) throws SQLException { PreparedStatement p = null; ResultSet result = null; StringBuilder query = new StringBuilder(); query.append("SELECT * FROM objects a, buckets b WHERE a.bucketId = b.bucketId AND b.bucketName=? AND objKey=?"); if (version != null){ query.append(" AND versionNumber=?"); } if (versionChecksum != null){ query.append(" AND versionChecksum=?"); } if (tag != null){ query.append(" AND tag=?"); } if (!searchInDeleted && !searchInPurged){ query.append(" AND status=?"); } if ((!searchInDeleted && searchInPurged) || (searchInDeleted && !searchInPurged)){ query.append(" AND status in (?,?)"); } query.append(" ORDER BY a.creationDate DESC LIMIT 1"); try { p = connectionLocal.get().prepareStatement(query.toString()); p.setString(1, bucketName); p.setString(2, key); int i = 3; if (version != null){ p.setInt(i++, version); } if (versionChecksum != null){ p.setString(i++, versionChecksum); } if (tag != null){ p.setString(i++, tag); } if ((!searchInDeleted && !searchInPurged) || (!searchInDeleted && searchInPurged) || (searchInDeleted && !searchInPurged)) { p.setInt(i++, Status.USED.getValue()); if (searchInDeleted){ p.setInt(i++, Status.DELETED.getValue()); } else if (searchInPurged){ p.setInt(i++, Status.PURGED.getValue()); } } result = p.executeQuery(); if (result.next()) { RepoObject repoObject = mapObjectRow(result); return repoObject; } else return null; } finally { closeDbStuff(result, p); } }