syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1469831 - in /syncope/trunk: ./ build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java
Date Fri, 19 Apr 2013 14:00:15 GMT
Author: ilgrosso
Date: Fri Apr 19 14:00:15 2013
New Revision: 1469831

URL: http://svn.apache.org/r1469831
Log:
[SYNCOPE-363] Merge from 1_1_X

Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1469813-1469830

Modified: syncope/trunk/build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java
URL: http://svn.apache.org/viewvc/syncope/trunk/build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java?rev=1469831&r1=1469830&r2=1469831&view=diff
==============================================================================
--- syncope/trunk/build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java
(original)
+++ syncope/trunk/build-tools/src/main/java/org/apache/syncope/buildtools/ApacheDSStartStopListener.java
Fri Apr 19 14:00:15 2013
@@ -153,9 +153,12 @@ public class ApacheDSStartStopListener i
      * partitions.
      *
      * @param workDir the directory to be used for storing the data
+     * @param loadDefaultContent if default content should be loaded
      * @throws Exception if there were some problems while initializing
      */
-    private void initDirectoryService(final ServletContext servletContext, final File workDir)
throws Exception {
+    private void initDirectoryService(final ServletContext servletContext, final File workDir,
+            final boolean loadDefaultContent) throws Exception {
+
         // Initialize the LDAP service
         service = new DefaultDirectoryService();
         service.setWorkingDirectory(workDir);
@@ -180,10 +183,12 @@ public class ApacheDSStartStopListener i
         service.startup();
 
         // Finally, load content LDIF
-        final LdifURLLoader contentLoader = new LdifURLLoader(service.getAdminSession(),
-                servletContext.getResource("/WEB-INF/classes/content.ldif"));
-        final int numEntries = contentLoader.execute();
-        LOG.info("Successfully created {} entries", numEntries);
+        if (loadDefaultContent) {
+            final LdifURLLoader contentLoader = new LdifURLLoader(service.getAdminSession(),
+                    servletContext.getResource("/WEB-INF/classes/content.ldif"));
+            final int numEntries = contentLoader.execute();
+            LOG.info("Successfully created {} entries", numEntries);
+        }
     }
 
     /**
@@ -195,13 +200,16 @@ public class ApacheDSStartStopListener i
     public void contextInitialized(final ServletContextEvent sce) {
         File workDir = (File) sce.getServletContext().getAttribute("javax.servlet.context.tempdir");
         workDir = new File(workDir, "server-work");
-        if (!workDir.mkdirs()) {
+        
+        final boolean loadDefaultContent = !workDir.exists();
+        
+        if (loadDefaultContent && !workDir.mkdirs()) {
             throw new RuntimeException("Could not create " + workDir.getAbsolutePath());
         }
 
         Entry result;
         try {
-            initDirectoryService(sce.getServletContext(), workDir);
+            initDirectoryService(sce.getServletContext(), workDir, loadDefaultContent);
 
             server = new LdapServer();
             server.setTransports(



Mime
View raw message