use of bio.terra.service.filedata.FSFile in project jade-data-repo by DataBiosphere.
the class GcsPdao method fileAclOp.
private void fileAclOp(AclOp op, Dataset dataset, List<String> fileIds, String readersPolicyEmail) {
Acl.Group readerGroup = new Acl.Group(readersPolicyEmail);
Acl acl = Acl.newBuilder(readerGroup, Acl.Role.READER).build();
for (String fileId : fileIds) {
FSItem fsItem = fileDao.retrieveById(dataset, fileId, 0, true);
if (fsItem instanceof FSFile) {
FSFile fsFile = (FSFile) fsItem;
GoogleBucketResource bucketForFile = dataLocationService.lookupBucket(fsFile.getBucketResourceId());
Storage storage = storageForBucket(bucketForFile);
URI gsUri = URI.create(fsFile.getGspath());
String bucketPath = StringUtils.removeStart(gsUri.getPath(), "/");
BlobId blobId = BlobId.of(bucketForFile.getName(), bucketPath);
switch(op) {
case ACL_OP_CREATE:
storage.createAcl(blobId, acl);
break;
case ACL_OP_DELETE:
storage.deleteAcl(blobId, readerGroup);
break;
}
}
}
}
use of bio.terra.service.filedata.FSFile in project jade-data-repo by DataBiosphere.
the class FireStoreDao method makeFSFile.
// Handle files - the fireStoreDirectoryEntry is a reference to a file in a dataset.
private FSItem makeFSFile(Firestore firestore, String collectionId, FireStoreDirectoryEntry fireStoreDirectoryEntry) {
if (!fireStoreDirectoryEntry.getIsFileRef()) {
throw new IllegalStateException("Expected file; got directory!");
}
String fullPath = fireStoreUtils.getFullPath(fireStoreDirectoryEntry.getPath(), fireStoreDirectoryEntry.getName());
String fileId = fireStoreDirectoryEntry.getFileId();
// Lookup the file in its owning dataset, not in the collection. The collection may be a snapshot directory
// pointing to the files in one or more datasets.
FireStoreFile fireStoreFile = fileDao.retrieveFileMetadata(firestore, fireStoreDirectoryEntry.getDatasetId(), fileId);
if (fireStoreFile == null) {
return null;
}
FSFile fsFile = new FSFile();
fsFile.fileId(UUID.fromString(fileId)).collectionId(UUID.fromString(collectionId)).datasetId(UUID.fromString(fireStoreDirectoryEntry.getDatasetId())).createdDate(Instant.parse(fireStoreFile.getFileCreatedDate())).path(fullPath).checksumCrc32c(fireStoreFile.getChecksumCrc32c()).checksumMd5(fireStoreFile.getChecksumMd5()).size(fireStoreFile.getSize()).description(fireStoreFile.getDescription()).gspath(fireStoreFile.getGspath()).mimeType(fireStoreFile.getMimeType()).bucketResourceId(fireStoreFile.getBucketResourceId()).loadTag(fireStoreFile.getLoadTag());
return fsFile;
}
Aggregations