本文整理匯總了Java中com.google.cloud.storage.Storage.BlobListOption類的典型用法代碼示例。如果您正苦於以下問題:Java BlobListOption類的具體用法?Java BlobListOption怎麽用?Java BlobListOption使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlobListOption類屬於com.google.cloud.storage.Storage包,在下文中一共展示了BlobListOption類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testErrorMessageIsCleared_afterSuccessfulBucketList
import com.google.cloud.storage.Storage.BlobListOption; //導入依賴的package包/類
@Test
public void testErrorMessageIsCleared_afterSuccessfulBucketList() {
when(bucketVirtualFile.getBucket().list(any(BlobListOption.class), any(BlobListOption.class)))
.thenThrow(StorageException.class);
editorPanel = new GcsBucketContentEditorPanel(bucketVirtualFile.getBucket());
editorPanel.initTableModel();
assertTrue(editorPanel.getErrorPanel().isVisible());
// Re-initialize mocks so the exception is not thrown and update the UI
reset(bucketVirtualFile.getBucket());
editorPanel.updateTableModel("");
assertFalse(editorPanel.getErrorPanel().isVisible());
}
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-intellij,代碼行數:17,代碼來源:GcsBucketContentEditorPanelTest.java
示例2: setupVirtualFileWithBucketMocks
import com.google.cloud.storage.Storage.BlobListOption; //導入依賴的package包/類
static GcsBucketVirtualFile setupVirtualFileWithBucketMocks(
GcsBucketVirtualFile gcsBucketVirtualFile) {
Bucket bucket = mock(Bucket.class);
Page<Blob> page = mock(Page.class);
Iterable<Blob> blobIterable = mock(Iterable.class);
Iterator<Blob> blobIterator = mock(Iterator.class);
when(gcsBucketVirtualFile.getBucket()).thenReturn(bucket);
when(bucket.list()).thenReturn(page);
when(bucket.list(any(BlobListOption.class), any(BlobListOption.class))).thenReturn(page);
when(page.iterateAll()).thenReturn(blobIterable);
when(blobIterable.iterator()).thenReturn(blobIterator);
return gcsBucketVirtualFile;
}
示例3: getScripts
import com.google.cloud.storage.Storage.BlobListOption; //導入依賴的package包/類
/**
* Gives the raw JS Scripts sepcified
* @return list of raw JS Script data as strings
*/
public List<String> getScripts() {
if (Strings.isNullOrEmpty(gcsJSPath())) {
return new ArrayList<>();
}
String bucketName = gcsJSPath().replace("gs://", "").split("/")[0];
String prefixPath = gcsJSPath().replace("gs://" + bucketName + "/", "");
Bucket bucket = getStorageService().get(bucketName);
if (bucket == null || !bucket.exists()) {
throw new IllegalArgumentException(
"Bucket does not exist, or do not have adequate permissions");
}
ArrayList<String> filePaths = new ArrayList<>();
if (prefixPath.endsWith(".js")) {
filePaths.add(prefixPath);
} else {
Page<Blob> blobs = bucket.list(BlobListOption.prefix(prefixPath));
blobs.iterateAll().forEach((Blob blob) -> {
if (blob.getName().endsWith(".js")) {
filePaths.add(blob.getName());
}
});
}
List<String> scripts = new ArrayList<>();
for (String filePath : filePaths) {
Blob b = bucket.get(filePath);
if (b == null || !b.exists()) {
throw new IllegalArgumentException(
"File does not exist, or do not have adequate permissions");
}
scripts.add(new String(b.getContent()));
}
return scripts;
}
示例4: testBucketListException_showsErrorMessage
import com.google.cloud.storage.Storage.BlobListOption; //導入依賴的package包/類
@Test
public void testBucketListException_showsErrorMessage() {
when(bucketVirtualFile.getBucket().list(any(BlobListOption.class), any(BlobListOption.class)))
.thenThrow(StorageException.class);
editorPanel = new GcsBucketContentEditorPanel(bucketVirtualFile.getBucket());
editorPanel.initTableModel();
JTable bucketTable = editorPanel.getBucketContentTable();
assertThat(bucketTable.getColumnCount()).isEqualTo(0);
assertThat(bucketTable.getRowCount()).isEqualTo(0);
assertFalse(editorPanel.getMessagePanel().isVisible());
assertFalse(editorPanel.getLoadingPanel().isVisible());
assertTrue(editorPanel.getErrorPanel().isVisible());
}
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-intellij,代碼行數:16,代碼來源:GcsBucketContentEditorPanelTest.java
示例5: loadBlobsStartingWith
import com.google.cloud.storage.Storage.BlobListOption; //導入依賴的package包/類
/**
* Returns the list of {@link Blob blobs} that start with the given prefix.
*
* <p>In the GCS backend there are no directories, just blobs with names. Implicit in the name,
* however, is a directory structure (e.g. "dir1/dir2/blob.zip"). Therefore, in order to create a
* directory browsing experience, we need to "unflatten" the blobs into a directory structure.
*
* <p>{@link Bucket#list(BlobListOption...)} provides options to help simulate directories by
* supplying the {@link BlobListOption#currentDirectory()} and {@link
* BlobListOption#prefix(String)} options. The prefix acts as the current directory for the blobs
* we wish to fetch.
*/
@SuppressWarnings("FutureReturnValueIgnored")
private void loadBlobsStartingWith(String prefix, Consumer<List<Blob>> afterLoad) {
showLoader();
hideError();
ThreadUtil.getInstance()
.executeInBackground(
() -> {
List<Blob> blobs;
try {
blobs =
Lists.newArrayList(
bucket
.list(BlobListOption.currentDirectory(), BlobListOption.prefix(prefix))
.iterateAll());
} catch (StorageException se) {
ApplicationManager.getApplication()
.invokeAndWait(
() -> {
hideLoader();
showError();
UsageTrackerProvider.getInstance()
.trackEvent(GctTracking.GCS_BLOB_BROWSE_EXCEPTION)
.ping();
log.warn(
"StorageException when performing GCS blob list operation, with message: "
+ se.getMessage());
});
return;
}
final List<Blob> loadedBlobs = blobs;
ApplicationManager.getApplication()
.invokeAndWait(
() -> {
hideLoader();
afterLoad.accept(loadedBlobs);
});
});
}