use of bio.terra.model.DRSAccessMethod in project jade-data-repo by DataBiosphere.
the class TestUtils method validateDrsAccessMethods.
public static String validateDrsAccessMethods(List<DRSAccessMethod> accessMethods) {
assertThat("Two access methods", accessMethods.size(), equalTo(2));
String gsuri = StringUtils.EMPTY;
boolean gotGs = false;
boolean gotHttps = false;
for (DRSAccessMethod accessMethod : accessMethods) {
if (accessMethod.getType() == DRSAccessMethod.TypeEnum.GS) {
assertFalse("have not seen GS yet", gotGs);
gotGs = true;
gsuri = accessMethod.getAccessUrl().getUrl();
} else if (accessMethod.getType() == DRSAccessMethod.TypeEnum.HTTPS) {
assertFalse("have not seen HTTPS yet", gotHttps);
gotHttps = true;
} else {
fail("Invalid access method");
}
}
assertTrue("got both access methods", gotGs && gotHttps);
return gsuri;
}
use of bio.terra.model.DRSAccessMethod in project jade-data-repo by DataBiosphere.
the class DrsService method drsObjectFromFSFile.
private DRSObject drsObjectFromFSFile(FSFile fsFile, String snapshotId, AuthenticatedUserRequest authUser) {
DRSObject fileObject = makeCommonDrsObject(fsFile, snapshotId);
GoogleBucketResource bucketResource = locationService.lookupBucketMetadata(fsFile.getBucketResourceId());
DRSAccessURL gsAccessURL = new DRSAccessURL().url(fsFile.getGspath());
DRSAccessMethod gsAccessMethod = new DRSAccessMethod().type(DRSAccessMethod.TypeEnum.GS).accessUrl(gsAccessURL).region(bucketResource.getRegion());
DRSAccessURL httpsAccessURL = new DRSAccessURL().url(makeHttpsFromGs(fsFile.getGspath())).headers(makeAuthHeader(authUser));
DRSAccessMethod httpsAccessMethod = new DRSAccessMethod().type(DRSAccessMethod.TypeEnum.HTTPS).accessUrl(httpsAccessURL).region(bucketResource.getRegion());
List<DRSAccessMethod> accessMethods = new ArrayList<>();
accessMethods.add(gsAccessMethod);
accessMethods.add(httpsAccessMethod);
fileObject.mimeType(fsFile.getMimeType()).checksums(fileService.makeChecksums(fsFile)).accessMethods(accessMethods);
return fileObject;
}
Aggregations