use of bio.terra.service.dataset.exception.DatasetNotFoundException in project jade-data-repo by DataBiosphere.
the class DatasetDao method getExclusiveLock.
/**
* TESTING ONLY. This method returns the internal state of the exclusive lock on a dataset.
* It is protected because it's for use in tests only.
* Currently, we don't expose the lock state of a dataset outside of the DAO for other API code to consume.
* @param id the dataset id
* @return the flightid that holds an exclusive lock. null if none.
*/
protected String getExclusiveLock(UUID id) {
try {
String sql = "SELECT flightid FROM dataset WHERE id = :id";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
return jdbcTemplate.queryForObject(sql, params, String.class);
} catch (EmptyResultDataAccessException ex) {
throw new DatasetNotFoundException("Dataset not found for id " + id);
}
}
use of bio.terra.service.dataset.exception.DatasetNotFoundException in project jade-data-repo by DataBiosphere.
the class DeleteSnapshotPrimaryDataStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
try {
// this fault is used by the SnapshotConnectedTest > testOverlappingDeletes
if (configService.testInsertFault(ConfigEnum.SNAPSHOT_DELETE_LOCK_CONFLICT_STOP_FAULT)) {
logger.info("SNAPSHOT_DELETE_LOCK_CONFLICT_STOP_FAULT");
while (!configService.testInsertFault(ConfigEnum.SNAPSHOT_DELETE_LOCK_CONFLICT_CONTINUE_FAULT)) {
logger.info("Sleeping for CONTINUE FAULT");
TimeUnit.SECONDS.sleep(5);
}
logger.info("SNAPSHOT_DELETE_LOCK_CONFLICT_CONTINUE_FAULT");
}
Snapshot snapshot = snapshotService.retrieve(snapshotId);
bigQueryPdao.deleteSnapshot(snapshot);
// Remove snapshot file references from the underlying datasets
for (SnapshotSource snapshotSource : snapshot.getSnapshotSources()) {
Dataset dataset = datasetService.retrieve(snapshotSource.getDataset().getId());
dependencyDao.deleteSnapshotFileDependencies(dataset, snapshotId.toString());
}
fileDao.deleteFilesFromSnapshot(snapshot);
} catch (SnapshotNotFoundException | DatasetNotFoundException nfe) {
// If we do not find the snapshot or dataset, we assume things are already clean
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.exception.DatasetNotFoundException in project jade-data-repo by DataBiosphere.
the class DatasetDao method getSharedLocks.
/**
* TESTING ONLY. This method returns the internal state of the shared locks on a dataset.
* It is protected because it's for use in tests only.
* Currently, we don't expose the lock state of a dataset outside of the DAO for other API code to consume.
* @param id the dataset id
* @return the array of flight ids that hold shared locks. empty if no shared locks are taken out.
*/
protected String[] getSharedLocks(UUID id) {
try {
String sql = "SELECT sharedlock FROM dataset WHERE id = :id";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
Array arr = jdbcTemplate.queryForObject(sql, params, Array.class);
if (arr == null) {
throw new CorruptMetadataException("Dataset shared locks array column should not be null. id " + id);
}
return (String[]) arr.getArray();
} catch (EmptyResultDataAccessException | SQLException ex) {
throw new DatasetNotFoundException("Dataset not found for id " + id);
}
}
use of bio.terra.service.dataset.exception.DatasetNotFoundException in project jade-data-repo by DataBiosphere.
the class DatasetDao method retrieveSummaryByName.
public DatasetSummary retrieveSummaryByName(String name) {
try {
String sql = "SELECT " + "id, name, description, default_profile_id, additional_profile_ids, created_date " + "FROM dataset WHERE name = :name";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("name", name);
return jdbcTemplate.queryForObject(sql, params, new DatasetSummaryMapper());
} catch (EmptyResultDataAccessException ex) {
throw new DatasetNotFoundException("Dataset not found for name " + name);
}
}
use of bio.terra.service.dataset.exception.DatasetNotFoundException in project jade-data-repo by DataBiosphere.
the class DatasetDao method retrieveSummaryById.
/**
* Retrieves a DatasetSummary object from the dataset id.
* @param id the dataset id
* @param onlyRetrieveAvailable true to exclude datasets that are exclusively locked, false to include all datasets
* @return the DatasetSummary object
*/
public DatasetSummary retrieveSummaryById(UUID id, boolean onlyRetrieveAvailable) {
try {
String sql = "SELECT " + "id, name, description, default_profile_id, additional_profile_ids, created_date " + "FROM dataset WHERE id = :id";
if (onlyRetrieveAvailable) {
// exclude datasets that are exclusively locked
sql += " AND flightid IS NULL";
}
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
return jdbcTemplate.queryForObject(sql, params, new DatasetSummaryMapper());
} catch (EmptyResultDataAccessException ex) {
throw new DatasetNotFoundException("Dataset not found for id " + id.toString());
}
}
Aggregations