/** * 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 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); } }
/** * Retrieves the given project record. * * @param restclient REST client instance * @param key Project key * * @return a project instance * * @throws JiraException when the retrieval fails */ public static Project get(RestClient restclient, String key) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "project/" + key); } catch (Exception ex) { throw new JiraException("Failed to retrieve project " + key, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Project(restclient, (JSONObject)result); }
/** * Retrieves the given project record. * * @param restclient REST client instance * @param key Project key * * @return a project instance * * @throws JiraException when the retrieval fails */ public static Project get(RestClient restclient, String key) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "project/" + key); } catch (Exception ex) { throw new JiraException("Failed to retrieve project " + key, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Project(restclient, (JSONObject)result); }
result = (T)new Priority(restclient, (JSONObject)r); else if (type == Project.class) result = (T)new Project(restclient, (JSONObject)r); else if (type == Resolution.class) result = (T)new Resolution(restclient, (JSONObject)r);
result = (T)new Priority(restclient, (JSONObject)r); else if (type == Project.class) result = (T)new Project(restclient, (JSONObject)r); else if (type == ProjectCategory.class) result = (T)new ProjectCategory(restclient, (JSONObject)r);