Search in sources :

Example 1 with AccessResultData

use of org.codelibs.fess.crawler.entity.AccessResultData in project fess-crawler by codelibs.

the class BinaryTransformer method transform.

/*
     * (non-Javadoc)
     *
     * @see
     * org.codelibs.fess.crawler.transformer.Transformer#getData(org.codelibs.fess.crawler.entity
     * .AccessResultData)
     */
@Override
public ResultData transform(final ResponseData responseData) {
    if (responseData == null || !responseData.hasResponseBody()) {
        throw new CrawlingAccessException("No response body.");
    }
    final ResultData resultData = new ResultData();
    resultData.setTransformerName(getName());
    try (BufferedInputStream bis = new BufferedInputStream(responseData.getResponseBody())) {
        resultData.setData(IOUtils.toByteArray(bis));
        resultData.setEncoding(responseData.getCharSet());
        return resultData;
    } catch (final IOException e) {
        throw new CrawlerSystemException("Could not convert the input stream.", e);
    }
}
Also used : ResultData(org.codelibs.fess.crawler.entity.ResultData) AccessResultData(org.codelibs.fess.crawler.entity.AccessResultData) CrawlingAccessException(org.codelibs.fess.crawler.exception.CrawlingAccessException) BufferedInputStream(java.io.BufferedInputStream) CrawlerSystemException(org.codelibs.fess.crawler.exception.CrawlerSystemException) IOException(java.io.IOException)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 AccessResultData (org.codelibs.fess.crawler.entity.AccessResultData)1 ResultData (org.codelibs.fess.crawler.entity.ResultData)1 CrawlerSystemException (org.codelibs.fess.crawler.exception.CrawlerSystemException)1 CrawlingAccessException (org.codelibs.fess.crawler.exception.CrawlingAccessException)1