Jeroen Hoffman pushed to branch release/5.0 at cms-community / hippo-site-toolkit
Commits: d5613a4c by Jeroen Hoffman at 2017-11-17T11:08:43+01:00 HSTTWO-4167 [Fwd port to 12.0] Using Component Info inheritance leads to "Ignoring duplicate parameter" warnings - - - - - 2 changed files: - client-modules/page-composer/src/main/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessor.java - client-modules/page-composer/src/test/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessorTest.java Changes: ===================================== client-modules/page-composer/src/main/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessor.java ===================================== --- a/client-modules/page-composer/src/main/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessor.java +++ b/client-modules/page-composer/src/main/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessor.java @@ -20,6 +20,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -272,7 +273,9 @@ public class ParametersInfoProcessor { final Multimap<String, ContainerItemComponentPropertyRepresentation> fieldGroupProperties = LinkedHashMultimap.create(); for (final Class<?> interfaceClass : getBreadthFirstInterfaceHierarchy(classType)) { + Multimap<String, ContainerItemComponentPropertyRepresentation> interfaceClassFieldGroupProperties = LinkedHashMultimap.create(); final FieldGroupList fieldGroupList = interfaceClass.getAnnotation(FieldGroupList.class); + Set<String> uniquePropertiesForInterfaceClass = new HashSet<>(); if (fieldGroupList != null) { final FieldGroup[] fieldGroups = fieldGroupList.value(); if (fieldGroups != null && fieldGroups.length > 0) { @@ -285,13 +288,19 @@ public class ParametersInfoProcessor { } for (final String propertyName : fieldGroup.value()) { final ContainerItemComponentPropertyRepresentation property = propertyMap.get(propertyName); - if (property == null) { + if (!uniquePropertiesForInterfaceClass.add(propertyName)) { + log.warn("Ignoring duplicate parameter '{}' in field group '{}' of parameters info interface '{}'", + propertyName, fieldGroup.titleKey(), classType.getCanonicalName()); + } else if (property == null) { log.warn("Ignoring unknown parameter '{}' in parameters info interface '{}'", propertyName, classType.getCanonicalName()); } else if (fieldGroupProperties.containsValue(property)) { - log.warn("Ignoring duplicate parameter '{}' in field group '{}' of parameters info interface '{}'", - new Object[]{ propertyName, fieldGroup.titleKey(), classType.getCanonicalName() }); + // valid if FieldGroup is (re)defined in inherited Info Class + log.debug("Parameter '{}' in field group '{}' of parameters info interface '{}' was already added to list.", + propertyName, fieldGroup.titleKey(), classType.getCanonicalName()); } else { + log.debug("Adding parameter '{}' to field group '{}' of parameters info interface '{}'", + propertyName, titleKey, classType.getCanonicalName()); property.setGroupLabel(groupLabel); fieldGroupProperties.put(titleKey, property); } @@ -362,7 +371,7 @@ public class ParametersInfoProcessor { * hierarchy BREADTH FIRST traversal. Empty array if there are no resource bundles at all */ protected static final ResourceBundle[] getResourceBundles(final ParametersInfo parameterInfo, final Locale locale) { - final List<ResourceBundle> resourceBundles = new ArrayList<ResourceBundle>(); + final List<ResourceBundle> resourceBundles = new ArrayList<>(); final List<Class<?>> breadthFirstInterfaceHierarchy = getBreadthFirstInterfaceHierarchy(parameterInfo.type()); for (final Class<?> clazz : breadthFirstInterfaceHierarchy) { ===================================== client-modules/page-composer/src/test/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessorTest.java ===================================== --- a/client-modules/page-composer/src/test/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessorTest.java +++ b/client-modules/page-composer/src/test/java/org/hippoecm/hst/pagecomposer/jaxrs/model/ParametersInfoProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2015 Hippo B.V. (http://www.onehippo.com) + * Copyright 2011-2017 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -422,7 +422,7 @@ public class ParametersInfoProcessorTest { @FieldGroupList({ @FieldGroup(titleKey = "group1", - value = {"parameter"} + value = {"parameter", "parameter"} ), @FieldGroup(titleKey = "group2", value = {"parameter"} @@ -486,7 +486,6 @@ public class ParametersInfoProcessorTest { value = {"d3"} ) }) - static interface FieldGroupInheritedInterfaceD { @Parameter(name = "d1") String getD1(); View it on GitLab: https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/d5613a4c0e1eb2f7f94f7b7495af5d8afc182a95 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/d5613a4c0e1eb2f7f94f7b7495af5d8afc182a95 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn