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 2012/02/11 12:59:30 UTC
svn commit: r1243039 - in /directory/shared/trunk/ldap:
client/api/src/main/java/org/apache/directory/ldap/client/api/
codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/
model/src/main/java/org/apache/directory/shared/ldap/model/const...
Author: elecharny
Date: Sat Feb 11 11:59:29 2012
New Revision: 1243039
URL: http://svn.apache.org/viewvc?rev=1243039&view=rev
Log:
o Renamed the SsseSchemaLoader to DefaultSchemaLoader
o The SchemaBinaryAttributeDetector now takes a SchemaManager as a parameter
o Store a MessageContainer in the ldapSession if we haven't have one already
o Added the loadSchema() method which load the schema from the remote server automatically
o When loading the default schema, first try to connect to the server
o Fixed the compilation issue I left yesterday
o Simplified the isBinary() detection in the BinaryAttributeDetector
o Added some constants in MetaSchemaConstants, cleaned up some others
o Added an addExtensions() method in the SchemaObject interface
o Correctly handling extensions for SchemaObjects
o Fixed a bug in LdapSyntax, when the X_NOT-HUMAN-READABLE flag was lower cased
Added:
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
- copied, changed from r1241243, directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SsseSchemaLoader.java
Removed:
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SsseSchemaLoader.java
Modified:
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/MetaSchemaConstants.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributesFactory.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaUtils.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/AbstractSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java
Copied: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java (from r1241243, directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SsseSchemaLoader.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java?p2=directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java&p1=directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SsseSchemaLoader.java&r1=1241243&r2=1243039&rev=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SsseSchemaLoader.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java Sat Feb 11 11:59:29 2012
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.apache.directory.ldap.client.api.exception.InvalidConnectionException;
import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
import org.apache.directory.shared.ldap.model.entry.Attribute;
@@ -74,10 +75,10 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class SsseSchemaLoader extends AbstractSchemaLoader
+public class DefaultSchemaLoader extends AbstractSchemaLoader
{
/** the logger */
- private static final Logger LOG = LoggerFactory.getLogger( SsseSchemaLoader.class );
+ private static final Logger LOG = LoggerFactory.getLogger( DefaultSchemaLoader.class );
/** the connection to the ldap server */
private LdapConnection connection;
@@ -107,16 +108,29 @@ public class SsseSchemaLoader extends Ab
* @throws Exception if the connection is not authenticated or if there are any problems
* while loading the schema entries
*/
- public SsseSchemaLoader( LdapConnection connection ) throws Exception
+ public DefaultSchemaLoader( LdapConnection connection ) throws LdapException
{
- // Get the subschemaSubentry Dn from the rootDSE
- this.connection = connection;
- Entry rootDse = connection.lookup( Dn.ROOT_DSE, SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
-
- String subschemaSubentryStr = rootDse.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).getString();
- subschemaSubentryDn = new Dn( connection.getSchemaManager(), subschemaSubentryStr );
+ if ( connection == null )
+ {
+ throw new InvalidConnectionException( "Cannot connect on the server, the connection is null" );
+ }
- loadSchemas();
+ // Get the subschemaSubentry Dn from the rootDSE
+ try
+ {
+ this.connection = connection;
+ connection.connect();
+ Entry rootDse = connection.lookup( Dn.ROOT_DSE, SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
+
+ String subschemaSubentryStr = rootDse.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).getString();
+ subschemaSubentryDn = new Dn( connection.getSchemaManager(), subschemaSubentryStr );
+
+ loadSchemas();
+ }
+ catch ( IOException ioe )
+ {
+ throw new LdapException( ioe );
+ }
}
@@ -127,7 +141,7 @@ public class SsseSchemaLoader extends Ab
* @throws Exception if the connection is not authenticated or if there are any problems
* while loading the schema entries
*/
- public SsseSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws Exception
+ public DefaultSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws Exception
{
if ( !connection.isAuthenticated() )
{
@@ -147,7 +161,7 @@ public class SsseSchemaLoader extends Ab
* @param subschemaSubentryDn
* @throws Exception
*/
- private void loadSchemas() throws Exception
+ private void loadSchemas() throws LdapException
{
LOG.debug( "initializing schemas" );
@@ -246,7 +260,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadAttributeTypes( Attribute attributeTypes ) throws LdapException, IOException
+ private void loadAttributeTypes( Attribute attributeTypes ) throws LdapException
{
for ( Value<?> value : attributeTypes )
{
@@ -269,7 +283,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadComparators( Attribute comparators ) throws LdapException, IOException
+ private void loadComparators( Attribute comparators ) throws LdapException
{
for ( Value<?> value : comparators )
{
@@ -292,7 +306,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadDitContentRules( Attribute ditContentRules ) throws LdapException, IOException
+ private void loadDitContentRules( Attribute ditContentRules ) throws LdapException
{
for ( Value<?> value : ditContentRules )
{
@@ -315,7 +329,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadDitStructureRules( Attribute ditStructureRules ) throws LdapException, IOException
+ private void loadDitStructureRules( Attribute ditStructureRules ) throws LdapException
{
for ( Value<?> value : ditStructureRules )
{
@@ -338,7 +352,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadLdapSyntaxes( Attribute ldapSyntaxes ) throws LdapException, IOException
+ private void loadLdapSyntaxes( Attribute ldapSyntaxes ) throws LdapException
{
for ( Value<?> value : ldapSyntaxes )
{
@@ -361,7 +375,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadMatchingRules( Attribute matchingRules ) throws LdapException, IOException
+ private void loadMatchingRules( Attribute matchingRules ) throws LdapException
{
for ( Value<?> value : matchingRules )
{
@@ -384,7 +398,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadMatchingRuleUses( Attribute matchingRuleUses ) throws LdapException, IOException
+ private void loadMatchingRuleUses( Attribute matchingRuleUses ) throws LdapException
{
for ( Value<?> value : matchingRuleUses )
{
@@ -407,7 +421,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadNameForms( Attribute nameForms ) throws LdapException, IOException
+ private void loadNameForms( Attribute nameForms ) throws LdapException
{
for ( Value<?> value : nameForms )
{
@@ -430,7 +444,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadNormalizers( Attribute normalizers ) throws LdapException, IOException
+ private void loadNormalizers( Attribute normalizers ) throws LdapException
{
for ( Value<?> value : normalizers )
{
@@ -453,7 +467,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadObjectClasses( Attribute objectClasses ) throws LdapException, IOException
+ private void loadObjectClasses( Attribute objectClasses ) throws LdapException
{
for ( Value<?> value : objectClasses )
{
@@ -476,7 +490,7 @@ public class SsseSchemaLoader extends Ab
/**
* {@inheritDoc}
*/
- private void loadSyntaxCheckers( Attribute syntaxCheckers ) throws LdapException, IOException
+ private void loadSyntaxCheckers( Attribute syntaxCheckers ) throws LdapException
{
for ( Value<?> value : syntaxCheckers )
{
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Sat Feb 11 11:59:29 2012
@@ -67,6 +67,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
import org.apache.directory.shared.ldap.codec.api.LdapApiService;
import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
+import org.apache.directory.shared.ldap.codec.api.LdapDecoder;
import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.api.MessageDecorator;
import org.apache.directory.shared.ldap.codec.api.MessageEncoderException;
@@ -352,7 +353,7 @@ public class LdapNetworkConnection exten
config.setUseSsl( false );
config.setLdapPort( config.getDefaultLdapPort() );
config.setLdapHost( config.getDefaultLdapHost() );
- config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+ config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
messageId = new AtomicInteger( 0 );
}
@@ -388,7 +389,7 @@ public class LdapNetworkConnection exten
config.setUseSsl( useSsl );
config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort() );
config.setLdapHost( config.getDefaultLdapHost() );
- config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+ config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
messageId = new AtomicInteger( 0 );
}
@@ -416,7 +417,7 @@ public class LdapNetworkConnection exten
config.setLdapHost( server );
}
- config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+ config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
messageId = new AtomicInteger( 0 );
}
@@ -447,7 +448,7 @@ public class LdapNetworkConnection exten
config.setLdapHost( server );
}
- config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+ config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
messageId = new AtomicInteger( 0 );
}
@@ -492,7 +493,7 @@ public class LdapNetworkConnection exten
config.setLdapHost( server );
}
- config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+ config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
messageId = new AtomicInteger();
}
@@ -654,8 +655,16 @@ public class LdapNetworkConnection exten
ldapSession = connectionFuture.getSession();
connected.set( true );
- // Store the container into the session
- ldapSession.setAttribute( "LDAP-Container", codec.newMessageContainer() );
+ // Store the container into the session if we don't have one
+ LdapMessageContainer<MessageDecorator<? extends Message>> container =
+ (LdapMessageContainer<MessageDecorator<? extends Message>>)ldapSession.getAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR );
+
+ if ( container == null )
+ {
+ ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
+ new LdapMessageContainer<MessageDecorator<? extends Message>>( codec,
+ new DefaultConfigurableBinaryAttributeDetector() ) );
+ }
// Initialize the MessageId
messageId.set( 0 );
@@ -3354,8 +3363,29 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ public void loadSchema() throws LdapException
+ {
+ loadSchema( new DefaultSchemaLoader( this ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public void loadDefaultSchema() throws LdapException
{
+ if ( !isConnected() )
+ {
+ try
+ {
+ connect();
+ }
+ catch ( IOException ioe )
+ {
+ throw new InvalidConnectionException( "Cannot connect on the server" );
+ }
+ }
+
try
{
JarLdifSchemaLoader jarSchemaLoader = new JarLdifSchemaLoader();
@@ -3428,6 +3458,12 @@ public class LdapNetworkConnection exten
}
schemaManager = tmp;
+
+ // Change the container's BinaryDetector
+ ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
+ new LdapMessageContainer<MessageDecorator<? extends Message>>( codec,
+ new SchemaBinaryAttributeDetector( schemaManager ) ) );
+
}
catch ( LdapException le )
{
@@ -3641,7 +3677,7 @@ public class LdapNetworkConnection exten
new LdapMessageContainer<MessageDecorator<Message>>(
codec, config.getBinaryAttributeDetector() );
- session.setAttribute( "messageContainer", ldapMessageContainer );
+ session.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR, ldapMessageContainer );
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java Sat Feb 11 11:59:29 2012
@@ -36,7 +36,7 @@ public class SchemaBinaryAttributeDetect
private SchemaManager schemaManager;
- public SchemaBinaryAttributeDetector()
+ protected SchemaBinaryAttributeDetector()
{
}
@@ -78,10 +78,7 @@ public class SchemaBinaryAttributeDetect
LdapSyntax ldapSyntax = attributeType.getSyntax();
- return ( ( ldapSyntax != null ) &&
- ldapSyntax.hasHumanReadableFlag() &&
- ldapSyntax.hasHumanReadableFlag() ) &&
- !ldapSyntax.isHumanReadable();
+ return ( ( ldapSyntax != null ) && !ldapSyntax.isHumanReadable() );
}
return false;
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/MetaSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/MetaSchemaConstants.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/MetaSchemaConstants.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/MetaSchemaConstants.java Sat Feb 11 11:59:29 2012
@@ -163,9 +163,6 @@ public final class MetaSchemaConstants
public final static String M_BYTECODE_AT = "m-bytecode";
public final static String M_BYTECODE_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.33";
- public final static String X_NOT_HUMAN_READABLE_AT = "x-not-human-readable";
- public final static String X_NOT_HUMAN_READABLE_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.34";
-
public final static String M_DISABLED_AT = "m-disabled";
public final static String M_DISABLED_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.37";
@@ -176,8 +173,12 @@ public final class MetaSchemaConstants
public final static String M_LENGTH_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.39";
// -- schema extensions & values --
- public final static String X_SCHEMA = "X-SCHEMA";
- public final static String X_NOT_HUMAN_READABLE = "X-NOT-HUMAN-READABLE";
- public final static String X_READ_ONLY = "X-READ-ONLY";
- public final static String X_ENABLED = "X-ENABLED";
+ public final static String X_SCHEMA_AT = "X-SCHEMA";
+ public final static String X_SCHEMA_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.35";
+
+ public final static String X_NOT_HUMAN_READABLE_AT = "x-not-human-readable";
+ public final static String X_NOT_HUMAN_READABLE_AT_OID = "1.3.6.1.4.1.18060.0.4.0.2.34";
+
+ public final static String X_READ_ONLY_AT = "X-READ-ONLY";
+ public final static String X_ENABLED_AT = "X-ENABLED";
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java Sat Feb 11 11:59:29 2012
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.model.schema;
@@ -37,7 +37,7 @@ import org.apache.directory.shared.util.
/**
* Most schema objects have some common attributes. This class
- * contains the minimum set of properties exposed by a SchemaObject.<br>
+ * contains the minimum set of properties exposed by a SchemaObject.<br>
* We have 11 types of SchemaObjects :
* <li> AttributeType
* <li> DitCOntentRule
@@ -52,9 +52,9 @@ import org.apache.directory.shared.util.
* <li> SyntaxChecker (specific to ADS)
* <br>
* <br>
- * This class provides accessors and setters for the following attributes,
+ * This class provides accessors and setters for the following attributes,
* which are common to all those SchemaObjects :
- * <li>oid : The numeric OID
+ * <li>oid : The numeric OID
* <li>description : The SchemaObject description
* <li>obsolete : Tells if the schema object is obsolete
* <li>extensions : The extensions, a key/Values map
@@ -67,7 +67,7 @@ import org.apache.directory.shared.util.
* Some of those attributes are not used by some Schema elements, even if they should
* have been used. Here is the list :
* <b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
- * <b>numericOid</b> : DitStructureRule,
+ * <b>numericOid</b> : DitStructureRule,
* <b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -246,7 +246,7 @@ public abstract class AbstractSchemaObje
/**
* Add a new name to the list of names for this SchemaObject. The name
* is lowercased and trimmed.
- *
+ *
* @param namesToAdd The names to add
*/
public void addName( String... namesToAdd )
@@ -287,7 +287,7 @@ public abstract class AbstractSchemaObje
/**
* Sets the list of names for this SchemaObject. The names are
* lowercased and trimmed.
- *
+ *
* @param names The list of names. Can be empty
*/
public void setNames( List<String> names )
@@ -320,7 +320,7 @@ public abstract class AbstractSchemaObje
/**
* Sets the list of names for this SchemaObject. The names are
* lowercased and trimmed.
- *
+ *
* @param names The list of names.
*/
public void setNames( String... names )
@@ -412,8 +412,8 @@ public abstract class AbstractSchemaObje
/**
* Tells if this SchemaObject is enabled.
- *
- * @return true if the SchemaObject is enabled, or if it depends on
+ *
+ * @return true if the SchemaObject is enabled, or if it depends on
* an enabled schema
*/
public boolean isEnabled()
@@ -424,7 +424,7 @@ public abstract class AbstractSchemaObje
/**
* Tells if this SchemaObject is disabled.
- *
+ *
* @return true if the SchemaObject is disabled
*/
public boolean isDisabled()
@@ -449,7 +449,7 @@ public abstract class AbstractSchemaObje
/**
* Tells if this SchemaObject is ReadOnly.
- *
+ *
* @return true if the SchemaObject is not modifiable
*/
public boolean isReadOnly()
@@ -521,6 +521,32 @@ public abstract class AbstractSchemaObje
* @param key The extension key
* @param values The associated values
*/
+ public void addExtension( String key, String... values )
+ {
+ if ( locked )
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
+ }
+
+ if ( !isReadOnly )
+ {
+ List<String> valueList = new ArrayList<String>();
+
+ for ( String value : values )
+ {
+ valueList.add( value );
+ }
+
+ extensions.put( key, valueList );
+ }
+ }
+
+
+ /**
+ * Add an extension with its values
+ * @param key The extension key
+ * @param values The associated values
+ */
public void addExtension( String key, List<String> values )
{
if ( locked )
@@ -623,7 +649,7 @@ public abstract class AbstractSchemaObje
/**
* This method is final to forbid the inherited classes to implement
- * it. This has been done for performances reasons : the hashcode should
+ * it. This has been done for performances reasons : the hashcode should
* be computed only once, and stored locally.
*
* The hashcode is currently computed in the lock() method, which is a hack
@@ -880,8 +906,8 @@ public abstract class AbstractSchemaObje
/**
- * Clear the current SchemaObject : remove all the references to other objects,
- * and all the Maps.
+ * Clear the current SchemaObject : remove all the references to other objects,
+ * and all the Maps.
*/
public void clear()
{
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributesFactory.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributesFactory.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributesFactory.java Sat Feb 11 11:59:29 2012
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
import java.util.List;
+import java.util.Map;
import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -153,7 +154,6 @@ public class AttributesFactory
Entry entry = new DefaultEntry( schemaManager );
entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_OC );
- entry.put( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT, getBoolean( !syntax.isHumanReadable() ) );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
injectCommon( syntax, entry, schemaManager );
@@ -421,6 +421,22 @@ public class AttributesFactory
{
entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, object.getDescription() );
}
+
+ // The extensions
+ Map<String, List<String>> extensions = object.getExtensions();
+
+ if ( extensions != null )
+ {
+ for ( String key : extensions.keySet() )
+ {
+ List<String> values = extensions.get( key );
+
+ for ( String value : values )
+ {
+ entry.add( key, value );
+ }
+ }
+ }
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java Sat Feb 11 11:59:29 2012
@@ -139,7 +139,7 @@ public class LdapSyntax extends Abstract
}
else
{
- List<String> values = extensions.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE );
+ List<String> values = extensions.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT );
if ( ( values == null ) || ( values.size() == 0 ) )
{
@@ -151,7 +151,7 @@ public class LdapSyntax extends Abstract
String value = values.get( 0 );
hasHumanReadableFlag = true;
- if ( value.equals( "FALSE" ) )
+ if ( value.equalsIgnoreCase( "FALSE" ) )
{
isHumanReadable = true;
return true;
@@ -181,6 +181,7 @@ public class LdapSyntax extends Abstract
if ( !isReadOnly )
{
this.isHumanReadable = humanReadable;
+ this.hasHumanReadableFlag = true;
}
}
@@ -189,7 +190,7 @@ public class LdapSyntax extends Abstract
* Gets whether or not the Human Readable extension is present in the Syntax.
*
* @return true if the syntax contains teh X-NOT-HUMAN-READABLE extension
- */
+ *
public boolean hasHumanReadableFlag()
{
return hasHumanReadableFlag;
@@ -198,7 +199,7 @@ public class LdapSyntax extends Abstract
/**
* Sets the hasHumanReadableFlag to true if we have a X-NOT-HUMAN-READABLE extension
- */
+ *
public void setHasHumanReadableFlag()
{
hasHumanReadableFlag = true;
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java Sat Feb 11 11:59:29 2012
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.model.schema;
@@ -29,7 +29,7 @@ import org.apache.directory.shared.ldap.
/**
* Most schema objects have some common attributes. This class
- * contains the minimum set of properties exposed by a SchemaObject.<br>
+ * contains the minimum set of properties exposed by a SchemaObject.<br>
* We have 11 types of SchemaObjects :
* <li> AttributeType
* <li> DitCOntentRule
@@ -44,9 +44,9 @@ import org.apache.directory.shared.ldap.
* <li> SyntaxChecker (specific to ADS)
* <br>
* <br>
- * This class provides accessors and setters for the following attributes,
+ * This class provides accessors and setters for the following attributes,
* which are common to all those SchemaObjects :
- * <li>oid : The numeric OID
+ * <li>oid : The numeric OID
* <li>description : The SchemaObject description
* <li>obsolete : Tells if the schema object is obsolete
* <li>extensions : The extensions, a key/Values map
@@ -59,7 +59,7 @@ import org.apache.directory.shared.ldap.
* Some of those attributes are not used by some Schema elements, even if they should
* have been used. Here is the list :
* <b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
- * <b>numericOid</b> : DitStructureRule,
+ * <b>numericOid</b> : DitStructureRule,
* <b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -130,7 +130,7 @@ public interface SchemaObject
/**
* Add a new name to the list of names for this SchemaObject. The name
* is lower cased and trimmed.
- *
+ *
* @param names The names to add
*/
void addName( String... names );
@@ -139,7 +139,7 @@ public interface SchemaObject
/**
* Sets the list of names for this SchemaObject. The names are
* lower cased and trimmed.
- *
+ *
* @param names The list of names. Can be empty
*/
void setNames( List<String> names );
@@ -179,8 +179,8 @@ public interface SchemaObject
/**
* Tells if this SchemaObject is enabled.
- *
- * @return true if the SchemaObject is enabled, or if it depends on
+ *
+ * @return true if the SchemaObject is enabled, or if it depends on
* an enabled schema
*/
boolean isEnabled();
@@ -188,7 +188,7 @@ public interface SchemaObject
/**
* Tells if this SchemaObject is disabled.
- *
+ *
* @return true if the SchemaObject is disabled
*/
boolean isDisabled();
@@ -204,7 +204,7 @@ public interface SchemaObject
/**
* Tells if this SchemaObject is ReadOnly.
- *
+ *
* @return true if the SchemaObject is not modifiable
*/
boolean isReadOnly();
@@ -248,6 +248,14 @@ public interface SchemaObject
* @param key The extension key
* @param values The associated values
*/
+ void addExtension( String key, String... values );
+
+
+ /**
+ * Add an extension with its values
+ * @param key The extension key
+ * @param values The associated values
+ */
void addExtension( String key, List<String> values );
@@ -334,8 +342,8 @@ public interface SchemaObject
/**
- * Clear the current SchemaObject : remove all the references to other objects,
- * and all the Maps.
+ * Clear the current SchemaObject : remove all the references to other objects,
+ * and all the Maps.
*/
void clear();
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaUtils.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaUtils.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaUtils.java Sat Feb 11 11:59:29 2012
@@ -1099,7 +1099,7 @@ public final class SchemaUtils
private static String getSchemaName( SchemaObject desc )
{
- List<String> values = desc.getExtensions().get( MetaSchemaConstants.X_SCHEMA );
+ List<String> values = desc.getExtensions().get( MetaSchemaConstants.X_SCHEMA_AT );
if ( values == null || values.size() == 0 )
{
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/AbstractSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/AbstractSchemaParser.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/AbstractSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/AbstractSchemaParser.java Sat Feb 11 11:59:29 2012
@@ -128,7 +128,7 @@ public abstract class AbstractSchemaPars
protected static void updateSchemaName( SchemaObject schemaObject )
{
// Update the Schema if we have the X-SCHEMA extension
- List<String> schemaExtension = schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA );
+ List<String> schemaExtension = schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA_AT );
if ( schemaExtension != null )
{
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java?rev=1243039&r1=1243038&r2=1243039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java Sat Feb 11 11:59:29 2012
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.model.schema.parsers;
@@ -81,7 +81,7 @@ public class LdapSyntaxDescriptionSchema
{
LdapSyntax ldapSyntax = parser.ldapSyntaxDescription();
ldapSyntax.setSpecification( ldapSyntaxDescription );
-
+
// Update the schemaName
updateSchemaName( ldapSyntax );