From 533cbfb4b741d4f90306f60027af6f283c1ae85d Mon Sep 17 00:00:00 2001
From: sin <sin@localhost>
Date: Wed, 29 Apr 2009 15:43:23 +0000
Subject: [PATCH] issue 3444:Only a single name form allowed per structural object class
---
opends/src/server/org/opends/server/backends/SchemaBackend.java | 49 +++++++++++++++++++++++++++----------------------
1 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/SchemaBackend.java b/opends/src/server/org/opends/server/backends/SchemaBackend.java
index 541eb36..6ffe7f1 100644
--- a/opends/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -1846,14 +1846,19 @@
// Make sure that the attribute type isn't used as a required or optional
// attribute type in any name form.
- for (NameForm nf : schema.getNameFormsByObjectClass().values())
+ for (List<NameForm> mappedForms :
+ schema.getNameFormsByObjectClass().values())
{
- if (nf.getRequiredAttributes().contains(removeType) ||
- nf.getOptionalAttributes().contains(removeType))
+ for(NameForm nf : mappedForms)
{
- Message message = ERR_SCHEMA_MODIFY_REMOVE_AT_IN_NF.get(
- removeType.getNameOrOID(), nf.getNameOrOID());
- throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
+ if (nf.getRequiredAttributes().contains(removeType) ||
+ nf.getOptionalAttributes().contains(removeType))
+ {
+ Message message = ERR_SCHEMA_MODIFY_REMOVE_AT_IN_NF.get(
+ removeType.getNameOrOID(), nf.getNameOrOID());
+ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
+ message);
+ }
}
}
@@ -2158,11 +2163,17 @@
// Make sure that the objectclass isn't used as the structural class for
// any name form.
- NameForm nf = schema.getNameForm(removeClass);
- if (nf != null)
+ List<NameForm> mappedForms = schema.getNameForm(removeClass);
+ if (mappedForms != null)
{
+ StringBuilder buffer = new StringBuilder();
+ for(NameForm nf : mappedForms)
+ {
+ buffer.append(nf.getNameOrOID());
+ buffer.append("\t");
+ }
Message message = ERR_SCHEMA_MODIFY_REMOVE_OC_IN_NF.get(
- removeClass.getNameOrOID(), nf.getNameOrOID());
+ removeClass.getNameOrOID(), buffer.toString());
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
@@ -2267,15 +2278,6 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- NameForm existingNFForClass = schema.getNameForm(structuralClass);
- if ((existingNFForClass != null) && (existingNFForClass != existingNF))
- {
- Message message = ERR_SCHEMA_MODIFY_STRUCTURAL_OC_CONFLICT_FOR_ADD_NF.
- get(nameForm.getNameOrOID(), structuralClass.getNameOrOID(),
- existingNFForClass.getNameOrOID());
- throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
- }
-
for (AttributeType at : nameForm.getRequiredAttributes())
{
if (! schema.hasAttributeType(at.getOID()))
@@ -3345,12 +3347,15 @@
// is no hierarchical relationship between name forms, we don't need to
// worry about ordering.
values = new LinkedHashSet<AttributeValue>();
- for (NameForm nf : schema.getNameFormsByObjectClass().values())
+ for (List<NameForm> forms : schema.getNameFormsByObjectClass().values())
{
- if (schemaFile.equals(nf.getSchemaFile()))
+ for(NameForm nf : forms)
{
- values.add(AttributeValues.create(
- nameFormsType, nf.getDefinition()));
+ if (schemaFile.equals(nf.getSchemaFile()))
+ {
+ values.add(AttributeValues.create(
+ nameFormsType, nf.getDefinition()));
+ }
}
}
--
Gitblit v1.10.0