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();
}
Aggregations