use of org.apache.manifoldcf.crawler.connectors.confluence.v6.model.builder.ConfluenceResourceBuilder in project manifoldcf by apache.
the class ConfluenceClient method pageFromHttpEntity.
/**
* <p>
* Creates a Confluence page object from the given entity returned by the server
* </p>
*
* @param entity
* the {@code HttpEntity} to create the {@code MutablePage} from
* @return the Confluence page instance
* @throws Exception
*/
private MutablePage pageFromHttpEntity(final HttpEntity entity) throws Exception {
final String stringEntity = EntityUtils.toString(entity, "UTF-8");
final JSONParser parser = new JSONParser();
final JSONObject responseObject = (JSONObject) parser.parse(new StringReader(stringEntity));
@SuppressWarnings("unchecked") final MutablePage response = ((ConfluenceResourceBuilder<MutablePage>) MutablePage.builder()).fromJson(responseObject, new MutablePage());
return response;
}
use of org.apache.manifoldcf.crawler.connectors.confluence.v6.model.builder.ConfluenceResourceBuilder in project manifoldcf by apache.
the class ConfluenceClient method getConfluenceRestrictionsResources.
/**
* <p>
* Get the {@code ConfluenceResources} from the given url
* </p>
*
* @param url
* The url identifying the REST resource to get the documents
* @param builder
* The builder used to build the resources contained in the response
* @return a {@code ConfluenceRestrictionsResponse} containing the page results
* @throws Exception
*/
private ConfluenceRestrictionsResponse<? extends ConfluenceResource> getConfluenceRestrictionsResources(final String url, final ConfluenceResourceBuilder<? extends ConfluenceResource> builder) throws Exception {
logger.debug("[Processing] Hitting url for get confluence resources: {}", sanitizeUrl(url));
final HttpGet httpGet = createGetRequest(url);
try (CloseableHttpResponse response = executeRequest(httpGet)) {
final ConfluenceRestrictionsResponse<? extends ConfluenceResource> confluenceResponse = restrictionsResponseFromHttpEntity(response.getEntity(), builder);
EntityUtils.consume(response.getEntity());
return confluenceResponse;
} catch (final IOException e) {
logger.error("[Processing] Failed to get page(s)", e);
throw new Exception("Confluence appears to be down", e);
}
}
use of org.apache.manifoldcf.crawler.connectors.confluence.v6.model.builder.ConfluenceResourceBuilder in project manifoldcf by apache.
the class ConfluenceClient method getConfluenceResources.
/**
* <p>
* Get the {@code ConfluenceResources} from the given url
* </p>
*
* @param url
* The url identifying the REST resource to get the documents
* @param builder
* The builder used to build the resources contained in the response
* @return a {@code ConfluenceResponse} containing the page results
* @throws Exception
*/
private ConfluenceResponse<? extends ConfluenceResource> getConfluenceResources(final String url, final ConfluenceResourceBuilder<? extends ConfluenceResource> builder) throws Exception {
logger.debug("[Processing] Hitting url for get confluence resources: {}", sanitizeUrl(url));
final HttpGet httpGet = createGetRequest(url);
try (CloseableHttpResponse response = executeRequest(httpGet)) {
final ConfluenceResponse<? extends ConfluenceResource> confluenceResponse = responseFromHttpEntity(response.getEntity(), builder);
EntityUtils.consume(response.getEntity());
return confluenceResponse;
} catch (final IOException e) {
logger.error("[Processing] Failed to get page(s)", e);
throw new Exception("Confluence appears to be down", e);
}
}
Aggregations