public VersionRetriever getVersionList(ResourceIDImpl resourceID, long snapshotID)
throws RegistryException {
Connection conn = JDBCDatabaseTransaction.getConnection();
ResultSet result = null;
PreparedStatement ps = null;
VersionRetriever versionRetriever = null;
try {
if (resourceID.isCollection()) {
String sql =
"SELECT REG_PATH_ID, REG_RESOURCE_VIDS FROM REG_SNAPSHOT " +
"WHERE REG_SNAPSHOT_ID=? AND REG_PATH_ID = ? " +
"AND REG_RESOURCE_NAME IS NULL AND REG_TENANT_ID=?";
ps = conn.prepareStatement(sql);
ps.setLong(1, snapshotID);
ps.setInt(2, resourceID.getPathID());
ps.setInt(3, CurrentSession.getTenantId());
} else {
String sql =
"SELECT REG_PATH_ID, REG_RESOURCE_VIDS FROM REG_SNAPSHOT " +
"WHERE REG_SNAPSHOT_ID=? AND REG_PATH_ID = ? " +
"AND REG_RESOURCE_NAME=? AND REG_TENANT_ID=?";
ps = conn.prepareStatement(sql);
ps.setLong(1, snapshotID);
ps.setInt(2, resourceID.getPathID());
ps.setString(3, resourceID.getName());
ps.setInt(4, CurrentSession.getTenantId());
}
result = ps.executeQuery();
if (result.next()) {
InputStream resourceVIDStream = RegistryUtils.getMemoryStream(
result.getBinaryStream(DatabaseConstants.RESOURCE_VIDS_FIELD));
versionRetriever = new VersionRetriever(resourceVIDStream);
}
} catch (Exception e) {
String msg = "Failed to get version of resource " + resourceID.getPath() +
" of snapshot " + snapshotID + ". " + e.getMessage();