Search in sources :

Example 1 with Runtime

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;
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) HashMap(java.util.HashMap)

Example 2 with Runtime

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"));
    }
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 3 with Runtime

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);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Point(org.eclipse.swt.graphics.Point)

Example 4 with 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);
}
Also used : Arrays(java.util.Arrays) Azure(com.microsoft.azure.toolkit.lib.Azure) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FocusEvent(org.eclipse.swt.events.FocusEvent) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) CommonUtils(com.microsoft.azuretools.webapp.util.CommonUtils) PluginUtil(com.microsoft.azuretools.core.utils.PluginUtil) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) TraverseEvent(org.eclipse.swt.events.TraverseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ILog(org.eclipse.core.runtime.ILog) PlatformUI(org.eclipse.ui.PlatformUI) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Status(org.eclipse.core.runtime.Status) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) TraverseListener(org.eclipse.swt.events.TraverseListener) Window(org.eclipse.jface.window.Window) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) SWT(org.eclipse.swt.SWT) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) SelectionListener(org.eclipse.swt.events.SelectionListener) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) SimpleDateFormat(java.text.SimpleDateFormat) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Listener(org.eclipse.swt.widgets.Listener) ErrorWindow(com.microsoft.azuretools.core.ui.ErrorWindow) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Link(org.eclipse.swt.widgets.Link) Nullable(javax.annotation.Nullable) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) TableItem(org.eclipse.swt.widgets.TableItem) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) Shell(org.eclipse.swt.widgets.Shell) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) ASP_CREATE_PRICING(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_PRICING) ProgressDialog(com.microsoft.azuretools.core.utils.ProgressDialog) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) TableEditor(org.eclipse.swt.custom.TableEditor) Activator(com.microsoft.azuretools.webapp.Activator) URL(java.net.URL) Date(java.util.Date) TableColumn(org.eclipse.swt.widgets.TableColumn) CommonUtils.getSelectedItem(com.microsoft.azuretools.webapp.util.CommonUtils.getSelectedItem) MavenUtils(com.microsoft.azuretools.core.utils.MavenUtils) IStatus(org.eclipse.core.runtime.IStatus) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Button(org.eclipse.swt.widgets.Button) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) CREATE_WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_WEBAPP) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) Label(org.eclipse.swt.widgets.Label) WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.WEBAPP) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) HashMap(java.util.HashMap) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Table(org.eclipse.swt.widgets.Table) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) Event(org.eclipse.swt.widgets.Event) Region(com.microsoft.azure.toolkit.lib.common.model.Region) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Schedulers(reactor.core.scheduler.Schedulers) LinkedList(java.util.LinkedList) FillLayout(org.eclipse.swt.layout.FillLayout) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) Combo(org.eclipse.swt.widgets.Combo) MalformedURLException(java.net.MalformedURLException) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Group(org.eclipse.swt.widgets.Group) ASP_CREATE_LOCATION(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_LOCATION) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AccessibilityUtils(com.microsoft.azuretools.core.utils.AccessibilityUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Comparator(java.util.Comparator) FocusAdapter(org.eclipse.swt.events.FocusAdapter) WebAppSettingModel(com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel) Control(org.eclipse.swt.widgets.Control) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Point(org.eclipse.swt.graphics.Point)

Example 5 with Runtime

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);
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime)

Aggregations

Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)12 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)4 HashMap (java.util.HashMap)4 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)3 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)3 Point (org.eclipse.swt.graphics.Point)3 AzureArtifact (com.microsoft.azure.toolkit.intellij.common.AzureArtifact)2 AzureArtifactManager (com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)2 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)2 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)2 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)2 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 AppServiceInfoAdvancedPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceInfoAdvancedPanel)1 AppServiceMonitorPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 AppServiceBaseEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity)1