use of bio.terra.service.snapshot.exception.SnapshotNotFoundException in project jade-data-repo by DataBiosphere.
the class DrsService method parseAndValidateDrsId.
private DrsId parseAndValidateDrsId(String drsObjectId) {
DrsId drsId = drsIdService.fromObjectId(drsObjectId);
try {
UUID snapshotId = UUID.fromString(drsId.getSnapshotId());
snapshotDao.retrieveSummaryById(snapshotId);
return drsId;
} catch (IllegalArgumentException ex) {
throw new InvalidDrsIdException("Invalid object id format '" + drsObjectId + "'", ex);
} catch (SnapshotNotFoundException ex) {
throw new DrsObjectNotFoundException("No snapshot found for DRS object id '" + drsObjectId + "'", ex);
}
}
use of bio.terra.service.snapshot.exception.SnapshotNotFoundException 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.snapshot.exception.SnapshotNotFoundException in project jade-data-repo by DataBiosphere.
the class CreateSnapshotMetadataStep method doStep.
@Override
public StepResult doStep(FlightContext context) {
try {
Snapshot snapshot = snapshotService.makeSnapshotFromSnapshotRequest(snapshotReq);
UUID snapshotId = snapshotDao.createAndLock(snapshot, context.getFlightId());
FlightMap workingMap = context.getWorkingMap();
workingMap.put(SnapshotWorkingMapKeys.SNAPSHOT_ID, snapshotId);
SnapshotSummary snapshotSummary = snapshotDao.retrieveSummaryById(snapshot.getId());
SnapshotSummaryModel response = snapshotService.makeSummaryModelFromSummary(snapshotSummary);
FlightUtils.setResponse(context, response, HttpStatus.CREATED);
return StepResult.getStepResultSuccess();
} catch (InvalidSnapshotException isEx) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, isEx);
} catch (SnapshotNotFoundException ex) {
FlightUtils.setErrorResponse(context, ex.toString(), HttpStatus.BAD_REQUEST);
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, ex);
}
}
use of bio.terra.service.snapshot.exception.SnapshotNotFoundException in project jade-data-repo by DataBiosphere.
the class SnapshotDao method getExclusiveLockState.
/**
* This method is protected because it's for use in tests only.
* Currently, we don't expose the lock state of a snapshot outside of the DAO for other API code to consume.
* @param id
* @return the flightid that holds an exclusive lock. null if none.
*/
protected String getExclusiveLockState(UUID id) {
try {
String sql = "SELECT flightid FROM snapshot WHERE id = :id";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
return jdbcTemplate.queryForObject(sql, params, String.class);
} catch (EmptyResultDataAccessException ex) {
throw new SnapshotNotFoundException("Snapshot not found for id " + id);
}
}
use of bio.terra.service.snapshot.exception.SnapshotNotFoundException in project jade-data-repo by DataBiosphere.
the class SnapshotDao method retrieveSnapshotByName.
public Snapshot retrieveSnapshotByName(String name) {
String sql = "SELECT * FROM snapshot WHERE name = :name";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("name", name);
Snapshot snapshot = retrieveWorker(sql, params);
if (snapshot == null) {
throw new SnapshotNotFoundException("Snapshot not found - name: '" + name + "'");
}
return snapshot;
}
Aggregations