Skip to content

Commit c30ef6d

Browse files
committed
Fix serialization of JavaVersion in WebAppConfiguration
1 parent 4e8954a commit c30ef6d

File tree

1 file changed

+22
-0
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/runner/webappconfig

1 file changed

+22
-0
lines changed

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()) {

0 commit comments

Comments
 (0)