Index: editor/repository/src/main/resources/cms-validators.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- editor/repository/src/main/resources/cms-validators.xml (revision 34367)
+++ editor/repository/src/main/resources/cms-validators.xml (revision )
@@ -67,6 +67,17 @@
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$
+
+
+ frontend:plugin
+
+
+ org.hippoecm.frontend.editor.validator.plugins.NodeReferenceValidator
+
+
+ validation.service.translator.config
+
+
frontend:plugin
\ No newline at end of file
Index: editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/plugins/NodeReferenceValidator.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/plugins/NodeReferenceValidator.java (revision )
+++ editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/plugins/NodeReferenceValidator.java (revision )
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012 Hippo.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hippoecm.frontend.editor.validator.plugins;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.wicket.model.IModel;
+import org.hippoecm.frontend.model.JcrNodeModel;
+import org.hippoecm.frontend.plugin.IPluginContext;
+import org.hippoecm.frontend.plugin.config.IPluginConfig;
+import org.hippoecm.frontend.validation.IFieldValidator;
+import org.hippoecm.frontend.validation.ValidationException;
+import org.hippoecm.frontend.validation.Violation;
+
+public class NodeReferenceValidator extends AbstractCmsValidator {
+
+ public NodeReferenceValidator(IPluginContext context, IPluginConfig config) {
+ super(context, config);
+ }
+
+ @Override
+ public void preValidation(final IFieldValidator type) throws ValidationException {
+ if (!"String".equals(type.getFieldType().getType())) {
+ throw new ValidationException("Invalid validation exception; cannot validate non-string field for emptiness");
+ }
+ }
+
+ @Override
+ public Set validate(final IFieldValidator fieldValidator, final JcrNodeModel model, final IModel childModel) throws ValidationException {
+ Set violations = new HashSet();
+ String ref = (String) childModel.getObject();
+ if(ref == null || ref.equals("") || ref.equals("cafebabe-cafe-babe-cafe-babecafebabe")) {
+ violations.add(fieldValidator.newValueViolation(childModel, "reference-is-empty"));
+ }
+ return violations;
+ }
+}
Index: editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/ValidationFeedback.properties
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>MacRoman
===================================================================
--- editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/ValidationFeedback.properties (revision 34367)
+++ editor/frontend/src/main/java/org/hippoecm/frontend/editor/validator/ValidationFeedback.properties (revision )
@@ -4,3 +4,4 @@
invalid-character=Invalid character present
invalid-xml=XML is not valid
html-is-empty=Rich text field is empty
+reference-is-empty=Reference is empty
\ No newline at end of file
Index: editor/repository/src/main/resources/namespace-hippo.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- editor/repository/src/main/resources/namespace-hippo.xml (revision 34367)
+++ editor/repository/src/main/resources/namespace-hippo.xml (revision )
@@ -545,6 +545,9 @@
Docbase
+
+ references
+