use of bio.terra.service.resourcemanagement.exception.DataProjectNotFoundException in project jade-data-repo by DataBiosphere.
the class DataLocationService method getProject.
/**
* Fetch existing SnapshotDataProject for the Snapshot.
* Delete it if it's invalid, that is, the referenced cloud resource doesn't exist.
* @param snapshot
* @return a populated SnapshotDataProject if one exists, empty if not
*/
public Optional<SnapshotDataProject> getProject(Snapshot snapshot) {
SnapshotDataProjectSummary snapshotDataProjectSummary = null;
try {
// first, check if SnapshotDataProjectSummary (= mapping btw Snapshot ID and cloud Project ID) exists
snapshotDataProjectSummary = dataProjectDao.retrieveSnapshotDataProject(snapshot.getId());
// second, check if the referenced cloud resource exists
GoogleProjectResource googleProjectResource = resourceService.getProjectResourceById(snapshotDataProjectSummary.getProjectResourceId());
// if both exist, then create the DatasetDataProject object from the summary and return here
return Optional.of(new SnapshotDataProject(snapshotDataProjectSummary).googleProjectResource(googleProjectResource));
} catch (DataProjectNotFoundException projNfEx) {
// suppress exception here, will create later
} catch (GoogleResourceNotFoundException rsrcNfEx) {
// I don't think this null check will ever be false, but just in case
if (snapshotDataProjectSummary != null) {
logger.warn("metadata has a project resource id it can't resolve for snapshot: " + snapshot.getName());
dataProjectDao.deleteSnapshotDataProject(snapshotDataProjectSummary.getId());
}
}
// did not find a valid SnapshotDataProject for the given Snapshot
return Optional.empty();
}
use of bio.terra.service.resourcemanagement.exception.DataProjectNotFoundException in project jade-data-repo by DataBiosphere.
the class DataProjectDao method retrieveDatasetDataProject.
public DatasetDataProjectSummary retrieveDatasetDataProject(UUID datasetId) {
try {
String sql = "SELECT id, dataset_id, project_resource_id FROM dataset_data_project " + " WHERE dataset_id = :dataset_id";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("dataset_id", datasetId);
return jdbcTemplate.queryForObject(sql, params, new DatasetDataProjectSummaryMapper());
} catch (EmptyResultDataAccessException ex) {
throw new DataProjectNotFoundException("Dataset data project not found for: " + datasetId);
}
}
use of bio.terra.service.resourcemanagement.exception.DataProjectNotFoundException in project jade-data-repo by DataBiosphere.
the class DataLocationService method getProject.
/**
* Fetch existing DatasetDataProject for the Dataset.
* Delete it if it's invalid, that is, the referenced cloud resource doesn't exist.
* @param dataset
* @return a populated DatasetDataProject if one exists, empty if not
*/
public Optional<DatasetDataProject> getProject(Dataset dataset) {
DatasetDataProjectSummary datasetDataProjectSummary = null;
try {
// first, check if DatasetDataProjectSummary (= mapping btw Dataset ID and cloud Project ID) exists
datasetDataProjectSummary = dataProjectDao.retrieveDatasetDataProject(dataset.getId());
// second, check if the referenced cloud resource exists
GoogleProjectResource googleProjectResource = resourceService.getProjectResourceById(datasetDataProjectSummary.getProjectResourceId());
// if both exist, then create the DatasetDataProject object from the summary and return here
return Optional.of(new DatasetDataProject(datasetDataProjectSummary).googleProjectResource(googleProjectResource));
} catch (DataProjectNotFoundException projNfEx) {
// suppress exception here, will create later
} catch (GoogleResourceNotFoundException rsrcNfEx) {
// I don't think this null check will ever be false, but just in case
if (datasetDataProjectSummary != null) {
logger.warn("metadata has a project resource id it can't resolve for dataset: " + dataset.getName());
dataProjectDao.deleteDatasetDataProject(datasetDataProjectSummary.getId());
}
}
// did not find a valid DatasetDataProject for the given Dataset
return Optional.empty();
}
use of bio.terra.service.resourcemanagement.exception.DataProjectNotFoundException in project jade-data-repo by DataBiosphere.
the class DataProjectDao method retrieveSnapshotDataProject.
public SnapshotDataProjectSummary retrieveSnapshotDataProject(UUID snapshotId) {
try {
String sql = "SELECT id, snapshot_id, project_resource_id FROM snapshot_data_project " + "WHERE snapshot_id = :snapshot_id";
MapSqlParameterSource params = new MapSqlParameterSource().addValue("snapshot_id", snapshotId);
return jdbcTemplate.queryForObject(sql, params, new SnapshotDataProjectSummaryMapper());
} catch (EmptyResultDataAccessException ex) {
throw new DataProjectNotFoundException("Snapshot data project not found for: " + snapshotId);
}
}
Aggregations