66package com .microsoft .azure .toolkit .intellij .springcloud .streaminglog ;
77
88import com .intellij .openapi .project .Project ;
9- import com .microsoft .azure .management .appplatform .v2020_07_01 .DeploymentInstance ;
10- import com .microsoft .azure .management .appplatform .v2020_07_01 .implementation .AppPlatformManager ;
119import com .microsoft .azure .management .resources .fluentcore .arm .ResourceId ;
1210import com .microsoft .azure .management .resources .fluentcore .arm .ResourceUtils ;
1311import com .microsoft .azure .toolkit .lib .Azure ;
1715import com .microsoft .azure .toolkit .lib .common .task .AzureTaskManager ;
1816import com .microsoft .azure .toolkit .lib .springcloud .AzureSpringCloud ;
1917import com .microsoft .azure .toolkit .lib .springcloud .SpringCloudApp ;
18+ import com .microsoft .azure .toolkit .lib .springcloud .SpringCloudCluster ;
2019import com .microsoft .azure .toolkit .lib .springcloud .SpringCloudDeployment ;
21- import com .microsoft .azuretools . authmanage . AuthMethodManager ;
20+ import com .microsoft .azure . toolkit . lib . springcloud . SpringCloudDeploymentInstanceEntity ;
2221import com .microsoft .azuretools .azurecommons .helpers .AzureCmdException ;
2322import com .microsoft .azuretools .telemetrywrapper .EventUtil ;
2423import com .microsoft .intellij .util .PluginUtil ;
3231import org .apache .commons .lang .StringUtils ;
3332
3433import java .util .List ;
34+ import java .util .Objects ;
3535import java .util .Optional ;
3636
3737import static com .microsoft .azuretools .telemetry .TelemetryConstants .SPRING_CLOUD ;
@@ -58,7 +58,8 @@ public SpringCloudStreamingLogAction(SpringCloudAppNode springCloudAppNode) {
5858 final ResourceId appId = ResourceId .fromString (this .appId );
5959 final String subscriptionId = appId .subscriptionId ();
6060 final String clusterName = appId .parent ().name ();
61- this .app = Azure .az (AzureSpringCloud .class ).subscription (subscriptionId ).cluster (clusterName ).app (appId .name ());
61+ final SpringCloudCluster cluster = Azure .az (AzureSpringCloud .class ).subscription (subscriptionId ).cluster (clusterName );
62+ this .app = Objects .requireNonNull (cluster , String .format ("cluster(%s) not exist" , clusterName )).app (appId .name ());
6263 }
6364
6465 @ Override
@@ -74,7 +75,7 @@ protected void actionPerformed(NodeActionEvent nodeActionEvent) throws AzureCmdE
7475 PluginUtil .displayWarningDialog (FAILED_TO_START_LOG_STREAMING , NO_ACTIVE_DEPLOYMENT ));
7576 return ;
7677 }
77- final List <DeploymentInstance > instances = deployment .entity ().getInstances ();
78+ final List <SpringCloudDeploymentInstanceEntity > instances = deployment .entity ().getInstances ();
7879 if (CollectionUtils .isEmpty (instances )) {
7980 DefaultLoader .getIdeHelper ().invokeLater (() ->
8081 PluginUtil .displayWarningDialog (FAILED_TO_START_LOG_STREAMING , NO_AVAILABLE_INSTANCES ));
@@ -90,12 +91,12 @@ protected void actionPerformed(NodeActionEvent nodeActionEvent) throws AzureCmdE
9091 });
9192 }
9293
93- private void showLogStreamingDialog (List <DeploymentInstance > instances ) {
94+ private void showLogStreamingDialog (List <? extends SpringCloudDeploymentInstanceEntity > instances ) {
9495 DefaultLoader .getIdeHelper ().invokeLater (() -> {
9596 final SpringCloudStreamingLogDialog dialog = new SpringCloudStreamingLogDialog (project , instances );
9697 if (dialog .showAndGet ()) {
97- final DeploymentInstance target = dialog .getInstance ();
98- SpringCloudStreamingLogManager .getInstance ().showStreamingLog (project , appId , target .name ());
98+ final SpringCloudDeploymentInstanceEntity target = dialog .getInstance ();
99+ SpringCloudStreamingLogManager .getInstance ().showStreamingLog (project , appId , target .getName ());
99100 }
100101 });
101102 }
@@ -114,8 +115,4 @@ protected String getOperationName(final NodeActionEvent event) {
114115 public int getGroup () {
115116 return Groupable .DIAGNOSTIC_GROUP ;
116117 }
117-
118- private static AppPlatformManager getSpringManager (String sid ) {
119- return AuthMethodManager .getInstance ().getAzureSpringCloudClient (sid );
120- }
121118}
0 commit comments