use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.
the class WebAppSettingModel method getTelemetryProperties.
public Map<String, String> getTelemetryProperties(Map<String, String> properties) {
Map<String, String> result = new HashMap<>();
try {
if (properties != null) {
result.putAll(properties);
}
final Runtime runtime = getRuntime();
final String osValue = Optional.ofNullable(runtime.getOperatingSystem()).map(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem::toString).orElse(StringUtils.EMPTY);
final String webContainerValue = Optional.ofNullable(runtime.getWebContainer()).map(WebContainer::getValue).orElse(StringUtils.EMPTY);
final String javaVersionValue = Optional.ofNullable(runtime.getJavaVersion()).map(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion::getValue).orElse(StringUtils.EMPTY);
result.put(TelemetryConstants.RUNTIME, String.format("%s-%s-%s", osValue, webContainerValue, javaVersionValue));
result.put(TelemetryConstants.WEBAPP_DEPLOY_TO_SLOT, String.valueOf(isDeployToSlot()));
result.put(TelemetryConstants.SUBSCRIPTIONID, getSubscriptionId());
result.put(TelemetryConstants.CREATE_NEWWEBAPP, String.valueOf(isCreatingNew()));
result.put(TelemetryConstants.CREATE_NEWASP, String.valueOf(isCreatingAppServicePlan()));
result.put(TelemetryConstants.CREATE_NEWRG, String.valueOf(isCreatingResGrp()));
result.put(TelemetryConstants.FILETYPE, WebAppUtils.getFileType(getTargetName()));
result.put(TelemetryConstants.PRICING_TIER, pricing);
result.put(TelemetryConstants.REGION, region);
} catch (final Exception ignore) {
}
return result;
}
use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.
the class WebAppConfiguration method validate.
@Override
public void validate() throws ConfigurationException {
if (webAppSettingModel.isCreatingNew()) {
if (Utils.isEmptyString(webAppSettingModel.getWebAppName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noWebAppName"));
}
if (Utils.isEmptyString(webAppSettingModel.getSubscriptionId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noSubscription"));
}
if (Utils.isEmptyString(webAppSettingModel.getResourceGroup())) {
throw new ConfigurationException(message("webapp.deploy.validate.noResourceGroup"));
}
if (webAppSettingModel.isCreatingAppServicePlan()) {
if (Utils.isEmptyString(webAppSettingModel.getRegion())) {
throw new ConfigurationException(message("webapp.deploy.validate.noLocation"));
}
if (Utils.isEmptyString(webAppSettingModel.getPricing())) {
throw new ConfigurationException(message("webapp.deploy.validate.noPricingTier"));
}
if (Utils.isEmptyString(webAppSettingModel.getAppServicePlanName())) {
throw new ConfigurationException(message("webapp.deploy.validate.noAppServicePlan"));
}
} else {
if (Utils.isEmptyString(webAppSettingModel.getAppServicePlanId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noAppServicePlan"));
}
}
} else {
if (Utils.isEmptyString(webAppSettingModel.getWebAppId())) {
throw new ConfigurationException(message("webapp.deploy.validate.noWebApp"));
}
if (webAppSettingModel.isDeployToSlot()) {
if (webAppSettingModel.getSlotName().equals(Constants.CREATE_NEW_SLOT)) {
if (Utils.isEmptyString(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();
if (runtime == null) {
throw new ConfigurationException(message("webapp.deploy.validate.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"));
}
}
use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method collectData.
private void collectData() {
model.setCreatingNew(true);
model.setWebAppName(textAppName.getText().trim());
int index = comboSubscription.getSelectionIndex();
model.setSubscriptionId(index < 0 ? null : binderSubscriptionDetails.get(index).getId());
// Resource Group
boolean isCreatingNewResGrp = btnResourceGroupCreateNew.getSelection();
model.setCreatingResGrp(isCreatingNewResGrp);
if (isCreatingNewResGrp) {
model.setResourceGroup(textResourceGroupName.getText().trim());
} else {
index = comboResourceGroup.getSelectionIndex();
model.setResourceGroup(index < 0 ? null : binderResourceGroup.get(index).getName());
}
// App Service Plan
boolean isCreatingAppServicePlan = btnAppServiceCreateNew.getSelection();
model.setCreatingAppServicePlan(isCreatingAppServicePlan);
if (isCreatingAppServicePlan) {
model.setAppServicePlanName(textAppSevicePlanName.getText().trim());
index = comboAppServicePlanLocation.getSelectionIndex();
model.setRegion(index < 0 ? null : binderAppServicePlanLocation.get(index).getName());
model.setPricing(Optional.ofNullable(getSelectedPricingTier()).map(PricingTier::toString).orElse(APPSETTINGS_TOOLTIP));
} else {
index = comboAppServicePlan.getSelectionIndex();
model.setAppServicePlanId(index < 0 ? null : binderAppServicePlan.get(index).id());
}
// Runtime
final OperatingSystem os = getSelectedOS();
final Runtime runtime = os == OperatingSystem.LINUX ? getSelectedRuntimeStack() : Runtime.getRuntime(OperatingSystem.WINDOWS, getSelectedWebcontainer(), getSelectedJavaVersion());
model.saveRuntime(runtime);
}
use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method fillLinuxRuntime.
private void fillLinuxRuntime() {
List<Runtime> runtimeStacks = Runtime.WEBAPP_RUNTIME.stream().filter(runtime -> runtime.isLinux()).collect(Collectors.toList());
binderRuntimeStacks = new ArrayList<Runtime>();
for (int i = 0; i < runtimeStacks.size(); i++) {
Runtime runtimeStack = runtimeStacks.get(i);
comboLinuxRuntime.add(runtimeStack.toString());
binderRuntimeStacks.add(runtimeStack);
if (Objects.equals(runtimeStack, DEFAULT_LINUX_RUNTIME)) {
comboLinuxRuntime.select(i);
}
}
String linuxRuntime = CommonUtils.getPreference(CommonUtils.RUNTIME_LINUX);
CommonUtils.selectComboIndex(comboLinuxRuntime, linuxRuntime);
}
use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.
the class AppServiceInfoBasicPanel method init.
private void init() {
this.subscription = az(AzureAccount.class).account().getSelectedSubscriptions().get(0);
this.textName.setRequired(true);
this.textName.setSubscription(subscription);
this.selectorRuntime.setRequired(true);
this.selectorApplication.setFileFilter(virtualFile -> {
final String ext = FileNameUtils.getExtension(virtualFile.getPath());
final Runtime platform = this.selectorRuntime.getValue();
return StringUtils.isNotBlank(ext) && isSupportedArtifactType(platform, ext);
});
this.setDeploymentVisible(false);
this.config = initConfig();
setData(this.config);
this.lblName.setLabelFor(textName);
this.lblPlatform.setLabelFor(selectorRuntime);
this.lblArtifact.setLabelFor(selectorApplication);
}
Aggregations