Skip to content

Commit

Permalink
[#401] Change "Object class violation (65)" -> "Naming violation (64)…
Browse files Browse the repository at this point in the history
…" LDAP result code for DIT Structure Rule violation (#410)

Co-authored-by: Maxim Thomas <maxim.thomas@gmail.com>
  • Loading branch information
vharseko and maximthomas authored Sep 24, 2024
1 parent 88aec8f commit 8006c79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,15 @@ public void applyModifications(List<Modification> mods)
}



private ResultCode typeConformsToSchemaError = null;

/**
* Returns a error when entry type does not conform to a schema
* requirements. Otherwise returns {@code null}
**/
public ResultCode getTypeConformsToSchemaError() {
return typeConformsToSchemaError;
}
/**
* Indicates whether this entry conforms to the server's schema
* requirements. The checks performed by this method include:
Expand Down Expand Up @@ -1564,6 +1572,7 @@ public boolean conformsToSchema(Entry parentEntry,
boolean validateStructureRules,
LocalizableMessageBuilder invalidReason)
{
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 =
Expand Down Expand Up @@ -1640,6 +1649,7 @@ else if (structuralPolicy == AcceptRejectWarn.WARN)

if (validateNameForms)
{
typeConformsToSchemaError = NAMING_VIOLATION;
/**
* There may be multiple nameforms registered with this
* structural objectclass.However, we need to select only one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.getTypeConformsToSchemaError(),
invalidReason.toMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -670,7 +671,7 @@ private void applyRDNChanges(List<Modification> modifications)
if (! newEntry.conformsToSchema(null, false, true, true,
invalidReason))
{
throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION,
throw new DirectoryException(newEntry.getTypeConformsToSchemaError(),
ERR_MODDN_VIOLATES_SCHEMA.get(entryDN, invalidReason));
}

Expand Down Expand Up @@ -742,7 +743,7 @@ private void applyPreOpModifications(List<Modification> modifications,
if (! newEntry.conformsToSchema(null, false, true, true,
invalidReason))
{
throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION,
throw new DirectoryException(newEntry.getTypeConformsToSchemaError(),
ERR_MODDN_PREOP_VIOLATES_SCHEMA.get(entryDN, invalidReason));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.getTypeConformsToSchemaError());
appendErrorMessage(ERR_MODIFY_VIOLATES_SCHEMA.get(entryDN, invalidReason));
return;
}
Expand Down

0 comments on commit 8006c79

Please sign in to comment.