/**
  * Check method to validate the authentication details
  *
  * @param request the {@link StaplerRequest}
  * @return the {@link FormValidation} result
  * @throws IOException in case of IO exceptions
  */
 public FormValidation doLoginCheck(StaplerRequest request) throws IOException {
   String url = Util.fixEmpty(request.getParameter("url"));
   if (url == null) {
     return FormValidation.ok();
   }
   JIRASite site =
       new JIRASite(
           "Login Check",
           new URL(url),
           request.getParameter("user"),
           request.getParameter("pass"),
           false,
           null,
           false);
   try {
     site.createClient();
     return FormValidation.ok();
   } catch (RemoteAuthenticationException e) {
     return FormValidation.error(e.getMessage());
   } catch (AxisFault e) {
     return FormValidation.error(e.getFaultString());
   } catch (ServiceException e) {
     return FormValidation.error(e.getMessage());
   }
 }
 /**
  * Fill method for the IssueType field list box
  *
  * @param siteName the name of the selected {@link JIRASite}
  * @param projectKey the key of the JIRA Project
  * @return the possible values for the list box in a {@link ListBoxModel}
  * @throws FormException in case of communication issues with JIRA
  */
 public ListBoxModel doFillIssueTypeItems(
     @QueryParameter(PARAMETER_PREFIX + "siteName") String siteName,
     @QueryParameter(PARAMETER_PREFIX + "projectKey") String projectKey)
     throws FormException {
   ListBoxModel model = new ListBoxModel();
   if (StringUtils.isBlank(siteName) || StringUtils.isBlank(projectKey)) {
     return model;
   }
   JIRAClient client = null;
   try {
     client = JIRASite.getSite(siteName).createClient();
     for (RemoteIssueType issueType : client.getIssueTypesForProject(projectKey)) {
       model.add(issueType.getName(), issueType.getId());
     }
   } catch (RemoteException e) {
     LOGGER.log(Level.SEVERE, "Failed to get the JIRA Projects", e);
     throw new FormException(
         "Failed to get JIRA Project IssueTypes", e, PARAMETER_PREFIX + "projectKey");
   } catch (MalformedURLException e) {
     throw new FormException("Invalid JIRA URL provided", e, PARAMETER_PREFIX + "projectKey");
   } catch (ServiceException e) {
     LOGGER.log(Level.SEVERE, "Failed to get the JIRA Projects", e);
     throw new FormException(
         "Failed to get JIRA Project IssueTypes", e, PARAMETER_PREFIX + "projectKey");
   } finally {
     if (client != null) {
       client.logout();
     }
   }
   return model;
 }
 /**
  * Fill method for the Issue Priorities select box
  *
  * @param siteName the {@link JIRASite} name to get the priorities from
  * @return the possible priorities
  * @throws FormException in case of errors
  */
 public ListBoxModel doFillIssuePriorityItems(
     @QueryParameter(PARAMETER_PREFIX + "siteName") String siteName) throws FormException {
   ListBoxModel model = new ListBoxModel();
   if (StringUtils.isBlank(siteName)) {
     return model;
   }
   JIRAClient client = null;
   try {
     client = JIRASite.getSite(siteName).createClient();
     for (Map.Entry<String, String> priority : client.getPriorities().entrySet()) {
       model.add(priority.getValue(), priority.getKey());
     }
   } catch (RemoteException e) {
     LOGGER.log(Level.SEVERE, "Failed to get the JIRA Projects", e);
     throw new FormException(
         "Failed to get JIRA Project Keys", e, PARAMETER_PREFIX + "projectKey");
   } catch (MalformedURLException e) {
     throw new FormException("Invalid JIRA URL provided", e, PARAMETER_PREFIX + "projectKey");
   } catch (ServiceException e) {
     LOGGER.log(Level.SEVERE, "Failed to get the JIRA Projects", e);
     throw new FormException(
         "Failed to get JIRA Project Keys", e, PARAMETER_PREFIX + "projectKey");
   } finally {
     if (client != null) {
       client.logout();
     }
   }
   return model;
 }