Search in sources :

Example 1 with FileDetail

use of org.pmiops.workbench.model.FileDetail in project workbench by all-of-us.

the class WorkspacesController method convertBlobToFileDetail.

/**
 * Convers Blob to FileDetail
 * @param blobList
 * @param bucketName
 * @return List of FileDetail
 */
private List<FileDetail> convertBlobToFileDetail(List<Blob> blobList, String bucketName) {
    List<FileDetail> fileList = new ArrayList<>();
    blobList.forEach(blob -> {
        String[] parts = blob.getName().split("/");
        FileDetail fileDetail = new FileDetail();
        fileDetail.setName(parts[parts.length - 1]);
        fileDetail.setPath("gs://" + bucketName + "/" + blob.getName());
        fileList.add(fileDetail);
    });
    return fileList;
}
Also used : FileDetail(org.pmiops.workbench.model.FileDetail) ArrayList(java.util.ArrayList)

Example 2 with FileDetail

use of org.pmiops.workbench.model.FileDetail in project workbench by all-of-us.

the class WorkspacesController method getNoteBookList.

@Override
public ResponseEntity<List<FileDetail>> getNoteBookList(String workspaceNamespace, String workspaceId) {
    List<FileDetail> fileList = new ArrayList<>();
    try {
        org.pmiops.workbench.firecloud.model.Workspace fireCloudWorkspace = fireCloudService.getWorkspace(workspaceNamespace, workspaceId).getWorkspace();
        String bucketName = fireCloudWorkspace.getBucketName();
        fileList = getFilesFromNotebooks(bucketName);
    } catch (org.pmiops.workbench.firecloud.ApiException e) {
        if (e.getCode() == 404) {
            throw new NotFoundException(String.format("Workspace %s/%s not found", workspaceNamespace, workspaceId));
        }
        throw new ServerErrorException(e);
    }
    return ResponseEntity.ok(fileList);
}
Also used : FileDetail(org.pmiops.workbench.model.FileDetail) ArrayList(java.util.ArrayList) NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) ApiException(org.pmiops.workbench.firecloud.ApiException) ServerErrorException(org.pmiops.workbench.exceptions.ServerErrorException)

Aggregations

ArrayList (java.util.ArrayList)2 FileDetail (org.pmiops.workbench.model.FileDetail)2 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)1 ServerErrorException (org.pmiops.workbench.exceptions.ServerErrorException)1 ApiException (org.pmiops.workbench.firecloud.ApiException)1