use of bio.terra.service.filedata.exception.InvalidDrsIdException in project jade-data-repo by DataBiosphere.
the class DrsService method makeHttpsFromGs.
private String makeHttpsFromGs(String gspath) {
try {
URI gsuri = URI.create(gspath);
String gsBucket = gsuri.getAuthority();
String gsPath = StringUtils.removeStart(gsuri.getPath(), "/");
String encodedPath = URLEncoder.encode(gsPath, StandardCharsets.UTF_8.toString());
return String.format("https://www.googleapis.com/storage/v1/b/%s/o/%s?alt=media", gsBucket, encodedPath);
} catch (UnsupportedEncodingException ex) {
throw new InvalidDrsIdException("Failed to urlencode file path", ex);
}
}
use of bio.terra.service.filedata.exception.InvalidDrsIdException in project jade-data-repo by DataBiosphere.
the class DrsService method parseAndValidateDrsId.
private DrsId parseAndValidateDrsId(String drsObjectId) {
DrsId drsId = drsIdService.fromObjectId(drsObjectId);
try {
UUID snapshotId = UUID.fromString(drsId.getSnapshotId());
snapshotDao.retrieveSummaryById(snapshotId);
return drsId;
} catch (IllegalArgumentException ex) {
throw new InvalidDrsIdException("Invalid object id format '" + drsObjectId + "'", ex);
} catch (SnapshotNotFoundException ex) {
throw new DrsObjectNotFoundException("No snapshot found for DRS object id '" + drsObjectId + "'", ex);
}
}
use of bio.terra.service.filedata.exception.InvalidDrsIdException in project jade-data-repo by DataBiosphere.
the class DrsIdService method fromUri.
public DrsId fromUri(String drsuri) {
URI uri = URI.create(drsuri);
if (!StringUtils.equals(uri.getScheme(), "drs") || uri.getAuthority() == null || !StringUtils.startsWith(uri.getPath(), "/")) {
throw new InvalidDrsIdException("Invalid DRS URI '" + drsuri + "'");
}
String objectId = StringUtils.remove(uri.getPath(), '/');
return parseObjectId(objectId).dnsname(uri.getAuthority()).build();
}
Aggregations