public int updateFetchStatus( AbstractSearchRequest searchRequest, FetchStatus fetchStatus, int bufferSize, TaskLog taskLog) throws SearchLibException { setCurrentTaskLog(taskLog); try { int total = 0; FileItemFieldEnum.INSTANCE.fetchStatus.addFilterQuery( searchRequest, fetchStatus.value, false, true); List<FileItem> fileItemList = new ArrayList<FileItem>(); for (; ; ) { fileItemList.clear(); getFileList(searchRequest, 0, bufferSize, fileItemList); if (fileItemList.size() == 0) break; for (FileItem fileItem : fileItemList) fileItem.setFetchStatus(fetchStatus); updateFileItems(fileItemList); total += fileItemList.size(); taskLog.setInfo(total + " URI(s) updated"); if (taskLog.isAbortRequested()) throw new SearchLibException.AbortException(); } return total; } catch (ParseException e) { throw new SearchLibException(e); } finally { resetCurrentTaskLog(); } }
@Override public void execute( Client client, TaskProperties properties, Variables variables, TaskLog taskLog) throws SearchLibException { try { taskLog.setInfo("Crawl cache flush starts"); CrawlCacheManager.getInstance(client).flushCache(true); taskLog.setInfo("Crawl cache flush done"); } catch (IOException e) { throw new SearchLibException(e); } }
public int delete(AbstractSearchRequest searchRequest, TaskLog taskLog) throws SearchLibException { setCurrentTaskLog(taskLog); try { int total = 0; List<FileItem> itemList = new ArrayList<FileItem>(); for (; ; ) { itemList.clear(); getFileList(searchRequest, 0, 1000, itemList); if (itemList.size() == 0) break; List<String> uriList = new ArrayList<String>(itemList.size()); for (FileItem fileItem : itemList) uriList.add(fileItem.getUri()); dbClient.deleteDocuments(FileItemFieldEnum.INSTANCE.uri.getName(), uriList); total += itemList.size(); taskLog.setInfo(total + " URI(s) deleted"); if (taskLog.isAbortRequested()) throw new SearchLibException.AbortException(); } return total; } finally { resetCurrentTaskLog(); } }