o added support for instantiating jetty http server
o added dependency on apacheds-http-server-integration


git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/apacheds-cidit@899890 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/default-config/pom.xml b/default-config/pom.xml
index b1dfeb1..4a1c130 100644
--- a/default-config/pom.xml
+++ b/default-config/pom.xml
@@ -68,5 +68,11 @@
       <artifactId>apacheds-protocol-ntp</artifactId>
       <version>${pom.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server.http</groupId>
+      <artifactId>apacheds-http-integration</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
   </dependencies>
 </project>
diff --git a/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java b/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
index 68dc1f1..8a9f5d7 100644
--- a/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
+++ b/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
@@ -54,6 +54,8 @@
 import org.apache.directory.server.dhcp.store.DhcpStore;
 import org.apache.directory.server.dhcp.store.SimpleDhcpStore;
 import org.apache.directory.server.dns.DnsServer;
+import org.apache.directory.server.integration.http.HttpServer;
+import org.apache.directory.server.integration.http.WebApp;
 import org.apache.directory.server.kerberos.kdc.KdcServer;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.ldap.LdapServer;
@@ -418,6 +420,58 @@
     }
 
     
+    public HttpServer getHttpServer() throws Exception
+    {
+        EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-httpServer" ) );
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+            controls );
+
+        if ( !cursor.next() )
+        {
+            throw new Exception( "No HTTP server was configured under the DN " + configPartition.getSuffixDn() );
+        }
+
+        ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+        cursor.close();
+
+        ClonedServerEntry httpEntry = configPartition.lookup( forwardEntry.getId() );
+        LOG.debug( "HTTP server entry {}", httpEntry );
+        if( !isEnabled( httpEntry ) )
+        {
+            return null;
+        }
+        
+        HttpServer httpServer = new HttpServer();
+        
+        EntryAttribute portAttr = httpEntry.get( "ads-systemPort" );
+        if( portAttr != null )
+        {
+            httpServer.setPort( Integer.parseInt( portAttr.getString() ) );
+        }
+        
+        EntryAttribute confFileAttr = httpEntry.get( "ads-httpConfFile" );
+        if( confFileAttr != null )
+        {
+            httpServer.setConfFile( confFileAttr.getString() );
+        }
+        
+        EntryAttribute webAppsAttr = httpEntry.get( "ads-httpWebApps" );
+        if( webAppsAttr != null )
+        {
+            LdapDN webAppsDN = new LdapDN( webAppsAttr.getString() );
+            webAppsDN.normalize( schemaManager.getNormalizerMapping() );
+         
+            Set<WebApp> webApps = getWebApps( webAppsDN );
+            httpServer.setWebApps( webApps );
+        }
+        
+        return httpServer;
+    }
+    
+    
     /**
      * 
      * instantiates a DirectoryService based on the configuration present in the partition 
@@ -887,6 +941,36 @@
     }
     
     
+    private Set<WebApp> getWebApps( LdapDN webAppsDN ) throws Exception
+    {
+        PresenceNode filter = new PresenceNode( "ads-httpWarFile" );
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        IndexCursor cursor = se.cursor( webAppsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+        
+        Set<WebApp> webApps = new HashSet<WebApp>();
+        
+        while( cursor.next() )
+        {
+            ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+            ServerEntry webAppEntry = configPartition.lookup( forwardEntry.getId() );
+            
+            WebApp app = new WebApp();
+            app.setWarFile( getString( "ads-httpWarFile", webAppEntry ) );
+            
+            EntryAttribute ctxPathAttr = webAppEntry.get( "ads-httpAppCtxPath" );
+            if( ctxPathAttr != null )
+            {
+                app.setContextPath( ctxPathAttr.getString() );
+            }
+            
+            webApps.add( app );
+        }
+        
+        return webApps;
+    }
+    
+    
     /**
      * internal class used for holding the Interceptor classname and order configuration
      */