Skip to content

Commit 7785675

Browse files
committed
refactor openResourceInPortal to make it a common method
1 parent ba37d9f commit 7785675

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterForm.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ public void getData(@NotNull AddNewClusterModel data) {
280280

281281
public void afterOkActionPerformed() {
282282
if (hdInsightModule != null) {
283-
hdInsightModule.load(false);
283+
// FIXME: There is a bug for linking cluster action: If the cluster name already exists, the linked cluster
284+
// will fail to be added to cache. If we don't force refresh again, the cluster will not be shown as linked
285+
// state in Azure Explorer.
286+
hdInsightModule.load(true);
284287
}
285288
}
286289

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/Node.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.google.common.base.Predicate;
2525
import com.google.common.collect.ImmutableList;
2626
import com.google.common.collect.Iterators;
27-
import com.microsoft.azure.management.resources.fluentcore.arm.models.HasId;
2827
import com.microsoft.azuretools.authmanage.AuthMethodManager;
2928
import com.microsoft.azuretools.azurecommons.helpers.AzureCmdException;
3029
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
@@ -53,7 +52,6 @@ public class Node implements MvpView, BasicTelemetryProperty {
5352
public static final String REST_SEGMENT_JOB_MANAGEMENT_TENANTID = "/#@";
5453
public static final String REST_SEGMENT_JOB_MANAGEMENT_RESOURCE = "/resource";
5554
public static final String OPEN_RESOURCES_IN_PORTAL_FAILED = "Fail to open resources in portal.";
56-
public static final String OPEN_RESOURCES_IN_PORTAL_NOT_SUPPORTED = "Open browsers is not supported in current system";
5755

5856
protected static Map<Class<? extends Node>, ImmutableList<Class<? extends NodeActionListener>>> node2Actions;
5957

@@ -399,7 +397,7 @@ public String getServiceName() {
399397
return TelemetryConstants.ACTION;
400398
}
401399

402-
public void openResourcesInPortal(HasId resource, String subscriptionId) throws AzureCmdException {
400+
public void openResourcesInPortal(String subscriptionId, String resourceRelativePath) throws AzureCmdException {
403401
try {
404402
final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
405403
// not signed in
@@ -412,7 +410,7 @@ public void openResourcesInPortal(HasId resource, String subscriptionId) throws
412410
+ REST_SEGMENT_JOB_MANAGEMENT_TENANTID
413411
+ tenantId
414412
+ REST_SEGMENT_JOB_MANAGEMENT_RESOURCE
415-
+ resource.id();
413+
+ resourceRelativePath;
416414
DefaultLoader.getIdeHelper().openLinkInBrowser(url);
417415
} catch (IOException e) {
418416
throw new AzureCmdException(OPEN_RESOURCES_IN_PORTAL_FAILED, e);

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/storage/StorageNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public OpenInPortalAction() {
7373

7474
@Override
7575
protected void azureNodeAction(NodeActionEvent e) throws AzureCmdException {
76-
openResourcesInPortal(storageAccount, subscriptionId);
76+
openResourcesInPortal(subscriptionId, storageAccount.id());
7777
}
7878

7979
@Override

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/serverexplore/hdinsightnode/StorageAccountNode.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,15 @@
2727
import com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail;
2828
import com.microsoft.azure.hdinsight.sdk.storage.IHDIStorageAccount;
2929
import com.microsoft.azure.hdinsight.sdk.storage.StorageAccountType;
30-
import com.microsoft.azuretools.authmanage.AuthMethodManager;
3130
import com.microsoft.azuretools.azurecommons.helpers.AzureCmdException;
3231
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
33-
import com.microsoft.azuretools.sdkmanage.AzureManager;
3432
import com.microsoft.azuretools.telemetry.AppInsightsConstants;
3533
import com.microsoft.azuretools.telemetry.TelemetryConstants;
3634
import com.microsoft.azuretools.telemetry.TelemetryProperties;
37-
import com.microsoft.tooling.msservices.components.DefaultLoader;
3835
import com.microsoft.tooling.msservices.serviceexplorer.Node;
3936
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent;
4037
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener;
4138

42-
import java.io.IOException;
4339
import java.util.HashMap;
4440
import java.util.Map;
4541

@@ -66,24 +62,9 @@ protected void loadAdditionalActions() {
6662
addAction("Open Storage in Azure Management Portal", new NodeActionListener() {
6763
@Override
6864
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
69-
try {
70-
final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
71-
// not signed in
72-
if (azureManager == null) {
73-
return;
74-
}
75-
final String portalUrl = azureManager.getPortalUrl();
76-
final String tenantId = clusterDetail.getSubscription().getTenantId();
77-
String url = portalUrl
78-
+ REST_SEGMENT_JOB_MANAGEMENT_TENANTID
79-
+ tenantId
80-
+ REST_SEGMENT_JOB_MANAGEMENT_RESOURCE
81-
+ ((ClusterDetail) clusterDetail).getId()
82-
+ REST_SEGMENT_STORAGE_ACCOUNT;
83-
DefaultLoader.getIdeHelper().openLinkInBrowser(url);
84-
} catch (IOException ex) {
85-
throw new AzureCmdException(OPEN_RESOURCES_IN_PORTAL_FAILED, ex);
86-
}
65+
String subscriptionId = clusterDetail.getSubscription().getSubscriptionId();
66+
String storageRelativePath = ((ClusterDetail) clusterDetail).getId() + REST_SEGMENT_STORAGE_ACCOUNT;
67+
openResourcesInPortal(subscriptionId, storageRelativePath);
8768
}
8869
});
8970
}

0 commit comments

Comments
 (0)