Search in sources :

Example 6 with AzureCmdException

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);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 7 with AzureCmdException

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);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 8 with AzureCmdException

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);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 9 with AzureCmdException

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);
    }
}
Also used : DockerContainer(com.microsoft.azure.docker.model.DockerContainer) DockerImage(com.microsoft.azure.docker.model.DockerImage) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 10 with AzureCmdException

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);
    }
}
Also used : Azure(com.microsoft.azure.management.Azure) RedisCache(com.microsoft.azure.management.redis.RedisCache) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ArrayList(java.util.ArrayList) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

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