AdvancedFilterValidator implements GenericMetaInfDataValidator, FilterValidator, DocumentViewXmlValidator, JcrPathValidator { static boolean isRegexValidForRootPath(String regex, String rootPath) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(rootPath); if (matcher.matches()) { return true; } return matcher.hitEnd(); } AdvancedFilterValidator(@NotNull DocumentBuilderFactory factory, @NotNull ValidationMessageSeverity defaultSeverity, @NotNull ValidationMessageSeverity severityForUncoveredAncestorNodes, @NotNull ValidationMessageSeverity severityForUncoveredFilterRootAncestors, @NotNull ValidationMessageSeverity severityForOrphanedFilterEntries, boolean isSubPackage, @NotNull Collection<PackageInfo> dependenciesMetaInfo, @NotNull WorkspaceFilter filter, @NotNull Collection<String> validRoots); void setFilterValidators(Map<String, FilterValidator> filterValidators); @Override Collection<ValidationMessage> done(); @Override Collection<ValidationMessage> validate(@NotNull WorkspaceFilter filter); @Override @Nullable Collection<ValidationMessage> validateJcrPath(@NotNull NodeContext nodeContext,
            boolean isFolder); @Override @Nullable Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull NodeContext nodeContext,
            boolean isRoot); @Override Collection<ValidationMessage> validateMetaInfData(@NotNull InputStream input, @NotNull Path filePath, @NotNull Path basePath); @Override boolean shouldValidateMetaInfData(@NotNull Path filePath);  }
@Test public void testIsRegexValidForRootPath() { Assert.assertTrue(AdvancedFilterValidator.isRegexValidForRootPath("/apps/test", "/apps")); Assert.assertTrue(AdvancedFilterValidator.isRegexValidForRootPath(".*/somepath", "/apps")); Assert.assertTrue(AdvancedFilterValidator.isRegexValidForRootPath("^.*/somepath$", "/apps")); Assert.assertFalse(AdvancedFilterValidator.isRegexValidForRootPath("/[aps]{4}", "/apps/test")); Assert.assertFalse(AdvancedFilterValidator.isRegexValidForRootPath("/apps", "/apps/test")); Assert.assertFalse(AdvancedFilterValidator.isRegexValidForRootPath("/apps/test", "/apps2/test")); Assert.assertFalse(AdvancedFilterValidator.isRegexValidForRootPath("/[aps]{3}/somepath", "/apps")); Assert.assertTrue(AdvancedFilterValidator.isRegexValidForRootPath("/apps/test", "/apps/test")); }