public RemotePermissionScheme[] getPermissionSchemes(JiraConfiguration config) { JiraSession session = getJiraSession(config); JiraClient client = new JiraClient(session); RemotePermissionScheme[] schemes; schemes = client.getPermissionSchemes(); session.close(); return schemes; }
@JavaScriptMethod public RemoteUser[] getExistingUsers(String jiraConfigName, String query) { JiraSession session = getJiraSession(getJiraConfig(jiraConfigName)); JiraClient client = new JiraClient(session); RemoteUser[] users = client.searchUser(query); session.close(); return users; }
@JavaScriptMethod public RemoteGroupSummary[] getExistingGroups(String jiraConfigName, String query) { JiraSession session = getJiraSession(getJiraConfig(jiraConfigName)); JiraClient client = new JiraClient(session); RemoteGroupSummary[] groups; groups = client.searchGroups(query); session.close(); return groups; }
private boolean isEmailAddressRegistered(JiraClient client, String email) { for (RemoteUser user : client.searchUser(email)) { if (user.getEmail().equalsIgnoreCase(email)) { return true; } } return false; }
private boolean isUsernameRegistered(JiraClient client, String username) { for (RemoteUser user : client.searchUser(username)) { if (user.getName().equalsIgnoreCase(username)) { return true; } } return false; }
@JavaScriptMethod public String isValidJIRAProjectKey(String jiraConfigName, String key) { if (GenericValidator.isBlankOrNull(key)) { return "Please provide a key"; } else if (!KEY_PATTERN.matcher(key).matches()) { return "The project key is not in the required format (^[A-Z]+$)."; } try { JiraSession session = getJiraSession(getJiraConfig(jiraConfigName)); JiraClient client = new JiraClient(session); client.getProject(key); session.close(); return "Project key already used."; } catch (AtlassianException ex) { if (ex.getMessage().contains("No project could be found")) { return null; } throw ex; } }