@Test public void collectExtraMetadataProperties() { ctx.registerInjectActivateService(new MetadataSchemaPropertiesImpl(), ImmutableMap.<String, Object>builder(). put("extra.metadata.properties", new String[]{ "jcr:content/foo=My Foo", "jcr:content/metadata/bar=My Bar", "./jcr:content/foo=My Foo 2" }). build()); MetadataSchemaPropertiesImpl metadataSchemaProperties = (MetadataSchemaPropertiesImpl) ctx.getService(MetadataProperties.class); Map<String, List<String>> collectedMetadata = new HashMap<>(); collectedMetadata = metadataSchemaProperties.collectExtraMetadataProperties(collectedMetadata); assertEquals(2, collectedMetadata.size()); assertEquals(2, collectedMetadata.get("./jcr:content/foo").size()); assertEquals("My Foo", collectedMetadata.get("./jcr:content/foo").get(0)); assertEquals("My Foo 2", collectedMetadata.get("./jcr:content/foo").get(1)); assertEquals(1, collectedMetadata.get("./jcr:content/metadata/bar").size()); assertEquals("My Bar", collectedMetadata.get("./jcr:content/metadata/bar").get(0)); }
protected final Map<String, List<String>> collectExtraMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.extra_metadata_properties() != null) { for (final String entry : cfg.extra_metadata_properties()) { final String propertyName = StringUtils.substringBefore(entry, "="); final String fieldLabel = StringUtils.substringAfter(entry, "="); collectMetadataProperty(fieldLabel, propertyName, collectedMetadata); } } return collectedMetadata; }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> collectExtraMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.extra_metadata_properties() != null) { for (final String entry : cfg.extra_metadata_properties()) { final String propertyName = StringUtils.substringBefore(entry, "="); final String fieldLabel = StringUtils.substringAfter(entry, "="); collectMetadataProperty(fieldLabel, propertyName, collectedMetadata); } } return collectedMetadata; } }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> collectExtraMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.extra_metadata_properties() != null) { for (final String entry : cfg.extra_metadata_properties()) { final String propertyName = StringUtils.substringBefore(entry, "="); final String fieldLabel = StringUtils.substringAfter(entry, "="); collectMetadataProperty(fieldLabel, propertyName, collectedMetadata); } } return collectedMetadata; }  }
MetadataSchemaPropertiesImpl implements MetadataProperties { protected final Map<String, List<String>> collectExtraMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.extra_metadata_properties() != null) { for (final String entry : cfg.extra_metadata_properties()) { final String propertyName = StringUtils.substringBefore(entry, "="); final String fieldLabel = StringUtils.substringAfter(entry, "="); collectMetadataProperty(fieldLabel, propertyName, collectedMetadata); } } 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>> collectExtraMetadataProperties(final Map<String, List<String>> collectedMetadata) { if (cfg != null && cfg.extra_metadata_properties() != null) { for (final String entry : cfg.extra_metadata_properties()) { final String propertyName = StringUtils.substringBefore(entry, "="); final String fieldLabel = StringUtils.substringAfter(entry, "="); collectMetadataProperty(fieldLabel, propertyName, collectedMetadata); } } return collectedMetadata; }  @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request); @Override Map<String, List<String>> getMetadataProperties(final SlingHttpServletRequest request, final List<String> metadataFieldResourceTypes);  }