/** * Asserts whether or not the attribute's value conforms to the attribute * syntax. * * @param value the value of some attribute with the syntax * @throws LdapException if the value does not conform to the attribute syntax. */ public void assertSyntax( Object value ) throws LdapException { if ( !isValidSyntax( value ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX ); } }
/** * Creates a new instance of LdapInvalidAttributeValueException. * * @param resultCode the ResultCodeEnum for this exception */ public LdapInvalidAttributeValueException( ResultCodeEnum resultCode ) { super( null ); checkResultCode( resultCode ); this.resultCode = resultCode; }
/** * {@inheritDoc} */ public String normalize( String value ) throws LdapException { try { String normalized = PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING ); return normalized; } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } } }
/** * Creates a new instance of LdapInvalidAttributeValueException. * * @param resultCode the ResultCodeEnum for this exception * @param message The exception message */ public LdapInvalidAttributeValueException( ResultCodeEnum resultCode, String message ) { super( message ); checkResultCode( resultCode ); this.resultCode = resultCode; }
/** * {@inheritDoc} */ public String normalize( String value ) throws LdapException { if ( value == null ) { return null; } try { String normalized = PrepareString.normalize( value, PrepareString.StringType.CASE_IGNORE ); return normalized; } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } } }
/** * Get an OID from an entry. Handles the bad cases (null OID, * not a valid OID, ...) */ private String getOid( SchemaObject description, String objectType ) throws LdapInvalidAttributeValueException { // The OID String oid = description.getOid(); if ( oid == null ) { String msg = I18n.err( I18n.ERR_10005, objectType, MetaSchemaConstants.M_OID_AT ); LOG.warn( msg ); throw new NullPointerException( msg ); } if ( !OID.isOID( oid ) ) { String msg = I18n.err( I18n.ERR_10006, oid ); LOG.warn( msg ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); } return oid; }
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12085, (pos+1) ) ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12086, (pos+1) ) ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12087 ) );
/** * <p> * Get the String value, if and only if the value is known to be a String, * otherwise a InvalidAttributeValueException will be thrown * </p> * <p> * Note that this method returns the first value only. * </p> * * @return The value as a String * @throws LdapInvalidAttributeValueException If the value is a byte[] */ public String getString() throws LdapInvalidAttributeValueException { Value<?> value = get(); if ( value instanceof StringValue ) { return value.getString(); } else { String message = I18n.err( I18n.ERR_04131 ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } }
/** * Get an OID from an entry. Handles the bad cases (null OID, * not a valid OID, ...) */ private String getOid( Entry entry, String objectType ) throws LdapInvalidAttributeValueException { // The OID EntryAttribute mOid = entry.get( MetaSchemaConstants.M_OID_AT ); if ( mOid == null ) { String msg = I18n.err( I18n.ERR_10005, objectType, MetaSchemaConstants.M_OID_AT ); LOG.warn( msg ); throw new NullPointerException( msg ); } String oid = mOid.getString(); if ( !OID.isOID( oid ) ) { String msg = I18n.err( I18n.ERR_10006, oid ); LOG.warn( msg ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); } return oid; }
/** * {@inheritDoc} */ public String normalize( String value ) throws LdapException { try { String prepared = PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING ); GeneralizedTime time = new GeneralizedTime( prepared ); String normalized = time.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION, FractionDelimiter.DOT, 3, TimeZoneFormat.Z ); return normalized; } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } catch ( ParseException pe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } } }
/** * <p> * Get the byte[] value, if and only if the value is known to be Binary, * otherwise a InvalidAttributeValueException will be thrown * </p> * <p> * Note that this method returns the first value only. * </p> * * @return The value as a byte[] * @throws LdapInvalidAttributeValueException If the value is a String */ public byte[] getBytes() throws LdapInvalidAttributeValueException { Value<?> value = get(); if ( value.isBinary() ) { return value.getBytes(); } else { String message = I18n.err( I18n.ERR_04130 ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.CASE_IGNORE ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
throw new LdapInvalidAttributeValueException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
/** * Checks to see numbers of values of attributes conforms to the schema */ private void assertNumberOfAttributeValuesValid( Attribute attribute ) throws InvalidAttributeValueException, NamingException { AttributeTypeRegistry registry = this.globalRegistries.getAttributeTypeRegistry(); if ( attribute.size() > 1 && registry.lookup( attribute.getID() ).isSingleValue() ) { throw new LdapInvalidAttributeValueException( "More than one value has been provided " + "for the single-valued attribute: " + attribute.getID(), ResultCodeEnum.CONSTRAINTVIOLATION ); } }
throw new LdapInvalidAttributeValueException( "No value is not a valid value for an attribute.", ResultCodeEnum.INVALIDATTRIBUTESYNTAX );
throw new LdapInvalidAttributeValueException( "No value is not a valid value for an attribute.", ResultCodeEnum.INVALIDATTRIBUTESYNTAX );
throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX );
throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX );