@Test public void testIsOsgiBundleOrConfigurationFile() { validator = new PackageTypeValidator(filter, ValidationMessageSeverity.ERROR, ValidationMessageSeverity.WARN, ValidationMessageSeverity.INFO, false, false, false, PackageType.CONTENT, PackageTypeValidatorFactory.DEFAULT_JCR_INSTALLER_NODE_PATH_REGEX, PackageTypeValidatorFactory.DEFAULT_ADDITIONAL_JCR_INSTALLER_FILE_NODE_PATH_REGEX, null); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/install/mybundle-123.jar", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/config/mmyconfig-123.cfg.json", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/config/mmyconfig-123.cfg", true)); Assert.assertFalse(validator.isOsgiBundleOrConfiguration("/apps/config/mmyconfig-123.json", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/config/mmyconfig-123.config", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/level2/config/mybundle-123.jar", true)); Assert.assertFalse(validator.isOsgiBundleOrConfiguration("/apps/level2/config/myconfig-123.xml", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/level2/config/myconfig-123.xml", false)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/install.runmode1.runmode2/mybundle-123.jar", true)); Assert.assertTrue(validator.isOsgiBundleOrConfiguration("/apps/install.runmode1.runmode2/12/mybundle-123.jar", true)); Assert.assertFalse(validator.isOsgiBundleOrConfiguration("/apps/level2/level3/level4/l5/install/mybundle-123.jar", true)); }
boolean isOsgiBundleOrConfiguration(String nodePath, boolean onlyFile) { if (jcrInstallerNodePathRegex.matcher(nodePath).matches()) { if (onlyFile) { return additionalJcrInstallerFileNodePathRegex.matcher(nodePath).matches(); } else { return true; } } return false; }
PackageTypeValidator implements NodePathValidator, FilterValidator, PropertiesValidator, MetaInfPathValidator, DocumentViewXmlValidator { boolean isOsgiBundleOrConfiguration(String nodePath, boolean onlyFile) { if (jcrInstallerNodePathRegex.matcher(nodePath).matches()) { if (onlyFile) { return additionalJcrInstallerFileNodePathRegex.matcher(nodePath).matches(); } else { return true; } } return false; } }
PackageTypeValidator implements NodePathValidator, FilterValidator, PropertiesValidator, MetaInfPathValidator, DocumentViewXmlValidator { boolean isOsgiBundleOrConfiguration(String nodePath, boolean onlyFile) { if (jcrInstallerNodePathRegex.matcher(nodePath).matches()) { if (onlyFile) { return additionalJcrInstallerFileNodePathRegex.matcher(nodePath).matches(); } else { return true; } } return false; } PackageTypeValidator(@NotNull WorkspaceFilter workspaceFilter, @NotNull ValidationMessageSeverity severity,
            @NotNull ValidationMessageSeverity severityForNoPackageType, @NotNull ValidationMessageSeverity severityForLegacyType,
            boolean prohibitMutableContent, boolean prohibitImmutableContent, boolean allowComplexFilterRulesInApplicationPackages,
            @NotNull PackageType type, @NotNull Pattern jcrInstallerNodePathRegex, @NotNull Pattern additionalJcrInstallerFileNodePathRegex,
            @Nullable ValidationContext containerValidationContext); }
PackageTypeValidator implements NodePathValidator, FilterValidator, PropertiesValidator, MetaInfPathValidator, DocumentViewXmlValidator { boolean isOsgiBundleOrConfiguration(String nodePath, boolean onlyFile) { if (jcrInstallerNodePathRegex.matcher(nodePath).matches()) { if (onlyFile) { return additionalJcrInstallerFileNodePathRegex.matcher(nodePath).matches(); } else { return true; } } return false; } PackageTypeValidator(@NotNull WorkspaceFilter workspaceFilter, @NotNull ValidationMessageSeverity severity,
            @NotNull ValidationMessageSeverity severityForNoPackageType, @NotNull ValidationMessageSeverity severityForLegacyType,
            boolean prohibitMutableContent, boolean prohibitImmutableContent, boolean allowComplexFilterRulesInApplicationPackages,
            @NotNull PackageType type, @NotNull Pattern jcrInstallerNodePathRegex, @NotNull Pattern additionalJcrInstallerFileNodePathRegex,
            @Nullable ValidationContext containerValidationContext); @Override @Nullable Collection<ValidationMessage> done(); @Override @Nullable Collection<ValidationMessage> validate(@NotNull NodeContext nodeContext); @Override Collection<ValidationMessage> validate(@NotNull WorkspaceFilter filter); @Override Collection<ValidationMessage> validate(@NotNull PackageProperties properties); @Override Collection<ValidationMessage> validateMetaInfPath(@NotNull Path filePath, @NotNull Path basePath, boolean isFolder); @Override @Nullable Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull String nodePath,
            @NotNull Path filePath, boolean isRoot); }
PackageTypeValidator implements NodePathValidator, FilterValidator, PropertiesValidator, MetaInfPathValidator, DocumentViewXmlValidator { boolean isOsgiBundleOrConfiguration(String nodePath, boolean onlyFile) { if (jcrInstallerNodePathRegex.matcher(nodePath).matches()) { if (onlyFile) { return additionalJcrInstallerFileNodePathRegex.matcher(nodePath).matches(); } else { return true; } } return false; } PackageTypeValidator(@NotNull WorkspaceFilter workspaceFilter, @NotNull ValidationMessageSeverity severity,
            @NotNull ValidationMessageSeverity severityForNoPackageType, @NotNull ValidationMessageSeverity severityForLegacyType,
            boolean prohibitMutableContent, boolean prohibitImmutableContent, boolean allowComplexFilterRulesInApplicationPackages,
            @NotNull PackageType type, @NotNull Pattern jcrInstallerNodePathRegex, @NotNull Pattern additionalJcrInstallerFileNodePathRegex,
            @Nullable ValidationContext containerValidationContext); @Override @Nullable Collection<ValidationMessage> done(); @Override @Nullable Collection<ValidationMessage> validate(@NotNull NodeContext nodeContext); @Override Collection<ValidationMessage> validate(@NotNull WorkspaceFilter filter); @Override Collection<ValidationMessage> validate(@NotNull PackageProperties properties); @Override Collection<ValidationMessage> validateMetaInfPath(@NotNull Path filePath, @NotNull Path basePath, boolean isFolder); @Override @Nullable Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull String nodePath,
            @NotNull Path filePath, boolean isRoot);  }