Search in sources :

Example 36 with AzureCmdException

use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getTables.

@NotNull
public List<Table> getTables(@NotNull StorageAccount storageAccount) throws AzureCmdException {
    List<Table> tList = new ArrayList<Table>();
    try {
        CloudTableClient client = getCloudTableClient(storageAccount);
        for (String tableName : client.listTables()) {
            CloudTable cloudTable = client.getTableReference(tableName);
            String uri = cloudTable.getUri() != null ? cloudTable.getUri().toString() : "";
            tList.add(new Table(tableName, uri));
        }
        return tList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Table list", t);
    }
}
Also used : Table(com.microsoft.tooling.msservices.model.storage.Table) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 37 with AzureCmdException

use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method createTableEntity.

@NotNull
public TableEntity createTableEntity(@NotNull StorageAccount storageAccount, @NotNull String tableName, @NotNull String partitionKey, @NotNull String rowKey, @NotNull Map<String, Property> properties) throws AzureCmdException {
    try {
        CloudTableClient client = getCloudTableClient(storageAccount);
        CloudTable cloudTable = client.getTableReference(tableName);
        DynamicTableEntity entity = getDynamicTableEntity(partitionKey, rowKey, properties);
        TableRequestOptions tro = new TableRequestOptions();
        tro.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata);
        TableResult result = cloudTable.execute(TableOperation.insert(entity, true), tro, null);
        DynamicTableEntity resultEntity = result.getResultAsType();
        return getTableEntity(tableName, resultEntity);
    } catch (Throwable t) {
        throw new AzureCmdException("Error creating the Table Entity", t);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 38 with AzureCmdException

use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getRootDirectory.

@NotNull
public BlobDirectory getRootDirectory(@NotNull String connectionString, @NotNull BlobContainer blobContainer) throws AzureCmdException {
    try {
        CloudBlobClient client = getCloudBlobClient(connectionString);
        CloudBlobContainer container = client.getContainerReference(blobContainer.getName());
        CloudBlobDirectory directory = container.getDirectoryReference("");
        String uri = directory.getUri() != null ? directory.getUri().toString() : "";
        return new BlobDirectory("", uri, blobContainer.getName(), "");
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the root Blob Directory", t);
    }
}
Also used : BlobDirectory(com.microsoft.tooling.msservices.model.storage.BlobDirectory) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 39 with AzureCmdException

use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method deleteBlobFile.

public void deleteBlobFile(@NotNull String connectionString, @NotNull BlobFile blobFile) throws AzureCmdException {
    try {
        CloudBlobClient client = getCloudBlobClient(connectionString);
        String containerName = blobFile.getContainerName();
        CloudBlobContainer container = client.getContainerReference(containerName);
        CloudBlob blob = getCloudBlob(container, blobFile);
        blob.deleteIfExists();
    } catch (Throwable t) {
        throw new AzureCmdException("Error deleting the Blob File", t);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 40 with AzureCmdException

use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method downloadBlobFileContent.

public void downloadBlobFileContent(@NotNull String connectionString, @NotNull BlobFile blobFile, @NotNull OutputStream content) throws AzureCmdException {
    try {
        CloudBlobClient client = getCloudBlobClient(connectionString);
        String containerName = blobFile.getContainerName();
        CloudBlobContainer container = client.getContainerReference(containerName);
        CloudBlob blob = getCloudBlob(container, blobFile);
        blob.download(content);
    } catch (Throwable t) {
        throw new AzureCmdException("Error downloading the Blob File content", t);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Aggregations

AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)55 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)20 BlobFile (com.microsoft.tooling.msservices.model.storage.BlobFile)8 CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)7 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 Task (com.intellij.openapi.progress.Task)5 Azure (com.microsoft.azure.management.Azure)5 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)5 NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)5 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)5 IOException (java.io.IOException)5 BlobDirectory (com.microsoft.tooling.msservices.model.storage.BlobDirectory)4 BlobItem (com.microsoft.tooling.msservices.model.storage.BlobItem)4 ArrayList (java.util.ArrayList)4 CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)3 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)3 BlobContainer (com.microsoft.tooling.msservices.model.storage.BlobContainer)3 FileInputStream (java.io.FileInputStream)3 SocketTimeoutException (java.net.SocketTimeoutException)3