public static URI parseURI(final String str) { try { return new URI(str); } catch (URISyntaxException e) { throw new RestClientException(e); } }
public static DateTime parseDate(final String str) { try { return JIRA_DATE_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } }
public static URI parseURI(final String str) { try { return new URI(str); } catch (URISyntaxException e) { throw new RestClientException(e); } }
public static DateTime parseDateTime(final String str) { try { return JIRA_DATE_TIME_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } }
public static DateTime parseDateTime(final String str) { try { return JIRA_DATE_TIME_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } }
public static DateTime parseDate(final String str) { try { return JIRA_DATE_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } }
@Override public T apply(@Nullable Response input) { try { return responseHandler.handle(input); } catch (JSONException e) { throw new RestClientException(e); } catch (IOException e) { throw new RestClientException(e); } } };
@Override public T apply(@Nullable Response input) { try { return responseHandler.handle(input); } catch (JSONException e) { throw new RestClientException(e); } catch (IOException e) { throw new RestClientException(e); } } };
/** * Tries to parse date and time and return that. If fails then tries to parse date only. * * @param str String contains either date and time or date only * @return date and time or date only */ public static DateTime parseDateTimeOrDate(final String str) { try { return JIRA_DATE_TIME_FORMATTER.parseDateTime(str); } catch (Exception ignored) { try { return JIRA_DATE_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } } }
/** * Tries to parse date and time and return that. If fails then tries to parse date only. * * @param str String contains either date and time or date only * @return date and time or date only */ public static DateTime parseDateTimeOrDate(final String str) { try { return JIRA_DATE_TIME_FORMATTER.parseDateTime(str); } catch (Exception ignored) { try { return JIRA_DATE_FORMATTER.parseDateTime(str); } catch (Exception e) { throw new RestClientException(e); } } }
@Override public T claim() { try { return delegate.claim(); } catch (RestClientException e) { throw new RestClientException(e); } }
@Override public T claim() { try { return delegate.claim(); } catch (RestClientException e) { throw new RestClientException(e); } }
@Override public BasicProjectRole apply(@Nullable final String key) { try { return new BasicProjectRole(JsonParseUtil.parseURI(json.getString(key)), key); } catch (JSONException e) { throw new RestClientException(e); } } }
@Override public BasicProjectRole apply(@Nullable final String key) { try { return new BasicProjectRole(JsonParseUtil.parseURI(json.getString(key)), key); } catch (JSONException e) { throw new RestClientException(e); } } }
@Override public T apply(Response response) { try { final String body = response.getEntity(); final Collection<ErrorCollection> errorMessages = extractErrors(response.getStatusCode(), body); throw new RestClientException(errorMessages, response.getStatusCode()); } catch (JSONException e) { throw new RestClientException(e, response.getStatusCode()); } } };
@Override public T apply(Response response) { try { final String body = response.getEntity(); final Collection<ErrorCollection> errorMessages = extractErrors(response.getStatusCode(), body); throw new RestClientException(errorMessages, response.getStatusCode()); } catch (JSONException e) { throw new RestClientException(e, response.getStatusCode()); } } };
@Override public JSONObject generate(VersionPosition versionPosition) throws JSONException { final JSONObject res = new JSONObject(); final String posValue; switch (versionPosition) { case FIRST: posValue = "First"; break; case LAST: posValue = "Last"; break; case EARLIER: posValue = "Earlier"; break; case LATER: posValue = "Later"; break; default: throw new RestClientException("Unsupported position [" + versionPosition + "]", null); } res.put("position", posValue); return res; } }
@Override public JSONObject generate(VersionPosition versionPosition) throws JSONException { final JSONObject res = new JSONObject(); final String posValue; switch (versionPosition) { case FIRST: posValue = "First"; break; case LAST: posValue = "Last"; break; case EARLIER: posValue = "Earlier"; break; case LATER: posValue = "Later"; break; default: throw new RestClientException("Unsupported position [" + versionPosition + "]", null); } res.put("position", posValue); return res; } }
private Promise<SearchResult> searchJqlImplPost(@Nullable Integer maxResults, @Nullable Integer startAt, Iterable<String> expandosValues, String jql, @Nullable Set<String> fields) { final JSONObject postEntity = new JSONObject(); try { postEntity.put(JQL_ATTRIBUTE, jql) .put(EXPAND_ATTRIBUTE, ImmutableList.copyOf(expandosValues)) .putOpt(START_AT_ATTRIBUTE, startAt) .putOpt(MAX_RESULTS_ATTRIBUTE, maxResults); if (fields != null) { postEntity.put(FIELDS_ATTRIBUTE, fields); // putOpt doesn't work with collections } } catch (JSONException e) { throw new RestClientException(e); } return postAndParse(searchUri, postEntity, searchResultJsonParser); }
private Promise<SearchResult> searchJqlImplPost(@Nullable Integer maxResults, @Nullable Integer startAt, Iterable<String> expandosValues, String jql, @Nullable Set<String> fields) { final JSONObject postEntity = new JSONObject(); try { postEntity.put(JQL_ATTRIBUTE, jql) .put(EXPAND_ATTRIBUTE, ImmutableList.copyOf(expandosValues)) .putOpt(START_AT_ATTRIBUTE, startAt) .putOpt(MAX_RESULTS_ATTRIBUTE, maxResults); if (fields != null) { postEntity.put(FIELDS_ATTRIBUTE, fields); // putOpt doesn't work with collections } } catch (JSONException e) { throw new RestClientException(e); } return postAndParse(searchUri, postEntity, searchResultJsonParser); }