Jeroen Hoffman pushed to branch release/4.2 at cms-community / 
hippo-site-toolkit


Commits:
0a1e08b8 by Bert Leunis at 2017-11-09T16:18:43+01:00
HSTTWO-4163 only warn about duplicate field group properties defined in the 
same class

- - - - -
ca4bc4d6 by Bert Leunis at 2017-11-10T13:51:41+01:00
HSTTWO-4163 warning for duplicates in the same class, logging of duplicate 
properties overall now debug level

- - - - -
de1318df by Jeroen Hoffman at 2017-11-15T14:25:12+01:00
HSTTWO-4163 Merge branch 'release/4.2' into bugfix/HSTTWO-4163

- - - - -
bf4f04bb by Jeroen Hoffman at 2017-11-15T15:33:53+01:00
HSTTWO-4163 reuse titleKey variable; add a 'final'

- - - - -
f2c762a8 by Jeroen Hoffman at 2017-11-15T16:35:37+01:00
HSTTWO-4163 add debug statement for when adding a parameter to a field group

- - - - -
d39a04f7 by Jeroen Hoffman at 2017-11-17T10:47:58+01:00
HSTTWO-4163 Reintegrate branch 'bugfix/HSTTWO-4163' into release/4.2

- - - - -


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
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2011-2016 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.
@@ -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;
@@ -240,6 +241,7 @@ public class ParametersInfoProcessor {
 
         for (Class<?> interfaceClass : 
getBreadthFirstInterfaceHierarchy(classType)) {
             final FieldGroupList fieldGroupList = 
interfaceClass.getAnnotation(FieldGroupList.class);
+            final Set<String> uniquePropertiesForInterfaceClass = new 
HashSet<>();
             if (fieldGroupList != null) {
                 FieldGroup[] fieldGroups = fieldGroupList.value();
                 if (fieldGroups != null && fieldGroups.length > 0) {
@@ -252,13 +254,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, 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);
                             }
@@ -329,7 +337,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) {
-        List<ResourceBundle> resourceBundles = new ArrayList<ResourceBundle>();
+        List<ResourceBundle> resourceBundles = new ArrayList<>();
 
         final List<Class<?>> breadthFirstInterfaceHierarchy = 
getBreadthFirstInterfaceHierarchy(parameterInfo.type());
         for (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/d56af56e658b1f6e0b104f36f4fce91896cb8d56...d39a04f70aaa1a7863d2ed71bd9b0f89061eabe9

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-site-toolkit/compare/d56af56e658b1f6e0b104f36f4fce91896cb8d56...d39a04f70aaa1a7863d2ed71bd9b0f89061eabe9
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

Reply via email to