Source:
<code>private boolean determineIfUserIsAdminInHierarchy(int userCanvasId, int courseAccountId){ M_log.debug("determineIfUserIsAdminInHierarchy() call"); boolean isAdmin = false; <START> String url = canvasURL + "/api/v1/accounts/" + courseAccountId + "/admins/?user_id[]=" + userCanvasId; <END> M_log.info("API call "+url); HttpResponse response = processApiCall(new HttpGet(url)); if (response == null) { M_log.error(String.format("check user %s is an admin in the course account %s had null response" , userCanvasId, courseAccountId)); return isAdmin; } int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { M_log.error(String.format("check user %s is an admin in the course account %s returned status %s " + "with error message", userCanvasId, statusCode, response.toString())); return isAdmin; } String subAccountAdminsResponse = null; try { subAccountAdminsResponse = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch (IOException e) { M_log.error(String.format("check user %s is an admin in the course account %s failed due to" ,userCanvasId, statusCode, e.getMessage())); return isAdmin; } JSONArray subAccountAdminsJson = new JSONArray(subAccountAdminsResponse); if (subAccountAdminsJson.length() > 0) { M_log.info(String.format("User %s is an admin",userCanvasId)); isAdmin = true; return isAdmin; } int parentAccount = getParentAccount(courseAccountId); if (parentAccount == 0) { return isAdmin; } return determineIfUserIsAdminInHierarchy(userCanvasId, parentAccount); }</code><technical_language>'canvasURL + "/api/v1/accounts/"' part replaced a method takes rest of url argument? IMHO easier read, reduces repetition, means work do (and test) canvas changes api v2 v3... E.g. makeCanvasUrl(courseAccountId + "/admins/?user_id[]=" + userCanvasId);</technical_language>

Target:
private boolean determineIfUserIsAdminInHierarchy(int userCanvasId, int courseAccountId){ M_log.debug("determineIfUserIsAdminInHierarchy() call"); String url = makeCanvasURL("/accounts/" + courseAccountId + "/admins/?user_id[]=" + userCanvasId); HttpResponse response = processApiCall(new HttpGet(url)); if (response == null) { M_log.error(String.format("check user %s is an admin in the course account %s had null response" , userCanvasId, courseAccountId)); return false; } int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { M_log.error(String.format("check user %s is an admin in the course account %s returned status %s " + "with error message", userCanvasId, statusCode, response.toString())); return false; } String errMsg = "check user %s is an admin in the course account %s failed due to"; String subAccountAdminsResponse = null; try { subAccountAdminsResponse = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch (IOException e) { M_log.error(String.format(errMsg, userCanvasId, statusCode, e.getMessage())); return false; } catch (Exception e) { M_log.error(String.format(errMsg, userCanvasId, statusCode, e.getMessage())); return false; } JSONArray subAccountAdminsJson = new JSONArray(subAccountAdminsResponse); if (subAccountAdminsJson.length() > 0) { return true; } int parentAccount = getParentAccount(courseAccountId); if (parentAccount == 0) { return false; } return determineIfUserIsAdminInHierarchy(userCanvasId, parentAccount); }