// Code to add comments for Jira Issue public static void RestAddComment(String strComment, String strIssueID) { try { String auth = new String(Base64.encode("admin:admin")); String createCommentData = "{\"body\": \"" + strComment + "\"}\""; String comment = invokePostMethod( auth, BASE_URL + "/rest/api/2/issue/" + strIssueID + "/comment", createCommentData); System.out.println(comment); JSONObject issueObj = new JSONObject(comment); String newKey = issueObj.getString("id"); System.out.println("id:" + newKey); } catch (AuthenticationException e) { System.out.println("Username or Password wrong!"); e.printStackTrace(); } catch (ClientHandlerException e) { System.out.println("Error invoking REST method"); e.printStackTrace(); } catch (JSONException e) { System.out.println("Invalid JSON output"); e.printStackTrace(); } }
public User getUser(String uid) throws DataSourceException, ConfigException { try { String s = "(&(objectClass=" + source.getUsersObjectClassValue() + ")(" + source.getUsersIdKey() + "=" + uid + "))"; List<SearchResult> r = this.search(s, SecurityEntityType.USER); if (!r.isEmpty()) { return newUser(r.get(0).getAttributes()); } else { return null; } } catch (javax.naming.AuthenticationException e) { e.printStackTrace(); throw new ConfigException(e, "LDAP connection failed, please check your settings"); } catch (NamingException e) { throw new DataSourceException(e, "LDAP Exception : " + e.getMessage()); } }