protected void doValidation() {
    // Validate comment and permissions
    super.doValidation();

    // Make sure the URL belongs to an application link
    appLink = validatePageUrl(pageUrl);

    String pageId = null;
    if (!hasAnyErrors()) {
      pageId = getPageId(pageUrl, appLink);
    }

    if (!hasAnyErrors()) {
      if (pageId == null) {
        addErrorMessage(getText("addconfluencelink.error.pageid.notfound"));
      }
    }

    if (!hasAnyErrors()) {
      final String globalId = ConfluenceGlobalIdFactoryImpl.encode(appLink.getId(), pageId);

      final RemoteIssueLink remoteIssueLink =
          new RemoteIssueLinkBuilder()
              .issueId(getIssue().getLong("id"))
              .url(buildPageUrl(appLink, pageId))
              .title(TITLE)
              .globalId(globalId)
              .relationship(RELATIONSHIP)
              .applicationType(RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE)
              .applicationName(appLink.getName())
              .build();

      validationResult = remoteIssueLinkService.validateCreate(getLoggedInUser(), remoteIssueLink);

      if (!validationResult.isValid()) {
        mapErrors(validationResult.getErrorCollection());
        addErrorCollection(validationResult.getErrorCollection());
      }
    }
  }