in PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.java [94:163]
public void validate() throws ConfigurationException {
if (webAppSettingModel.isCreatingNew()) {
if (StringUtils.isEmpty(webAppSettingModel.getWebAppName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noWebAppName"));
}
if (StringUtils.isEmpty(webAppSettingModel.getSubscriptionId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noSubscription"));
}
if (StringUtils.isEmpty(webAppSettingModel.getResourceGroup())) {
throw new ConfigurationException(message("webapp.deploy.validate.noResourceGroup"));
}
if (webAppSettingModel.isCreatingAppServicePlan()) {
if (StringUtils.isEmpty(webAppSettingModel.getRegion())) {
throw new ConfigurationException(message("webapp.deploy.validate.noLocation"));
}
if (StringUtils.isEmpty(webAppSettingModel.getPricing())) {
throw new ConfigurationException(message("webapp.deploy.validate.noPricingTier"));
}
if (StringUtils.isEmpty(webAppSettingModel.getAppServicePlanName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noAppServicePlan"));
}
} else {
if (StringUtils.isEmpty(webAppSettingModel.getAppServicePlanId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noAppServicePlan"));
}
}
} else {
if (StringUtils.isEmpty(webAppSettingModel.getWebAppId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noWebApp"));
}
if (StringUtils.isEmpty(webAppSettingModel.getAppServicePlanId())) {
// Service plan could be null as lazy loading, throw exception in this case
throw new ConfigurationException(message("webapp.validate_deploy_configuration.loading"));
}
if (webAppSettingModel.isDeployToSlot()) {
if (Constants.CREATE_NEW_SLOT.equals(webAppSettingModel.getSlotName())) {
if (StringUtils.isEmpty(webAppSettingModel.getNewSlotName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noSlotName"));
}
if (!webAppSettingModel.getNewSlotName().matches(SLOT_NAME_REGEX)) {
throw new ConfigurationException(message("webapp.deploy.validate.invalidSlotName"));
}
} else if (StringUtils.isEmpty(webAppSettingModel.getSlotName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noSlotName"));
}
}
}
// validate runtime with artifact
final Runtime runtime = webAppSettingModel.getRuntime();
final OperatingSystem operatingSystem = Optional.ofNullable(runtime).map(Runtime::getOperatingSystem).orElse(null);
final JavaVersion javaVersion = Optional.ofNullable(runtime).map(Runtime::getJavaVersion).orElse(null);
if (operatingSystem == OperatingSystem.DOCKER) {
throw new ConfigurationException(message("webapp.validate_deploy_configuration.dockerRuntime"));
}
if (javaVersion == null || Objects.equals(javaVersion, JavaVersion.OFF)) {
throw new ConfigurationException(message("webapp.validate_deploy_configuration.invalidRuntime"));
}
final String webContainer = runtime.getWebContainer().getValue();
final String artifactPackage = webAppSettingModel.getPackaging();
if (StringUtils.containsIgnoreCase(webContainer, TOMCAT) && !StringUtils.equalsAnyIgnoreCase(artifactPackage, "war")) {
throw new ConfigurationException(message("webapp.deploy.validate.invalidTomcatArtifact"));
} else if (StringUtils.containsIgnoreCase(webContainer, JBOSS) && !StringUtils.equalsAnyIgnoreCase(artifactPackage, "war", "ear")) {
throw new ConfigurationException(message("webapp.deploy.validate.invalidJbossArtifact"));
} else if (Objects.equals(runtime.getWebContainer(), WebContainer.JAVA_SE) && !StringUtils.equalsAnyIgnoreCase(artifactPackage, "jar")) {
throw new ConfigurationException(message("webapp.deploy.validate.invalidJavaSeArtifact"));
}
if (StringUtils.isEmpty(webAppSettingModel.getArtifactIdentifier())) {
throw new ConfigurationException(message("webapp.deploy.validate.missingArtifact"));
}
}