|
53 | 53 | import com.microsoft.azure.management.resources.ResourceGroup; |
54 | 54 | import com.microsoft.azure.management.resources.Subscription; |
55 | 55 | import com.microsoft.azuretools.authmanage.AuthMethodManager; |
| 56 | +import com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException; |
56 | 57 | import com.microsoft.azuretools.azurecommons.helpers.Nullable; |
57 | 58 | import com.microsoft.azuretools.azurecommons.util.Utils; |
58 | 59 | import com.microsoft.azuretools.container.ConsoleLogger; |
59 | 60 | import com.microsoft.azuretools.container.Constant; |
60 | 61 | import com.microsoft.azuretools.container.DockerProgressHandler; |
61 | | -import com.microsoft.azuretools.container.InvalidDataException; |
62 | 62 | import com.microsoft.azuretools.container.ui.common.ContainerSettingComposite; |
63 | 63 | import com.microsoft.azuretools.container.utils.DockerUtil; |
64 | 64 | import com.microsoft.azuretools.core.components.AzureTitleAreaDialogWrapper; |
@@ -163,7 +163,7 @@ protected void okPressed() { |
163 | 163 | validation(); |
164 | 164 | execute(); |
165 | 165 | super.okPressed(); |
166 | | - } catch (InvalidDataException e) { |
| 166 | + } catch (InvalidFormDataException e) { |
167 | 167 | this.onErrorWithException("Validation Failure", e); |
168 | 168 | } |
169 | 169 | } |
@@ -279,7 +279,7 @@ private void apply() { |
279 | 279 | System.getenv("AcrPassword"), // cpAcr.getPassword(), |
280 | 280 | "eclipse:latest", // cpAcr.getImageTag(), |
281 | 281 | "" // cpAcr.getStartupFile() |
282 | | - )); |
| 282 | + )); |
283 | 283 | // set target |
284 | 284 | model.setTargetPath(targetPath); |
285 | 285 | model.setTargetName(Paths.get(targetPath).getFileName().toString()); |
@@ -356,96 +356,96 @@ private void apply() { |
356 | 356 | } |
357 | 357 | } |
358 | 358 |
|
359 | | - private void validation() throws InvalidDataException { |
| 359 | + private void validation() throws InvalidFormDataException { |
360 | 360 | try { |
361 | 361 | if (!AuthMethodManager.getInstance().isSignedIn()) { |
362 | | - throw new InvalidDataException(NEED_SIGN_IN); |
| 362 | + throw new InvalidFormDataException(NEED_SIGN_IN); |
363 | 363 | } |
364 | 364 | } catch (IOException e) { |
365 | | - throw new InvalidDataException(NEED_SIGN_IN); |
| 365 | + throw new InvalidFormDataException(NEED_SIGN_IN); |
366 | 366 | } |
367 | 367 | if (Utils.isEmptyString(model.getDockerFilePath()) || !Paths.get(model.getDockerFilePath()).toFile().exists()) { |
368 | | - throw new InvalidDataException(INVALID_DOCKER_FILE); |
| 368 | + throw new InvalidFormDataException(INVALID_DOCKER_FILE); |
369 | 369 | } |
370 | 370 | // acr |
371 | 371 | PrivateRegistryImageSetting setting = model.getPrivateRegistryImageSetting(); |
372 | 372 | if (Utils.isEmptyString(setting.getServerUrl()) || !setting.getServerUrl().matches(DOMAIN_NAME_REGEX)) { |
373 | | - throw new InvalidDataException(MISSING_SERVER_URL); |
| 373 | + throw new InvalidFormDataException(MISSING_SERVER_URL); |
374 | 374 | } |
375 | 375 | if (Utils.isEmptyString(setting.getUsername())) { |
376 | | - throw new InvalidDataException(MISSING_USERNAME); |
| 376 | + throw new InvalidFormDataException(MISSING_USERNAME); |
377 | 377 | } |
378 | 378 | if (Utils.isEmptyString(setting.getPassword())) { |
379 | | - throw new InvalidDataException(MISSING_PASSWORD); |
| 379 | + throw new InvalidFormDataException(MISSING_PASSWORD); |
380 | 380 | } |
381 | 381 | String imageTag = setting.getImageTagWithServerUrl(); |
382 | 382 | if (Utils.isEmptyString(imageTag)) { |
383 | | - throw new InvalidDataException(MISSING_IMAGE_WITH_TAG); |
| 383 | + throw new InvalidFormDataException(MISSING_IMAGE_WITH_TAG); |
384 | 384 | } |
385 | 385 | if (imageTag.endsWith(":")) { |
386 | | - throw new InvalidDataException(CANNOT_END_WITH_COLON); |
| 386 | + throw new InvalidFormDataException(CANNOT_END_WITH_COLON); |
387 | 387 | } |
388 | 388 | final String[] repoAndTag = imageTag.split(":"); |
389 | 389 |
|
390 | 390 | // check repository first |
391 | 391 | if (repoAndTag[0].length() < 1 || repoAndTag[0].length() > REPO_LENGTH) { |
392 | | - throw new InvalidDataException(REPO_LENGTH_INVALID); |
| 392 | + throw new InvalidFormDataException(REPO_LENGTH_INVALID); |
393 | 393 | } |
394 | 394 | if (repoAndTag[0].endsWith("/")) { |
395 | | - throw new InvalidDataException(CANNOT_END_WITH_SLASH); |
| 395 | + throw new InvalidFormDataException(CANNOT_END_WITH_SLASH); |
396 | 396 | } |
397 | 397 | final String[] repoComponents = repoAndTag[0].split("/"); |
398 | 398 | for (String component : repoComponents) { |
399 | 399 | if (!component.matches(REPO_COMPONENTS_REGEX)) { |
400 | | - throw new InvalidDataException(String.format(REPO_COMPONENT_INVALID, component, REPO_COMPONENTS_REGEX)); |
| 400 | + throw new InvalidFormDataException(String.format(REPO_COMPONENT_INVALID, component, REPO_COMPONENTS_REGEX)); |
401 | 401 | } |
402 | 402 | } |
403 | 403 | // check when contains tag |
404 | 404 | if (repoAndTag.length == 2) { |
405 | 405 | if (repoAndTag[1].length() > TAG_LENGTH) { |
406 | | - throw new InvalidDataException(TAG_LENGTH_INVALID); |
| 406 | + throw new InvalidFormDataException(TAG_LENGTH_INVALID); |
407 | 407 | } |
408 | 408 | if (!repoAndTag[1].matches(TAG_REGEX)) { |
409 | | - throw new InvalidDataException(String.format(TAG_INVALID, repoAndTag[1], TAG_REGEX)); |
| 409 | + throw new InvalidFormDataException(String.format(TAG_INVALID, repoAndTag[1], TAG_REGEX)); |
410 | 410 | } |
411 | 411 | } |
412 | 412 | if (repoAndTag.length > 2) { |
413 | | - throw new InvalidDataException(INVALID_IMAGE_WITH_TAG); |
| 413 | + throw new InvalidFormDataException(INVALID_IMAGE_WITH_TAG); |
414 | 414 | } |
415 | 415 | // web app |
416 | 416 | if (model.isCreatingNewWebAppOnLinux()) { |
417 | 417 | if (Utils.isEmptyString(model.getWebAppName())) { |
418 | | - throw new InvalidDataException(MISSING_WEB_APP); |
| 418 | + throw new InvalidFormDataException(MISSING_WEB_APP); |
419 | 419 | } |
420 | 420 | if (Utils.isEmptyString(model.getSubscriptionId())) { |
421 | | - throw new InvalidDataException(MISSING_SUBSCRIPTION); |
| 421 | + throw new InvalidFormDataException(MISSING_SUBSCRIPTION); |
422 | 422 | } |
423 | 423 | if (Utils.isEmptyString(model.getResourceGroupName())) { |
424 | | - throw new InvalidDataException(MISSING_RESOURCE_GROUP); |
| 424 | + throw new InvalidFormDataException(MISSING_RESOURCE_GROUP); |
425 | 425 | } |
426 | 426 |
|
427 | 427 | if (model.isCreatingNewAppServicePlan()) { |
428 | 428 | if (Utils.isEmptyString(model.getAppServicePlanName())) { |
429 | | - throw new InvalidDataException(MISSING_APP_SERVICE_PLAN); |
| 429 | + throw new InvalidFormDataException(MISSING_APP_SERVICE_PLAN); |
430 | 430 | } |
431 | 431 | } else { |
432 | 432 | if (Utils.isEmptyString(model.getAppServicePlanId())) { |
433 | | - throw new InvalidDataException(MISSING_APP_SERVICE_PLAN); |
| 433 | + throw new InvalidFormDataException(MISSING_APP_SERVICE_PLAN); |
434 | 434 | } |
435 | 435 | } |
436 | 436 |
|
437 | 437 | } else { |
438 | 438 | if (Utils.isEmptyString(model.getWebAppId())) { |
439 | | - throw new InvalidDataException(MISSING_WEB_APP); |
| 439 | + throw new InvalidFormDataException(MISSING_WEB_APP); |
440 | 440 | } |
441 | 441 | } |
442 | 442 |
|
443 | 443 | // target package |
444 | 444 | if (Utils.isEmptyString(model.getTargetName())) { |
445 | | - throw new InvalidDataException(MISSING_ARTIFACT); |
| 445 | + throw new InvalidFormDataException(MISSING_ARTIFACT); |
446 | 446 | } |
447 | 447 | if (!model.getTargetName().matches(ARTIFACT_NAME_REGEX)) { |
448 | | - throw new InvalidDataException(String.format(INVALID_WAR_FILE, model.getTargetName())); |
| 448 | + throw new InvalidFormDataException(String.format(INVALID_WAR_FILE, model.getTargetName())); |
449 | 449 | } |
450 | 450 | } |
451 | 451 |
|
|
0 commit comments