Skip to content

Commit 5009ffa

Browse files
authored
Merge pull request #5213 from microsoft/feature-track2-file-explorer
Merge feature track2 file explorer to develop
2 parents fa357b8 + de27023 commit 5009ffa

File tree

20 files changed

+533
-377
lines changed

20 files changed

+533
-377
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/ProcessComboBox.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
import com.intellij.ui.components.fields.ExtendableTextComponent;
1010
import com.microsoft.azure.management.appservice.WebAppBase;
1111
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
12-
import com.microsoft.azure.toolkit.lib.appservice.ProcessInfo;
1312
import com.microsoft.azure.toolkit.lib.appservice.jfr.FlightRecorderManager;
13+
import com.microsoft.azure.toolkit.lib.appservice.model.ProcessInfo;
14+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1415
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1516
import lombok.Getter;
1617
import lombok.Setter;
@@ -28,7 +29,7 @@
2829
public class ProcessComboBox extends AzureComboBox<ProcessInfo> {
2930
@Setter
3031
@Getter
31-
private WebAppBase appService;
32+
private IAppService appService;
3233

3334
@NotNull
3435
@Override

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/action/ProfileFlightRecordAction.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@
99
import com.intellij.openapi.progress.ProgressManager;
1010
import com.intellij.openapi.project.Project;
1111
import com.intellij.openapi.ui.DialogWrapper;
12-
import com.microsoft.azure.management.appservice.OperatingSystem;
13-
import com.microsoft.azure.management.appservice.WebAppBase;
1412
import com.microsoft.azure.toolkit.intellij.appservice.jfr.RunFlightRecorderDialog;
1513
import com.microsoft.azure.toolkit.lib.appservice.jfr.FlightRecorderConfiguration;
1614
import com.microsoft.azure.toolkit.lib.appservice.jfr.FlightRecorderManager;
1715
import com.microsoft.azure.toolkit.lib.appservice.jfr.FlightRecorderStarterBase;
16+
import com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem;
17+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1818
import com.microsoft.azure.toolkit.lib.appservice.utils.Utils;
1919
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle;
2020
import com.microsoft.azure.toolkit.lib.common.operation.IAzureOperationTitle;
2121
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
2222
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
2323
import com.microsoft.azuretools.core.mvp.model.AzureMvpModel;
24-
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
2524
import com.microsoft.azuretools.telemetry.TelemetryConstants;
2625
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
2726
import com.microsoft.intellij.util.PluginUtil;
@@ -50,12 +49,13 @@ public class ProfileFlightRecordAction extends NodeActionListener {
5049
private final Project project;
5150
private final String webAppId;
5251

53-
private WebAppBase appService;
52+
private IAppService appService;
5453

5554
public ProfileFlightRecordAction(WebAppNode webAppNode) {
5655
super();
5756
this.project = (Project) webAppNode.getProject();
5857
this.webAppId = webAppNode.getWebAppId();
58+
this.appService = webAppNode.getWebappManager();
5959
}
6060

6161
@Override
@@ -73,9 +73,7 @@ private void doProfileFlightRecorderAll() {
7373
// prerequisite check
7474
final String subscriptionId = AzureMvpModel.getSegment(webAppId, "subscriptions");
7575
// Always get latest app service status, workaround for https://dev.azure.com/mseng/VSJava/_workitems/edit/1797916
76-
appService = AzureWebAppMvpModel.getInstance().getWebAppById(subscriptionId, webAppId);
77-
if (appService.operatingSystem() == OperatingSystem.LINUX &&
78-
StringUtils.containsIgnoreCase(appService.linuxFxVersion(), "DOCKER|")) {
76+
if (appService.getRuntime().getOperatingSystem() == OperatingSystem.DOCKER) {
7977
final String message = message("webapp.flightRecord.error.notSupport.message", appService.name());
8078
notifyUserWithErrorMessage(message("webapp.flightRecord.error.notSupport.title"), message);
8179
return;
@@ -117,7 +115,7 @@ private void doProfileFlightRecorderAll() {
117115

118116
private FlightRecorderConfiguration collectFlightRecorderConfiguration() {
119117
RunFlightRecorderDialog ui = new RunFlightRecorderDialog(project, appService);
120-
ui.setTitle(message("webapp.flightRecord.task.startRecorder.title", appService.defaultHostName()));
118+
ui.setTitle(message("webapp.flightRecord.task.startRecorder.title", appService.hostName()));
121119
ui.setOkActionListener((config) -> {
122120
ui.close(DialogWrapper.OK_EXIT_CODE);
123121
});

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/jfr/RunFlightRecorderDialog.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
package com.microsoft.azure.toolkit.intellij.appservice.jfr;
77

88
import com.intellij.openapi.project.Project;
9-
import com.microsoft.azure.management.appservice.WebAppBase;
109
import com.microsoft.azure.toolkit.intellij.appservice.ProcessComboBox;
1110
import com.microsoft.azure.toolkit.intellij.common.AzureDialog;
12-
import com.microsoft.azure.toolkit.lib.appservice.ProcessInfo;
1311
import com.microsoft.azure.toolkit.lib.appservice.jfr.FlightRecorderConfiguration;
12+
import com.microsoft.azure.toolkit.lib.appservice.model.ProcessInfo;
13+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1414
import com.microsoft.azure.toolkit.lib.common.form.AzureForm;
1515
import com.microsoft.azure.toolkit.lib.common.form.AzureFormInput;
1616
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
@@ -28,9 +28,9 @@ public class RunFlightRecorderDialog extends AzureDialog<FlightRecorderConfigura
2828
private ProcessComboBox processComboBox1;
2929
private DurationPanel durationPanel;
3030

31-
private WebAppBase appService;
31+
private IAppService appService;
3232

33-
public RunFlightRecorderDialog(final Project project, WebAppBase appService) {
33+
public RunFlightRecorderDialog(final Project project, IAppService appService) {
3434
super(project);
3535
this.appService = appService;
3636
this.init();

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/appservice/TunnelProxy.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import com.google.common.base.Joiner;
99
import com.jcraft.jsch.*;
10-
import com.microsoft.azure.management.appservice.PublishingProfile;
11-
import com.microsoft.azure.management.appservice.WebAppBase;
10+
import com.microsoft.azure.toolkit.lib.appservice.model.PublishingProfile;
11+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1212
import com.microsoft.azure.toolkit.lib.common.utils.WebSocketSSLProxy;
1313
import org.apache.commons.io.IOUtils;
1414
import org.jetbrains.annotations.NotNull;
@@ -29,21 +29,21 @@ public class TunnelProxy {
2929
public static final String DEFAULT_SSH_PASSWORD = "Docker!";
3030
private static final Logger logger = Logger.getLogger(TunnelProxy.class.getName());
3131
private static final String LOCALHOST = "localhost";
32-
private WebAppBase webAppBase;
32+
private IAppService appService;
3333
private WebSocketSSLProxy wssProxy;
3434

35-
public TunnelProxy(@NotNull WebAppBase webAppBase) {
36-
this.webAppBase = webAppBase;
35+
public TunnelProxy(@NotNull IAppService webAppBase) {
36+
this.appService = webAppBase;
3737
reset();
3838
}
3939

4040
public void reset() {
41-
String host = webAppBase.defaultHostName().toLowerCase().replace("http://", "").replace("https://", "");
41+
String host = appService.hostName().toLowerCase().replace("http://", "").replace("https://", "");
4242
String[] parts = host.split("\\.", 2);
4343
host = Joiner.on('.').join(parts[0], "scm", parts[1]);
44-
PublishingProfile publishingProfile = webAppBase.getPublishingProfile();
44+
PublishingProfile publishingProfile = appService.getPublishingProfile();
4545
wssProxy = new WebSocketSSLProxy(String.format("wss://%s/AppServiceTunnel/Tunnel.ashx", host),
46-
publishingProfile.gitUsername(), publishingProfile.gitPassword());
46+
publishingProfile.getGitUsername(), publishingProfile.getGitPassword());
4747
}
4848

4949
public void close() {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/appservice/jfr/CommandOutput.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/appservice/jfr/FlightRecorderKuduClient.java

Lines changed: 0 additions & 171 deletions
This file was deleted.

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/appservice/jfr/FlightRecorderManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
package com.microsoft.azure.toolkit.lib.appservice.jfr;
77

8-
import com.microsoft.azure.management.appservice.OperatingSystem;
9-
import com.microsoft.azure.management.appservice.WebAppBase;
8+
import com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem;
9+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1010
import org.jetbrains.annotations.NotNull;
1111

1212
import java.util.Map;
@@ -17,14 +17,14 @@
1717
public class FlightRecorderManager {
1818
private static Map<String, FlightRecorderStarterBase> jfrStarters = new ConcurrentHashMap<>();
1919

20-
public static FlightRecorderStarterBase getFlightRecorderStarter(@NotNull WebAppBase appService) {
20+
public static FlightRecorderStarterBase getFlightRecorderStarter(@NotNull IAppService appService) {
2121
return jfrStarters.computeIfAbsent(appService.id(), id -> {
22-
if (appService.operatingSystem() == OperatingSystem.LINUX) {
22+
if (appService.getRuntime().getOperatingSystem() == OperatingSystem.LINUX) {
2323
return new LinuxFlightRecorderStarter(appService);
24-
} else if (appService.operatingSystem() == OperatingSystem.WINDOWS) {
24+
} else if (appService.getRuntime().getOperatingSystem() == OperatingSystem.WINDOWS) {
2525
return new WindowFlightRecorderStarter(appService);
2626
} else {
27-
throw new IllegalStateException(message("appService.jfr.error.unknownOs", appService.operatingSystem(), appService.name()));
27+
throw new IllegalStateException(message("appService.jfr.error.unknownOs", appService.getRuntime().getOperatingSystem(), appService.name()));
2828
}
2929
});
3030
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/appservice/jfr/FlightRecorderStarterBase.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55

66
package com.microsoft.azure.toolkit.lib.appservice.jfr;
77

8-
import com.microsoft.azure.management.appservice.WebAppBase;
9-
import com.microsoft.azure.toolkit.lib.appservice.ProcessInfo;
8+
import com.azure.core.util.FluxUtil;
9+
import com.microsoft.azure.toolkit.lib.appservice.model.ProcessInfo;
10+
import com.microsoft.azure.toolkit.lib.appservice.model.CommandOutput;
11+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
12+
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
1013
import org.jetbrains.annotations.NotNull;
1114

1215
import java.io.IOException;
1316
import java.util.List;
1417

1518
public abstract class FlightRecorderStarterBase {
16-
protected WebAppBase appService;
17-
protected FlightRecorderKuduClient client;
19+
protected IAppService appService;
1820

19-
public FlightRecorderStarterBase(@NotNull WebAppBase appService) {
21+
public FlightRecorderStarterBase(@NotNull IAppService appService) {
2022
this.appService = appService;
21-
client = new FlightRecorderKuduClient(appService);
2223
}
2324

2425
public abstract List<ProcessInfo> listProcess() throws IOException;
@@ -33,6 +34,7 @@ protected String constructJcmdCommand(int pid, int timeInSeconds, String fileNam
3334
public abstract CommandOutput startFlightRecorder(int pid, int timeInSeconds, String fileName) throws IOException;
3435

3536
public byte[] downloadJFRFile(String fileName) {
36-
return client.getFileContent(getFinalJfrPath(fileName));
37+
return FluxUtil.collectBytesInByteBufferStream(appService.getFileContent(getFinalJfrPath(fileName))).blockOptional()
38+
.orElseThrow(() -> new AzureToolkitRuntimeException(String.format("Failed to download JFR file %s from %s", fileName, appService.name())));
3739
}
3840
}

0 commit comments

Comments
 (0)