/** * Gets a list of JIRA resources from the given object. * * @param type Resource data type * @param ra a JSONArray instance * @param restclient REST client instance * * @return a list of Resources found in ra */ public static <T extends Resource> List<T> getResourceArray( Class<T> type, Object ra, RestClient restclient) { return getResourceArray(type, ra, restclient, null); }
/** * Deserializes a change log from a json payload. * @param json the json payload */ private void deserialise(JSONObject json) { Map map = json; entries = Field.getResourceArray(ChangeLogEntry.class, map.get( Field.CHANGE_LOG_ENTRIES), restclient); }
/** * Deserializes a change log from a json payload. * @param json the json payload */ private void deserialise(JSONObject json) { Map map = json; entries = Field.getResourceArray(ChangeLogEntry.class, map.get( Field.CHANGE_LOG_ENTRIES), restclient); }
/** * Gets a list of remote links from the given object. * * @param c a JSONObject instance * @param restclient REST client instance * * @return a list of remote links found in c */ public static List<RemoteLink> getRemoteLinks(Object c, RestClient restclient) { List<RemoteLink> results = new ArrayList<RemoteLink>(); if (c instanceof JSONArray) results = getResourceArray(RemoteLink.class, c, restclient); return results; }
/** * Gets a list of work logs from the given object. * * @param c a JSONObject instance * @param restclient REST client instance * * @return a list of work logs found in c */ public static List<WorkLog> getWorkLogs(Object c, RestClient restclient) { List<WorkLog> results = new ArrayList<WorkLog>(); if (c instanceof JSONObject && !((JSONObject)c).isNullObject()) results = getResourceArray(WorkLog.class, ((Map)c).get("worklogs"), restclient); return results; }
/** * Gets a list of comments from the given object. * * @param c a JSONObject instance * @param restclient REST client instance * * @return a list of comments found in c */ public static List<Comment> getComments(Object c, RestClient restclient) { List<Comment> results = new ArrayList<Comment>(); if (c instanceof JSONObject && !((JSONObject)c).isNullObject()) results = getResourceArray(Comment.class, ((Map)c).get("comments"), restclient); return results; }
/** * Gets a list of work logs from the given object. * * @param c a JSONObject instance * @param restclient REST client instance * * @return a list of work logs found in c */ public static List<WorkLog> getWorkLogs(Object c, RestClient restclient) { List<WorkLog> results = new ArrayList<WorkLog>(); if (c instanceof JSONObject && !((JSONObject)c).isNullObject()) results = getResourceArray(WorkLog.class, ((Map)c).get("worklogs"), restclient); return results; }
/** * Gets a list of comments from the given object. * * @param c a JSONObject instance * @param restclient REST client instance * @param issueKey key of the parent issue * * @return a list of comments found in c */ public static List<Comment> getComments(Object c, RestClient restclient, String issueKey) { List<Comment> results = new ArrayList<Comment>(); if (c instanceof JSONObject && !((JSONObject)c).isNullObject()) { results = getResourceArray( Comment.class, ((Map)c).get("comments"), restclient, issueKey ); } return results; }
/** * Deserializes a change log entry from a json payload. * @param json the json payload */ private void deserialise(JSONObject json) { Map map = json; id = Field.getString(map.get("id")); author = Field.getResource(User.class, map.get("author"), restclient); created = Field.getDateTime(map.get("created")); items = Field.getResourceArray(ChangeLogItem.class, map.get( Field.CHANGE_LOG_ITEMS), restclient); }
/** * Deserializes a change log entry from a json payload. * @param json the json payload */ private void deserialise(JSONObject json) { Map map = json; id = Field.getString(map.get("id")); author = Field.getResource(User.class, map.get("author"), restclient); created = Field.getDate(map.get("created")); items = Field.getResourceArray(ChangeLogItem.class, map.get( Field.CHANGE_LOG_ITEMS), restclient); }
private void deserialise(JSONObject json) { Map map = json; self = Field.getString(map.get("self")); id = Field.getString(map.get("id")); watchCount = Field.getInteger(map.get("watchCount")); isWatching = Field.getBoolean(map.get("isWatching")); watchers = Field.getResourceArray(User.class, map.get("watchers"), null); }
private void deserialise(JSONObject json) { Map map = json; self = Field.getString(map.get("self")); id = Field.getString(map.get("id")); avatarUrls = Field.getMap(String.class, String.class, map.get("avatarUrls")); key = Field.getString(map.get("key")); name = Field.getString(map.get("name")); description = Field.getString(map.get("description")); lead = Field.getResource(User.class, map.get("lead"), restclient); assigneeType = Field.getString(map.get("assigneeType")); components = Field.getResourceArray(Component.class, map.get("components"), restclient); issueTypes = Field.getResourceArray( IssueType.class, map.containsKey("issueTypes") ? map.get("issueTypes") : map.get("issuetypes"), restclient); versions = Field.getResourceArray(Version.class, map.get("versions"), restclient); roles = Field.getMap(String.class, String.class, map.get("roles")); }
private void deserialise(JSONObject json) { Map map = json; self = Field.getString(map.get("self")); id = Field.getString(map.get("id")); avatarUrls = Field.getMap(String.class, String.class, map.get("avatarUrls")); key = Field.getString(map.get("key")); name = Field.getString(map.get("name")); description = Field.getString(map.get("description")); lead = Field.getResource(User.class, map.get("lead"), restclient); assigneeType = Field.getString(map.get("assigneeType")); components = Field.getResourceArray(Component.class, map.get("components"), restclient); issueTypes = Field.getResourceArray( IssueType.class, map.containsKey("issueTypes") ? map.get("issueTypes") : map.get("issuetypes"), restclient); versions = Field.getResourceArray(Version.class, map.get("versions"), restclient); roles = Field.getMap(String.class, String.class, map.get("roles")); category = Field.getResource(ProjectCategory.class, map.get( "projectCategory" ), restclient); email = Field.getString( map.get("email")); }
public List<User> getAssignableUsers() throws JiraException { JSON result = null; try { Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put("project", this.key); URI searchUri = restclient.buildURI(getBaseUri() + "user/assignable/search", queryParams); result = restclient.get(searchUri); } catch (Exception ex) { throw new JiraException("Failed to retrieve assignable users", ex); } if (!(result instanceof JSONArray)) throw new JiraException("JSON payload is malformed"); return Field.getResourceArray(User.class, result, restclient); }
/** * Get a list of options for a components * * @param project Key of the project context * @param issueType Name of the issue type * * @return a search result structure with results * * @throws JiraException when the search fails */ public List<Component> getComponentsAllowedValues(String project, String issueType) throws JiraException { JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType); JSONObject fieldMetadata = (JSONObject) createMetadata.get(Field.COMPONENTS); List<Component> componentOptions = Field.getResourceArray( Component.class, fieldMetadata.get("allowedValues"), restclient ); return componentOptions; }
/** * Get a list of options for a custom field * * @param field field id * @param project Key of the project context * @param issueType Name of the issue type * * @return a search result structure with results * * @throws JiraException when the search fails */ public List<CustomFieldOption> getCustomFieldAllowedValues(String field, String project, String issueType) throws JiraException { JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType); JSONObject fieldMetadata = (JSONObject) createMetadata.get(field); List<CustomFieldOption> customFieldOptions = Field.getResourceArray( CustomFieldOption.class, fieldMetadata.get("allowedValues"), restclient ); return customFieldOptions; }
/** * Get a list of options for a components * * @param project Key of the project context * @param issueType Name of the issue type * * @return a search result structure with results * * @throws JiraException when the search fails */ public List<Component> getComponentsAllowedValues(String project, String issueType) throws JiraException { JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType); JSONObject fieldMetadata = (JSONObject) createMetadata.get(Field.COMPONENTS); List<Component> componentOptions = Field.getResourceArray( Component.class, fieldMetadata.get("allowedValues"), restclient ); return componentOptions; }
/** * Get a list of options for a custom field * * @param field field id * @param project Key of the project context * @param issueType Name of the issue type * * @return a search result structure with results * * @throws JiraException when the search fails */ public List<CustomFieldOption> getCustomFieldAllowedValues(String field, String project, String issueType) throws JiraException { JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType); JSONObject fieldMetadata = (JSONObject) createMetadata.get(field); List<CustomFieldOption> customFieldOptions = Field.getResourceArray( CustomFieldOption.class, fieldMetadata.get("allowedValues"), restclient ); return customFieldOptions; }
/** * Retrieves all project records visible to the session user. * * @param restclient REST client instance * * @return a list of projects * * @throws JiraException when the retrieval fails */ public static List<Project> getAll(RestClient restclient) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "project"); } catch (Exception ex) { throw new JiraException("Failed to retrieve projects", ex); } if (!(result instanceof JSONArray)) throw new JiraException("JSON payload is malformed"); return Field.getResourceArray(Project.class, result, restclient); }
/** * Retrieves all project records visible to the session user. * * @param restclient REST client instance * * @return a list of projects * * @throws JiraException when the retrieval fails */ public static List<Project> getAll(RestClient restclient) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "project"); } catch (Exception ex) { throw new JiraException("Failed to retrieve projects", ex); } if (!(result instanceof JSONArray)) throw new JiraException("JSON payload is malformed"); return Field.getResourceArray(Project.class, result, restclient); }