Search in sources :

Example 1 with DRSAccessMethod

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;
}
Also used : DRSAccessMethod(bio.terra.model.DRSAccessMethod)

Example 2 with DRSAccessMethod

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;
}
Also used : GoogleBucketResource(bio.terra.service.resourcemanagement.google.GoogleBucketResource) DRSAccessMethod(bio.terra.model.DRSAccessMethod) DRSAccessURL(bio.terra.model.DRSAccessURL) ArrayList(java.util.ArrayList) DRSObject(bio.terra.model.DRSObject)

Aggregations

DRSAccessMethod (bio.terra.model.DRSAccessMethod)2 DRSAccessURL (bio.terra.model.DRSAccessURL)1 DRSObject (bio.terra.model.DRSObject)1 GoogleBucketResource (bio.terra.service.resourcemanagement.google.GoogleBucketResource)1 ArrayList (java.util.ArrayList)1