directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1485695 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/ shared/trunk/ldap/codec/core/src/main/java/org/apache/...
Date Thu, 23 May 2013 13:30:12 GMT
Author: elecharny
Date: Thu May 23 13:30:12 2013
New Revision: 1485695

URL: http://svn.apache.org/r1485695
Log:
o Fixed a potential synchronization issue on the DirectoryServcice
o Closed a stream that remained opened
o Remove unused fields in some classes
o Simplified some if() code
o Removed a method that was looping

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
    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/entry/DefaultAttribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemamanager/impl/DefaultSchemaManager.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Thu May 23 13:30:12 2013
@@ -981,9 +981,12 @@ public class DefaultDirectoryService imp
      */
     public CoreSession getSession( Dn principalDn, byte[] credentials ) throws LdapException
     {
-        if ( !started )
+        synchronized ( this )
         {
-            throw new IllegalStateException( "Service has not started." );
+            if ( !started )
+            {
+                throw new IllegalStateException( "Service has not started." );
+            }
         }
 
         BindOperationContext bindContext = new BindOperationContext( null );
@@ -1003,9 +1006,13 @@ public class DefaultDirectoryService imp
     public CoreSession getSession( Dn principalDn, byte[] credentials, String saslMechanism,
String saslAuthId )
         throws Exception
     {
-        if ( !started )
+        synchronized ( this )
         {
-            throw new IllegalStateException( "Service has not started." );
+            if ( !started )
+            {
+                throw new IllegalStateException( "Service has not started." );
+
+            }
         }
 
         BindOperationContext bindContext = new BindOperationContext( null );
@@ -1424,7 +1431,7 @@ public class DefaultDirectoryService imp
     }
 
 
-    public boolean isStarted()
+    public synchronized boolean isStarted()
     {
         return started;
     }

Modified: directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
(original)
+++ directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
Thu May 23 13:30:12 2013
@@ -203,6 +203,7 @@ public class HttpServer
 
                 OutputStream stream = new FileOutputStream( ksFile );
                 ks.store( stream, password.toCharArray() );
+                stream.close();
 
                 SslSocketConnector httpsConnector = new SslSocketConnector();
                 httpsConnector.setPort( httpsTransport.getPort() );

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
Thu May 23 13:30:12 2013
@@ -52,15 +52,9 @@ import org.apache.directory.api.util.Str
  */
 public class SubstringFilter extends Filter
 {
-    // ~ Instance fields
-    // ----------------------------------------------------------------------------
-
     /** The substring filter type (an attributeDescription) */
     private String type;
 
-    /** The type length */
-    private int typeLength;
-
     /**
      * This member is used to control the length of the three parts of the
      * substring filter
@@ -233,7 +227,7 @@ public class SubstringFilter extends Fil
     public int computeLength()
     {
         // The type
-        typeLength = Strings.getBytesUtf8( type ).length;
+        int typeLength = Strings.getBytesUtf8( type ).length;
 
         substringsFilterLength = 1 + TLV.getNbBytes( typeLength ) + typeLength;
         substringsFilterSequenceLength = 0;

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
Thu May 23 13:30:12 2013
@@ -48,7 +48,6 @@ public class PasswordPolicyDecorator ext
     private static final Asn1Decoder decoder = new Asn1Decoder();
 
     // Storage for computed lengths
-    private int valueLength = 0;
     private int ppolicySeqLength = 0;
     private int warningLength = 0;
     private int timeBeforeExpirationTagLength;

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
Thu May 23 13:30:12 2013
@@ -524,7 +524,7 @@ public class SyncInfoValueDecorator exte
 
                 value = buffer.array();
             }
-            catch ( Exception e )
+            catch ( EncoderException e )
             {
                 return null;
             }
@@ -544,8 +544,8 @@ public class SyncInfoValueDecorator exte
         decoder.decode( bb, container );
         return this;
     }
-    
-    
+
+
     /**
      * @see Object#toString()
      */

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=1485695&r1=1485694&r2=1485695&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
Thu May 23 13:30:12 2013
@@ -196,15 +196,12 @@ public abstract class AbstractValue<T> i
         {
             LdapSyntax syntax = attributeType.getSyntax();
 
-            if ( syntax != null )
+            // Check the syntax
+            if ( ( syntax != null ) && ( !isValid( syntax.getSyntaxChecker() ) )
)
             {
-                // Check the syntax
-                if ( !isValid( syntax.getSyntaxChecker() ) )
-                {
-                    String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, wrappedValue,
attributeType );
-                    LOG.info( message );
-                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
message );
-                }
+                String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, wrappedValue,
attributeType );
+                LOG.info( message );
+                throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
message );
             }
         }
         catch ( LdapException le )

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
Thu May 23 13:30:12 2013
@@ -694,12 +694,9 @@ public class DefaultAttribute implements
         }
 
         // Check that we can't have more than one value if the AT is single-value
-        if ( attributeType.isSingleValued() )
+        if ( ( attributeType.isSingleValued() ) && ( values.size() > 1 ) )
         {
-            if ( values.size() > 1 )
-            {
-                return false;
-            }
+            return false;
         }
 
         // Now check the values

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
Thu May 23 13:30:12 2013
@@ -87,22 +87,6 @@ public class OidNormalizer
 
 
     /**
-     * Copy an OidNormalizer(). The contained Normalizer will be cloned too.
-     * 
-     * @return A deep clone of the current OidNormalizer
-     */
-    public OidNormalizer copy() throws CloneNotSupportedException
-    {
-        OidNormalizer copy = new OidNormalizer( attributeTypeOid, normalizer );
-
-        // Copy the SchemaObject common data
-        copy.copy();
-
-        return copy;
-    }
-
-
-    /**
      * Return a String representation of this class
      */
     public String toString()

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
Thu May 23 13:30:12 2013
@@ -1325,15 +1325,12 @@ public class Registries implements Schem
         // Lock the SchemaObject
         schemaObject.lock();
 
-        if ( check )
+        if ( check && ( errors.isEmpty() ) )
         {
-            if ( errors.isEmpty() )
-            {
-                // Check the registries now
-                List<Throwable> checkErrors = checkRefInteg();
+            // Check the registries now
+            List<Throwable> checkErrors = checkRefInteg();
 
-                errors.addAll( checkErrors );
-            }
+            errors.addAll( checkErrors );
         }
 
         // Get back to Strict mode

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
Thu May 23 13:30:12 2013
@@ -99,16 +99,13 @@ public class LdapSyntaxHelper
     public static void removeFromRegistries( LdapSyntax ldapSyntax, List<Throwable>
errors, Registries registries )
         throws LdapException
     {
-        if ( registries != null )
+        if ( ( registries != null ) && ( ldapSyntax.getSyntaxChecker() != null )
)
         {
             /**
              * Remove the Syntax references (using and usedBy) :
              * S -> SC
              */
-            if ( ldapSyntax.getSyntaxChecker() != null )
-            {
-                registries.delReference( ldapSyntax, ldapSyntax.getSyntaxChecker() );
-            }
+            registries.delReference( ldapSyntax, ldapSyntax.getSyntaxChecker() );
         }
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
Thu May 23 13:30:12 2013
@@ -372,7 +372,6 @@ public class LdapUrl
                 // Let's check the string we had before the dot.
                 if ( isHostNumber && ( nbDots < 4 ) )
                 {
-
                     // We had only digits. It may be an IP adress? Check it
                     if ( ipElem[nbDots] > 65535 )
                     {

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
Thu May 23 13:30:12 2013
@@ -54,7 +54,6 @@ import org.slf4j.LoggerFactory;
  */
 public class DefaultSchemaLdifExtractor implements SchemaLdifExtractor
 {
-
     /** The base path. */
     private static final String BASE_PATH = "";
 
@@ -76,9 +75,6 @@ public class DefaultSchemaLdifExtractor 
     /** The output directory. */
     private File outputDirectory;
 
-    /** The schema directory. */
-    private File schemaDirectory;
-
 
     /**
      * Creates an extractor which deposits files into the specified output
@@ -90,7 +86,7 @@ public class DefaultSchemaLdifExtractor 
     {
         LOG.debug( "BASE_PATH set to {}, outputDirectory set to {}", BASE_PATH, outputDirectory
);
         this.outputDirectory = outputDirectory;
-        this.schemaDirectory = new File( outputDirectory, SCHEMA_SUBDIR );
+        File schemaDirectory = new File( outputDirectory, SCHEMA_SUBDIR );
 
         if ( !outputDirectory.exists() )
         {

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemamanager/impl/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemamanager/impl/DefaultSchemaManager.java?rev=1485695&r1=1485694&r2=1485695&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemamanager/impl/DefaultSchemaManager.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemamanager/impl/DefaultSchemaManager.java
Thu May 23 13:30:12 2013
@@ -30,10 +30,8 @@ import java.util.Set;
 
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.MetaSchemaConstants;
-import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.exception.LdapOtherException;
 import org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException;
 import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
@@ -113,9 +111,6 @@ public class DefaultSchemaManager implem
     /** the factory that generates respective SchemaObjects from LDIF entries */
     private final EntityFactory factory;
 
-    /** the normalized name for the schema modification attributes */
-    private Dn schemaModificationAttributesDn;
-
     /** A Map containing all the schema being dependent from a schema */
     private Map<String, Set<String>> schemaDependences = new HashMap<String,
Set<String>>();
 
@@ -1465,15 +1460,6 @@ public class DefaultSchemaManager implem
      */
     public void initialize() throws Exception
     {
-        try
-        {
-            schemaModificationAttributesDn = new Dn( SchemaConstants.SCHEMA_MODIFICATIONS_DN
);
-            schemaModificationAttributesDn.apply( new DefaultSchemaManager() );
-        }
-        catch ( LdapInvalidDnException e )
-        {
-            throw new RuntimeException( e );
-        }
     }
 
 



Mime
View raw message