Search in sources :

Example 1 with ResourceId

use of com.azure.resourcemanager.resources.fluentcore.arm.ResourceId in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyViewPresenter method getPublishingProfile.

protected boolean getPublishingProfile(@Nonnull String sid, @Nonnull String webAppId, @Nullable String name, @Nonnull String filePath) throws Exception {
    final ResourceId resourceId = ResourceId.fromString(webAppId);
    final File file = new File(Paths.get(filePath, String.format("%s_%s.PublishSettings", resourceId.name(), System.currentTimeMillis())).toString());
    try {
        file.createNewFile();
    } catch (final IOException e) {
        AzureMessager.getMessager().warning("failed to create publishing profile xml file");
        return false;
    }
    final IAppService resource = getWebAppBase(sid, webAppId, name);
    try (final InputStream inputStream = resource.listPublishingProfileXmlWithSecrets();
        final OutputStream outputStream = new FileOutputStream(file)) {
        IOUtils.copy(inputStream, outputStream);
        return true;
    } catch (final IOException e) {
        AzureMessager.getMessager().warning("failed to get publishing profile xml");
        return false;
    }
}
Also used : IAppService(com.microsoft.azure.toolkit.lib.appservice.service.IAppService) ResourceId(com.azure.resourcemanager.resources.fluentcore.arm.ResourceId) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 2 with ResourceId

use of com.azure.resourcemanager.resources.fluentcore.arm.ResourceId in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method openSqlServerPropertyView.

@Override
public void openSqlServerPropertyView(@NotNull String id, @NotNull Object project) {
    EventUtil.executeWithLog(ActionConstants.SqlServer.SHOW_PROPERTIES, (operation) -> {
        final ResourceId resourceId = ResourceId.fromString(id);
        final FileEditorManager fileEditorManager = getFileEditorManager(resourceId.subscriptionId(), resourceId.id(), (Project) project);
        if (fileEditorManager == null) {
            return;
        }
        LightVirtualFile itemVirtualFile = searchExistingFile(fileEditorManager, SqlServerPropertyViewProvider.TYPE, resourceId.id());
        if (itemVirtualFile == null) {
            itemVirtualFile = createVirtualFile(resourceId.name(), resourceId.subscriptionId(), resourceId.id());
            itemVirtualFile.setFileType(new AzureFileType(SqlServerPropertyViewProvider.TYPE, AzureIconLoader.loadIcon(AzureIconSymbol.SqlServer.MODULE)));
        }
        FileEditor[] editors = fileEditorManager.openFile(itemVirtualFile, true, true);
        for (FileEditor editor : editors) {
            if (editor.getName().equals(SqlServerPropertyView.ID) && editor instanceof SqlServerPropertyView) {
                ((SqlServerPropertyView) editor).onReadProperty(resourceId.subscriptionId(), resourceId.resourceGroupName(), resourceId.name());
            }
        }
    });
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) TableFileEditor(com.microsoft.intellij.helpers.storage.TableFileEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) QueueFileEditor(com.microsoft.intellij.helpers.storage.QueueFileEditor) BlobExplorerFileEditor(com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor) SqlServerPropertyView(com.microsoft.azure.toolkit.intellij.sqlserver.properties.SqlServerPropertyView) ResourceId(com.azure.resourcemanager.resources.fluentcore.arm.ResourceId) LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 3 with ResourceId

use of com.azure.resourcemanager.resources.fluentcore.arm.ResourceId in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method openMySQLPropertyView.

@Override
public void openMySQLPropertyView(@NotNull String id, @NotNull Object project) {
    EventUtil.executeWithLog(ActionConstants.MySQL.SHOW_PROPERTIES, (operation) -> {
        final ResourceId resourceId = ResourceId.fromString(id);
        final FileEditorManager fileEditorManager = getFileEditorManager(resourceId.subscriptionId(), resourceId.id(), (Project) project);
        if (fileEditorManager == null) {
            return;
        }
        LightVirtualFile itemVirtualFile = searchExistingFile(fileEditorManager, MySQLPropertyViewProvider.TYPE, resourceId.id());
        if (itemVirtualFile == null) {
            itemVirtualFile = createVirtualFile(resourceId.name(), resourceId.subscriptionId(), resourceId.id());
            itemVirtualFile.setFileType(new AzureFileType(MySQLPropertyViewProvider.TYPE, AzureIconLoader.loadIcon(AzureIconSymbol.MySQL.MODULE)));
        }
        FileEditor[] editors = fileEditorManager.openFile(itemVirtualFile, true, true);
        for (FileEditor editor : editors) {
            if (editor.getName().equals(MySQLPropertyView.ID) && editor instanceof MySQLPropertyView) {
                ((MySQLPropertyView) editor).onReadProperty(resourceId.subscriptionId(), resourceId.resourceGroupName(), resourceId.name());
            }
        }
    });
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) TableFileEditor(com.microsoft.intellij.helpers.storage.TableFileEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) QueueFileEditor(com.microsoft.intellij.helpers.storage.QueueFileEditor) BlobExplorerFileEditor(com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor) ResourceId(com.azure.resourcemanager.resources.fluentcore.arm.ResourceId) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MySQLPropertyView(com.microsoft.azure.toolkit.intellij.mysql.MySQLPropertyView)

Aggregations

ResourceId (com.azure.resourcemanager.resources.fluentcore.arm.ResourceId)3 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)2 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)2 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)2 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)2 MySQLPropertyView (com.microsoft.azure.toolkit.intellij.mysql.MySQLPropertyView)1 SqlServerPropertyView (com.microsoft.azure.toolkit.intellij.sqlserver.properties.SqlServerPropertyView)1 IAppService (com.microsoft.azure.toolkit.lib.appservice.service.IAppService)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1