use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method deleteTableEntity.
public void deleteTableEntity(@NotNull StorageAccount storageAccount, @NotNull TableEntity tableEntity) throws AzureCmdException {
try {
CloudTableClient client = getCloudTableClient(storageAccount);
CloudTable cloudTable = client.getTableReference(tableEntity.getTableName());
DynamicTableEntity entity = getDynamicTableEntity(tableEntity);
TableRequestOptions tro = new TableRequestOptions();
tro.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata);
cloudTable.execute(TableOperation.delete(entity), tro, null);
} catch (Throwable t) {
throw new AzureCmdException("Error deleting the Table Entity", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method getBlobContainers.
@NotNull
public List<BlobContainer> getBlobContainers(@NotNull String connectionString) throws AzureCmdException {
List<BlobContainer> bcList = new ArrayList<BlobContainer>();
try {
CloudBlobClient client = getCloudBlobClient(connectionString);
for (CloudBlobContainer container : client.listContainers(null, ContainerListingDetails.ALL, null, null)) {
String uri = container.getUri() != null ? container.getUri().toString() : "";
String eTag = "";
Calendar lastModified = new GregorianCalendar();
BlobContainerProperties properties = container.getProperties();
if (properties != null) {
eTag = Strings.nullToEmpty(properties.getEtag());
if (properties.getLastModified() != null) {
lastModified.setTime(properties.getLastModified());
}
}
String publicReadAccessType = "";
BlobContainerPermissions blobContainerPermissions = container.downloadPermissions();
if (blobContainerPermissions != null && blobContainerPermissions.getPublicAccess() != null) {
publicReadAccessType = blobContainerPermissions.getPublicAccess().toString();
}
bcList.add(new BlobContainer(Strings.nullToEmpty(container.getName()), uri, eTag, lastModified, publicReadAccessType));
}
return bcList;
} catch (Throwable t) {
throw new AzureCmdException("Error retrieving the Blob Container list", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class AzureModule method refreshFromAzure.
@Override
protected void refreshFromAzure() throws AzureCmdException {
try {
if (AuthMethodManager.getInstance().isSignedIn()) {
vmArmServiceModule.load(true);
redisCacheModule.load(true);
storageModule.load(true);
webappsModule.load(true);
hdInsightModule.load(true);
dockerHostModule.load(true);
}
} catch (Exception e) {
throw new AzureCmdException("Error loading Azure Explorer modules", e);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class DockerContainerNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
try {
Map<String, DockerImage> dockerImages = AzureDockerImageOps.getImages(dockerHost);
Map<String, DockerContainer> dockerContainers = AzureDockerContainerOps.getContainers(dockerHost);
AzureDockerContainerOps.setContainersAndImages(dockerContainers, dockerImages);
dockerHost.dockerImages = dockerImages;
if (dockerContainers != null) {
DockerContainer updatedDockerContainer = dockerContainers.get(dockerContainer.name);
if (updatedDockerContainer != null) {
dockerContainer = updatedDockerContainer;
setDockerContainerIconPath();
}
}
} catch (Exception e) {
DefaultLoader.getUIHelper().logError(e.getMessage(), e);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class RedisCacheModule method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
List<Pair<String, String>> failedSubscriptions = new ArrayList<>();
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
Set<String> sidList = subscriptionManager.getAccountSidList();
for (String sid : sidList) {
try {
Azure azure = azureManager.getAzure(sid);
for (RedisCache cache : azure.redisCaches().list()) {
addChildNode(new RedisCacheNode(this, sid, cache));
}
} catch (Exception ex) {
failedSubscriptions.add(new ImmutablePair<>(sid, ex.getMessage()));
continue;
}
}
} catch (Exception ex) {
DefaultLoader.getUIHelper().logError("An error occurred when trying to load Redis Caches\n\n" + ex.getMessage(), ex);
}
if (!failedSubscriptions.isEmpty()) {
StringBuilder errorMessage = new StringBuilder("An error occurred when trying to load Redis Caches for the subscriptions:\n\n");
for (Pair error : failedSubscriptions) {
errorMessage.append(error.getKey()).append(": ").append(error.getValue()).append("\n");
}
DefaultLoader.getUIHelper().logError("An error occurred when trying to load Redis Caches\n\n" + errorMessage.toString(), null);
}
}
Aggregations