Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAT-98: report skipped files #417

Draft
wants to merge 131 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
64db218
added working directory
Claudenw Jan 13, 2025
4a68b3c
updated merge issues
Claudenw Jan 13, 2025
9939413
initial design comments
Claudenw Dec 14, 2024
8d5d83b
fixes for tests
Claudenw Dec 21, 2024
0b9b8b9
fixes for RAT-335
Claudenw Dec 22, 2024
058120d
fixes for. gitignore and other descending processors
Claudenw Dec 25, 2024
b3990be
cleaned up checkstyle issues
Claudenw Dec 25, 2024
26b881d
cleaned up checkstyle issues
Claudenw Dec 25, 2024
ae25ee2
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
53be57e
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
eba23cb
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
b6a5ce2
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
ab8e00a
updated and fixed plugin tests
Claudenw Dec 27, 2024
5fb0fdf
fixed last tests in plugin module
Claudenw Dec 27, 2024
4b564ba
fixed Ant task issues
Claudenw Dec 27, 2024
0e40a8b
added missing files
Claudenw Dec 27, 2024
528e46a
fixed tests on Windows
Claudenw Dec 27, 2024
52f0589
turned on mvn debugging
Claudenw Dec 27, 2024
0741f3a
Fixed command line file name processing
Claudenw Dec 28, 2024
e6c723a
added test failure info
Claudenw Dec 28, 2024
7e9c7dd
Added more info to decompose messages
Claudenw Dec 28, 2024
07ca02a
updated some tests
Claudenw Jan 1, 2025
136ddb6
clean up of remaingin core tests
Claudenw Jan 2, 2025
047358b
fixed archive processing and naming issues
Claudenw Jan 4, 2025
9748adf
fixed checkstyle issues
Claudenw Jan 4, 2025
c23f19d
added debug to test
Claudenw Jan 4, 2025
1ce3724
added debug to test
Claudenw Jan 4, 2025
754e698
added debug to test
Claudenw Jan 4, 2025
99a550a
Added detail to decomposition
Claudenw Jan 4, 2025
e03c483
used decomposition in more tests
Claudenw Jan 4, 2025
0b79d61
used decomposition in more tests
Claudenw Jan 4, 2025
143def2
cleaned up decomposition reports
Claudenw Jan 4, 2025
460b85b
cleaned up decomposition reports
Claudenw Jan 4, 2025
aeb058f
Added wild logging to find Windows problem
Claudenw Jan 4, 2025
0023c54
removed excess builds
Claudenw Jan 4, 2025
b6f09a5
Added wild logging to find Windows problem
Claudenw Jan 4, 2025
295093f
debugging for tests
Claudenw Jan 5, 2025
db8d117
debugging for tests
Claudenw Jan 5, 2025
af28b37
debugging for tests
Claudenw Jan 5, 2025
76da4a7
debugging for tests
Claudenw Jan 5, 2025
82e0d37
debugging for tests
Claudenw Jan 5, 2025
fc7bd52
removed unused imports
Claudenw Jan 5, 2025
86ce6ca
possible fix
Claudenw Jan 5, 2025
59b05f5
debugging for tests
Claudenw Jan 5, 2025
f5847c9
debugging for tests
Claudenw Jan 5, 2025
d7b6006
put full testing back
Claudenw Jan 5, 2025
8a80dbe
Fix for windows bug
Claudenw Jan 7, 2025
9c14a1e
RAT-98: Fix typos
ottlinger Jan 6, 2025
fb1dd27
Minor cleanup
ottlinger Jan 6, 2025
e989016
removed dead lines / updated javadoc
Claudenw Jan 7, 2025
3b1ac56
fixed rebase errors
Claudenw Jan 13, 2025
9f82d3d
Added FSInfo to handle file system differences
Claudenw Jan 12, 2025
f9a46f6
updated spotbugs
Claudenw Jan 12, 2025
cefaff7
attempt to fix windows error
Claudenw Jan 12, 2025
a46a244
fixed merge error
Claudenw Jan 12, 2025
103d9db
fixed pattern match
Claudenw Jan 13, 2025
5076009
fix for file delete on windows
Claudenw Jan 14, 2025
818618f
added more descriptive failure messages
Claudenw Jan 14, 2025
faecfca
fixed merg issues
Claudenw Jan 14, 2025
a0bd888
added file converter + test
Claudenw Jan 14, 2025
12d4f1c
Minor cleanups
ottlinger Jan 14, 2025
36f8a31
Minor fixes
ottlinger Jan 14, 2025
b66ff14
fixes file list walker
Claudenw Jan 16, 2025
81a97f6
fixed deprecated messages
Claudenw Jan 17, 2025
3cef2f0
Merge remote-tracking branch 'origin/master' into RAT-98_report_skipp…
Claudenw Jan 23, 2025
53a3f8e
removed MatcherPredicate and inlined the code to make it easier to read
Claudenw Jan 27, 2025
e5073ff
Merge branch 'master' into add_file_arg_converter
Claudenw Jan 27, 2025
89192f8
implemented matcher set in ExclusionProcessor
Claudenw Jan 23, 2025
95ef0a1
Merge branch 'add_matcher_set' into 98_update
Claudenw Jan 28, 2025
b928be2
fixed NoteGuesserTest
Claudenw Jan 28, 2025
b358eee
Merge branch 'Add_workingDirectory_to_resolve_relative_document_names…
Claudenw Jan 28, 2025
7d9e739
fixed DocumentNameMatcher idiom misuse
Claudenw Feb 3, 2025
cc5724b
Merge branch 'RAT-98_fix_merge_issue' into 98_update
Claudenw Feb 3, 2025
e140777
fixed javadoc
Claudenw Feb 3, 2025
f7679b5
fixed checkstyle
Claudenw Feb 3, 2025
04a9da1
initial design comments
Claudenw Dec 14, 2024
6180a13
fixes for tests
Claudenw Dec 21, 2024
89e4e9c
fixes for RAT-335
Claudenw Dec 22, 2024
d0d7b54
fixes for. gitignore and other descending processors
Claudenw Dec 25, 2024
df6412c
cleaned up checkstyle issues
Claudenw Dec 25, 2024
3456632
cleaned up checkstyle issues
Claudenw Dec 25, 2024
cd416a9
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
5d5dab4
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
4c4c97e
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
4daa9c9
fixed and cleaned up plugin tests
Claudenw Dec 26, 2024
2bc6556
updated and fixed plugin tests
Claudenw Dec 27, 2024
4a7a5a7
fixed last tests in plugin module
Claudenw Dec 27, 2024
3bd8ae9
fixed Ant task issues
Claudenw Dec 27, 2024
1fd2550
added missing files
Claudenw Dec 27, 2024
060a4a9
fixed tests on Windows
Claudenw Dec 27, 2024
24a3974
turned on mvn debugging
Claudenw Dec 27, 2024
2f57b8d
Fixed command line file name processing
Claudenw Dec 28, 2024
c489363
added test failure info
Claudenw Dec 28, 2024
eeecd8d
Added more info to decompose messages
Claudenw Dec 28, 2024
f6c6992
updated some tests
Claudenw Jan 1, 2025
79a2b44
clean up of remaingin core tests
Claudenw Jan 2, 2025
cc16bd9
clean up of remaingin core tests
Claudenw Jan 2, 2025
08b1143
fixed archive processing and naming issues
Claudenw Jan 4, 2025
8a18223
fixed checkstyle issues
Claudenw Jan 4, 2025
68f0425
Added detail to decomposition
Claudenw Jan 4, 2025
96c1613
used decomposition in more tests
Claudenw Jan 4, 2025
9148cfe
used decomposition in more tests
Claudenw Jan 4, 2025
9484e22
Added wild logging to find Windows problem
Claudenw Jan 4, 2025
b1e170e
removed excess builds
Claudenw Jan 4, 2025
bbdd9ad
Added wild logging to find Windows problem
Claudenw Jan 4, 2025
f7bc6e5
debugging for tests
Claudenw Jan 5, 2025
c32b768
debugging for tests
Claudenw Jan 5, 2025
51a81d1
debugging for tests
Claudenw Jan 5, 2025
d1fd7b2
removed unused imports
Claudenw Jan 5, 2025
401628c
possible fix
Claudenw Jan 5, 2025
cbc9e30
debugging for tests
Claudenw Jan 5, 2025
6b6aa38
debugging for tests
Claudenw Jan 5, 2025
1e06dae
put full testing back
Claudenw Jan 5, 2025
d69d544
Fix for windows bug
Claudenw Jan 7, 2025
b8b53db
Minor cleanup
ottlinger Jan 6, 2025
c2fcdef
removed dead lines / updated javadoc
Claudenw Jan 7, 2025
10a9460
fixed rebase errors
Claudenw Jan 13, 2025
67b615f
removed MatcherPredicate and inlined the code to make it easier to read
Claudenw Jan 27, 2025
6aee0aa
added working directory
Claudenw Jan 13, 2025
3ff0436
fix for file delete on windows
Claudenw Jan 14, 2025
c2088ee
attempt to fix windows error
Claudenw Jan 12, 2025
1ee90ba
fixed pattern match
Claudenw Jan 13, 2025
e157dc5
fixes file list walker
Claudenw Jan 16, 2025
7d0c643
implemented matcher set in ExclusionProcessor
Claudenw Jan 23, 2025
4834728
fixed NoteGuesserTest
Claudenw Jan 28, 2025
3364d20
Minor cleanups
ottlinger Jan 14, 2025
3e7d699
Minor fixes
ottlinger Jan 14, 2025
3e50462
fixed javadoc
Claudenw Feb 3, 2025
ec474c3
fixed rebase issues
Claudenw Feb 4, 2025
24637cb
Merge branch '98_to_master' into RAT-98_report_skipped_files
Claudenw Feb 4, 2025
d20bfd4
Merge branch 'master' into RAT-98_report_skipped_files
Claudenw Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--output-style
xml
--input-exclude
**/.gitignore
--input-exclude-parsed-scm
GIT
--
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,11 @@ private static Map<String, String> mapOf(String... parts) {
output = new File(args[0])
content = output.text

//Map<ClaimStatistic.Counter, String> data = new HashMap<>()
//data.put(ClaimStatistic.Counter.APPROVED, "2")
//data.put(ClaimStatistic.Counter.ARCHIVES, "0")
//data.put(ClaimStatistic.Counter.BINARIES, "0")
//data.put(ClaimStatistic.Counter.DOCUMENT_TYPES, "3")
//data.put(ClaimStatistic.Counter.IGNORED, "6")
//data.put(ClaimStatistic.Counter.LICENSE_CATEGORIES, "2")
//data.put(ClaimStatistic.Counter.LICENSE_NAMES, "2")
//data.put(ClaimStatistic.Counter.NOTICES, "1")
//data.put(ClaimStatistic.Counter.STANDARDS, "6")
//data.put(ClaimStatistic.Counter.UNAPPROVED, "4")
//data.put(ClaimStatistic.Counter.UNKNOWN, "4")

Document document = XmlUtils.toDom(new FileInputStream(args[0]))
XPath xPath = XPathFactory.newInstance().newXPath()

//for (ClaimStatistic.Counter counter : ClaimStatistic.Counter.values()) {
// String xpath = String.format("/rat-report/statistics/statistic[@name='%s']", counter.displayName())
// Map<String, String> map = mapOf("approval",
// counter == ClaimStatistic.Counter.UNAPPROVED ? "false" : "true",
// "count", data.get(counter),
// "description", counter.getDescription())
// XmlUtils.assertAttributes(document, xPath, xpath, map)
//}

//// license categories
//XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/licenseCategory[@name='?????']",
// mapOf("count", "4" ))
//
//XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/licenseCategory[@name='AL ']",
// mapOf("count", "2" ))
//
//// license names
//XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/licenseName[@name='Apache License Version 2.0']",
// mapOf("count", "2" ))
//
//XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/licenseName[@name='Unknown license']",
// mapOf("count", "4" ))

List<String> ignoredFiles = new ArrayList<>(Arrays.asList(
"/dir1/dir1.txt",
"/dir1/file1.log",
"/dir1/.gitignore",
"/dir2/dir2.md",
"/dir3/dir3.log",
Expand All @@ -102,24 +65,4 @@ XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/documentType[
mapOf("count", "1" ))

XmlUtils.assertAttributes(document, xPath, "/rat-report/statistics/documentType[@name='STANDARD']",
mapOf("count", "6" ))

/*
TextUtils.assertPatternInTarget("^ Approved:\\s+8 ", content)
TextUtils.assertPatternInTarget("^ Archives:\\s+1 ", content)
TextUtils.assertPatternInTarget("^ Binaries:\\s+2 ", content)
TextUtils.assertPatternInTarget("^ Document types:\\s+5 ", content)
TextUtils.assertPatternInTarget("^ Ignored:\\s+1 ", content)
TextUtils.assertPatternInTarget("^ License categories:\\s+4 ", content)
TextUtils.assertPatternInTarget("^ License names:\\s+5", content)
TextUtils.assertPatternInTarget("^ Notices:\\s+2 ", content)
TextUtils.assertPatternInTarget("^ Standards:\\s+8 ", content)
TextUtils.assertPatternInTarget("^ Unapproved:\\s+2 ", content)
TextUtils.assertPatternInTarget("^ Unknown:\\s+2 ", content)

logOutput = new File(args[1])
log = logOutput.text

TextUtils.assertPatternNotInTarget("^ERROR:", log)
TextUtils.assertPatternNotInTarget("^WARN:", log)
*/
mapOf("count", "4" ))
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public static InputStream markSupportedInputStream(final InputStream stream) {
* @throws RatDocumentAnalysisException on error.
*/
public static String process(final Document document) throws RatDocumentAnalysisException {
Metadata metadata = new Metadata();
try (InputStream stream = markSupportedInputStream(document.inputStream())) {
metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, document.getName().getName());
Metadata metadata = new Metadata();
metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, document.getName().getShortName());
String result = TIKA.detect(stream, metadata);
String[] parts = result.split("/");
MediaType mediaType = new MediaType(parts[0], parts[1]);
Expand All @@ -146,7 +146,6 @@ public static String process(final Document document) throws RatDocumentAnalysis
document.getMetaData().setDocumentType(Document.Type.NOTICE);
}
}

return result;
} catch (IOException e) {
throw new RatDocumentAnalysisException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.apache.rat.config.exclusion.plexus.MatchPatterns;
import org.apache.rat.document.DocumentName;
import org.apache.rat.document.DocumentNameMatcher;
import org.apache.rat.utils.DefaultLog;
Expand Down Expand Up @@ -85,10 +85,8 @@ private void resetLastMatcher() {
* @return this
*/
public ExclusionProcessor addIncludedPatterns(final Iterable<String> patterns) {
List<String> lst = new ArrayList<>();
patterns.forEach(lst::add);
DefaultLog.getInstance().info(format("Including patterns: %s", String.join(", ", lst)));
includedPatterns.addAll(lst);
DefaultLog.getInstance().info(format("Including patterns: %s", String.join(", ", patterns)));
patterns.forEach(includedPatterns::add);
resetLastMatcher();
return this;
}
Expand Down Expand Up @@ -140,10 +138,8 @@ public ExclusionProcessor addIncludedCollection(final StandardCollection collect
* @return this
*/
public ExclusionProcessor addExcludedPatterns(final Iterable<String> patterns) {
List<String> lst = new ArrayList<>();
patterns.forEach(lst::add);
DefaultLog.getInstance().info(format("Excluding patterns: %s", String.join(", ", lst)));
excludedPatterns.addAll(lst);
DefaultLog.getInstance().info(format("Excluding patterns: %s", String.join(", ", patterns)));
patterns.forEach(excludedPatterns::add);
resetLastMatcher();
return this;
}
Expand Down Expand Up @@ -175,22 +171,6 @@ public ExclusionProcessor addExcludedCollection(final StandardCollection collect
return this;
}

/**
* Adds to lists of qualified file patterns. Non-matching patterns start with a {@code !}.
* @param matching the list to put matching file patterns into.
* @param notMatching the list to put non-matching files patterns into.
* @param patterns the patterns to match.
*/
private void segregateList(final Set<String> matching, final Set<String> notMatching,
final Iterable<String> patterns) {
if (patterns.iterator().hasNext()) {
ExtendedIterator.create(patterns.iterator()).filter(ExclusionUtils.MATCH_FILTER).forEachRemaining(matching::add);
ExtendedIterator.create(patterns.iterator()).filter(ExclusionUtils.NOT_MATCH_FILTER)
.map(s -> s.substring(1))
.forEachRemaining(notMatching::add);
}
}

/**
* Creates a Document name matcher that will return {@code false} on any
* document that is excluded.
Expand All @@ -204,84 +184,132 @@ public DocumentNameMatcher getNameMatcher(final DocumentName basedir) {
if (lastMatcher == null || !basedir.equals(lastMatcherBaseDir)) {
lastMatcherBaseDir = basedir;

final Set<String> incl = new TreeSet<>();
final Set<String> excl = new TreeSet<>();
final List<DocumentNameMatcher> inclMatchers = new ArrayList<>();

// add the file processors
for (StandardCollection sc : fileProcessors) {
ExtendedIterator<FileProcessor> iter = sc.fileProcessor();
if (iter.hasNext()) {
iter.forEachRemaining(fp -> {
segregateList(excl, incl, fp.apply(basedir));
fp.customDocumentNameMatchers().forEach(inclMatchers::add);
});
} else {
DefaultLog.getInstance().info(String.format("%s does not have a fileProcessor.", sc));
}
}
final List<MatcherSet> matchers = extractFileProcessors(basedir);
final MatcherSet.Builder fromCommandLine = new MatcherSet.Builder();
DocumentName.Builder nameBuilder = DocumentName.builder(basedir).setBaseName(basedir);
extractPatterns(nameBuilder, fromCommandLine);
extractCollectionPatterns(nameBuilder, fromCommandLine);
extractCollectionMatchers(fromCommandLine);
extractPaths(fromCommandLine);
matchers.add(fromCommandLine.build());

// add the standard patterns
segregateList(incl, excl, new FileProcessor(includedPatterns).apply(basedir));
segregateList(excl, incl, new FileProcessor(excludedPatterns).apply(basedir));
lastMatcher = MatcherSet.merge(matchers).createMatcher();
DefaultLog.getInstance().debug(format("Created matcher set for %s%n%s", basedir.getName(),
lastMatcher));
}
return lastMatcher;
}

// add the collection patterns
for (StandardCollection sc : includedCollections) {
Set<String> patterns = sc.patterns();
if (patterns.isEmpty()) {
DefaultLog.getInstance().info(String.format("%s does not have a defined collection for inclusion.", sc));
} else {
segregateList(incl, excl, new FileProcessor(sc.patterns()).apply(basedir));
}
}
for (StandardCollection sc : excludedCollections) {
Set<String> patterns = sc.patterns();
if (patterns.isEmpty()) {
DefaultLog.getInstance().info(String.format("%s does not have a defined collection for exclusion.", sc));
} else {
segregateList(excl, incl, new FileProcessor(sc.patterns()).apply(basedir));
}
/**
* Extracts the file processors from {@link #fileProcessors}.
* @param basedir The directory to base the file processors on.
* @return a list of MatcherSets that are created for each {@link #fileProcessors} entry.
*/
private List<MatcherSet> extractFileProcessors(final DocumentName basedir) {
final List<MatcherSet> fileProcessorList = new ArrayList<>();
for (StandardCollection sc : fileProcessors) {
ExtendedIterator<List<MatcherSet>> iter = sc.fileProcessorBuilder().map(builder -> builder.build(basedir));
if (iter.hasNext()) {
iter.forEachRemaining(fileProcessorList::addAll);
} else {
DefaultLog.getInstance().debug(String.format("%s does not have a fileProcessor.", sc));
}
}
return fileProcessorList;
}

// add the matchers
ExtendedIterator.create(includedCollections.iterator())
.map(StandardCollection::staticDocumentNameMatcher)
.filter(Objects::nonNull)
.forEachRemaining(inclMatchers::add);

List<DocumentNameMatcher> exclMatchers = ExtendedIterator.create(excludedCollections.iterator())
.map(StandardCollection::staticDocumentNameMatcher)
.filter(Objects::nonNull)
.addTo(new ArrayList<>());
/**
* Converts the pattern to use the directory separator specified by the document name and localises it for
* exclusion processing.
* @param documentName The document name to adjust the pattern against.
* @param pattern the pattern.
* @return the prepared pattern.
*/
private String preparePattern(final DocumentName documentName, final String pattern) {
return ExclusionUtils.qualifyPattern(documentName,
ExclusionUtils.convertSeparator(pattern, "/", documentName.getDirectorySeparator()));
}
/**
* Extracts {@link #includedPatterns} and {@link #excludedPatterns} into the specified matcherBuilder.
* @param nameBuilder The name builder for the pattern. File names are resolved against the generated name.
* @param matcherBuilder the MatcherSet.Builder to add the patterns to.
*/
private void extractPatterns(final DocumentName.Builder nameBuilder, final MatcherSet.Builder matcherBuilder) {
DocumentName name = nameBuilder.setName("Patterns").build();
if (!excludedPatterns.isEmpty()) {
matcherBuilder.addExcluded(name, excludedPatterns.stream()
.map(s -> preparePattern(name, s))
.collect(Collectors.toSet()));
}
if (!includedPatterns.isEmpty()) {
matcherBuilder.addIncluded(name, includedPatterns.stream()
.map(s -> preparePattern(name, s)).collect(Collectors.toSet()));
}
}

if (!incl.isEmpty()) {
inclMatchers.add(new DocumentNameMatcher("included patterns", MatchPatterns.from(basedir.getDirectorySeparator(), incl), basedir));
/**
* Extracts {@link #includedCollections} and {@link #excludedCollections} patterns into the specified matcherBuilder.
* @param nameBuilder the name builder for the pattern names.
* @param matcherBuilder the MatcherSet.Builder to add the collections to.
*/
private void extractCollectionPatterns(final DocumentName.Builder nameBuilder, final MatcherSet.Builder matcherBuilder) {
final Set<String> incl = new TreeSet<>();
final Set<String> excl = new TreeSet<>();
for (StandardCollection sc : includedCollections) {
Set<String> patterns = sc.patterns();
if (patterns.isEmpty()) {
DefaultLog.getInstance().debug(String.format("%s does not have a defined collection for inclusion.", sc));
} else {
MatcherSet.Builder.segregateList(incl, excl, sc.patterns());
}
if (!excl.isEmpty()) {
exclMatchers.add(new DocumentNameMatcher("excluded patterns", MatchPatterns.from(basedir.getDirectorySeparator(), excl), basedir));
}
for (StandardCollection sc : excludedCollections) {
Set<String> patterns = sc.patterns();
if (patterns.isEmpty()) {
DefaultLog.getInstance().debug(String.format("%s does not have a defined collection for exclusion.", sc));
} else {
MatcherSet.Builder.segregateList(excl, incl, sc.patterns());
}
}
DocumentName name = nameBuilder.setName("Collections").build();
matcherBuilder
.addExcluded(name, excl.stream().map(s -> preparePattern(name.getBaseDocumentName(), s)).collect(Collectors.toSet()))
.addIncluded(name, incl.stream().map(s -> preparePattern(name.getBaseDocumentName(), s)).collect(Collectors.toSet()));
}

if (!includedPaths.isEmpty()) {
for (DocumentNameMatcher matcher : includedPaths) {
DefaultLog.getInstance().info(format("Including path matcher %s", matcher));
inclMatchers.add(matcher);
}
}
if (!excludedPaths.isEmpty()) {
for (DocumentNameMatcher matcher : excludedPaths) {
DefaultLog.getInstance().info(format("Excluding path matcher %s", matcher));
exclMatchers.add(matcher);
}
}
/**
* Extracts {@link #includedCollections} and {@link #excludedCollections} matchers into the specified matcherBuilder.
* @param matcherBuilder the MatcherSet.Builder to add the collections to.
*/
private void extractCollectionMatchers(final MatcherSet.Builder matcherBuilder) {
ExtendedIterator.create(includedCollections.iterator())
.map(StandardCollection::staticDocumentNameMatcher)
.filter(Objects::nonNull)
.forEachRemaining(matcherBuilder::addIncluded);

ExtendedIterator.create(excludedCollections.iterator())
.map(StandardCollection::staticDocumentNameMatcher)
.filter(Objects::nonNull)
.forEachRemaining(matcherBuilder::addExcluded);
}

lastMatcher = DocumentNameMatcher.MATCHES_ALL;
if (!exclMatchers.isEmpty()) {
lastMatcher = DocumentNameMatcher.not(DocumentNameMatcher.or(exclMatchers));
if (!inclMatchers.isEmpty()) {
lastMatcher = DocumentNameMatcher.or(DocumentNameMatcher.or(inclMatchers), lastMatcher);
}
/**
* Extracts {@link #includedPaths} and {@link #excludedPaths} patterns into the specified matcherBuilder.
* @param matcherBuilder the MatcherSet.Builder to add the collections to.
*/
private void extractPaths(final MatcherSet.Builder matcherBuilder) {
if (!includedPaths.isEmpty()) {
for (DocumentNameMatcher matcher : includedPaths) {
DefaultLog.getInstance().info(format("Including path matcher %s", matcher));
matcherBuilder.addIncluded(matcher);
}
}
if (!excludedPaths.isEmpty()) {
for (DocumentNameMatcher matcher : excludedPaths) {
DefaultLog.getInstance().info(format("Excluding path matcher %s", matcher));
matcherBuilder.addExcluded(matcher);
}
}
return lastMatcher;
}
}
Loading