use of org.apache.manifoldcf.crawler.connectors.confluence.v6.exception.ConfluenceException in project manifoldcf by apache.
the class ConfluenceClient method getSpacePermissionsForUser.
private List<String> getSpacePermissionsForUser(final Space space, final String username) throws Exception {
final String url = String.format(Locale.ROOT, "%s://%s:%s%s%sgetPermissionsForUser", protocol, host, port, path, AUTHORITY_PATH);
logger.debug("[Processing] Hitting url {} for getting Confluence permissions for user {} in space {}", url, username, space.getKey());
final HttpPost httpPost = createPostRequest(url);
final JSONArray jsonArray = new JSONArray();
jsonArray.add(space.getKey());
jsonArray.add(username);
final StringEntity stringEntity = new StringEntity(jsonArray.toJSONString());
httpPost.setEntity(stringEntity);
final HttpResponse response = httpClient.execute(httpPost);
if (response.getStatusLine().getStatusCode() != 200) {
throw new ConfluenceException("Confluence error. " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
}
final HttpEntity entity = response.getEntity();
final List<String> permissions = permissionsFromHttpEntity(entity);
EntityUtils.consume(entity);
return permissions;
}
Aggregations