Bert Leunis pushed to branch master at cms-community / 
hippo-addon-channel-manager


Commits:
a97bbc54 by Bert Leunis at 2018-02-23T14:25:51+01:00
CHANNELMGR-1751 log an error message when document types cannot be used due to 
unavailable prototype nodes

- - - - -
20c48ce8 by Bert Leunis at 2018-02-23T14:32:23+01:00
CHANNELMGR-1751 Reintegrate bugfix/CHANNELMGR-1751

- - - - -


3 changed files:

- 
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/ChoiceFieldType.java
- 
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/RichTextFieldType.java


Changes:

=====================================
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/ChoiceFieldType.java
=====================================
--- 
a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/ChoiceFieldType.java
+++ 
b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/ChoiceFieldType.java
@@ -27,6 +27,7 @@ import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 
+import org.hippoecm.repository.util.JcrUtils;
 import org.hippoecm.repository.util.NodeIterable;
 import org.onehippo.cms.channelmanager.content.document.model.FieldValue;
 import org.onehippo.cms.channelmanager.content.document.util.FieldPath;
@@ -80,6 +81,11 @@ public class ChoiceFieldType extends AbstractFieldType 
implements NodeFieldType 
 
         trimToMaxValues(values);
 
+        if (values.size() < getMinValues()) {
+            log.error("No values available for node of type '{}' of document 
at {}. This document type cannot be " +
+                    "used to create new documents in the Channel Manager.", 
getId(), JcrUtils.getNodePathQuietly(node));
+        }
+
         return values.isEmpty() ? Optional.empty() : Optional.of(values);
     }
 


=====================================
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
@@ -27,6 +27,7 @@ import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 
+import org.hippoecm.repository.util.JcrUtils;
 import org.hippoecm.repository.util.NodeIterable;
 import org.onehippo.cms.channelmanager.content.document.model.FieldValue;
 import org.onehippo.cms.channelmanager.content.document.util.FieldPath;
@@ -81,6 +82,11 @@ public class CompoundFieldType extends AbstractFieldType 
implements NodeFieldTyp
 
         trimToMaxValues(values);
 
+        if (values.size() < getMinValues()) {
+            log.error("No values available for node of type '{}' of document 
at {}. This document type cannot be " +
+                    "used to create new documents in the Channel Manager.", 
getId(), JcrUtils.getNodePathQuietly(node));
+        }
+
         return values.isEmpty() ? Optional.empty() : Optional.of(values);
     }
 


=====================================
content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/RichTextFieldType.java
=====================================
--- 
a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/RichTextFieldType.java
+++ 
b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/RichTextFieldType.java
@@ -53,7 +53,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * A document field of type hippostd:html.
- *
+ * <p>
  * <smell>
  * The configuration of the link- and image pickers is looked up in the 
_default_ plugin cluster of hippostd:html
  * instead of in the 'root/linkpicker' and 'root/imagepicker' child nodes. The 
only difference is that the names in the
@@ -182,13 +182,19 @@ public class RichTextFieldType extends 
FormattedTextFieldType implements NodeFie
     protected List<FieldValue> readValues(final Node node) {
         try {
             final NodeIterator children = node.getNodes(getId());
-            final List<FieldValue> values = new 
ArrayList<>((int)children.getSize());
+            final List<FieldValue> values = new ArrayList<>((int) 
children.getSize());
             for (final Node child : new NodeIterable(children)) {
                 final FieldValue value = readValue(child);
                 if (value.hasValue()) {
                     values.add(value);
                 }
             }
+
+            if (values.size() < getMinValues()) {
+                log.error("No values available for node of type '{}' of 
document at {}. This document type cannot be " +
+                        "used to create new documents in the Channel 
Manager.", getId(), JcrUtils.getNodePathQuietly(node));
+            }
+
             return values;
         } catch (final RepositoryException e) {
             log.warn("Failed to read rich text field '{}'", getId(), e);



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/166487369ae93aab8c05301ab6863a6616ad5a2e...20c48ce880126f8e0086cb7d92100f0bf08a7102

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/166487369ae93aab8c05301ab6863a6616ad5a2e...20c48ce880126f8e0086cb7d92100f0bf08a7102
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