/** * Creates a new component in the given project. * * @param project Key of the project to create in * * @return a fluent create instance */ public Component.FluentCreate createComponent(String project) { return Component.create(restclient, project); }
/** * Creates a component from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Component(RestClient restclient, JSONObject json) { super(restclient); if (json != null) deserialise(json); }
/** * Obtains a component given its ID. * * @param id the component ID * * @return the component * * @throws JiraException failed to obtain the component */ public Component getComponent(String id) throws JiraException { return Component.get(restclient, id); }
/** * Retrieves the given component record. * * @param restclient REST client instance * @param id Internal JIRA ID of the component * * @return a component instance * * @throws JiraException when the retrieval fails */ public static Component get(RestClient restclient, String id) throws JiraException { JSON result = null; try { result = restclient.get(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to retrieve component " + id, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Component(restclient, (JSONObject)result); }
/** * Executes the create action. * @return the created component * * @throws JiraException when the create fails */ public Component execute() throws JiraException { JSON result = null; try { result = restclient.post(getRestUri(null), req); } catch (Exception ex) { throw new JiraException("Failed to create issue", ex); } if (!(result instanceof JSONObject) || !((JSONObject) result).containsKey("id") || !(((JSONObject) result).get("id") instanceof String)) { throw new JiraException("Unexpected result on create component"); } return new Component(restclient, (JSONObject) result); } }
@Override public String toString() { return getName(); }
/** * Deletes a component from a project. * * @throws JiraException failed to delete the component */ public void delete() throws JiraException { try { restclient.delete(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to delete component " + id, ex); } } }
private static String getRestUri(String id) { return getBaseUri() + "component/" + (id != null ? id : ""); }
/** * Retrieves the given component record. * * @param restclient REST client instance * @param id Internal JIRA ID of the component * * @return a component instance * * @throws JiraException when the retrieval fails */ public static Component get(RestClient restclient, String id) throws JiraException { JSON result = null; try { result = restclient.get(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to retrieve component " + id, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Component(restclient, (JSONObject)result); }
/** * Executes the create action. * @return the created component * * @throws JiraException when the create fails */ public Component execute() throws JiraException { JSON result = null; try { result = restclient.post(getRestUri(null), req); } catch (Exception ex) { throw new JiraException("Failed to create issue", ex); } if (!(result instanceof JSONObject) || !((JSONObject) result).containsKey("id") || !(((JSONObject) result).get("id") instanceof String)) { throw new JiraException("Unexpected result on create component"); } return new Component(restclient, (JSONObject) result); } }
@Override public String toString() { return getName(); }
/** * Deletes a component from a project. * * @throws JiraException failed to delete the component */ public void delete() throws JiraException { try { restclient.delete(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to delete component " + id, ex); } } }
private static String getRestUri(String id) { return getBaseUri() + "component/" + (id != null ? id : ""); }
result = (T)new Comment(restclient, (JSONObject)r); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r); else if (type == CustomFieldOption.class) result = (T)new CustomFieldOption(restclient, (JSONObject)r);
/** * Creates a component from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Component(RestClient restclient, JSONObject json) { super(restclient); if (json != null) deserialise(json); }
/** * Creates a new component in the given project. * * @param project Key of the project to create in * * @return a fluent create instance */ public Component.FluentCreate createComponent(String project) { return Component.create(restclient, project); }
/** * Obtains a component given its ID. * * @param id the component ID * * @return the component * * @throws JiraException failed to obtain the component */ public Component getComponent(String id) throws JiraException { return Component.get(restclient, id); } }
result = (T)new Comment(restclient, (JSONObject)r, parentId); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r); else if (type == CustomFieldOption.class) result = (T)new CustomFieldOption(restclient, (JSONObject)r);