Search in sources :

Example 1 with WebApp

use of com.microsoft.azure.management.appservice.WebApp in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method editAppService.

private void editAppService() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
        String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
        WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
        AppServiceChangeSettingsDialog d = AppServiceChangeSettingsDialog.go(wad, project);
        if (d == null) {
            // something went wrong - report an error!
            return;
        }
        WebApp wa = d.getWebApp();
        doFillTable();
        selectTableRowWithWebAppName(wa.name());
    }
//fillAppServiceDetails();
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) DefaultTableModel(javax.swing.table.DefaultTableModel) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 2 with WebApp

use of com.microsoft.azure.management.appservice.WebApp in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method doValidate.

@Nullable
@Override
protected ValidationInfo doValidate() {
    model.collectData();
    String webappName = model.webAppName;
    if (webappName.length() > 60 || !webappName.matches("^[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]$")) {
        StringBuilder builder = new StringBuilder();
        builder.append("The name can contain letters, numbers and hyphens but the first and last characters must be a letter or number. ");
        builder.append("The length can be between 2 and 60 characters. ");
        return new ValidationInfo(builder.toString(), textFieldWebappName);
    } else {
        for (List<WebApp> wal : AzureModel.getInstance().getResourceGroupToWebAppMap().values()) {
            for (WebApp wa : wal) {
                if (wa.name().toLowerCase().equals(webappName.toLowerCase())) {
                    return new ValidationInfo("The name is already taken", textFieldWebappName);
                }
            }
        }
    }
    if (model.subscriptionDetail == null) {
        return new ValidationInfo("Select a valid subscription.", comboBoxSubscription);
    }
    if (model.isAppServicePlanCreateNew) {
        if (model.appServicePlanNameCreateNew.isEmpty()) {
            return new ValidationInfo("Enter a valid App Service Plan name.", textFieldAppServicePlanName);
        } else {
            if (!model.appServicePlanNameCreateNew.matches("^[A-Za-z0-9-]*[A-Za-z0-9-]$")) {
                return new ValidationInfo("App Service Plan name can only include alphanumeric characters and hyphens.", textFieldAppServicePlanName);
            }
            // App service plan name must be unuque in each subscription
            SubscriptionDetail sd = model.subscriptionDetail;
            List<ResourceGroup> rgl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().get(sd);
            for (ResourceGroup rg : rgl) {
                List<AppServicePlan> aspl = AzureModel.getInstance().getResourceGroupToAppServicePlanMap().get(rg);
                for (AppServicePlan asp : aspl) {
                    if (asp.name().toLowerCase().equals(model.appServicePlanNameCreateNew.toLowerCase())) {
                        return new ValidationInfo("App service plan name must be unuque in each subscription.", textFieldAppServicePlanName);
                    }
                }
            }
        }
        if (model.appServicePlanLocationCreateNew == null) {
            return new ValidationInfo("Select a valid App Service Plan Location.", comboBoxAppServicePlanLocation);
        }
        if (model.appServicePricingTierCreateNew == null) {
            return new ValidationInfo("Select a valid App Service Plan PricingTier.", comboBoxAppServicePlanPricingTier);
        }
    } else {
        if (model.appServicePlan == null) {
            return new ValidationInfo("Select a valid App Service Plan.", comboBoxResourceGroup);
        }
    }
    if (model.isResourceGroupCreateNew) {
        if (model.resourceGroupNameCreateNew.isEmpty()) {
            return new ValidationInfo("Enter a valid resource group name", textFieldResourceGroupName);
        } else {
            if (!model.resourceGroupNameCreateNew.matches("^[A-Za-z0-9-_()\\.]*[A-Za-z0-9-_()]$")) {
                return new ValidationInfo("Resounce group name can only include alphanumeric characters, periods, underscores, hyphens, and parenthesis and can't end in a period.", textFieldResourceGroupName);
            }
            for (List<ResourceGroup> rgl : AzureModel.getInstance().getSubscriptionToResourceGroupMap().values()) {
                for (ResourceGroup rg : rgl) {
                    if (rg.name().toLowerCase().equals(model.resourceGroupNameCreateNew.toLowerCase())) {
                        return new ValidationInfo("The name is already taken", textFieldResourceGroupName);
                    }
                }
            }
        }
    } else {
        if (model.resourceGroup == null) {
            return new ValidationInfo("Select a valid resource group.", comboBoxResourceGroup);
        }
    }
    ValidationInfo res = validateJdkTab();
    if (res != null)
        return res;
    return super.doValidate();
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with WebApp

use of com.microsoft.azure.management.appservice.WebApp in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method validated.

protected boolean validated() {
    cleanError();
    model.collectData();
    String webappName = model.webAppName;
    if (webappName.length() > 60 || !webappName.matches("^[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]$")) {
        StringBuilder builder = new StringBuilder();
        builder.append("The name can contain letters, numbers and hyphens but the first and last characters must be a letter or number. ");
        builder.append("The length can be between 2 and 60 characters. ");
        setError(dec_textAppName, builder.toString());
        return false;
    } else {
        for (List<WebApp> wal : AzureModel.getInstance().getResourceGroupToWebAppMap().values()) {
            for (WebApp wa : wal) {
                if (wa.name().toLowerCase().equals(webappName.toLowerCase())) {
                    setError(dec_textAppName, "The name is already taken");
                    return false;
                }
            }
        }
    }
    if (model.webContainer == null) {
        setError(dec_comboWebContainer, "Select a valid web container.");
        return false;
    }
    if (model.subscriptionDetail == null) {
        setError(dec_comboSubscription, "Select a valid subscription.");
        return false;
    }
    if (model.isAppServicePlanCreateNew) {
        if (model.appServicePlanNameCreateNew.isEmpty()) {
            setError(dec_textAppSevicePlanName, "Enter a valid App Service Plan name.");
            return false;
        } else {
            if (!model.appServicePlanNameCreateNew.matches("^[A-Za-z0-9-]*[A-Za-z0-9-]$")) {
                setError(dec_textAppSevicePlanName, "App Service Plan name can only include alphanumeric characters and hyphens.");
                return false;
            }
            // App service plan name must be unique in each subscription
            SubscriptionDetail sd = model.subscriptionDetail;
            List<ResourceGroup> rgl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().get(sd);
            for (ResourceGroup rg : rgl) {
                List<AppServicePlan> aspl = AzureModel.getInstance().getResourceGroupToAppServicePlanMap().get(rg);
                for (AppServicePlan asp : aspl) {
                    if (asp.name().toLowerCase().equals(model.appServicePlanNameCreateNew.toLowerCase())) {
                        setError(dec_textAppSevicePlanName, "App service plan name must be unuque in each subscription.");
                        return false;
                    }
                }
            }
        }
        if (model.appServicePlanLocationCreateNew == null) {
            setError(dec_comboAppServicePlanLocation, "Select a location.");
            return false;
        }
    } else {
        if (model.appServicePlan == null) {
            setError(dec_comboAppServicePlan, "Select a valid App Service Plan.");
            return false;
        }
    }
    if (model.isResourceGroupCreateNew) {
        if (model.resourceGroupNameCreateNew.isEmpty()) {
            setError(dec_textNewResGrName, "Enter a valid resource group name");
            return false;
        } else {
            if (!model.resourceGroupNameCreateNew.matches("^[A-Za-z0-9-_()\\.]*[A-Za-z0-9-_()]$")) {
                setError(dec_textNewResGrName, "Resounce group name can only include alphanumeric characters, periods, underscores, hyphens, and parenthesis and can't end in a period.");
                return false;
            }
            for (List<ResourceGroup> rgl : AzureModel.getInstance().getSubscriptionToResourceGroupMap().values()) {
                for (ResourceGroup rg : rgl) {
                    if (rg.name().toLowerCase().equals(model.resourceGroupNameCreateNew.toLowerCase())) {
                        setError(dec_textNewResGrName, "The name is already taken");
                        return false;
                    }
                }
            }
        }
    } else {
        if (model.resourceGroup == null) {
            setError(dec_comboSelectResGr, "Select a valid resource group.");
            return false;
        }
    }
    return volidatedJdkTab();
}
Also used : SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan)

Example 4 with WebApp

use of com.microsoft.azure.management.appservice.WebApp in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method doFillTable.

private void doFillTable() {
    Map<SubscriptionDetail, List<ResourceGroup>> srgMap = AzureModel.getInstance().getSubscriptionToResourceGroupMap();
    Map<ResourceGroup, List<WebApp>> rgwaMap = AzureModel.getInstance().getResourceGroupToWebAppMap();
    Map<ResourceGroup, List<AppServicePlan>> rgaspMap = AzureModel.getInstance().getResourceGroupToAppServicePlanMap();
    webAppDetailsMap.clear();
    table.removeAll();
    for (SubscriptionDetail sd : srgMap.keySet()) {
        if (!sd.isSelected())
            continue;
        Map<String, WebAppUtils.AspDetails> aspMap = new HashMap<>();
        for (ResourceGroup rg : srgMap.get(sd)) {
            for (AppServicePlan asp : rgaspMap.get(rg)) {
                aspMap.put(asp.id(), new WebAppUtils.AspDetails(asp, rg));
            }
        }
        for (ResourceGroup rg : srgMap.get(sd)) {
            for (WebApp wa : rgwaMap.get(rg)) {
                TableItem item = new TableItem(table, SWT.NULL);
                if (wa.javaVersion() != JavaVersion.OFF) {
                    item.setText(new String[] { wa.name(), wa.javaVersion().toString(), wa.javaContainer() + " " + wa.javaContainerVersion(), wa.resourceGroupName() });
                } else {
                    item.setText(new String[] { wa.name(), "Off", "N/A", wa.resourceGroupName() });
                }
                WebAppDetails webAppDetails = new WebAppDetails();
                webAppDetails.webApp = wa;
                webAppDetails.subscriptionDetail = sd;
                webAppDetails.resourceGroup = rg;
                webAppDetails.appServicePlan = aspMap.get(wa.appServicePlanId()).getAsp();
                webAppDetails.appServicePlanResourceGroup = aspMap.get(wa.appServicePlanId()).getRg();
                webAppDetailsMap.put(wa.name(), webAppDetails);
            }
        }
    }
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) WebAppUtils(com.microsoft.azuretools.utils.WebAppUtils) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 5 with WebApp

use of com.microsoft.azure.management.appservice.WebApp in project azure-tools-for-java by Microsoft.

the class WebappsModule method fillWebappsNodes.

private void fillWebappsNodes() {
    Map<SubscriptionDetail, List<ResourceGroup>> srgMap = AzureModel.getInstance().getSubscriptionToResourceGroupMap();
    Map<ResourceGroup, List<WebApp>> rgwaMap = AzureModel.getInstance().getResourceGroupToWebAppMap();
    if (srgMap != null) {
        for (SubscriptionDetail sd : srgMap.keySet()) {
            if (!sd.isSelected())
                continue;
            for (ResourceGroup rg : srgMap.get(sd)) {
                for (WebApp webApp : rgwaMap.get(rg)) {
                    addChildNode(new WebappNode(this, webApp, rg, RUN_STATUS.equalsIgnoreCase(webApp.inner().state()) ? WEB_RUN_ICON : WEB_STOP_ICON));
                }
            }
        }
    }
}
Also used : SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp)

Aggregations

WebApp (com.microsoft.azure.management.appservice.WebApp)32 AppServicePlan (com.microsoft.azure.management.appservice.AppServicePlan)15 IOException (java.io.IOException)12 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)6 File (java.io.File)6 PublishingProfile (com.microsoft.azure.management.appservice.PublishingProfile)5 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)5 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)5 AppServiceDomain (com.microsoft.azure.management.appservice.AppServiceDomain)3 TrafficManagerProfile (com.microsoft.azure.management.trafficmanager.TrafficManagerProfile)3 HashMap (java.util.HashMap)3 List (java.util.List)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 Git (org.eclipse.jgit.api.Git)3 SqlDatabase (com.microsoft.azure.management.sql.SqlDatabase)2 SqlServer (com.microsoft.azure.management.sql.SqlServer)2 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)2 StorageException (com.microsoft.azure.storage.StorageException)2 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)2