use of bio.terra.datarepo.client.ApiException in project terra-workspace-manager by DataBiosphere.
the class DataRepoService method snapshotReadable.
/**
* Returns whether or not a given snapshot is readable for a given user. On the TDR side,
* retrieveSnapshot requires that a user have read access to the snapshot's data.
*/
@Traced
public boolean snapshotReadable(String instanceName, String snapshotId, AuthenticatedUserRequest userRequest) {
RepositoryApi repositoryApi = repositoryApi(instanceName, userRequest);
try {
repositoryApi.retrieveSnapshot(snapshotId);
logger.info("Retrieved snapshotId {} on Data Repo instance {}", snapshotId, instanceName);
return true;
} catch (ApiException e) {
// UNAUTHORIZED here instead of FORBIDDEN.
if (e.getCode() == HttpStatus.NOT_FOUND.value() || e.getCode() == HttpStatus.UNAUTHORIZED.value()) {
return false;
} else {
throw new DataRepoInternalServerErrorException("Data Repo returned the following error: " + e.getMessage(), e.getCause());
}
}
}
use of bio.terra.datarepo.client.ApiException in project terra-cli by DataBiosphere.
the class DataRepoService method getVersion.
/**
* Call the Data Repo "/configuration" endpoint to get the version of the server that is currently
* running.
*
* @return the Data Repo configuration object
*/
public RepositoryConfigurationModel getVersion() {
UnauthenticatedApi unauthenticatedApi = new UnauthenticatedApi(apiClient);
RepositoryConfigurationModel repositoryConfig = null;
try {
repositoryConfig = unauthenticatedApi.retrieveRepositoryConfig();
} catch (ApiException ex) {
throw new SystemException("Error getting Data Repo version", ex);
}
return repositoryConfig;
}
Aggregations