use of org.codelibs.fess.crawler.client.AccessTimeoutTarget in project fess-crawler by codelibs.
the class FtpClient method processRequest.
protected ResponseData processRequest(final String uri, final boolean includeContent) {
if (ftpAuthenticationHolder == null) {
init();
}
// start
AccessTimeoutTarget accessTimeoutTarget = null;
TimeoutTask accessTimeoutTask = null;
if (accessTimeout != null) {
accessTimeoutTarget = new AccessTimeoutTarget(Thread.currentThread());
accessTimeoutTask = TimeoutManager.getInstance().addTimeoutTarget(accessTimeoutTarget, accessTimeout.intValue(), false);
}
try {
return getResponseData(uri, includeContent);
} finally {
if (accessTimeout != null) {
accessTimeoutTarget.stop();
if (!accessTimeoutTask.isCanceled()) {
accessTimeoutTask.cancel();
}
}
}
}
use of org.codelibs.fess.crawler.client.AccessTimeoutTarget in project fess-crawler by codelibs.
the class ApiExtractor method getText.
@Override
public ExtractData getText(final InputStream in, final Map<String, String> params) {
if (logger.isDebugEnabled()) {
logger.debug("Accessing " + url);
}
// start
AccessTimeoutTarget accessTimeoutTarget = null;
TimeoutTask accessTimeoutTask = null;
if (accessTimeout != null) {
accessTimeoutTarget = new AccessTimeoutTarget(Thread.currentThread());
accessTimeoutTask = TimeoutManager.getInstance().addTimeoutTarget(accessTimeoutTarget, accessTimeout.intValue(), false);
}
final ExtractData data = new ExtractData();
final HttpPost httpPost = new HttpPost(url);
final HttpEntity postEntity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).setCharset(Charset.forName("UTF-8")).addBinaryBody("filedata", in).build();
httpPost.setEntity(postEntity);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
if (response.getStatusLine().getStatusCode() != Constants.OK_STATUS_CODE) {
logger.error("Failed to access " + url + ", code: " + response.getStatusLine().getStatusCode() + ".");
return null;
}
data.setContent(EntityUtils.toString(response.getEntity(), Charsets.UTF_8));
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
data.putValue(header.getName(), header.getValue());
}
} catch (final IOException e) {
throw new ExtractException(e);
} finally {
if (accessTimeout != null) {
accessTimeoutTarget.stop();
if (!accessTimeoutTask.isCanceled()) {
accessTimeoutTask.cancel();
}
}
}
return data;
}
use of org.codelibs.fess.crawler.client.AccessTimeoutTarget in project fess-crawler by codelibs.
the class FileSystemClient method processRequest.
protected ResponseData processRequest(final String uri, final boolean includeContent) {
if (!isInit.get()) {
synchronized (isInit) {
if (!isInit.get()) {
init();
isInit.set(true);
}
}
}
// start
AccessTimeoutTarget accessTimeoutTarget = null;
TimeoutTask accessTimeoutTask = null;
if (accessTimeout != null) {
accessTimeoutTarget = new AccessTimeoutTarget(Thread.currentThread());
accessTimeoutTask = TimeoutManager.getInstance().addTimeoutTarget(accessTimeoutTarget, accessTimeout.intValue(), false);
}
try {
return getResponseData(uri, includeContent);
} finally {
if (accessTimeout != null) {
accessTimeoutTarget.stop();
if (!accessTimeoutTask.isCanceled()) {
accessTimeoutTask.cancel();
}
}
}
}
use of org.codelibs.fess.crawler.client.AccessTimeoutTarget in project fess-crawler by codelibs.
the class HcHttpClient method doHttpMethod.
public ResponseData doHttpMethod(final String url, final HttpUriRequest httpRequest) {
if (httpClient == null) {
init();
}
if (logger.isDebugEnabled()) {
logger.debug("Accessing " + url);
}
// start
AccessTimeoutTarget accessTimeoutTarget = null;
TimeoutTask accessTimeoutTask = null;
if (accessTimeout != null) {
accessTimeoutTarget = new AccessTimeoutTarget(Thread.currentThread());
accessTimeoutTask = TimeoutManager.getInstance().addTimeoutTarget(accessTimeoutTarget, accessTimeout.intValue(), false);
}
try {
return processHttpMethod(url, httpRequest);
} finally {
if (accessTimeout != null) {
accessTimeoutTarget.stop();
if (!accessTimeoutTask.isCanceled()) {
accessTimeoutTask.cancel();
}
}
}
}
use of org.codelibs.fess.crawler.client.AccessTimeoutTarget in project fess-crawler by codelibs.
the class SmbClient method processRequest.
protected ResponseData processRequest(final String uri, final boolean includeContent) {
if (smbAuthenticationHolder == null) {
init();
}
// start
AccessTimeoutTarget accessTimeoutTarget = null;
TimeoutTask accessTimeoutTask = null;
if (accessTimeout != null) {
accessTimeoutTarget = new AccessTimeoutTarget(Thread.currentThread());
accessTimeoutTask = TimeoutManager.getInstance().addTimeoutTarget(accessTimeoutTarget, accessTimeout.intValue(), false);
}
try {
return getResponseData(uri, includeContent);
} finally {
if (accessTimeout != null) {
accessTimeoutTarget.stop();
if (!accessTimeoutTask.isCanceled()) {
accessTimeoutTask.cancel();
}
}
}
}
Aggregations