Search in sources :

Example 1 with DeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.DeployType in project azure-tools-for-java by Microsoft.

the class AzureWebAppMvpModel method deployArtifactsToWebApp.

@AzureOperation(name = "webapp|artifact.upload", params = { "file.getName()", "deployTarget.name()" }, type = AzureOperation.Type.SERVICE)
public void deployArtifactsToWebApp(@NotNull final IWebAppBase deployTarget, @NotNull final File file, boolean isDeployToRoot, @NotNull final IProgressIndicator progressIndicator) {
    if (!(deployTarget instanceof IWebApp || deployTarget instanceof IWebAppDeploymentSlot)) {
        final String error = "the deployment target is not a valid (deployment slot of) Web App";
        final String action = "select a valid Web App or deployment slot to deploy the artifact";
        throw new AzureToolkitRuntimeException(error, action);
    }
    // stop target app service
    String stopMessage = deployTarget instanceof IWebApp ? STOP_WEB_APP : STOP_DEPLOYMENT_SLOT;
    progressIndicator.setText(stopMessage);
    deployTarget.stop();
    final DeployType deployType = getDeployTypeByWebContainer(deployTarget.getRuntime().getWebContainer());
    // java se runtime will always deploy to root
    if (isDeployToRoot || Objects.equals(deployTarget.getRuntime().getWebContainer(), com.microsoft.azure.toolkit.lib.appservice.model.WebContainer.JAVA_SE)) {
        deployTarget.deploy(deployType, file);
    } else {
        final String webappPath = String.format("webapps/%s", FilenameUtils.getBaseName(file.getName()).replaceAll("#", StringUtils.EMPTY));
        deployTarget.deploy(deployType, file, webappPath);
    }
    String successMessage = deployTarget instanceof IWebApp ? DEPLOY_SUCCESS_WEB_APP : DEPLOY_SUCCESS_DEPLOYMENT_SLOT;
    progressIndicator.setText(successMessage);
    deployTarget.start();
}
Also used : DeployType(com.microsoft.azure.toolkit.lib.appservice.model.DeployType) IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

DeployType (com.microsoft.azure.toolkit.lib.appservice.model.DeployType)1 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)1 IWebAppDeploymentSlot (com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1