Mathijs den Burger pushed to branch master at cms-community / 
hippo-addon-channel-manager


Commits:
9bdc56e1 by Mathijs den Burger at 2017-03-03T12:06:44+01:00
CHANNELMGR-1182 Exclude field with unsupported validator from doctype

Such fields should not be rendered by the frontend at all, so don't
include them in the REST response either.

- - - - -


4 changed files:

- 
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldType.java
- 
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldType.java
- 
content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldTypeTest.java
- 
content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldTypeTest.java


Changes:

=====================================
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldType.java
=====================================
--- 
a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldType.java
+++ 
b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2016-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.
@@ -53,7 +53,7 @@ public class CompoundFieldType extends FieldType {
 
     @Override
     public boolean isValid() {
-        return !fields.isEmpty();
+        return super.isValid() && !fields.isEmpty();
     }
 
     @Override


=====================================
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldType.java
=====================================
--- 
a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldType.java
+++ 
b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldType.java
@@ -156,7 +156,7 @@ public abstract class FieldType {
      * @return true or false
      */
     public boolean isValid() {
-        return true;
+        return !hasUnsupportedValidator();
     }
 
     /**


=====================================
content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldTypeTest.java
=====================================
--- 
a/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldTypeTest.java
+++ 
b/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/CompoundFieldTypeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2016-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.
@@ -81,6 +81,17 @@ public class CompoundFieldTypeTest {
     }
 
     @Test
+    public void isValid() {
+        assertTrue(fieldType.isValid());
+
+        CompoundFieldType empty = new CompoundFieldType();
+        assertFalse(empty.isValid());
+
+        fieldType.addValidator(FieldType.Validator.UNSUPPORTED);
+        assertFalse(fieldType.isValid());
+    }
+
+    @Test
     public void readFromSinglePresentCompound() throws Exception {
         node.addNode(NODE_NAME, 
"compound:type").setProperty(STRING_PROPERTY_1, "Value");
 


=====================================
content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldTypeTest.java
=====================================
--- 
a/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldTypeTest.java
+++ 
b/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/FieldTypeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2016-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.
@@ -91,6 +91,9 @@ public class FieldTypeTest {
     @Test
     public void isValid() {
         assertTrue(fieldType.isValid());
+
+        fieldType.addValidator(FieldType.Validator.UNSUPPORTED);
+        assertFalse(fieldType.isValid());
     }
 
     @Test



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/9bdc56e1fe6de9119c6cdaffb15144f1fccad4a6
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to