in PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.container/src/main/java/com/microsoft/azuretools/container/ui/PublishWebAppOnLinuxDialog.java [347:440]
private void validate() throws InvalidFormDataException {
if (!AuthMethodManager.getInstance().isSignedIn()) {
throw new InvalidFormDataException(NEED_SIGN_IN);
}
// docker file
if (Utils.isEmptyString(model.getDockerFilePath())) {
throw new InvalidFormDataException(INVALID_DOCKER_FILE);
}
File dockerFile = Paths.get(model.getDockerFilePath()).toFile();
if (!dockerFile.exists() || !dockerFile.isFile()) {
throw new InvalidFormDataException(INVALID_DOCKER_FILE);
}
// acr
PrivateRegistryImageSetting setting = model.getPrivateRegistryImageSetting();
if (Utils.isEmptyString(setting.getServerUrl()) || !setting.getServerUrl().matches(DOMAIN_NAME_REGEX)) {
throw new InvalidFormDataException(MISSING_SERVER_URL);
}
if (Utils.isEmptyString(setting.getUsername())) {
throw new InvalidFormDataException(MISSING_USERNAME);
}
if (Utils.isEmptyString(setting.getPassword())) {
throw new InvalidFormDataException(MISSING_PASSWORD);
}
String imageTag = setting.getImageTagWithServerUrl();
if (Utils.isEmptyString(imageTag)) {
throw new InvalidFormDataException(MISSING_IMAGE_WITH_TAG);
}
if (imageTag.endsWith(":")) {
throw new InvalidFormDataException(CANNOT_END_WITH_COLON);
}
final String[] repoAndTag = imageTag.split(":");
// check repository first
if (repoAndTag[0].length() < 1 || repoAndTag[0].length() > REPO_LENGTH) {
throw new InvalidFormDataException(REPO_LENGTH_INVALID);
}
if (repoAndTag[0].endsWith("/")) {
throw new InvalidFormDataException(CANNOT_END_WITH_SLASH);
}
final String[] repoComponents = repoAndTag[0].split("/");
for (String component : repoComponents) {
if (!component.matches(REPO_COMPONENTS_REGEX)) {
throw new InvalidFormDataException(
String.format(REPO_COMPONENT_INVALID, component, REPO_COMPONENTS_REGEX));
}
}
// check when contains tag
if (repoAndTag.length == 2) {
if (repoAndTag[1].length() > TAG_LENGTH) {
throw new InvalidFormDataException(TAG_LENGTH_INVALID);
}
if (!repoAndTag[1].matches(TAG_REGEX)) {
throw new InvalidFormDataException(String.format(TAG_INVALID, repoAndTag[1], TAG_REGEX));
}
}
if (repoAndTag.length > 2) {
throw new InvalidFormDataException(INVALID_IMAGE_WITH_TAG);
}
// web app
if (model.isCreatingNewWebAppOnLinux()) {
if (Utils.isEmptyString(model.getWebAppName())) {
throw new InvalidFormDataException(MISSING_WEB_APP);
}
if (Utils.isEmptyString(model.getSubscriptionId())) {
throw new InvalidFormDataException(MISSING_SUBSCRIPTION);
}
if (Utils.isEmptyString(model.getResourceGroupName())) {
throw new InvalidFormDataException(MISSING_RESOURCE_GROUP);
}
if (model.isCreatingNewAppServicePlan()) {
if (Utils.isEmptyString(model.getAppServicePlanName())) {
throw new InvalidFormDataException(MISSING_APP_SERVICE_PLAN);
}
} else {
if (Utils.isEmptyString(model.getAppServicePlanId())) {
throw new InvalidFormDataException(MISSING_APP_SERVICE_PLAN);
}
}
} else {
if (Utils.isEmptyString(model.getWebAppId())) {
throw new InvalidFormDataException(MISSING_WEB_APP);
}
}
// target package
if (Utils.isEmptyString(model.getTargetName())) {
throw new InvalidFormDataException(MISSING_ARTIFACT);
}
if (!model.getTargetName().matches(ARTIFACT_NAME_REGEX)) {
throw new InvalidFormDataException(String.format(INVALID_WAR_FILE, model.getTargetName()));
}
}