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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations