use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.
the class IngestUtils method getDataset.
public static Dataset getDataset(FlightContext context, DatasetService datasetService) {
FlightMap inputParameters = context.getInputParameters();
UUID datasetId = UUID.fromString(inputParameters.get(JobMapKeys.DATASET_ID.getKeyName(), String.class));
return datasetService.retrieve(datasetId);
}
use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.
the class CreateDatasetAssetStep method doStep.
@Override
public StepResult doStep(FlightContext context) {
// TODO: Asset columns and tables need to match things in the dataset schema
Dataset dataset = getDataset(context);
FlightMap map = context.getWorkingMap();
// get the dataset assets that already exist --asset name needs to be unique
AssetSpecification newAssetSpecification = getNewAssetSpec(context, dataset);
// add a fault that forces an exception to make sure the undo works
try {
configService.fault(ConfigEnum.CREATE_ASSET_FAULT, () -> {
throw new RuntimeException("fault insertion");
});
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
assetDao.create(newAssetSpecification, dataset.getId());
} catch (InvalidAssetException e) {
FlightUtils.setErrorResponse(context, e.getMessage(), HttpStatus.BAD_REQUEST);
map.put(DatasetWorkingMapKeys.ASSET_NAME_COLLISION, true);
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, e);
}
map.put(JobMapKeys.STATUS_CODE.getKeyName(), HttpStatus.CREATED);
return StepResult.getStepResultSuccess();
}
use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.
the class CreateDatasetAuthzBqJobUserStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
FlightMap workingMap = context.getWorkingMap();
UUID datasetId = workingMap.get(DatasetWorkingMapKeys.DATASET_ID, UUID.class);
Map<IamRole, String> policies = workingMap.get(DatasetWorkingMapKeys.POLICY_EMAILS, Map.class);
Dataset dataset = datasetService.retrieve(datasetId);
DatasetModel datasetModel = datasetService.retrieveModel(dataset);
// The underlying service provides retries so we do not need to retry this operation
resourceService.grantPoliciesBqJobUser(datasetModel.getDataProject(), policies.values());
return StepResult.getStepResultSuccess();
}
use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.
the class CreateDatasetAuthzIamStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) throws InterruptedException {
FlightMap workingMap = context.getWorkingMap();
UUID datasetId = workingMap.get(DatasetWorkingMapKeys.DATASET_ID, UUID.class);
try {
iamClient.deleteDatasetResource(userReq, datasetId);
} catch (UnauthorizedException ex) {
// suppress exception
logger.error("NEEDS CLEANUP: delete sam resource for dataset " + datasetId.toString(), ex);
} catch (NotFoundException ex) {
// if the SAM resource is not found, then it was likely not created -- continue undoing
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.
the class CreateDatasetAuthzIamStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
FlightMap workingMap = context.getWorkingMap();
UUID datasetId = workingMap.get(DatasetWorkingMapKeys.DATASET_ID, UUID.class);
Map<IamRole, String> policyEmails = iamClient.createDatasetResource(userReq, datasetId);
workingMap.put(DatasetWorkingMapKeys.POLICY_EMAILS, policyEmails);
return StepResult.getStepResultSuccess();
}
Aggregations