You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by go...@apache.org on 2012/05/13 15:54:30 UTC

svn commit: r1337884 - in /directory/apacheds/branches/apacheds-osgi/hub/core: ./ src/main/java/org/apache/directory/server/hub/core/ src/main/java/org/apache/directory/server/hub/core/configurator/ src/main/java/org/apache/directory/server/hub/core/co...

Author: gokturk
Date: Sun May 13 13:54:29 2012
New Revision: 1337884

URL: http://svn.apache.org/viewvc?rev=1337884&view=rev
Log:
* Bug fixes while integrating
* ConfiguratorInterceptor implementation and injection into chain

Modified:
    directory/apacheds/branches/apacheds-osgi/hub/core/pom.xml
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ComponentHubImpl.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ParentLinkRegistry.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/configurator/ConfiguratorInterceptor.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/connector/collection/CollectionOperations.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/meta/DCMetadataNormalizer.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/ApacheDSConfigStore.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreConfigManager.java
    directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreSchemaManager.java

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/pom.xml?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/pom.xml (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/pom.xml Sun May 13 13:54:29 2012
@@ -38,6 +38,11 @@
     </dependency>
     
     <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-hub-connector-ipojo-core</artifactId>
+    </dependency>
+    
+    <dependency>
       <groupId>org.apache.directory.shared</groupId>
       <artifactId>shared-ldap-model</artifactId>
     </dependency>

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ComponentHubImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ComponentHubImpl.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ComponentHubImpl.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ComponentHubImpl.java Sun May 13 13:54:29 2012
@@ -2,17 +2,23 @@ package org.apache.directory.server.hub.
 
 
 import java.lang.reflect.Array;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.directory.server.core.api.interceptor.Interceptor;
 import org.apache.directory.server.hub.api.AbstractHubClient;
 import org.apache.directory.server.hub.api.ComponentHub;
 import org.apache.directory.server.hub.api.HubStore;
 import org.apache.directory.server.hub.api.component.DCConfiguration;
 import org.apache.directory.server.hub.api.component.DCProperty;
+import org.apache.directory.server.hub.api.component.DCRuntime;
 import org.apache.directory.server.hub.api.component.DirectoryComponent;
 import org.apache.directory.server.hub.api.component.DirectoryComponentConstants;
+import org.apache.directory.server.hub.api.component.util.InterceptionPoint;
+import org.apache.directory.server.hub.api.component.util.InterceptorConstants;
+import org.apache.directory.server.hub.api.component.util.InterceptorOperation;
 import org.apache.directory.server.hub.api.exception.BadConfigurationException;
 import org.apache.directory.server.hub.api.exception.ComponentInstantiationException;
 import org.apache.directory.server.hub.api.exception.ComponentReconfigurationException;
@@ -27,11 +33,15 @@ import org.apache.directory.server.hub.a
 import org.apache.directory.server.hub.api.registry.DirectoryComponentRegistry;
 import org.apache.directory.server.hub.api.registry.InjectionRegistry;
 import org.apache.directory.server.hub.api.registry.PIDHandlerRegistry;
+import org.apache.directory.server.hub.connector.ipojo.core.IPojoConnector;
+import org.apache.directory.server.hub.core.configurator.ConfiguratorInterceptor;
 import org.apache.directory.server.hub.core.connector.collection.CollectionConnector;
 import org.apache.directory.server.hub.core.meta.DCMetadataNormalizer;
 import org.apache.directory.server.hub.core.util.DCDependency;
 import org.apache.directory.server.hub.core.util.ParentLink;
 import org.apache.directory.server.hub.core.util.DCDependency.DCDependencyType;
+import org.apache.felix.ipojo.IPojoContext;
+import org.osgi.framework.Version;
 
 
 public class ComponentHubImpl implements ComponentHub
@@ -44,6 +54,7 @@ public class ComponentHubImpl implements
     private ParentLinkRegistry parentLinksReg = new ParentLinkRegistry();
 
     private CollectionConnector collectionConnector;
+    public IPojoConnector ipojoConnector;
 
     private HubStore store;
 
@@ -51,6 +62,8 @@ public class ComponentHubImpl implements
 
     private DependencyResolver dependencyResolver = new DependencyResolver();
 
+    private ConfiguratorInterceptor configurator;
+
 
     public ComponentHubImpl( HubStore store )
     {
@@ -87,6 +100,11 @@ public class ComponentHubImpl implements
         collectionConnector = new CollectionConnector();
         collectionConnector.init( this );
 
+        ipojoConnector = new IPojoConnector();
+        ipojoConnector.init( this );
+
+        insertConfiguratorInterceptor();
+
     }
 
 
@@ -517,7 +535,7 @@ public class ComponentHubImpl implements
         {
             if ( pd.getPropertyContext() == DCPropertyType.CONSTANT )
             {
-                component.getConfiguration().addProperty( new DCProperty( pd.getName(), pd.getDefaultValue() ) );
+                component.getConfiguration().addConstant( pd.getName(), pd.getDefaultValue() );
             }
         }
 
@@ -554,6 +572,12 @@ public class ComponentHubImpl implements
 
                     if ( propertyValue.equals( DirectoryComponentConstants.DC_VAL_NULL ) )
                     {
+                        if ( pd.isMandatory() )
+                        {
+                            throw new BadConfigurationException( "Mandatory property can not be set to null"
+                                + pd.getName() );
+                        }
+
                         property.setObject( null );
                         break;
                     }
@@ -632,6 +656,7 @@ public class ComponentHubImpl implements
                         throw new BadConfigurationException( "Component:" + component.getComponentPID()
                             + " is lacking property:" + propertyName );
                     }
+                    property.setObject( injection );
             }
         }
     }
@@ -754,7 +779,7 @@ public class ComponentHubImpl implements
                     .getProperty( parentLink.getLinkPoint() );
                 refProperty.setValue( "null" );
 
-                reconfigureComponent( component );
+                reconfigureComponent( parentLink.getParent() );
             }
         }
 
@@ -768,6 +793,38 @@ public class ComponentHubImpl implements
     }
 
 
+    private void insertConfiguratorInterceptor()
+    {
+        configurator = new ConfiguratorInterceptor();
+        configurator.init( this );
+
+        DCConfiguration config = new DCConfiguration( new ArrayList<DCProperty>() );
+        config.addConstant( InterceptorConstants.PROP_INTERCEPTION_POINT, InterceptionPoint.END.toString() );
+        config.addConstant( InterceptorConstants.PROP_INTERCEPTOR_OPERATIONS,
+            "[" +
+                InterceptorOperation.ADD + "," +
+                InterceptorOperation.DELETE + "," +
+                InterceptorOperation.MODIFY + "," +
+                InterceptorOperation.RENAME
+                + "]" );
+
+        DirectoryComponent component = new DirectoryComponent( "configuratorMeta", "configuratorInterceptor", config );
+        component.setRuntimeInfo( new DCRuntime( null, configurator ) );
+        component.setConfigLocation( "ads-instance=configuratorInterceptor,ou=config" );
+        component.setDirty( false );
+
+        DCMetadataDescriptor configuratorMeta =
+            new DCMetadataDescriptor( "configuratorMeta", false, new Version( "2.0.0" ),
+                ConfiguratorInterceptor.class.getName(), new String[]
+                    { Interceptor.class.getName() }, new String[0], new DCPropertyDescription[0] );
+
+        metadatasReg.addMetadataDescriptor( configuratorMeta );
+        componentsReg.addDirectoryComponent( component );
+
+        clientManager.fireDCActivated( component );
+    }
+
+
     /* (non-Javadoc)
      * @see org.apache.directory.server.hub.ComponentHub#getDCRegistry()
      */

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ParentLinkRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ParentLinkRegistry.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ParentLinkRegistry.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/ParentLinkRegistry.java Sun May 13 13:54:29 2012
@@ -46,12 +46,21 @@ public class ParentLinkRegistry
     public void destroyComponentLinks( DirectoryComponent component )
     {
         Collection<DirectoryComponent> childs = ( Collection ) childLinks.remove( component );
-        
+
         if ( childs != null )
         {
             for ( DirectoryComponent child : childs )
             {
-                parentLinks.remove( child, component );
+                Collection<ParentLink> links = new ArrayList<ParentLink>(
+                    ( Collection<ParentLink> ) parentLinks.get( child ) );
+
+                for ( ParentLink link : links )
+                {
+                    if ( link.getParent().equals( component ) )
+                    {
+                        parentLinks.remove( child, link );
+                    }
+                }
             }
         }
     }

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/configurator/ConfiguratorInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/configurator/ConfiguratorInterceptor.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/configurator/ConfiguratorInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/configurator/ConfiguratorInterceptor.java Sun May 13 13:54:29 2012
@@ -122,7 +122,7 @@ public class ConfiguratorInterceptor ext
             return;
         }
 
-        String componentLocation = deleteContext.getDn().getNormName();
+        String componentLocation = deleteContext.getDn().getName();
         DirectoryComponent component = hub.getDCRegistry().getComponentByLocation( componentLocation );
 
         if ( component != null )
@@ -152,7 +152,7 @@ public class ConfiguratorInterceptor ext
             return;
         }
 
-        String location = modifyContext.getDn().getNormName();
+        String location = modifyContext.getDn().getName();
         DirectoryComponent component = hub.getDCRegistry().getComponentByLocation( location );
 
         if ( component == null )
@@ -235,7 +235,7 @@ public class ConfiguratorInterceptor ext
             next( renameContext );
             return;
         }
-        String oldLocation = renameContext.getDn().getNormName();
+        String oldLocation = renameContext.getDn().getName();
         DirectoryComponent component = hub.getDCRegistry().getComponentByLocation( oldLocation );
         if ( component != null )
         {
@@ -257,7 +257,7 @@ public class ConfiguratorInterceptor ext
                 }
             }
 
-            String newLocation = renameContext.getNewDn().getNormName();
+            String newLocation = renameContext.getNewDn().getName();
             hub.getDCRegistry().changeComponentLocation( component, newLocation );
 
         }
@@ -270,7 +270,7 @@ public class ConfiguratorInterceptor ext
     {
         try
         {
-            Dn targetDn = new Dn( operation.getDn().getNormName() );
+            Dn targetDn = new Dn( operation.getDn().getName() );
 
             return targetDn.isDescendantOf( new Dn( "ou=config" ) );
         }

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/connector/collection/CollectionOperations.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/connector/collection/CollectionOperations.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/connector/collection/CollectionOperations.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/connector/collection/CollectionOperations.java Sun May 13 13:54:29 2012
@@ -60,7 +60,11 @@ public class CollectionOperations implem
         Hashtable<DirectoryComponent, Integer> indexMap = generateIndexMap( component );
         List<DirectoryComponent> sortedList = extractSortedList( indexMap );
 
-        collection.addAll( sortedList );
+        for ( DirectoryComponent comp : sortedList )
+        {
+            collection.add( comp.getRuntimeInfo().getPojo() );
+        }
+
         Object pojo = ( type != CollectionType.ARRAY ) ? collection : collection.toArray();
 
         component.setRuntimeInfo( new DCRuntime( null, pojo ) );
@@ -88,7 +92,10 @@ public class CollectionOperations implem
         Hashtable<DirectoryComponent, Integer> indexMap = generateIndexMap( component );
         List<DirectoryComponent> sortedList = extractSortedList( indexMap );
 
-        collection.addAll( sortedList );
+        for ( DirectoryComponent comp : sortedList )
+        {
+            collection.add( comp.getRuntimeInfo().getPojo() );
+        }
 
         Object pojo = ( type != CollectionType.ARRAY ) ? collection : collection.toArray();
 
@@ -112,9 +119,16 @@ public class CollectionOperations implem
             if ( prop.getName().startsWith( DirectoryComponentConstants.DC_PROP_ITEM_PREFIX ) )
             {
                 DirectoryComponent reference = ( DirectoryComponent ) prop.getObject();
-                Integer index = reference.getConfiguration().getCollectionIndex();
+                if ( reference != null )
+                {
+                    Integer index = reference.getConfiguration().getCollectionIndex();
+                    if ( index == null )
+                    {
+                        index = 0;
+                    }
+                    collectionMap.put( reference, index );
+                }
 
-                collectionMap.put( reference, index );
             }
         }
 

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/meta/DCMetadataNormalizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/meta/DCMetadataNormalizer.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/meta/DCMetadataNormalizer.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/meta/DCMetadataNormalizer.java Sun May 13 13:54:29 2012
@@ -9,6 +9,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InstanceLayout;
 import org.apache.directory.server.hub.api.component.util.ComponentConstants;
 import org.apache.directory.server.hub.api.meta.DCMetadataDescriptor;
 import org.apache.directory.server.hub.api.meta.DCPropertyDescription;
@@ -22,6 +23,11 @@ public class DCMetadataNormalizer
     {
         for ( DCPropertyDescription pd : metadata.getPropertyDescriptons() )
         {
+            if ( pd.getPropertyContext() == DCPropertyType.CONSTANT )
+            {
+                continue;
+            }
+
             if ( isPrimitive( pd.getType() ) )
             {
                 pd.setPropertyContext( DCPropertyType.PRIMITIVE );
@@ -115,6 +121,8 @@ public class DCMetadataNormalizer
     private static String[] injectionTypes = new String[]
         {
             DirectoryService.class.getName(),
-            SchemaManager.class.getName()
+            SchemaManager.class.getName(),
+            InstanceLayout.class.getName(),
+            "org.apache.directory.server.core.authn.ppolicy.PpolicyConfigContainer"
     };
 }

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/ApacheDSConfigStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/ApacheDSConfigStore.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/ApacheDSConfigStore.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/ApacheDSConfigStore.java Sun May 13 13:54:29 2012
@@ -89,8 +89,6 @@ public class ApacheDSConfigStore impleme
     {
         try
         {
-            List<DCPropertyDescription> configurables = extractConfigurableDCs( metadata );
-
             schemaStoreManager.installMetadata( metadata );
 
             configStoreManager.installMetadata( metadata );
@@ -100,7 +98,6 @@ public class ApacheDSConfigStore impleme
         {
             throw new HubStoreException( "Error occured while installing metadata:" + metadata.getMetadataPID(), e );
         }
-
     }
 
 
@@ -157,7 +154,10 @@ public class ApacheDSConfigStore impleme
             schemaStoreManager.uninstallAttributes( dropped );
             schemaStoreManager.installAttributes( added );
 
-            schemaStoreManager.updateOC( newMetadata );
+            if ( dropped.size() != 0 && added.size() != 0 )
+            {
+                schemaStoreManager.updateOC( newMetadata );
+            }
 
             if ( attachedComponents != null )
             {
@@ -171,8 +171,17 @@ public class ApacheDSConfigStore impleme
                 }
             }
 
-            configStoreManager.uninstallMetadata( oldMetadata );
-            configStoreManager.installMetadata( newMetadata );
+            if ( dropped.size() != 0 && added.size() != 0 )
+            {
+                if ( oldMetadata.getPropertyDescriptons().length != newMetadata.getPropertyDescriptons().length )
+                {
+                    if ( !oldMetadata.getMetaVersion().equals( newMetadata.getMetaVersion() ) )
+                    {
+                        configStoreManager.uninstallMetadata( oldMetadata );
+                        configStoreManager.installMetadata( newMetadata );
+                    }
+                }
+            }
         }
         catch ( LdapException e )
         {

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreConfigManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreConfigManager.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreConfigManager.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreConfigManager.java Sun May 13 13:54:29 2012
@@ -189,7 +189,7 @@ public class StoreConfigManager
 
         for ( DCPropertyDescription pd : metadata.getPropertyDescriptons() )
         {
-            if ( pd.getPropertyContext() == DCPropertyType.INJECTION )
+            if ( pd.getPropertyContext() == DCPropertyType.CONSTANT )
             {
                 continue;
             }

Modified: directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreSchemaManager.java?rev=1337884&r1=1337883&r2=1337884&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreSchemaManager.java (original)
+++ directory/apacheds/branches/apacheds-osgi/hub/core/src/main/java/org/apache/directory/server/hub/core/store/StoreSchemaManager.java Sun May 13 13:54:29 2012
@@ -390,9 +390,10 @@ public class StoreSchemaManager
 
     public void updateOC( DCMetadataDescriptor metadata ) throws LdapException
     {
-        Entry ocEntry = generateOC( metadata, installNamers( metadata ) );
-
         uninstallOC( metadata.getMetadataPID() );
+        
+        Entry ocEntry = generateOC( metadata, installNamers( metadata ) );
+        
         installOCEntry( ocEntry );
     }
 }