You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/07/29 22:43:24 UTC
svn commit: r980566 - in /directory/samples/trunk/apacheds-archetype-webapp:
./ src/main/resources/archetype-resources/
src/main/resources/archetype-resources/src/main/java/
src/main/resources/archetype-resources/src/main/resources/
Author: kayyagari
Date: Thu Jul 29 20:43:23 2010
New Revision: 980566
URL: http://svn.apache.org/viewvc?rev=980566&view=rev
Log:
o upgraded the webapp to 1.5.8-SNAPSHOT
o changed the log level to WARN
Modified:
directory/samples/trunk/apacheds-archetype-webapp/archetype-catalog.xml
directory/samples/trunk/apacheds-archetype-webapp/pom.xml
directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/pom.xml
directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/resources/log4j.properties
Modified: directory/samples/trunk/apacheds-archetype-webapp/archetype-catalog.xml
URL: http://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/archetype-catalog.xml?rev=980566&r1=980565&r2=980566&view=diff
==============================================================================
--- directory/samples/trunk/apacheds-archetype-webapp/archetype-catalog.xml (original)
+++ directory/samples/trunk/apacheds-archetype-webapp/archetype-catalog.xml Thu Jul 29 20:43:23 2010
@@ -26,7 +26,7 @@
<archetype>
<groupId>org.apache.directory.samples</groupId>
<artifactId>apacheds-archetype-webapp</artifactId>
- <version>1.5.5-SNAPSHOT</version>
+ <version>1.5.8-SNAPSHOT</version>
<!-- FIX ME after the first release
<version>RELEASE</version>
-->
Modified: directory/samples/trunk/apacheds-archetype-webapp/pom.xml
URL: http://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/pom.xml?rev=980566&r1=980565&r2=980566&view=diff
==============================================================================
--- directory/samples/trunk/apacheds-archetype-webapp/pom.xml (original)
+++ directory/samples/trunk/apacheds-archetype-webapp/pom.xml Thu Jul 29 20:43:23 2010
@@ -32,7 +32,7 @@ under the License.
<packaging>maven-archetype</packaging>
<name>ApacheDS Archetype Web Application</name>
<description>Archetype to embed ApacheDS as a Web Application</description>
- <version>1.5.5-SNAPSHOT</version>
+ <version>1.5.8-SNAPSHOT</version>
<prerequisites>
<maven>2.0.9</maven>
Modified: directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/pom.xml?rev=980566&r1=980565&r2=980566&view=diff
==============================================================================
--- directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/pom.xml (original)
+++ directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/pom.xml Thu Jul 29 20:43:23 2010
@@ -63,8 +63,8 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-protocol-ldap</artifactId>
- <version>1.5.5</version>
+ <artifactId>apacheds-all</artifactId>
+ <version>1.5.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
URL: http://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java?rev=980566&r1=980565&r2=980566&view=diff
==============================================================================
--- directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java (original)
+++ directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java Thu Jul 29 20:43:23 2010
@@ -21,16 +21,30 @@ package ${package};
import java.io.File;
+import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.DefaultDirectoryService;
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.factory.JdbmPartitionFactory;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.schema.SchemaPartition;
+import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.server.core.factory.JdbmPartitionFactory;
/**
* A Servlet context listener to start and stop ApacheDS.
@@ -67,8 +81,14 @@ public class StartStopListener implement
// Determine an appropriate working directory
ServletContext servletContext = evt.getServletContext();
File workingDir = ( File ) servletContext.getAttribute( "javax.servlet.context.tempdir" );
+ workingDir = new File( workingDir, "server-work" );
+ workingDir.mkdirs();
+
directoryService.setWorkingDirectory( workingDir );
+ initSchema();
+ initSystemPartition();
+
directoryService.startup();
ldapServer.start();
@@ -97,4 +117,77 @@ public class StartStopListener implement
throw new RuntimeException( e );
}
}
+
+
+ /**
+ * Inits the schema and schema partition.
+ */
+ private void initSchema() throws Exception
+ {
+ SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
+
+ // Init the LdifPartition
+ LdifPartition ldifPartition = new LdifPartition();
+ String workingDirectory = directoryService.getWorkingDirectory().getPath();
+ ldifPartition.setWorkingDirectory( workingDirectory + "/schema" );
+
+ // Extract the schema on disk (a brand new one) and load the registries
+ File serverWorkDirectory = new File( workingDirectory );
+ File schemaRepository = new File( serverWorkDirectory, "schema" );
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( serverWorkDirectory );
+ if( ! schemaRepository.exists() )
+ {
+ // extract only if the schema directory is not present
+ extractor.extractOrCopy();
+ }
+ else
+ {
+ System.out.println( "schema partition directory exists, skipping schema extraction" );
+ }
+
+ schemaPartition.setWrappedPartition( ldifPartition );
+
+ SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+ SchemaManager schemaManager = new DefaultSchemaManager( loader );
+ directoryService.setSchemaManager( schemaManager );
+
+ // We have to load the schema now, otherwise we won't be able
+ // to initialize the Partitions, as we won't be able to parse
+ // and normalize their suffix DN
+ schemaManager.loadAllEnabled();
+
+ schemaPartition.setSchemaManager( schemaManager );
+
+ List<Throwable> errors = schemaManager.getErrors();
+
+ if ( errors.size() != 0 )
+ {
+ System.out.println( errors );
+ throw new RuntimeException( "there were errors while loading schema" );
+ }
+ }
+
+
+ /**
+ * Inits the system partition.
+ *
+ * @throws Exception the exception
+ */
+ private void initSystemPartition() throws Exception
+ {
+ // change the working directory to something that is unique
+ // on the system and somewhere either under target directory
+ // or somewhere in a temp area of the machine.
+ JdbmPartitionFactory partitionFactory = new JdbmPartitionFactory();
+
+ // Inject the System Partition
+ Partition systemPartition = partitionFactory.createPartition( "system", ServerDNConstants.SYSTEM_DN, 500,
+ new File( directoryService.getWorkingDirectory(), "system" ) );
+ systemPartition.setSchemaManager( directoryService.getSchemaManager() );
+
+ partitionFactory.addIndex( systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100 );
+
+ directoryService.setSystemPartition( systemPartition );
+ }
+
}
\ No newline at end of file
Modified: directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/resources/log4j.properties?rev=980566&r1=980565&r2=980566&view=diff
==============================================================================
--- directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/resources/log4j.properties (original)
+++ directory/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/resources/log4j.properties Thu Jul 29 20:43:23 2010
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#############################################################################
-log4j.rootCategory=INFO, stdout, R
+log4j.rootCategory=WARN, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout