You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/02/03 14:42:15 UTC
svn commit: r1728310 - in /directory/shared/trunk/ldap:
model/src/main/java/org/apache/directory/api/ldap/model/entry/
model/src/main/java/org/apache/directory/api/ldap/model/schema/
model/src/main/java/org/apache/directory/api/ldap/model/schema/syntax...
Author: elecharny
Date: Wed Feb 3 13:42:15 2016
New Revision: 1728310
URL: http://svn.apache.org/viewvc?rev=1728310&view=rev
Log:
o Propagated the relaxed flag to the AttributeType
o Relaxed the check in the AbstractValue when the AT is relaxed too
o Improved the TelephoneNumber SyntaxChecker regexp
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java?rev=1728310&r1=1728309&r2=1728310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java Wed Feb 3 13:42:15 2016
@@ -207,24 +207,27 @@ public abstract class AbstractValue<T> i
}
// and checks that the value syntax is valid
- try
+ if ( !attributeType.isRelaxed() )
{
- LdapSyntax syntax = attributeType.getSyntax();
-
- // Check the syntax
- if ( ( syntax != null ) && ( !isValid( syntax.getSyntaxChecker() ) ) )
+ try
+ {
+ LdapSyntax syntax = attributeType.getSyntax();
+
+ // Check the syntax
+ if ( ( syntax != null ) && ( !isValid( syntax.getSyntaxChecker() ) ) )
+ {
+ String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, upValue, attributeType );
+ LOG.info( message );
+ throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
+ }
+ }
+ catch ( LdapException le )
{
- String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, upValue, attributeType );
+ String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, le.getLocalizedMessage() );
LOG.info( message );
- throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
+ throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message, le );
}
}
- catch ( LdapException le )
- {
- String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, le.getLocalizedMessage() );
- LOG.info( message );
- throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message, le );
- }
// Rehash the Value now
h = 0;
@@ -306,7 +309,14 @@ public abstract class AbstractValue<T> i
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
}
- return syntaxChecker.isValidSyntax( normalizedValue );
+ if ( ( attributeType != null ) && attributeType.isRelaxed() )
+ {
+ return true;
+ }
+ else
+ {
+ return syntaxChecker.isValidSyntax( normalizedValue );
+ }
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java?rev=1728310&r1=1728309&r2=1728310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java Wed Feb 3 13:42:15 2016
@@ -174,6 +174,9 @@ public class AttributeType extends Abstr
/** the length of this attribute in bytes */
protected long syntaxLength = 0L;
+
+ /** A flag set when the SchemaManager is in relaxed mode */
+ private boolean isRelaxed = false;
/**
@@ -221,6 +224,26 @@ public class AttributeType extends Abstr
}
+ /**
+ * @return Tells if the AttributeType is relaxed (the SyntaxChecker will not be activated)
+ */
+ public boolean isRelaxed()
+ {
+ return isRelaxed;
+ }
+
+
+ /**
+ * Set this AttributeType mode to relaxed
+ *
+ * @param isRelaxed <tt>true</tt> if the syntax checker for this AttributeType should not be activated
+ */
+ public void setRelaxed( boolean isRelaxed )
+ {
+ this.isRelaxed = isRelaxed;
+ }
+
+
/**
* Determines the usage for this AttributeType.
*
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java?rev=1728310&r1=1728309&r2=1728310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java Wed Feb 3 13:42:15 2016
@@ -36,9 +36,9 @@ import org.slf4j.LoggerFactory;
* A SyntaxChecker which verifies that a value is a TelephoneNumber according to ITU
* recommendation E.123 (which is quite vague ...).
*
- * A valid Telephone number respect more or less this syntax :
+ * A valid Telephone number respects more or less this syntax :
*
- * " *[+]? *((\([0-9- ]+\))|[0-9- ]+)+"
+ * " *[+]? *((\([0-9- ,;/#*]+\))|[0-9- ,;/#*]+)+"
*
* If needed, and to allow more syntaxes, a list of regexps has been added
* which can be initialized to other values
@@ -58,7 +58,7 @@ public class TelephoneNumberSyntaxChecke
private List<Pattern> compiledREs;
/** The default pattern used to check a TelephoneNumber */
- private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;#*]+\\))|[0-9- ,;#*]+)+$";
+ private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;/#*]+\\))|[0-9- ,;/#*]+)+$";
/** The compiled default pattern */
private Pattern defaultPattern = Pattern.compile( DEFAULT_REGEXP );
Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java?rev=1728310&r1=1728309&r2=1728310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java (original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java Wed Feb 3 13:42:15 2016
@@ -901,6 +901,11 @@ public class SchemaEntityFactory impleme
// Create the new AttributeType
MutableAttributeType attributeType = new MutableAttributeType( oid );
+
+ if ( schemaManager.isRelaxed() )
+ {
+ attributeType.setRelaxed( true );
+ }
// Syntax
Attribute mSyntax = entry.get( MetaSchemaConstants.M_SYNTAX_AT );