use of bio.terra.service.iam.exception.IamUnauthorizedException in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method createSnapshot.
@Override
public ResponseEntity<JobModel> createSnapshot(@Valid @RequestBody SnapshotRequestModel snapshotRequestModel) {
AuthenticatedUserRequest userReq = getAuthenticatedInfo();
List<UUID> snapshotSourceDatasetIds = snapshotService.getSourceDatasetIdsFromSnapshotRequest(snapshotRequestModel);
// TODO auth should be put into flight?
List<UUID> unauthorized = getUnauthorizedSources(snapshotSourceDatasetIds, userReq);
if (unauthorized.isEmpty()) {
String jobId = snapshotService.createSnapshot(snapshotRequestModel, userReq);
// we can retrieve the job we just created
return jobToResponse(jobService.retrieveJob(jobId, userReq));
}
throw new IamUnauthorizedException("User is not authorized to create snapshots for these datasets " + unauthorized);
}
Aggregations