Skip to content

Commit

Permalink
Partial fix for DIRSERVER-1728: core-api errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elecharny committed Aug 19, 2024
1 parent 51da44a commit 0c6d560
Show file tree
Hide file tree
Showing 25 changed files with 350 additions and 362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public LdapPrincipal( SchemaManager schemaManager, Dn dn, AuthenticationLevel au

if ( !dn.isSchemaAware() )
{
throw new IllegalStateException( I18n.err( I18n.ERR_436 ) );
throw new IllegalStateException( I18n.err( I18n.ERR_02038_NAMES_OF_PRINCIPAL_MUST_BE_NORMALIZED ) );
}

this.authenticationLevel = authenticationLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ public static ReferralHandlingMode getModeFromJndi( String jndiValue )
return THROW_FINDING_BASE;
}

throw new IllegalArgumentException( I18n.err( I18n.ERR_437, jndiValue ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_02037_UNKNOWN_JNDI_CONTEXT_REFERRAL, jndiValue ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public MoveOperationContext( CoreSession session, ModifyDnRequest modifyDnReques

if ( newSuperior == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_02019_NEW_SUPERIROR_CANNOT_BE_NULL, modifyDnRequest ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_02019_NEW_SUPERIOR_CANNOT_BE_NULL, modifyDnRequest ) );
}

this.requestControls = modifyDnRequest.getControls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public SyntaxCheckerDescription[] parseSyntaxCheckers( Attribute attr ) throws L
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_405,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02052_BAD_SYNTEX_CHECKER_DESCRIPTION_SYNTAX,
value ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -166,7 +166,7 @@ public NormalizerDescription[] parseNormalizers( Attribute attr ) throws LdapInv
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_406,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02053_BAD_SYNTAX_NORMALIZER_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -197,7 +197,7 @@ public LdapComparatorDescription[] parseComparators( Attribute attr ) throws Lda
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_407,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02054_BAD_SYNTAX_COMPARATOR_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -238,7 +238,7 @@ public AttributeType[] parseAttributeTypes( Attribute attr ) throws LdapExceptio
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_408,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02055_BAD_SYNTAX_ATTRIBUTE_TYPE_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand All @@ -249,39 +249,39 @@ public AttributeType[] parseAttributeTypes( Attribute attr ) throws LdapExceptio
&& !schemaManager.getAttributeTypeRegistry().contains( attributeType.getSuperiorOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_409, attributeType.getSuperiorOid() ) );
I18n.err( I18n.ERR_02056_ATTRIBUTE_TYPE_ADDITION_INVALID_SUPER_TYPE, attributeType.getSuperiorOid() ) );
}

// if the syntax is provided by the description make sure it exists in some schema
if ( ( attributeType.getSyntaxOid() != null )
&& !schemaManager.getLdapSyntaxRegistry().contains( attributeType.getSyntaxOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_410, attributeType.getSyntaxOid() ) );
I18n.err( I18n.ERR_02057_ATTRIBUTE_TYPE_ADDITION_INVALID_SYNTAX, attributeType.getSyntaxOid() ) );
}

// if the matchingRule is provided make sure it exists in some schema
if ( ( attributeType.getEqualityOid() != null )
&& !schemaManager.getMatchingRuleRegistry().contains( attributeType.getEqualityOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_411, attributeType.getEqualityOid() ) );
I18n.err( I18n.ERR_02058_ATTRIBUTE_TYPE_ADDITION_INVALID_EQUALITY_MR, attributeType.getEqualityOid() ) );
}

// if the matchingRule is provided make sure it exists in some schema
if ( ( attributeType.getOrderingOid() != null )
&& !schemaManager.getMatchingRuleRegistry().contains( attributeType.getOrderingOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_412, attributeType.getOrderingOid() ) );
I18n.err( I18n.ERR_02059_ATTRIBUTE_TYPE_ADDITION_INVALID_ORDERING_MR, attributeType.getOrderingOid() ) );
}

// if the matchingRule is provided make sure it exists in some schema
if ( ( attributeType.getSubstringOid() != null )
&& !schemaManager.getMatchingRuleRegistry().contains( attributeType.getSubstringOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_413, attributeType.getSubstringOid() ) );
I18n.err( I18n.ERR_02060_ATTRIBUTE_TYPE_ADDITION_INVALID_SUBSTRING_MR, attributeType.getSubstringOid() ) );
}

attributeTypes[pos++] = attributeType;
Expand Down Expand Up @@ -321,7 +321,7 @@ public ObjectClass[] parseObjectClasses( Attribute attr ) throws LdapException
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_417,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02061_OBJECT_CLASS_DESCRIPTION_NOT_CONFORM,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand All @@ -341,7 +341,7 @@ public ObjectClass[] parseObjectClasses( Attribute attr ) throws LdapException
if ( !schemaManager.getObjectClassRegistry().contains( superiorOid ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_418, superiorOid ) );
I18n.err( I18n.ERR_02062_OBJECT_CLASS_ADDITION_INVALID_SUPERIOR, superiorOid ) );
}
}
}
Expand All @@ -354,7 +354,7 @@ public ObjectClass[] parseObjectClasses( Attribute attr ) throws LdapException
if ( !schemaManager.getAttributeTypeRegistry().contains( mayAttrOid ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_419, mayAttrOid ) );
I18n.err( I18n.ERR_02063_OBJECT_CLASS_ADDITION_INVALID_ATTRIBUTE_TYPE_MAY, mayAttrOid ) );
}
}
}
Expand All @@ -367,7 +367,7 @@ public ObjectClass[] parseObjectClasses( Attribute attr ) throws LdapException
if ( !schemaManager.getAttributeTypeRegistry().contains( mustAttrOid ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_420, mustAttrOid ) );
I18n.err( I18n.ERR_02064_OBJECT_CLASS_ADDITION_INVALID_ATTRIBUTE_TYPE_MUST, mustAttrOid ) );
}
}
}
Expand Down Expand Up @@ -410,7 +410,7 @@ public MatchingRuleUse[] parseMatchingRuleUses( Attribute attr ) throws LdapExce
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_421,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02065_NOT_CONFORM_TO_MATCHING_RULE_USE_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -454,15 +454,16 @@ public LdapSyntax[] parseLdapSyntaxes( Attribute attr ) throws LdapException
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_422,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02066_NOT_CONFORM_TO_LDAP_SYNTAX_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
}

if ( !schemaManager.getSyntaxCheckerRegistry().contains( ldapSyntax.getOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_423 ) );
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_02067_SYNTAX_ADDITION_FORBIDDEN_WITHOUT_SYNTAX_CHECKER ) );
}

// Call this method once to initialize the flags
Expand Down Expand Up @@ -506,7 +507,7 @@ public MatchingRule[] parseMatchingRules( Attribute attr ) throws LdapException
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_424,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02068_NOT_CONFORM_TO_MATCHING_RULE_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand All @@ -515,7 +516,7 @@ public MatchingRule[] parseMatchingRules( Attribute attr ) throws LdapException
if ( !schemaManager.getLdapSyntaxRegistry().contains( matchingRule.getSyntaxOid() ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_425, matchingRule.getSyntaxOid() ) );
I18n.err( I18n.ERR_02069_MATCHING_RULE_CREATION_WITHOUT_NON_EXISTANT_SYNTAX, matchingRule.getSyntaxOid() ) );
}

matchingRules[pos++] = matchingRule;
Expand Down Expand Up @@ -556,7 +557,7 @@ public DitStructureRule[] parseDitStructureRules( Attribute attr ) throws LdapEx
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_426,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02070_NOT_CONFORM_TO_DIT_STRUCTURE_RULE_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -600,7 +601,7 @@ public DitContentRule[] parseDitContentRules( Attribute attr ) throws LdapExcept
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_427,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02071_NOT_CONFORM_TO_DIT_CONTENT_RULE_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down Expand Up @@ -644,7 +645,7 @@ public NameForm[] parseNameForms( Attribute attr ) throws LdapException
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_428,
ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_02072_NOT_CONFORM_TO_NAME_FORM_DESCRIPTION,
value.getString() ) );
iave.initCause( e );
throw iave;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void setWrappedPartition( Partition wrapped )
{
if ( this.isInitialized() )
{
throw new IllegalStateException( I18n.err( I18n.ERR_429 ) );
throw new IllegalStateException( I18n.err( I18n.ERR_02046_WRAPPING_PARTITION_AFTER_INIT_FORBIDDEN ) );
}

this.wrapped = wrapped;
Expand Down Expand Up @@ -246,7 +246,7 @@ protected void doInit() throws LdapException
}
catch ( Exception e )
{
LOG.error( I18n.err( I18n.ERR_90 ), e );
LOG.error( I18n.err( I18n.ERR_02044_FAILED_INIT_WRAPPED_PARTITION ), e );
throw new RuntimeException( e );
}

Expand All @@ -267,7 +267,7 @@ protected void doDestroy( PartitionTxn partitionTxn )
}
catch ( Exception e )
{
LOG.error( I18n.err( I18n.ERR_91 ), e );
LOG.error( I18n.err( I18n.ERR_02045_FAILED_DESTROY_WRAPPED_PARTITION ), e );
throw new RuntimeException( e );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected String getSchemaName( Dn dn ) throws LdapException

if ( size < 2 )
{
throw new LdapInvalidDnException( I18n.err( I18n.ERR_276 ) );
throw new LdapInvalidDnException( I18n.err( I18n.ERR_02023_TWO_NAME_COMPOENENTS_EXPECTED ) );
}

Rdn rdn = dn.getRdn( size - 2 );
Expand All @@ -171,7 +171,7 @@ protected void checkOidIsUnique( Entry entry ) throws LdapException

if ( schemaManager.getGlobalOidRegistry().contains( oid ) )
{
throw new LdapOtherException( I18n.err( I18n.ERR_335, oid ) );
throw new LdapOtherException( I18n.err( I18n.ERR_02024_OID_NOT_UNIQUE, oid ) );
}
}

Expand All @@ -195,7 +195,7 @@ protected SchemaObject checkOidExists( Entry entry ) throws LdapException
else
{
throw new LdapSchemaViolationException( ResultCodeEnum.OTHER,
I18n.err( I18n.ERR_336, oid ) );
I18n.err( I18n.ERR_02025_OID_DOES_NOT_EXIST, oid ) );
}
}

Expand All @@ -212,7 +212,7 @@ protected void checkParent( Dn newParent, SchemaManager schemaManager, String ob
{
if ( newParent.size() != 3 )
{
throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_337 ) );
throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_02026_ATTRIBUTE_TYPE_PARENT_SHOULD_BE_3_NC_LONG ) );
}

Rdn rdn = newParent.getRdn();
Expand All @@ -221,13 +221,13 @@ protected void checkParent( Dn newParent, SchemaManager schemaManager, String ob
.equals( SchemaConstants.OU_AT_OID ) )
{
throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION,
I18n.err( I18n.ERR_338, objectType ) );
I18n.err( I18n.ERR_02027_PARENT_ENTRY_NOT_ORGANIZATIONAL_UNIT, objectType ) );
}

if ( !rdn.getValue().equalsIgnoreCase( OBJECT_TYPE_TO_PATH.get( objectType ) ) )
{
throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION,
I18n.err( I18n.ERR_339, objectType, OBJECT_TYPE_TO_PATH.get( objectType ) ) );
I18n.err( I18n.ERR_02028_PARENT_ENTRY_SHOULD_HAVE_RELATIVE_NAME, objectType, OBJECT_TYPE_TO_PATH.get( objectType ) ) );
}
}

Expand All @@ -239,7 +239,7 @@ protected void checkOidIsUnique( SchemaObject schemaObject ) throws LdapExceptio
if ( schemaManager.getGlobalOidRegistry().contains( oid ) )
{
throw new LdapSchemaViolationException( ResultCodeEnum.OTHER,
I18n.err( I18n.ERR_335, oid ) );
I18n.err( I18n.ERR_02024_OID_NOT_UNIQUE, oid ) );
}
}

Expand All @@ -249,7 +249,7 @@ protected void checkOidIsUnique( String oid ) throws LdapException
if ( schemaManager.getGlobalOidRegistry().contains( oid ) )
{
throw new LdapSchemaViolationException( ResultCodeEnum.OTHER,
I18n.err( I18n.ERR_335, oid ) );
I18n.err( I18n.ERR_02024_OID_NOT_UNIQUE, oid ) );
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ protected void addToSchema( SchemaObject schemaObject, String schemaName ) throw

if ( schemaObjects.contains( schemaObjectWrapper ) )
{
String msg = I18n.err( I18n.ERR_341, schemaObject.getName(), schemaName );
String msg = I18n.err( I18n.ERR_02029_SCHEMA_ALREADY_CONTAINS_ELEMENT, schemaObject.getName(), schemaName );
LOG.warn( msg );

throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
Expand All @@ -291,7 +291,7 @@ protected void addToSchema( SchemaObject schemaObject, String schemaName ) throw
}
else
{
String msg = I18n.err( I18n.ERR_342, schemaObject.getName(), schemaName );
String msg = I18n.err( I18n.ERR_02030_SCHEMA_NOT_LOADED, schemaObject.getName(), schemaName );
LOG.warn( msg );

throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
Expand All @@ -318,7 +318,7 @@ protected void deleteFromSchema( SchemaObject schemaObject, String schemaName )

if ( !schemaObjects.contains( schemaObjectWrapper ) )
{
String msg = I18n.err( I18n.ERR_343, schemaObject.getName(), schemaName );
String msg = I18n.err( I18n.ERR_02031_SCHEMA_DOES_NOT_CONTAIN_ELEMENT, schemaObject.getName(), schemaName );
LOG.warn( msg );

throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
Expand All @@ -329,7 +329,7 @@ protected void deleteFromSchema( SchemaObject schemaObject, String schemaName )
}
else
{
String msg = I18n.err( I18n.ERR_342, schemaObject.getName(), schemaName );
String msg = I18n.err( I18n.ERR_02030_SCHEMA_NOT_LOADED, schemaObject.getName(), schemaName );
LOG.warn( msg );

throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
Expand Down
Loading

0 comments on commit 0c6d560

Please sign in to comment.