@Test public void removeMetadataProperties() { ctx.registerInjectActivateService(new MetadataSchemaPropertiesImpl(), ImmutableMap.<String, Object>builder(). put("blacklisted.metadata.properties", new String[]{ "jcr:content/foo" }). build()); MetadataSchemaPropertiesImpl metadataSchemaProperties = (MetadataSchemaPropertiesImpl) ctx.getService(MetadataProperties.class); Map<String, List<String>> collectedMetadata = new HashMap<>(); collectedMetadata.put("jcr:content/foo", Arrays.asList("Blacklisted")); collectedMetadata.put("./jcr:content/foo", Arrays.asList("Blacklisted Too")); collectedMetadata.put("./jcr:content/metadata/bar", Arrays.asList("Not blacklisted")); collectedMetadata = metadataSchemaProperties.removeBlacklistedMetadataProperties(collectedMetadata); assertEquals(1, collectedMetadata.size()); assertEquals(1, collectedMetadata.get("./jcr:content/metadata/bar").size()); assertEquals("Not blacklisted", collectedMetadata.get("./jcr:content/metadata/bar").get(0)); }
protected final Map<String, List<String>> removeBlacklistedMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.blacklisted_metadata_properties() != null) { for (String propertyName : cfg.blacklisted_metadata_properties()) { String withoutDotSlash = StringUtils.removeStart(propertyName, "./"); String withDotSlash = "./" + withoutDotSlash; if (collectedMetadata.containsKey(withDotSlash)) { collectedMetadata.remove(withDotSlash); } if (collectedMetadata.containsKey(withoutDotSlash)) { collectedMetadata.remove(withoutDotSlash); } } } return collectedMetadata; }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> removeBlacklistedMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.blacklisted_metadata_properties() != null) { for (String propertyName : cfg.blacklisted_metadata_properties()) { String withoutDotSlash = StringUtils.removeStart(propertyName, "./"); String withDotSlash = "./" + withoutDotSlash; if (collectedMetadata.containsKey(withDotSlash)) { collectedMetadata.remove(withDotSlash); } if (collectedMetadata.containsKey(withoutDotSlash)) { collectedMetadata.remove(withoutDotSlash); } } } return collectedMetadata; } }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> removeBlacklistedMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.blacklisted_metadata_properties() != null) { for (String propertyName : cfg.blacklisted_metadata_properties()) { String withoutDotSlash = StringUtils.removeStart(propertyName, "./"); String withDotSlash = "./" + withoutDotSlash; if (collectedMetadata.containsKey(withDotSlash)) { collectedMetadata.remove(withDotSlash); } if (collectedMetadata.containsKey(withoutDotSlash)) { collectedMetadata.remove(withoutDotSlash); } } } return collectedMetadata; }  }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> removeBlacklistedMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.blacklisted_metadata_properties() != null) { for (String propertyName : cfg.blacklisted_metadata_properties()) { String withoutDotSlash = StringUtils.removeStart(propertyName, "./"); String withDotSlash = "./" + withoutDotSlash; if (collectedMetadata.containsKey(withDotSlash)) { collectedMetadata.remove(withDotSlash); } if (collectedMetadata.containsKey(withoutDotSlash)) { collectedMetadata.remove(withoutDotSlash); } } } return collectedMetadata; }  @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request); @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request, final List<String> metadataFieldResourceTypes); }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> removeBlacklistedMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.blacklisted_metadata_properties() != null) { for (String propertyName : cfg.blacklisted_metadata_properties()) { String withoutDotSlash = StringUtils.removeStart(propertyName, "./"); String withDotSlash = "./" + withoutDotSlash; if (collectedMetadata.containsKey(withDotSlash)) { collectedMetadata.remove(withDotSlash); } if (collectedMetadata.containsKey(withoutDotSlash)) { collectedMetadata.remove(withoutDotSlash); } } } return collectedMetadata; }  @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request); @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request, final List<String> metadataFieldResourceTypes);  }