@Override protected void doValidation() { setUrlAndTokenIfTesting(); if (StringUtils.isBlank(organization) || StringUtils.isBlank(url)) { addErrorMessage("Invalid request, missing url or organization/account information."); } if (StringUtils.isNotBlank(organization)) { Organization integratedAccount = organizationService.findIntegratedAccount(); if (integratedAccount != null && organization.trim().equalsIgnoreCase(integratedAccount.getName())) { addErrorMessage("It is not possible to add the same account as the integrated one."); } } AccountInfo accountInfo = organizationService.getAccountInfo(url, organization, BitbucketCommunicator.BITBUCKET); // Bitbucket REST API to determine existence of accountInfo accepts valid email associated with // BB account, but // it is not possible to create an account containing the '@' character. // [https://confluence.atlassian.com/display/BITBUCKET/account+Resource#accountResource-GETtheaccountprofile] if (accountInfo == null || organization.contains("@")) { addErrorMessage("Invalid user/team account."); } if (organizationService.getByHostAndName(url, organization) != null) { addErrorMessage("Account is already integrated with JIRA."); } if (invalidInput()) { triggerAddFailedEvent(FailureReason.VALIDATION); } }