use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method deleteSelectedFile.
private void deleteSelectedFile() {
final BlobFile blobItem = getFileSelection();
if (blobItem != null) {
if (JOptionPane.showConfirmDialog(mainPanel, "Are you sure you want to delete this blob?", "Delete Blob", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION) {
setUIState(true);
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Deleting blob...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
try {
StorageClientSDKManager.getManager().deleteBlobFile(connectionString, blobItem);
if (blobItems.size() <= 1) {
directoryQueue.clear();
directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
queryTextField.setText("");
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
fillGrid();
}
});
} catch (AzureCmdException ex) {
String msg = "An error occurred while attempting to delete blob." + "\n" + String.format(message("webappExpMsg"), ex.getMessage());
PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex);
}
}
});
}
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class IDEHelperImpl method buildArtifact.
@NotNull
@Override
public ListenableFuture<String> buildArtifact(@NotNull ProjectDescriptor projectDescriptor, @NotNull ArtifactDescriptor artifactDescriptor) {
try {
Project project = findOpenProject(projectDescriptor);
final Artifact artifact = findProjectArtifact(project, artifactDescriptor);
final SettableFuture<String> future = SettableFuture.create();
Futures.addCallback(buildArtifact(project, artifact, false), new FutureCallback<Boolean>() {
@Override
public void onSuccess(@Nullable Boolean succeded) {
if (succeded != null && succeded) {
future.set(artifact.getOutputFilePath());
} else {
future.setException(new AzureCmdException("An error occurred while building the artifact"));
}
}
@Override
public void onFailure(Throwable throwable) {
if (throwable instanceof ExecutionException) {
future.setException(new AzureCmdException("An error occurred while building the artifact", throwable.getCause()));
} else {
future.setException(new AzureCmdException("An error occurred while building the artifact", throwable));
}
}
});
return future;
} catch (AzureCmdException e) {
return Futures.immediateFailedFuture(e);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageAccountFolderNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
if (clusterDetail != null && !clusterDetail.isEmulator()) {
try {
clusterDetail.getConfigurationInfo(getProject());
addChildNode(new StorageAccountNode(this, clusterDetail.getStorageAccount(), true));
List<HDStorageAccount> additionalStorageAccount = clusterDetail.getAdditionalStorageAccounts();
if (additionalStorageAccount != null) {
for (HDStorageAccount account : additionalStorageAccount) {
addChildNode(new StorageNode(this, account, false));
}
}
} catch (Exception exception) {
DefaultLoader.getUIHelper().showException("Failed to get HDInsight cluster configuration.", exception, "HDInsight Explorer", false, true);
}
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class WebAppUtils method createAppService.
public static WebApp createAppService(IProgressIndicator progressIndicator, CreateAppServiceModel model) throws IOException, WebAppException, InterruptedException, AzureCmdException {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return null;
}
Azure azure = azureManager.getAzure(model.subscriptionDetail.getSubscriptionId());
AppServicePlan appServicePlan = null;
if (model.isAppServicePlanCreateNew) {
AppServicePlan.DefinitionStages.WithGroup ds1 = azure.appServices().appServicePlans().define(model.appServicePlanNameCreateNew).withRegion(model.appServicePlanLocationCreateNew.name());
AppServicePlan.DefinitionStages.WithPricingTier ds2;
if (model.isResourceGroupCreateNew) {
ds2 = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
} else {
ds2 = ds1.withExistingResourceGroup(model.resourceGroup);
}
appServicePlan = ds2.withPricingTier(model.appServicePricingTierCreateNew).withOperatingSystem(OperatingSystem.WINDOWS).create();
} else {
appServicePlan = model.appServicePlan;
}
WebApp.DefinitionStages.Blank definitionStages = azure.webApps().define(model.webAppName);
WebAppBase.DefinitionStages.WithCreate<WebApp> withCreate;
WebApp.DefinitionStages.ExistingWindowsPlanWithGroup ds1 = definitionStages.withExistingWindowsPlan(appServicePlan);
if (model.isResourceGroupCreateNew) {
withCreate = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
} else {
withCreate = ds1.withExistingResourceGroup(model.resourceGroup);
}
if (model.jdkDownloadUrl == null) {
// no custom jdk
withCreate = withCreate.withJavaVersion(JavaVersion.JAVA_8_NEWEST).withWebContainer(model.webContainer);
}
WebApp myWebApp = withCreate.create();
if (model.jdkDownloadUrl != null) {
progressIndicator.setText("Deploying custom jdk...");
WebAppUtils.deployCustomJdk(myWebApp, model.jdkDownloadUrl, model.webContainer, progressIndicator);
}
// update cache
if (model.isResourceGroupCreateNew) {
ResourceGroup rg = azure.resourceGroups().getByName(model.resourceGroupNameCreateNew);
if (rg == null) {
throw new AzureCmdException(String.format("azure.resourceGroups().getByName(%s) returned null"), model.resourceGroupNameCreateNew);
}
AzureModelController.addNewResourceGroup(model.subscriptionDetail, rg);
AzureModelController.addNewWebAppToJustCreatedResourceGroup(rg, myWebApp);
if (model.isAppServicePlanCreateNew) {
AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, appServicePlan);
} else {
// add empty list
AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, null);
}
} else {
ResourceGroup rg = model.resourceGroup;
AzureModelController.addNewWebAppToExistingResourceGroup(rg, myWebApp);
if (model.isAppServicePlanCreateNew) {
//AppServicePlan asp = azure.appServices().appServicePlans().getById(myWebApp.appServicePlanId());
AzureModelController.addNewAppServicePlanToExistingResourceGroup(rg, appServicePlan);
}
}
return myWebApp;
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class ClusterManager method getClusterDetails.
private List<IClusterDetail> getClusterDetails(List<SubscriptionDetail> subscriptions, final Object project) throws AggregatedException {
ExecutorService taskExecutor = Executors.newFixedThreadPool(MAX_CONCURRENT);
final List<IClusterDetail> cachedClusterList = new ArrayList<>();
final List<Exception> aggregateExceptions = new ArrayList<>();
for (SubscriptionDetail subscription : subscriptions) {
taskExecutor.execute(new CommonRunnable<SubscriptionDetail, Exception>(subscription) {
@Override
public void runSpecificParameter(SubscriptionDetail parameter) throws IOException, HDIException, AzureCmdException {
IClusterOperation clusterOperation = new ClusterOperationImpl(project);
List<ClusterRawInfo> clusterRawInfoList = clusterOperation.listCluster(parameter);
if (clusterRawInfoList != null) {
for (ClusterRawInfo item : clusterRawInfoList) {
IClusterDetail tempClusterDetail = new ClusterDetail(parameter, item);
synchronized (ClusterManager.class) {
cachedClusterList.add(tempClusterDetail);
}
}
}
}
@Override
public void exceptionHandle(Exception e) {
synchronized (aggregateExceptions) {
aggregateExceptions.add(e);
}
}
});
}
taskExecutor.shutdown();
try {
taskExecutor.awaitTermination(TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException exception) {
aggregateExceptions.add(exception);
}
if (aggregateExceptions.size() > 0) {
throw new AggregatedException(aggregateExceptions);
}
return cachedClusterList;
}
Aggregations