Search in sources :

Example 1 with SnapshotSummary

use of bio.terra.service.snapshot.SnapshotSummary 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);
    }
}
Also used : Snapshot(bio.terra.service.snapshot.Snapshot) SnapshotSummary(bio.terra.service.snapshot.SnapshotSummary) InvalidSnapshotException(bio.terra.service.snapshot.exception.InvalidSnapshotException) SnapshotSummaryModel(bio.terra.model.SnapshotSummaryModel) SnapshotNotFoundException(bio.terra.service.snapshot.exception.SnapshotNotFoundException) FlightMap(bio.terra.stairway.FlightMap) UUID(java.util.UUID) StepResult(bio.terra.stairway.StepResult)

Example 2 with SnapshotSummary

use of bio.terra.service.snapshot.SnapshotSummary in project jade-data-repo by DataBiosphere.

the class DeleteDatasetValidateStep method doStep.

@Override
public StepResult doStep(FlightContext context) {
    List<SnapshotSummary> snapshots = snapshotDao.retrieveSnapshotsForDataset(datasetId);
    Dataset dataset = datasetService.retrieve(datasetId);
    if (snapshots.size() != 0) {
        throw new ValidationException("Can not delete a dataset being used by snapshots");
    }
    // if there are no snapshots returned from retrieveSnapshotsForDataset.
    if (dependencyDao.datasetHasSnapshotReference(dataset)) {
        throw new FileSystemCorruptException("File system has snapshot dependencies; metadata does not");
    }
    return StepResult.getStepResultSuccess();
}
Also used : SnapshotSummary(bio.terra.service.snapshot.SnapshotSummary) ValidationException(bio.terra.app.controller.exception.ValidationException) Dataset(bio.terra.service.dataset.Dataset) FileSystemCorruptException(bio.terra.service.filedata.exception.FileSystemCorruptException)

Aggregations

SnapshotSummary (bio.terra.service.snapshot.SnapshotSummary)2 ValidationException (bio.terra.app.controller.exception.ValidationException)1 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)1 Dataset (bio.terra.service.dataset.Dataset)1 FileSystemCorruptException (bio.terra.service.filedata.exception.FileSystemCorruptException)1 Snapshot (bio.terra.service.snapshot.Snapshot)1 InvalidSnapshotException (bio.terra.service.snapshot.exception.InvalidSnapshotException)1 SnapshotNotFoundException (bio.terra.service.snapshot.exception.SnapshotNotFoundException)1 FlightMap (bio.terra.stairway.FlightMap)1 StepResult (bio.terra.stairway.StepResult)1 UUID (java.util.UUID)1