Jeroen Hoffman pushed to branch master at cms-community / hippo-site-toolkit
Commits: 633a7e1e by Jeroen Hoffman at 2017-11-17T11:38:08+01:00 HSTTWO-4168 [Fwd port to 12.1] Using Component Info inheritance leads to "Ignoring duplicate parameter" warnings - - - - - e990b143 by Jeroen Hoffman at 2017-11-17T11:41:09+01:00 HSTTWO-4168 (merge fix) remove unused variable, add final, reuse 'titleKey' variable - - - - - 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; @@ -273,6 +274,7 @@ public class ParametersInfoProcessor { for (final Class<?> interfaceClass : getBreadthFirstInterfaceHierarchy(classType)) { final FieldGroupList fieldGroupList = interfaceClass.getAnnotation(FieldGroupList.class); + final Set<String> uniquePropertiesForInterfaceClass = new HashSet<>(); if (fieldGroupList != null) { final FieldGroup[] fieldGroups = fieldGroupList.value(); if (fieldGroups != null && fieldGroups.length > 0) { @@ -285,13 +287,19 @@ public class ParametersInfoProcessor { } for (final String propertyName : fieldGroup.value()) { final ContainerItemComponentPropertyRepresentation property = propertyMap.get(propertyName); - if (property == null) { - log.warn("Ignoring unknown parameter '{}' in parameters info interface '{}'", - propertyName, classType.getCanonicalName()); - } else if (fieldGroupProperties.containsValue(property)) { + if (!uniquePropertiesForInterfaceClass.add(propertyName)) { log.warn("Ignoring duplicate parameter '{}' in field group '{}' of parameters info interface '{}'", - new Object[]{ propertyName, fieldGroup.titleKey(), classType.getCanonicalName() }); + propertyName, titleKey, classType.getCanonicalName()); + } else if (property == null) { + log.warn("Ignoring unknown parameter '{}' in field group '{}' of parameters info interface '{}'", + propertyName, titleKey, classType.getCanonicalName()); + } else if (fieldGroupProperties.containsValue(property)) { + // 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 +370,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/compare/674594e311e64ed0c4cba37be4085ca772c3b390...e990b143e8fd3c7947a9734568901b12c249e4d9 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-site-toolkit/compare/674594e311e64ed0c4cba37be4085ca772c3b390...e990b143e8fd3c7947a9734568901b12c249e4d9 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