Search in sources :

Example 41 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull 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 42 with NotNull

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

the class StorageClientSDKManager method getQueueMessages.

@NotNull
public List<QueueMessage> getQueueMessages(@NotNull StorageAccount storageAccount, @NotNull Queue queue) throws AzureCmdException {
    List<QueueMessage> qmList = new ArrayList<QueueMessage>();
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        String queueName = queue.getName();
        CloudQueue cloudQueue = client.getQueueReference(queueName);
        for (CloudQueueMessage cqm : cloudQueue.peekMessages(32)) {
            String id = Strings.nullToEmpty(cqm.getId());
            String content = Strings.nullToEmpty(cqm.getMessageContentAsString());
            Calendar insertionTime = new GregorianCalendar();
            if (cqm.getInsertionTime() != null) {
                insertionTime.setTime(cqm.getInsertionTime());
            }
            Calendar expirationTime = new GregorianCalendar();
            if (cqm.getExpirationTime() != null) {
                expirationTime.setTime(cqm.getExpirationTime());
            }
            int dequeueCount = cqm.getDequeueCount();
            qmList.add(new QueueMessage(id, queueName, content, insertionTime, expirationTime, dequeueCount));
        }
        return qmList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Queue Message list", t);
    }
}
Also used : QueueMessage(com.microsoft.tooling.msservices.model.storage.QueueMessage) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 43 with NotNull

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

the class StorageClientSDKManager method getQueues.

@NotNull
public List<Queue> getQueues(@NotNull StorageAccount storageAccount) throws AzureCmdException {
    List<Queue> qList = new ArrayList<Queue>();
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        for (CloudQueue cloudQueue : client.listQueues(null, QueueListingDetails.ALL, null, null)) {
            String uri = cloudQueue.getUri() != null ? cloudQueue.getUri().toString() : "";
            qList.add(new Queue(Strings.nullToEmpty(cloudQueue.getName()), uri, cloudQueue.getApproximateMessageCount()));
        }
        return qList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Queue list", t);
    }
}
Also used : CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) Queue(com.microsoft.tooling.msservices.model.storage.Queue) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 44 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull 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 45 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull 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)

Aggregations

NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)65 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)21 Nullable (com.microsoft.azuretools.azurecommons.helpers.Nullable)8 File (java.io.File)8 IOException (java.io.IOException)8 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)7 java.util (java.util)7 Observable (rx.Observable)7 URI (java.net.URI)6 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)5 ObjectConvertUtils (com.microsoft.azure.hdinsight.sdk.rest.ObjectConvertUtils)5 List (java.util.List)5 StringUtils (org.apache.commons.lang3.StringUtils)5 Project (com.intellij.openapi.project.Project)4 CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)4 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)4 ExecutionException (java.util.concurrent.ExecutionException)4 Collectors (java.util.stream.Collectors)4 ExecutionException (com.intellij.execution.ExecutionException)3 Artifact (com.intellij.packaging.artifacts.Artifact)3