Skip to content

Commit acba5d7

Browse files
committed
Merge branch 'release'
2 parents 177e1b5 + 287fe17 commit acba5d7

File tree

11 files changed

+93
-52
lines changed

11 files changed

+93
-52
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/run/SparkBatchJobRunner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ protected SparkSubmissionParameter updateStorageConfigForSubmissionParameter(Spa
9393
? new SparkConfigures(existingConfigEntry)
9494
: new SparkConfigures();
9595
wrappedConfig.put("spark.hadoop." + fsRoot.getHadoopBlobFsPropertyKey(), storageKey);
96+
// We need the following config to fix issue https://github.com/microsoft/azure-tools-for-java/issues/5002
97+
wrappedConfig.put("spark.hadoop." + fsRoot.getKeyProviderPropertyKey(), fsRoot.getDefaultKeyProviderPropertyValue());
9698
submissionParameter.getJobConfig().put(SparkSubmissionParameter.Conf, wrappedConfig);
9799
} catch (final UnknownFormatConversionException error) {
98100
final String errorHint = "Azure blob storage uploading path is not in correct format";

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureArtifactComboBox.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void addOrSelectExistingVirtualFile(VirtualFile virtualFile) {
126126
final List<AzureArtifact> artifacts = this.getItems();
127127
final AzureArtifactManager manager = AzureArtifactManager.getInstance(project);
128128
final AzureArtifact existingArtifact =
129-
artifacts.stream().filter(artifact -> manager.equalsAzureArtifactIdentifier(artifact, selectArtifact)).findFirst().orElse(null);
129+
artifacts.stream().filter(artifact -> manager.equalsAzureArtifact(artifact, selectArtifact)).findFirst().orElse(null);
130130
if (existingArtifact == null) {
131131
this.addItem(selectArtifact);
132132
this.setSelectedItem(selectArtifact);
@@ -141,7 +141,7 @@ private void resetDefaultValue(final AzureArtifact defaultArtifact) {
141141
}
142142
final List<AzureArtifact> artifacts = this.getItems();
143143
final AzureArtifactManager manager = AzureArtifactManager.getInstance(project);
144-
final Predicate<AzureArtifact> predicate = artifact -> manager.equalsAzureArtifactIdentifier(defaultArtifact, artifact);
144+
final Predicate<AzureArtifact> predicate = artifact -> manager.equalsAzureArtifact(defaultArtifact, artifact);
145145
final AzureArtifact toSelect = artifacts.stream().filter(predicate).findFirst().orElse(null);
146146
if (toSelect != null) {
147147
this.setSelectedItem(toSelect);

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureArtifactManager.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import static com.microsoft.azure.toolkit.intellij.common.AzureArtifactType.File;
3434

3535
public class AzureArtifactManager {
36-
private static Map<Project, AzureArtifactManager> projectAzureArtifactManagerMap = new HashMap<>();
36+
private static final Map<Project, AzureArtifactManager> projectAzureArtifactManagerMap = new HashMap<>();
3737
private final Project project;
3838

3939
private AzureArtifactManager(Project project) {
@@ -116,10 +116,15 @@ public String getPackaging(AzureArtifact artifact) {
116116
}
117117
}
118118

119-
public boolean equalsAzureArtifactIdentifier(AzureArtifact artifact1, AzureArtifact artifact2) {
119+
public boolean equalsAzureArtifact(AzureArtifact artifact1, AzureArtifact artifact2) {
120120
if (Objects.isNull(artifact1) || Objects.isNull(artifact2)) {
121121
return artifact1 == artifact2;
122122
}
123+
if (artifact1.getType() != artifact2.getType()) {
124+
// Artifact with different type may have same identifier, for instance, File and Artifact, both of them use file path as identifier
125+
// todo: re-design identifier, make it include the artifact type info
126+
return false;
127+
}
123128
return StringUtils.equals(getArtifactIdentifier(artifact1), getArtifactIdentifier(artifact2));
124129
}
125130

@@ -146,34 +151,28 @@ public Module getModuleFromAzureArtifact(AzureArtifact azureArtifact) {
146151
}
147152

148153
private String getGradleProjectId(ExternalProjectPojo gradleProjectPojo) {
149-
ExternalProject externalProject = getRelatedExternalProject(gradleProjectPojo);
154+
final ExternalProject externalProject = getRelatedExternalProject(gradleProjectPojo);
150155
return Objects.nonNull(externalProject) ? externalProject.getQName() : null;
151156
}
152157

153158
private ExternalProject getRelatedExternalProject(ExternalProjectPojo gradleProjectPojo) {
154-
ExternalProject externalProject =
155-
ExternalProjectDataCache.getInstance(project).getRootExternalProject(gradleProjectPojo.getPath());
156-
return externalProject;
159+
return ExternalProjectDataCache.getInstance(project).getRootExternalProject(gradleProjectPojo.getPath());
157160
}
158161

159162
private List<AzureArtifact> prepareAzureArtifacts(Predicate<String> packagingFilter) {
160-
List<AzureArtifact> azureArtifacts = new ArrayList<>();
161-
List<ExternalProjectPojo> gradleProjects = GradleUtils.listGradleProjects(project);
163+
final List<AzureArtifact> azureArtifacts = new ArrayList<>();
164+
final List<ExternalProjectPojo> gradleProjects = GradleUtils.listGradleProjects(project);
162165
if (Objects.nonNull(gradleProjects)) {
163166
azureArtifacts.addAll(gradleProjects.stream()
164167
.map(AzureArtifact::createFromGradleProject)
165168
.collect(Collectors.toList()));
166169
}
167-
List<MavenProject> mavenProjects = MavenProjectsManager.getInstance(project).getProjects();
168-
if (Objects.nonNull(mavenProjects)) {
169-
azureArtifacts.addAll(
170-
mavenProjects.stream().map(AzureArtifact::createFromMavenProject).collect(Collectors.toList()));
171-
}
172-
List<Artifact> artifactList = MavenRunTaskUtil.collectProjectArtifact(project);
173-
if (Objects.nonNull(artifactList)) {
174-
azureArtifacts.addAll(
175-
artifactList.stream().map(AzureArtifact::createFromArtifact).collect(Collectors.toList()));
176-
}
170+
final List<MavenProject> mavenProjects = MavenProjectsManager.getInstance(project).getProjects();
171+
azureArtifacts.addAll(mavenProjects.stream().map(AzureArtifact::createFromMavenProject).collect(Collectors.toList()));
172+
173+
final List<Artifact> artifactList = MavenRunTaskUtil.collectProjectArtifact(project);
174+
azureArtifacts.addAll(artifactList.stream().map(AzureArtifact::createFromArtifact).collect(Collectors.toList()));
175+
177176
if (packagingFilter == null) {
178177
return azureArtifacts;
179178
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureSettingPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected void artifactActionPerformed(Artifact selectArtifact) {
160160
}
161161

162162
protected void syncBeforeRunTasks(AzureArtifact azureArtifact, @NotNull final RunConfiguration configuration) {
163-
if (!AzureArtifactManager.getInstance(configuration.getProject()).equalsAzureArtifactIdentifier(lastSelectedAzureArtifact, azureArtifact)) {
163+
if (!AzureArtifactManager.getInstance(configuration.getProject()).equalsAzureArtifact(lastSelectedAzureArtifact, azureArtifact)) {
164164
final JPanel pnlRoot = getMainPanel();
165165
final DataContext context = DataManager.getInstance().getDataContext(pnlRoot);
166166
final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(context);

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/FunctionDeployConfiguration.java

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

66
package com.microsoft.azure.toolkit.intellij.function.runner.deploy;
77

8-
import com.intellij.execution.ExecutionException;
98
import com.intellij.execution.Executor;
109
import com.intellij.execution.configurations.ConfigurationFactory;
1110
import com.intellij.execution.configurations.RunConfiguration;
@@ -19,8 +18,8 @@
1918
import com.intellij.openapi.project.Project;
2019
import com.microsoft.azure.common.function.configurations.RuntimeConfiguration;
2120
import com.microsoft.azure.management.appservice.FunctionApp;
22-
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
2321
import com.microsoft.azure.toolkit.intellij.common.AzureRunConfigurationBase;
22+
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
2423
import com.microsoft.azure.toolkit.intellij.function.runner.core.FunctionUtils;
2524
import org.apache.commons.lang.StringUtils;
2625
import org.jetbrains.annotations.NotNull;
@@ -67,7 +66,7 @@ public String getFunctionId() {
6766
return functionDeployModel.getFunctionId();
6867
}
6968

70-
public Map getAppSettings() {
69+
public Map<String, String> getAppSettings() {
7170
return functionDeployModel.getAppSettings();
7271
}
7372

@@ -140,8 +139,7 @@ public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
140139

141140
@Nullable
142141
@Override
143-
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment)
144-
throws ExecutionException {
142+
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) {
145143
return new FunctionDeploymentState(getProject(), this);
146144
}
147145

@@ -227,7 +225,6 @@ public void setAppSettingsKey(String appSettingsStorageKey) {
227225
public void saveModel(FunctionAppComboBoxModel functionAppComboBoxModel) {
228226
if (functionAppComboBoxModel.getFunctionDeployModel() != null) {
229227
setFunctionDeployModel(functionAppComboBoxModel.getFunctionDeployModel());
230-
return;
231228
} else {
232229
functionDeployModel.saveModel(functionAppComboBoxModel);
233230
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/ui/FunctionDeployViewPresenter.java

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

88
import com.microsoft.azure.management.appservice.FunctionApp;
99
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
10-
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
11-
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1210
import com.microsoft.azuretools.core.mvp.ui.base.MvpPresenter;
1311
import com.microsoft.tooling.msservices.components.DefaultLoader;
1412
import rx.Observable;
@@ -33,17 +31,15 @@ public void loadAppSettings(FunctionApp functionApp) {
3331
return;
3432
}
3533
unsubscribeSubscription(loadAppSettingsSubscription);
36-
loadAppSettingsSubscription = Observable.fromCallable(() -> {
37-
AzureTaskManager.getInstance().runAndWait(() -> getMvpView().beforeFillAppSettings(), AzureTask.Modality.ANY);
38-
return functionApp.getAppSettings();
39-
}).subscribeOn(getSchedulerProvider().io())
40-
.subscribe(appSettings -> DefaultLoader.getIdeHelper().invokeLater(() -> {
41-
if (isViewDetached()) {
42-
return;
43-
}
44-
final Map<String, String> result = new HashMap<>();
45-
appSettings.entrySet().forEach(entry -> result.put(entry.getKey(), entry.getValue().value()));
46-
getMvpView().fillAppSettings(result);
47-
}));
34+
loadAppSettingsSubscription =
35+
Observable.fromCallable(functionApp::getAppSettings).subscribeOn(getSchedulerProvider().io())
36+
.subscribe(appSettings -> DefaultLoader.getIdeHelper().invokeLater(() -> {
37+
if (isViewDetached()) {
38+
return;
39+
}
40+
final Map<String, String> result = new HashMap<>();
41+
appSettings.forEach((key, value) -> result.put(key, value.value()));
42+
getMvpView().fillAppSettings(result);
43+
}));
4844
}
4945
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/ui/FunctionDeploymentPanel.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import com.intellij.icons.AllIcons;
99
import com.intellij.openapi.module.Module;
1010
import com.intellij.openapi.project.Project;
11+
import com.intellij.openapi.ui.ComboBox;
1112
import com.intellij.packaging.artifacts.Artifact;
1213
import com.intellij.ui.HyperlinkLabel;
1314
import com.intellij.ui.ListCellRendererWrapper;
1415
import com.microsoft.azure.toolkit.intellij.appservice.AppServiceComboBoxModel;
15-
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
16+
import com.microsoft.azure.toolkit.intellij.common.AzureSettingPanel;
1617
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBox;
1718
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
18-
import com.microsoft.azure.toolkit.intellij.common.AzureSettingPanel;
1919
import com.microsoft.azure.toolkit.intellij.function.runner.component.table.AppSettingsTable;
2020
import com.microsoft.azure.toolkit.intellij.function.runner.component.table.AppSettingsTableUtils;
2121
import com.microsoft.azure.toolkit.intellij.function.runner.core.FunctionUtils;
@@ -39,7 +39,7 @@
3939

4040
public class FunctionDeploymentPanel extends AzureSettingPanel<FunctionDeployConfiguration> implements FunctionDeployMvpView {
4141

42-
private FunctionDeployViewPresenter presenter = null;
42+
private final FunctionDeployViewPresenter<FunctionDeploymentPanel> presenter;
4343

4444
private JPanel pnlRoot;
4545
private HyperlinkLabel lblCreateFunctionApp;
@@ -53,10 +53,10 @@ public class FunctionDeploymentPanel extends AzureSettingPanel<FunctionDeployCon
5353

5454
public FunctionDeploymentPanel(@NotNull Project project, @NotNull FunctionDeployConfiguration functionDeployConfiguration) {
5555
super(project);
56-
this.presenter = new FunctionDeployViewPresenter();
56+
this.presenter = new FunctionDeployViewPresenter<>();
5757
this.presenter.onAttachView(this);
5858

59-
cbFunctionModule.setRenderer(new ListCellRendererWrapper<Module>() {
59+
cbFunctionModule.setRenderer(new ListCellRendererWrapper<>() {
6060
@Override
6161
public void customize(JList list, Module module, int i, boolean b, boolean b1) {
6262
if (module != null) {
@@ -101,7 +101,7 @@ public JPanel getMainPanel() {
101101
@NotNull
102102
@Override
103103
protected JComboBox<Artifact> getCbArtifact() {
104-
return new JComboBox<Artifact>();
104+
return new ComboBox<>();
105105
}
106106

107107
@NotNull
@@ -113,7 +113,7 @@ protected JLabel getLblArtifact() {
113113
@NotNull
114114
@Override
115115
protected JComboBox<MavenProject> getCbMavenProject() {
116-
return new JComboBox<MavenProject>();
116+
return new ComboBox<>();
117117
}
118118

119119
@NotNull
@@ -183,6 +183,7 @@ private void onSelectFunctionApp() {
183183
} else { // For existing Functions
184184
if (!AppServiceComboBoxModel.isSameApp(model, appSettingsFunctionApp) || appSettingsTable.isEmpty()) {
185185
// Do not refresh if selected function app is not changed except create run configuration from azure explorer
186+
this.beforeFillAppSettings();
186187
presenter.loadAppSettings(model.getResource());
187188
}
188189
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/runner/webappconfig/WebAppConfiguration.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.intellij.openapi.options.ConfigurationException;
1515
import com.intellij.openapi.options.SettingsEditor;
1616
import com.intellij.openapi.project.Project;
17+
import com.intellij.openapi.util.InvalidDataException;
18+
import com.intellij.openapi.util.WriteExternalException;
1719
import com.microsoft.azure.management.appservice.JavaVersion;
1820
import com.microsoft.azure.management.appservice.OperatingSystem;
1921
import com.microsoft.azure.management.appservice.RuntimeStack;
@@ -29,10 +31,12 @@
2931
import lombok.Getter;
3032
import lombok.Setter;
3133
import org.apache.commons.lang3.StringUtils;
34+
import org.jdom.Element;
3235
import org.jetbrains.annotations.NotNull;
3336
import org.jetbrains.annotations.Nullable;
3437

3538
import java.util.Map;
39+
import java.util.Optional;
3640

3741
import static com.microsoft.intellij.ui.messages.AzureBundle.message;
3842

@@ -43,6 +47,7 @@ public class WebAppConfiguration extends AzureRunConfigurationBase<IntelliJWebAp
4347
private static final String TOMCAT = "tomcat";
4448
private static final String JAVA = "java";
4549
private static final String JBOSS = "jboss";
50+
public static final String JAVA_VERSION = "javaVersion";
4651
private final IntelliJWebAppSettingModel webAppSettingModel;
4752
@Getter
4853
@Setter
@@ -71,6 +76,23 @@ public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEn
7176
return new WebAppRunState(getProject(), this);
7277
}
7378

79+
@Override
80+
public void readExternal(final Element element) throws InvalidDataException {
81+
super.readExternal(element);
82+
Optional.ofNullable(element.getChild(JAVA_VERSION))
83+
.map(javaVersionElement -> javaVersionElement.getAttributeValue(JAVA_VERSION))
84+
.ifPresent(javaVersion -> webAppSettingModel.setJdkVersion(JavaVersion.fromString(javaVersion)));
85+
}
86+
87+
@Override
88+
public void writeExternal(final Element element) throws WriteExternalException {
89+
super.writeExternal(element);
90+
Optional.ofNullable(webAppSettingModel.getJdkVersion())
91+
.map(JavaVersion::toString)
92+
.map(javaVersion -> new Element(JAVA_VERSION).setAttribute(JAVA_VERSION, javaVersion))
93+
.ifPresent(element::addContent);
94+
}
95+
7496
@Override
7597
public void validate() throws ConfigurationException {
7698
if (webAppSettingModel.isCreatingNew()) {

Utils/azuretools-core/src/com/microsoft/azuretools/telemetry/AppInsightsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private static boolean isAppInsightsClientAvailable() {
176176
private static void initTelemetryManager() {
177177
try {
178178
final Map<String, String> properties = buildProperties("", new HashMap<>());
179+
TelemetryClientSingleton.setConfiguration(configuration);
179180
final TelemetryClient client = TelemetryClientSingleton.getTelemetry();
180181
final String eventNamePrefix = configuration.eventName();
181182
TelemetryManager.getInstance().setTelemetryClient(client);
@@ -188,5 +189,4 @@ private static void initTelemetryManager() {
188189
} catch (Exception ignore) {
189190
}
190191
}
191-
192192
}

Utils/azuretools-core/src/com/microsoft/azuretools/telemetry/TelemetryClientSingleton.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,35 @@
44
*/
55

66
package com.microsoft.azuretools.telemetry;
7+
78
import com.microsoft.applicationinsights.TelemetryClient;
9+
import org.apache.commons.lang3.StringUtils;
810

911
public final class TelemetryClientSingleton {
1012
private TelemetryClient telemetry = null;
13+
private AppInsightsConfiguration configuration = null;
1114

1215
private static final class SingletonHolder {
1316
private static final TelemetryClientSingleton INSTANCE = new TelemetryClientSingleton();
1417
}
1518

16-
public static TelemetryClient getTelemetry(){
19+
public static TelemetryClient getTelemetry() {
1720
return SingletonHolder.INSTANCE.telemetry;
1821
}
1922

20-
private TelemetryClientSingleton(){
21-
telemetry = new TelemetryClient();
23+
public static void setConfiguration(final AppInsightsConfiguration configuration) {
24+
SingletonHolder.INSTANCE.configuration = configuration;
25+
}
26+
27+
private TelemetryClientSingleton() {
28+
telemetry = new TelemetryClient() {
29+
@Override
30+
public boolean isDisabled() {
31+
if (configuration == null) {
32+
return true;
33+
}
34+
return (StringUtils.isNotEmpty(configuration.preferenceVal()) && !Boolean.valueOf(configuration.preferenceVal())) || super.isDisabled();
35+
}
36+
};
2237
}
2338
}

0 commit comments

Comments
 (0)