/** * Creates an attachment from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Attachment(RestClient restclient, JSONObject json) { super(restclient); if (json != null) deserialise(json); }
@Override public String toString() { return getContentUrl(); }
/** * Retrieves the given attachment record. * * @param restclient REST client instance * @param id Internal JIRA ID of the attachment * * @return an attachment instance * * @throws JiraException when the retrieval fails */ public static Attachment get(RestClient restclient, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "attachment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve attachment " + id, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Attachment(restclient, (JSONObject)result); }
result = (T)new Attachment(restclient, (JSONObject)r); else if (type == ChangeLog.class) result = (T)new ChangeLog(restclient, (JSONObject)r);
/** * Retrieves the given attachment record. * * @param restclient REST client instance * @param id Internal JIRA ID of the attachment * * @return an attachment instance * * @throws JiraException when the retrieval fails */ public static Attachment get(RestClient restclient, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "attachment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve attachment " + id, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Attachment(restclient, (JSONObject)result); }
result = (T)new Attachment(restclient, (JSONObject)r); else if (type == ChangeLog.class) result = (T)new ChangeLog(restclient, (JSONObject)r);
/** * Creates an attachment from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Attachment(RestClient restclient, JSONObject json) { super(restclient); if (json != null) deserialise(json); }
@Override public String toString() { return getContentUrl(); }