refactor(transformer): add Document-accepting storeChildUrls overload - #177
Merged
Conversation
Extract the child-URL extraction logic from storeChildUrls(ResponseData, ResultData) into a new storeChildUrls(ResponseData, ResultData, Document) overload so a caller that has already parsed the response body into a DOM (e.g. an XPath-based content extractor) can reuse that Document instead of forcing a second parse of the same page. The existing two-argument method keeps identical behavior: it parses the body and delegates to the new overload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor
HtmlTransformer.storeChildUrlsto expose aDocument-accepting overload, so a caller that has already parsed the response body into a DOM (e.g. an XPath-based content extractor) can reuse thatDocumentfor child-URL extraction instead of parsing the same page a second time.Changes
protected void storeChildUrls(ResponseData, ResultData, Document)containing the existing child-URL extraction logic (base-href resolution, child-URL rules,getChildUrlSet()merge, self-URL removal).storeChildUrls(ResponseData, ResultData)keeps identical behavior: it parses the body exactly as before and delegates to the new overload.Behavior for all current callers (
HtmlTransformer,FileTransformer,XpathTransformer) is unchanged:setEncodingchange) and its try/catch is preserved.MalformedURLException, which the 2-arg method's existingcatch (Exception)wraps intoCrawlerSystemException("Could not store data.", e)exactly as before.getChildUrlRules,getUrlFromTagAttribute,getBaseHref,convertChildUrlList,addChildUrlFromTagAttribute) are still invoked via dynamic dispatch, so subclass customizations continue to apply.Testing
fess-crawlermodule test suite passes (1980 tests, 0 failures);mvn formatter:format/license:format/javadoc:jarall clean.Motivation
This enables a follow-up change in Fess (
FessXpathTransformer) to parse each crawled page's DOM once instead of twice per page.