From 00786b8f6e90c1a848c9c09d8b82e73a56042a0a Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 19 Jul 2007 14:54:30 +0000
Subject: [PATCH] Fix issues 1943 (unable to create je-index), 1996 (exception when creating components with empty names), and 1998 (exception when creating components with blank names).

---
 opends/resource/admin/preprocessor.xsl |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/opends/resource/admin/preprocessor.xsl b/opends/resource/admin/preprocessor.xsl
index 9b14b13..dee2c1e 100644
--- a/opends/resource/admin/preprocessor.xsl
+++ b/opends/resource/admin/preprocessor.xsl
@@ -827,6 +827,60 @@
   -->
   <xsl:template match="adm:one-to-many" mode="merge-relation">
     <xsl:param name="managed-object" select="/.." />
+    <!--
+      Make sure that if this relation uses a naming property that the
+      naming property exists, is single-valued, mandatory, and read-only.
+    -->
+    <xsl:if test="@naming-property">
+      <xsl:variable name="naming-property-name"
+        select="@naming-property" />
+
+      <!--
+        FIXME: this does not cope with the situation where the property
+        is inherited, referenced, or overridden.
+      -->
+      <xsl:variable name="naming-property"
+        select="$managed-object/adm:property[@name=$naming-property-name]" />
+      <xsl:if test="not($naming-property)">
+        <xsl:message terminate="yes">
+          <xsl:value-of
+            select="concat('Relation ', ../@name,
+                           ' references an unknown naming property ',
+                           $naming-property-name, ' in ',
+                           $managed-object/@name, '.')" />
+        </xsl:message>
+      </xsl:if>
+      <xsl:if test="not($naming-property/@read-only='true')">
+        <xsl:message terminate="yes">
+          <xsl:value-of
+            select="concat('Relation ', ../@name,
+                           ' references the naming property ',
+                           $naming-property-name, ' in ',
+                           $managed-object/@name, ' which is not read-only. ',
+                           'Naming properties must be read-only.')" />
+        </xsl:message>
+      </xsl:if>
+      <xsl:if test="not($naming-property/@mandatory='true')">
+        <xsl:message terminate="yes">
+          <xsl:value-of
+            select="concat('Relation ', ../@name,
+                           ' references the naming property ',
+                           $naming-property-name, ' in ',
+                           $managed-object/@name, ' which is not mandatory. ',
+                           'Naming properties must be mandatory.')" />
+        </xsl:message>
+      </xsl:if>
+      <xsl:if test="$naming-property/@multi-valued='true'">
+        <xsl:message terminate="yes">
+          <xsl:value-of
+            select="concat('Relation ', ../@name,
+                           ' references the naming property ',
+                           $naming-property-name, ' in ',
+                           $managed-object/@name, ' which is multi-valued. ',
+                           'Naming properties must be single-valued.')" />
+        </xsl:message>
+      </xsl:if>
+    </xsl:if>
     <xsl:copy>
       <xsl:copy-of select="@*" />
       <!--

--
Gitblit v1.10.0