use of bio.terra.service.filedata.exception.FileSystemExecutionException in project jade-data-repo by DataBiosphere.
the class FireStoreDependencyDao method deleteSnapshotFileDependencies.
public void deleteSnapshotFileDependencies(Dataset dataset, String snapshotId) throws InterruptedException {
DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
FireStoreProject fireStoreProject = FireStoreProject.get(dataProject.getGoogleProjectId());
String dependencyCollectionName = getDatasetDependencyId(dataset.getId().toString());
CollectionReference depColl = fireStoreProject.getFirestore().collection(dependencyCollectionName);
Query query = depColl.whereEqualTo("snapshotId", snapshotId);
ApiFuture<QuerySnapshot> querySnapshot = query.get();
try {
List<QueryDocumentSnapshot> documents = querySnapshot.get().getDocuments();
for (DocumentSnapshot docSnap : documents) {
logger.info("deleting: " + docSnap.toString());
docSnap.getReference().delete();
}
} catch (ExecutionException ex) {
throw new FileSystemExecutionException("delete dependencies - execution exception", ex);
}
}
use of bio.terra.service.filedata.exception.FileSystemExecutionException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method updateDirectoryEntry.
// Non-transactional update of a directory entry
void updateDirectoryEntry(Firestore firestore, String collectionId, FireStoreDirectoryEntry entry) {
try {
DocumentReference newRef = getDocRef(firestore, collectionId, entry);
ApiFuture<WriteResult> writeFuture = newRef.set(entry);
writeFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("updateDirectoryEntry - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("updateDirectoryEntry", ex);
}
}
use of bio.terra.service.filedata.exception.FileSystemExecutionException in project jade-data-repo by DataBiosphere.
the class FireStoreFileDao method lookupByFileId.
private DocumentSnapshot lookupByFileId(Firestore firestore, String collectionId, String fileId, Transaction xn) {
DocumentReference docRef = getFileDocRef(firestore, collectionId, fileId);
ApiFuture<DocumentSnapshot> docSnapFuture = xn.get(docRef);
try {
return docSnapFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("lookupByFileId - execution interrupted", ex);
} catch (ExecutionException ex) {
throw new FileSystemExecutionException("lookupByFileId - execution exception", ex);
}
}
use of bio.terra.service.filedata.exception.FileSystemExecutionException in project jade-data-repo by DataBiosphere.
the class FireStoreDependencyDao method getDatasetSnapshotFileIds.
public List<String> getDatasetSnapshotFileIds(Dataset dataset, String snapshotId) throws InterruptedException {
DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
FireStoreProject fireStoreProject = FireStoreProject.get(dataProject.getGoogleProjectId());
String dependencyCollectionName = getDatasetDependencyId(dataset.getId().toString());
CollectionReference depColl = fireStoreProject.getFirestore().collection(dependencyCollectionName);
Query query = depColl.whereEqualTo("snapshotId", snapshotId);
ApiFuture<QuerySnapshot> querySnapshot = query.get();
List<String> fileIds = new ArrayList<>();
try {
List<QueryDocumentSnapshot> documents = querySnapshot.get().getDocuments();
for (DocumentSnapshot docSnap : documents) {
FireStoreDependency fireStoreDependency = docSnap.toObject(FireStoreDependency.class);
fileIds.add(fireStoreDependency.getFileId());
}
return fileIds;
} catch (ExecutionException ex) {
throw new FileSystemExecutionException("get file ids - execution exception", ex);
}
}
use of bio.terra.service.filedata.exception.FileSystemExecutionException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method lookupByFilePath.
private DocumentSnapshot lookupByFilePath(Firestore firestore, String collectionId, String lookupPath, Transaction xn) {
try {
DocumentReference docRef = firestore.collection(collectionId).document(encodePathAsFirestoreDocumentName(lookupPath));
ApiFuture<DocumentSnapshot> docSnapFuture = xn.get(docRef);
return docSnapFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("lookupByEntryPath - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("lookupByEntryPath", ex);
}
}
Aggregations