/** * Obtains information about a project, given its project key. * @param key the project key * @return the project * @throws JiraException failed to obtain the project */ public Project getProject(String key) throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project/" + key); JSON response = restclient.get(uri); return new Project(restclient, (JSONObject) response); } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Obtains information about a project, given its project key. * @param key the project key * @return the project * @throws JiraException failed to obtain the project */ public Project getProject(String key) throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project/" + key); JSON response = restclient.get(uri); return new Project(restclient, (JSONObject) response); } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Obtains the list of all issue types in Jira. * @return all issue types * @throws JiraException failed to obtain the issue type list. */ public List<IssueType> getIssueTypes() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "issuetype"); JSON response = restclient.get(uri); JSONArray issueTypeArray = JSONArray.fromObject(response); List<IssueType> issueTypes = new ArrayList<IssueType>(issueTypeArray.size()); for (int i = 0; i < issueTypeArray.size(); i++) { JSONObject it = issueTypeArray.getJSONObject(i); issueTypes.add(new IssueType(restclient, it)); } return issueTypes; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * * @return a list of all priorities available in the Jira installation * @throws JiraException */ public List<Priority> getPriorities() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "priority"); JSON response = restclient.get(uri); JSONArray prioritiesArray = JSONArray.fromObject(response); List<Priority> priorities = new ArrayList<Priority>(prioritiesArray.size()); for (int i = 0; i < prioritiesArray.size(); i++) { JSONObject p = prioritiesArray.getJSONObject(i); priorities.add(new Priority(restclient, p)); } return priorities; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Obtains the list of all issue types in Jira. * @return all issue types * @throws JiraException failed to obtain the issue type list. */ public List<IssueType> getIssueTypes() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "issuetype"); JSON response = restclient.get(uri); JSONArray issueTypeArray = JSONArray.fromObject(response); List<IssueType> issueTypes = new ArrayList<IssueType>(issueTypeArray.size()); for (int i = 0; i < issueTypeArray.size(); i++) { JSONObject it = issueTypeArray.getJSONObject(i); issueTypes.add(new IssueType(restclient, it)); } return issueTypes; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * * @return a list of all priorities available in the Jira installation * @throws JiraException */ public List<Priority> getPriorities() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "priority"); JSON response = restclient.get(uri); JSONArray prioritiesArray = JSONArray.fromObject(response); List<Priority> priorities = new ArrayList<Priority>(prioritiesArray.size()); for (int i = 0; i < prioritiesArray.size(); i++) { JSONObject p = prioritiesArray.getJSONObject(i); priorities.add(new Priority(restclient, p)); } return priorities; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Obtains the list of all projects in Jira. * @return all projects; not all data is returned for each project; to get * the extra data use {@link #getProject(String)} * @throws JiraException failed to obtain the project list. */ public List<Project> getProjects() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project"); JSON response = restclient.get(uri); JSONArray projectsArray = JSONArray.fromObject(response); List<Project> projects = new ArrayList<Project>(projectsArray.size()); for (int i = 0; i < projectsArray.size(); i++) { JSONObject p = projectsArray.getJSONObject(i); projects.add(new Project(restclient, p)); } return projects; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Obtains the list of all projects in Jira. * @return all projects; not all data is returned for each project; to get * the extra data use {@link #getProject(String)} * @throws JiraException failed to obtain the project list. */ public List<Project> getProjects() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project"); JSON response = restclient.get(uri); JSONArray projectsArray = JSONArray.fromObject(response); List<Project> projects = new ArrayList<Project>(projectsArray.size()); for (int i = 0; i < projectsArray.size(); i++) { JSONObject p = projectsArray.getJSONObject(i); projects.add(new Project(restclient, p)); } return projects; } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
/** * Merges the given version with current version * * @param version * The version to merge */ public void mergeWith(Version version) { JSONObject req = new JSONObject(); req.put("description", version.getDescription()); req.put("name", version.getName()); req.put("archived", version.isArchived()); req.put("released", version.isReleased()); req.put("releaseDate", version.getReleaseDate()); try { restclient.put(Resource.getBaseUri() + "version/" + id, req); } catch (Exception ex) { throw new RuntimeException("Failed to merge", ex); } }
/** * Copies the version to the given project * * @param project * The project the version will be copied to */ public void copyTo(Project project) { JSONObject req = new JSONObject(); req.put("description", getDescription()); req.put("name", getName()); req.put("archived", isArchived()); req.put("released", isReleased()); req.put("releaseDate", getReleaseDate()); req.put("project", project.getKey()); req.put("projectId", project.getId()); try { restclient.post(Resource.getBaseUri() + "version/", req); } catch (Exception ex) { throw new RuntimeException("Failed to copy to project '" + project.getKey() + "'", ex); } }
/** * Merges the given version with current version * * @param version * The version to merge */ public void mergeWith(Version version) throws JiraException { JSONObject req = new JSONObject(); req.put("description", version.getDescription()); req.put("name", version.getName()); req.put("archived", version.isArchived()); req.put("released", version.isReleased()); req.put("releaseDate", version.getReleaseDate()); try { restclient.put(Resource.getBaseUri() + "version/" + id, req); } catch (Exception ex) { throw new JiraException("Failed to merge", ex); } }
/** * Copies the version to the given project * * @param project * The project the version will be copied to */ public void copyTo(Project project) throws JiraException { JSONObject req = new JSONObject(); req.put("description", getDescription()); req.put("name", getName()); req.put("archived", isArchived()); req.put("released", isReleased()); req.put("releaseDate", getReleaseDate()); req.put("project", project.getKey()); req.put("projectId", project.getId()); try { restclient.post(Resource.getBaseUri() + "version/", req); } catch (Exception ex) { throw new JiraException("Failed to copy to project '" + project.getKey() + "'", ex); } }