From d210d3431537c979d57d58eb68e84ace0db87a57 Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Mon, 23 Sep 2024 11:44:29 +0300 Subject: [PATCH 1/4] [#401] Change "Object class violation (65)" -> "Naming violation (64)" LDAP result code for DIT Structure Rule violation --- .../src/main/java/org/opends/server/types/Entry.java | 4 +++- .../localbackend/LocalBackendAddOperation.java | 2 +- .../localbackend/LocalBackendModifyDNOperation.java | 5 +++-- .../localbackend/LocalBackendModifyOperation.java | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java index a2fdb87aa2..7f485febe4 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java @@ -1507,7 +1507,7 @@ public void applyModifications(List mods) } - + public ResultCode typeErrorconformsToSchema=null; /** * Indicates whether this entry conforms to the server's schema * requirements. The checks performed by this method include: @@ -1564,6 +1564,7 @@ public boolean conformsToSchema(Entry parentEntry, boolean validateStructureRules, LocalizableMessageBuilder invalidReason) { + typeErrorconformsToSchema= OBJECTCLASS_VIOLATION; // Get the structural objectclass for the entry. If there isn't // one, or if there's more than one, then see if that's OK. AcceptRejectWarn structuralPolicy = @@ -1640,6 +1641,7 @@ else if (structuralPolicy == AcceptRejectWarn.WARN) if (validateNameForms) { + typeErrorconformsToSchema= NAMING_VIOLATION; /** * There may be multiple nameforms registered with this * structural objectclass.However, we need to select only one diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java index 3aa4daa70c..c65182e362 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java @@ -803,7 +803,7 @@ private void checkSchema(Entry parentEntry) throws DirectoryException LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (! entry.conformsToSchema(parentEntry, true, true, true, invalidReason)) { - throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, + throw new DirectoryException(entry.typeErrorconformsToSchema, invalidReason.toMessage()); } diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java index 91af23b47e..d83e4bac12 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java @@ -13,6 +13,7 @@ * * Copyright 2008-2010 Sun Microsystems, Inc. * Portions Copyright 2011-2016 ForgeRock AS. + * Portions copyright 2024 3A Systems,LLC. */ package org.opends.server.workflowelement.localbackend; @@ -670,7 +671,7 @@ private void applyRDNChanges(List modifications) if (! newEntry.conformsToSchema(null, false, true, true, invalidReason)) { - throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, + throw new DirectoryException(newEntry.typeErrorconformsToSchema, ERR_MODDN_VIOLATES_SCHEMA.get(entryDN, invalidReason)); } @@ -742,7 +743,7 @@ private void applyPreOpModifications(List modifications, if (! newEntry.conformsToSchema(null, false, true, true, invalidReason)) { - throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, + throw new DirectoryException(newEntry.typeErrorconformsToSchema, ERR_MODDN_PREOP_VIOLATES_SCHEMA.get(entryDN, invalidReason)); } } diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java index 070c5288c7..b890dee894 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java @@ -469,7 +469,7 @@ private void processModify() throws CanceledOperationException LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (!modifiedEntry.conformsToSchema(null, false, false, false, invalidReason)) { - setResultCode(ResultCode.OBJECTCLASS_VIOLATION); + setResultCode(modifiedEntry.typeErrorconformsToSchema); appendErrorMessage(ERR_MODIFY_VIOLATES_SCHEMA.get(entryDN, invalidReason)); return; } From efe0813a5fa6496217f066cce2918b68fc65904b Mon Sep 17 00:00:00 2001 From: Valery Kharseko Date: Mon, 23 Sep 2024 13:20:21 +0300 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Maxim Thomas --- .../src/main/java/org/opends/server/types/Entry.java | 10 +++++++++- .../localbackend/LocalBackendAddOperation.java | 2 +- .../localbackend/LocalBackendModifyDNOperation.java | 4 ++-- .../localbackend/LocalBackendModifyOperation.java | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java index 7f485febe4..35133c340b 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java @@ -1507,7 +1507,15 @@ public void applyModifications(List mods) } - public ResultCode typeErrorconformsToSchema=null; + private ResultCode typeConformsToSchemaError = null; + + /** + * Returns a error when entry type does not conform to a schema + * requirements. Otherwise returns {@code null} + **/ + public ResutCode getTypeConformsToSchemaError() { + return typeConformsToSchemaError; + } /** * Indicates whether this entry conforms to the server's schema * requirements. The checks performed by this method include: diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java index c65182e362..1b86927170 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java @@ -803,7 +803,7 @@ private void checkSchema(Entry parentEntry) throws DirectoryException LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (! entry.conformsToSchema(parentEntry, true, true, true, invalidReason)) { - throw new DirectoryException(entry.typeErrorconformsToSchema, + throw new DirectoryException(entry.getTypeConformsToSchemaError(), invalidReason.toMessage()); } diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java index d83e4bac12..a0a575d59e 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java @@ -671,7 +671,7 @@ private void applyRDNChanges(List modifications) if (! newEntry.conformsToSchema(null, false, true, true, invalidReason)) { - throw new DirectoryException(newEntry.typeErrorconformsToSchema, + throw new DirectoryException(newEntry.getTypeConformsToSchemaError(), ERR_MODDN_VIOLATES_SCHEMA.get(entryDN, invalidReason)); } @@ -743,7 +743,7 @@ private void applyPreOpModifications(List modifications, if (! newEntry.conformsToSchema(null, false, true, true, invalidReason)) { - throw new DirectoryException(newEntry.typeErrorconformsToSchema, + throw new DirectoryException(newEntry.getTypeConformsToSchemaError(), ERR_MODDN_PREOP_VIOLATES_SCHEMA.get(entryDN, invalidReason)); } } diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java index b890dee894..6995427b84 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java @@ -469,7 +469,7 @@ private void processModify() throws CanceledOperationException LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (!modifiedEntry.conformsToSchema(null, false, false, false, invalidReason)) { - setResultCode(modifiedEntry.typeErrorconformsToSchema); + setResultCode(modifiedEntry.getTypeConformsToSchemaError()); appendErrorMessage(ERR_MODIFY_VIOLATES_SCHEMA.get(entryDN, invalidReason)); return; } From 1deb3a4bc4a75c65ca4412f32fbcf19fca784da2 Mon Sep 17 00:00:00 2001 From: Maxim Thomas Date: Mon, 23 Sep 2024 13:34:06 +0300 Subject: [PATCH 3/4] Apply suggestions from code review --- .../src/main/java/org/opends/server/types/Entry.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java index 35133c340b..2116a9e0af 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java @@ -1572,7 +1572,7 @@ public boolean conformsToSchema(Entry parentEntry, boolean validateStructureRules, LocalizableMessageBuilder invalidReason) { - typeErrorconformsToSchema= OBJECTCLASS_VIOLATION; + typeConformsToSchemaError = OBJECTCLASS_VIOLATION; // Get the structural objectclass for the entry. If there isn't // one, or if there's more than one, then see if that's OK. AcceptRejectWarn structuralPolicy = @@ -1649,7 +1649,7 @@ else if (structuralPolicy == AcceptRejectWarn.WARN) if (validateNameForms) { - typeErrorconformsToSchema= NAMING_VIOLATION; + typeConformsToSchemaError = NAMING_VIOLATION; /** * There may be multiple nameforms registered with this * structural objectclass.However, we need to select only one From b060d89d406946244260d453504b3337e8ca6d20 Mon Sep 17 00:00:00 2001 From: Maxim Thomas Date: Mon, 23 Sep 2024 13:42:07 +0300 Subject: [PATCH 4/4] Apply suggestions from code review --- .../src/main/java/org/opends/server/types/Entry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java index 2116a9e0af..621792aea6 100644 --- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java +++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java @@ -1513,7 +1513,7 @@ public void applyModifications(List mods) * Returns a error when entry type does not conform to a schema * requirements. Otherwise returns {@code null} **/ - public ResutCode getTypeConformsToSchemaError() { + public ResultCode getTypeConformsToSchemaError() { return typeConformsToSchemaError; } /**