/** * Fill method for the ProjectKey field list box * * @param siteName the name of the selected {@link JIRASite} * @return the possible values for the list box in a {@link ListBoxModel} * @throws FormException in case of communication issues with JIRA */ public ListBoxModel doFillProjectKeyItems( @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 (RemoteProject project : client.getProjects()) { model.add(project.getName(), project.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; }