directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r655491 [1/2] - in /directory/studio/trunk/apacheds-configuration: META-INF/ src/main/java/org/apache/directory/studio/apacheds/configuration/ src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ src/main/java/org/apache...
Date Mon, 12 May 2008 12:39:54 GMT
Author: pamarcelot
Date: Mon May 12 05:39:53 2008
New Revision: 655491

URL: http://svn.apache.org/viewvc?rev=655491&view=rev
Log:
o Internal classes reorganization
o Added the ability to open both 1.5.0 and 1.5.1 server.xml files

Added:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPlugin.java
      - copied, changed from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginConstants.java
      - copied, changed from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginConstants.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginUtils.java
      - copied, changed from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/AbstractServerXmlIO.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIO.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIOException.java
      - copied, changed from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParserException.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV150IO.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV151IO.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV152IO.java
Removed:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginConstants.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParser.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParserException.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriterException.java
Modified:
    directory/studio/trunk/apacheds-configuration/META-INF/MANIFEST.MF
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java

Modified: directory/studio/trunk/apacheds-configuration/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/META-INF/MANIFEST.MF?rev=655491&r1=655490&r2=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/apacheds-configuration/META-INF/MANIFEST.MF Mon May 12 05:39:53 2008
@@ -3,7 +3,7 @@
 Bundle-Name: Apache Directory Studio Apache DS Configuration
 Bundle-SymbolicName: org.apache.directory.studio.apacheds.configuration;singleton:=true
 Bundle-Version: 1.2.0.SNAPSHOT
-Bundle-Activator: org.apache.directory.studio.apacheds.configuration.Activator
+Bundle-Activator: org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin
 Bundle-Vendor: Apache Software Foundation
 Bundle-Localization: plugin
 Eclipse-LazyStart: true

Copied: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPlugin.java (from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPlugin.java?p2=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPlugin.java&p1=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java&r1=653343&r2=655491&rev=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPlugin.java Mon May 12 05:39:53 2008
@@ -22,6 +22,8 @@
 
 import java.net.URL;
 
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlV152IO;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.dialogs.Dialog;
@@ -35,6 +37,9 @@
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlV150IO;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlV151IO;
+
 
 /**
  * The activator class controls the plug-in life cycle.
@@ -42,19 +47,22 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class Activator extends AbstractUIPlugin
+public class ApacheDSConfigurationPlugin extends AbstractUIPlugin
 {
     /** The plug-in ID */
     public static final String PLUGIN_ID = "org.apache.directory.studio.apacheds.configuration"; //$NON-NLS-1$
 
     /** The shared instance */
-    private static Activator plugin;
+    private static ApacheDSConfigurationPlugin plugin;
+
+    private ServerXmlIO[] serverXmlIOs = new ServerXmlIO[]
+        { new ServerXmlV152IO(), new ServerXmlV151IO(), new ServerXmlV150IO(), };
 
 
     /**
      * Creates a new instance of Activator.
      */
-    public Activator()
+    public ApacheDSConfigurationPlugin()
     {
         plugin = this;
     }
@@ -86,13 +94,26 @@
      * @return
      *      the shared instance
      */
-    public static Activator getDefault()
+    public static ApacheDSConfigurationPlugin getDefault()
     {
         return plugin;
     }
 
 
     /**
+     * Gets the array of available {@link ServerXmlIO} classes that 
+     * implements a parser and a writer for the 'server.xml' file. 
+     *
+     * @return
+     *      the array of available {@link ServerXmlIO} classes
+     */
+    public ServerXmlIO[] getServerXmlIOs()
+    {
+        return serverXmlIOs;
+    }
+
+
+    /**
      * Returns the button with respect to the font metrics.
      *
      * @param control a control

Copied: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginConstants.java (from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginConstants.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginConstants.java?p2=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginConstants.java&p1=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginConstants.java&r1=653343&r2=655491&rev=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginConstants.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginConstants.java Mon May 12 05:39:53 2008
@@ -26,7 +26,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface PluginConstants
+public interface ApacheDSConfigurationPluginConstants
 {
     // Images
     public static final String IMG_VERTICAL_ORIENTATION = "resources/icons/vertical_orientation.gif";

Copied: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginUtils.java (from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginUtils.java?p2=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginUtils.java&p1=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java&r1=653343&r2=655491&rev=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationPluginUtils.java Mon May 12 05:39:53 2008
@@ -24,7 +24,7 @@
 import org.eclipse.core.runtime.IExtensionPoint;
 import org.eclipse.core.runtime.Platform;
 
-public class PluginUtils
+public class ApacheDSConfigurationPluginUtils
 {
     /**
      * Checks, if this plugins runs in the Eclipse IDE or in RCP environment.

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java?rev=655491&r1=655490&r2=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java Mon May 12 05:39:53 2008
@@ -22,8 +22,8 @@
 
 import java.util.List;
 
-import org.apache.directory.studio.apacheds.configuration.Activator;
-import org.apache.directory.studio.apacheds.configuration.PluginConstants;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginConstants;
 import org.apache.directory.studio.apacheds.configuration.model.ExtendedOperation;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
 import org.eclipse.jface.action.Action;
@@ -136,7 +136,7 @@
         {
             public Image getImage( Object element )
             {
-                return Activator.getDefault().getImage( PluginConstants.IMG_EXTENDED_OPERATION );
+                return ApacheDSConfigurationPlugin.getDefault().getImage( ApacheDSConfigurationPluginConstants.IMG_EXTENDED_OPERATION );
             }
         } );
 
@@ -256,8 +256,8 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
+        horizontalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
         Action verticalAction = new Action( "Vertical Orientation", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
@@ -269,8 +269,8 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_VERTICAL_ORIENTATION ) );
+        verticalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );
         form.getToolBarManager().add( verticalAction );

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java?rev=655491&r1=655490&r2=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java Mon May 12 05:39:53 2008
@@ -22,8 +22,8 @@
 
 import java.util.List;
 
-import org.apache.directory.studio.apacheds.configuration.Activator;
-import org.apache.directory.studio.apacheds.configuration.PluginConstants;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginConstants;
 import org.apache.directory.studio.apacheds.configuration.model.Interceptor;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
 import org.eclipse.jface.action.Action;
@@ -140,7 +140,7 @@
         {
             public Image getImage( Object element )
             {
-                return Activator.getDefault().getImage( PluginConstants.IMG_INTERCEPTOR );
+                return ApacheDSConfigurationPlugin.getDefault().getImage( ApacheDSConfigurationPluginConstants.IMG_INTERCEPTOR );
             }
         } );
 
@@ -342,8 +342,8 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
+        horizontalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
         Action verticalAction = new Action( "Vertical Orientation", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
@@ -355,8 +355,8 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_VERTICAL_ORIENTATION ) );
+        verticalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );
         form.getToolBarManager().add( verticalAction );

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java?rev=655491&r1=655490&r2=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java Mon May 12 05:39:53 2008
@@ -22,8 +22,8 @@
 
 import java.util.List;
 
-import org.apache.directory.studio.apacheds.configuration.Activator;
-import org.apache.directory.studio.apacheds.configuration.PluginConstants;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginConstants;
 import org.apache.directory.studio.apacheds.configuration.model.Partition;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
 import org.eclipse.jface.action.Action;
@@ -138,9 +138,9 @@
             public Image getImage( Object element )
             {
 
-                return Activator.getDefault().getImage(
-                    ( ( Partition ) element ).isSystemPartition() ? PluginConstants.IMG_PARTITION_SYSTEM
-                        : PluginConstants.IMG_PARTITION );
+                return ApacheDSConfigurationPlugin.getDefault().getImage(
+                    ( ( Partition ) element ).isSystemPartition() ? ApacheDSConfigurationPluginConstants.IMG_PARTITION_SYSTEM
+                        : ApacheDSConfigurationPluginConstants.IMG_PARTITION );
             }
         } );
 
@@ -270,8 +270,8 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
+        horizontalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
         Action verticalAction = new Action( "Vertical Orientation", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
@@ -283,8 +283,8 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
-            PluginConstants.IMG_VERTICAL_ORIENTATION ) );
+        verticalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+            ApacheDSConfigurationPluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );
         form.getToolBarManager().add( verticalAction );

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java?rev=655491&r1=655490&r2=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java Mon May 12 05:39:53 2008
@@ -24,16 +24,17 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 
-import org.apache.directory.studio.apacheds.configuration.Activator;
-import org.apache.directory.studio.apacheds.configuration.PluginUtils;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginUtils;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
-import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationParser;
-import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationWriter;
-import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationWriterException;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIOException;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
@@ -76,6 +77,9 @@
     /** The Server Configuration */
     private ServerConfiguration serverConfiguration;
 
+    /** The associated ServerXmlIO class */
+    private ServerXmlIO serverXmlIO;
+
     /** The dirty flag */
     private boolean dirty = false;
 
@@ -94,40 +98,42 @@
         super.init( site, input );
         setPartName( input.getName() );
 
-        String inputClassName = input.getClass().getName();
+        //
+        //        String inputClassName = input.getClass().getName();
         try
         {
-            if ( input instanceof FileEditorInput )
-            // The 'FileEditorInput' class is used when the file is opened
-            // from a project in the workspace.
-            {
-                ServerConfigurationParser parser = new ServerConfigurationParser();
-                serverConfiguration = parser.parse( ( ( FileEditorInput ) input ).getFile().getContents() );
-            }
-            else if ( input instanceof IPathEditorInput )
-            {
-                ServerConfigurationParser parser = new ServerConfigurationParser();
-                serverConfiguration = parser.parse( new FileInputStream( new File( ( ( IPathEditorInput ) input )
-                    .getPath().toOSString() ) ) );
-            }
-            else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" )
-                || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
-            // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
-            // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
-            // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
-            // opening a file from the menu File > Open... in Eclipse 3.3.x
-            {
-                // We use the tooltip to get the full path of the file
-                ServerConfigurationParser parser = new ServerConfigurationParser();
-                serverConfiguration = parser.parse( new FileInputStream( new File( input.getToolTipText() ) ) );
-            }
-            else if ( input instanceof NonExistingServerConfigurationInput )
-            {
-                // The 'ServerConfigurationEditorInput' class is used when a
-                // new Server Configuration File is created.
-                serverConfiguration = ( ( NonExistingServerConfigurationInput ) input ).getServerConfiguration();
-                dirty = true;
-            }
+            readServerConfiguration( input );
+            //            if ( input instanceof FileEditorInput )
+            //            // The 'FileEditorInput' class is used when the file is opened
+            //            // from a project in the workspace.
+            //            {
+            //                ServerConfigurationParser parser = new ServerConfigurationParser();
+            //                serverConfiguration = parser.parse( ( ( FileEditorInput ) input ).getFile().getContents() );
+            //            }
+            //            else if ( input instanceof IPathEditorInput )
+            //            {
+            //                ServerConfigurationParser parser = new ServerConfigurationParser();
+            //                serverConfiguration = parser.parse( new FileInputStream( new File( ( ( IPathEditorInput ) input )
+            //                    .getPath().toOSString() ) ) );
+            //            }
+            //            else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" )
+            //                || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
+            //            // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
+            //            // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
+            //            // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
+            //            // opening a file from the menu File > Open... in Eclipse 3.3.x
+            //            {
+            //                // We use the tooltip to get the full path of the file
+            //                ServerConfigurationParser parser = new ServerConfigurationParser();
+            //                serverConfiguration = parser.parse( new FileInputStream( new File( input.getToolTipText() ) ) );
+            //            }
+            //            else if ( input instanceof NonExistingServerConfigurationInput )
+            //            {
+            //                // The 'ServerConfigurationEditorInput' class is used when a
+            //                // new Server Configuration File is created.
+            //                serverConfiguration = ( ( NonExistingServerConfigurationInput ) input ).getServerConfiguration();
+            //                dirty = true;
+            //            }
         }
         catch ( Exception e )
         {
@@ -141,6 +147,82 @@
     }
 
 
+    /**
+     * Reads the server configuration from the given editor input.
+     *
+     * @param input
+     *      the editor input
+     * @throws CoreException 
+     * @throws FileNotFoundException 
+     * @throws ServerXmlIOException 
+     */
+    private void readServerConfiguration( IEditorInput input ) throws CoreException, FileNotFoundException,
+        ServerXmlIOException
+    {
+        // If the input is a NonExistingServerConfigurationInput, then we only 
+        // need to get the server configuration and return
+        if ( input instanceof NonExistingServerConfigurationInput )
+        {
+            // The 'ServerConfigurationEditorInput' class is used when a
+            // new Server Configuration File is created.
+            serverConfiguration = ( ( NonExistingServerConfigurationInput ) input ).getServerConfiguration();
+            dirty = true;
+            return;
+        }
+
+        // Looping on the ServerXmlIO classes to find a corresponding one
+        ServerXmlIO[] serverXmlIOs = ApacheDSConfigurationPlugin.getDefault().getServerXmlIOs();
+        for ( ServerXmlIO validationServerXmlIO : serverXmlIOs )
+        {
+            // Checking if the ServerXmlIO
+            if ( validationServerXmlIO.isValid( getInputStream( input ) ) )
+            {
+                serverXmlIO = validationServerXmlIO;
+                serverConfiguration = serverXmlIO.parse( getInputStream( input ) );
+                return;
+            }
+        }
+    }
+
+
+    /**
+     * Gets an input stream from the editor input.
+     *
+     * @param input
+     *      the editor input
+     * @return
+     *      an input stream from the editor input, or <code>null</code>
+     * @throws CoreException
+     * @throws FileNotFoundException
+     */
+    private InputStream getInputStream( IEditorInput input ) throws CoreException, FileNotFoundException
+    {
+        String inputClassName = input.getClass().getName();
+        if ( input instanceof FileEditorInput )
+        // The 'FileEditorInput' class is used when the file is opened
+        // from a project in the workspace.
+        {
+            return ( ( FileEditorInput ) input ).getFile().getContents();
+        }
+        else if ( input instanceof IPathEditorInput )
+        {
+            return new FileInputStream( new File( ( ( IPathEditorInput ) input ).getPath().toOSString() ) );
+        }
+        else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" )
+            || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
+        // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
+        // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
+        // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
+        // opening a file from the menu File > Open... in Eclipse 3.3.x
+        {
+            // We use the tooltip to get the full path of the file
+            return new FileInputStream( new File( input.getToolTipText() ) );
+        }
+
+        return null;
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
      */
@@ -162,8 +244,9 @@
         }
         catch ( PartInitException e )
         {
-            Activator.getDefault().getLog().log(
-                new Status( Status.ERROR, Activator.PLUGIN_ID, Status.OK, e.getMessage(), e.getCause() ) );
+            ApacheDSConfigurationPlugin.getDefault().getLog().log(
+                new Status( Status.ERROR, ApacheDSConfigurationPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e
+                    .getCause() ) );
         }
     }
 
@@ -277,10 +360,10 @@
      * @throws IOException
      * @throws ServerConfigurationWriterException
      */
-    private void saveConfiguration( String path ) throws IOException, ServerConfigurationWriterException
+    private void saveConfiguration( String path ) throws IOException
     {
         BufferedWriter outFile = new BufferedWriter( new FileWriter( path ) );
-        String xml = ServerConfigurationWriter.toXml( serverConfiguration );
+        String xml = serverXmlIO.toXml( serverConfiguration );
         outFile.write( xml );
         outFile.close();
     }
@@ -294,10 +377,9 @@
      * @throws ServerConfigurationWriterException 
      * @throws CoreException 
      */
-    private void saveConfiguration( FileEditorInput fei, IProgressMonitor monitor )
-        throws ServerConfigurationWriterException, CoreException
+    private void saveConfiguration( FileEditorInput fei, IProgressMonitor monitor ) throws CoreException
     {
-        String xml = ServerConfigurationWriter.toXml( serverConfiguration );
+        String xml = serverXmlIO.toXml( serverConfiguration );
         fei.getFile().setContents( new ByteArrayInputStream( xml.getBytes() ), true, true, monitor );
     }
 
@@ -360,7 +442,7 @@
     {
         // detect IDE or RCP:
         // check if perspective org.eclipse.ui.resourcePerspective is available
-        boolean isIDE = PluginUtils.isIDEEnvironment();
+        boolean isIDE = ApacheDSConfigurationPluginUtils.isIDEEnvironment();
 
         if ( isIDE )
         {

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/AbstractServerXmlIO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/AbstractServerXmlIO.java?rev=655491&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/AbstractServerXmlIO.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/AbstractServerXmlIO.java Mon May 12 05:39:53 2008
@@ -0,0 +1,279 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration.model;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.directory.shared.ldap.ldif.LdifReader;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.DocumentResult;
+import org.dom4j.io.DocumentSource;
+
+
+/**
+ * This abstract class implements the {@link ServerXmlIO} class and adds 
+ * useful methods for reading and creating XML.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractServerXmlIO implements ServerXmlIO
+{
+    /**
+     * Gets the Bean element corresponding to the given ID.
+     *
+     * @param document
+     *      the document to use
+     * @param id
+     *      the id
+     * @return
+     *       the Bean element corresponding to the given ID or null if the bean was not found
+     */
+    Element getBeanElementById( Document document, String id )
+    {
+        for ( Iterator<?> i = document.getRootElement().elementIterator( "bean" ); i.hasNext(); )
+        {
+            Element element = ( Element ) i.next();
+            org.dom4j.Attribute idAttribute = element.attribute( "id" );
+            if ( idAttribute != null && ( idAttribute.getValue().equals( id ) ) )
+            {
+                return element;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the given property Element in the the bean
+     *
+     * @param property
+     *      the propery
+     * @param element
+     *      the bean Element
+     * @return
+     *      the associated property, or null if the property has not been found
+     */
+    Element getBeanPropertyElement( String property, Element element )
+    {
+        for ( Iterator<?> i = element.elementIterator( "property" ); i.hasNext(); )
+        {
+            Element propertyElement = ( Element ) i.next();
+            org.dom4j.Attribute nameAttribute = propertyElement.attribute( "name" );
+            if ( nameAttribute != null && ( nameAttribute.getValue().equals( property ) ) )
+            {
+                return propertyElement;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads the given property in the Bean and returns its value.
+     *
+     * @param property
+     *      the property
+     * @param element
+     *      the Bean Element
+     * @return
+     *      the value of the property, or null if the property has not been found
+     */
+    String readBeanProperty( String property, Element element )
+    {
+        Element propertyElement = getBeanPropertyElement( property, element );
+        if ( propertyElement != null )
+        {
+            org.dom4j.Attribute valueAttribute = propertyElement.attribute( "value" );
+            if ( valueAttribute != null )
+            {
+                return valueAttribute.getValue();
+            }
+
+            org.dom4j.Attribute refAttribute = propertyElement.attribute( "ref" );
+            if ( refAttribute != null )
+            {
+                return refAttribute.getValue();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Parses the string argument as a boolean.
+     *
+     * @param s
+     *      a String containing the boolean representation to be parsed
+     * @return
+     *      the boolean value represented by the argument.
+     * @throws BooleanFormatException
+     *      if the string does not contain a parsable boolean.
+     */
+    boolean parseBoolean( String s ) throws BooleanFormatException
+    {
+        if ( "true".equals( s ) )
+        {
+            return true;
+        }
+        else if ( "false".equals( s ) )
+        {
+            return false;
+        }
+        else
+        {
+            throw new BooleanFormatException( "The String '" + s + "' could not be parsed as a boolean." );
+        }
+    }
+
+    /**
+     * Thrown to indicate that the application has attempted to convert a string to a boolean, 
+     * but that the string does not have the appropriate format.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    class BooleanFormatException extends Exception
+    {
+        /** The Serial Version UID */
+        private static final long serialVersionUID = -6426955193802317452L;
+
+
+        /**
+         * Creates a new instance of BooleanFormatException.
+         *
+         * @param message
+         * @param cause
+         */
+        public BooleanFormatException( String message )
+        {
+            super( message );
+        }
+    }
+
+
+    /**
+     * Reads an entry (without DN)
+     * 
+     * @param text
+     *            The ldif format text
+     * @return An Attributes.
+     */
+    Attributes readContextEntry( String text )
+    {
+        StringReader strIn = new StringReader( text );
+        BufferedReader in = new BufferedReader( strIn );
+
+        String line = null;
+        Attributes attributes = new AttributesImpl( true );
+
+        try
+        {
+            while ( ( line = ( ( BufferedReader ) in ).readLine() ) != null )
+            {
+                if ( line.length() == 0 )
+                {
+                    continue;
+                }
+
+                String addedLine = line.trim();
+
+                if ( StringTools.isEmpty( addedLine ) )
+                {
+                    continue;
+                }
+
+                javax.naming.directory.Attribute attribute = LdifReader.parseAttributeValue( addedLine );
+                javax.naming.directory.Attribute oldAttribute = attributes.get( attribute.getID() );
+
+                if ( oldAttribute != null )
+                {
+                    try
+                    {
+                        oldAttribute.add( attribute.get() );
+                        attributes.put( oldAttribute );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        // Do nothing
+                    }
+                }
+                else
+                {
+                    attributes.put( attribute );
+                }
+            }
+        }
+        catch ( IOException ioe )
+        {
+            // Do nothing : we can't reach this point !
+        }
+
+        return attributes;
+    }
+
+
+    /**
+     * XML Pretty Printer XSLT Tranformation
+     * 
+     * @param document
+     *      the Dom4j Document
+     * @return
+     *      the stylized Document
+     * @throws TransformerException 
+     */
+    static Document styleDocument( Document document ) throws TransformerException
+    {
+        // load the transformer using JAXP
+        TransformerFactory factory = TransformerFactory.newInstance();
+        Transformer transformer = null;
+
+        transformer = factory
+            .newTransformer( new StreamSource( ApacheDSConfigurationPlugin.class.getResourceAsStream( "template.xslt" ) ) );
+
+        // now lets style the given document
+        DocumentSource source = new DocumentSource( document );
+        DocumentResult result = new DocumentResult();
+
+        transformer.transform( source, result );
+
+        // return the transformed document
+        Document transformedDoc = result.getDocument();
+        return transformedDoc;
+    }
+}

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIO.java?rev=655491&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIO.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIO.java Mon May 12 05:39:53 2008
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration.model;
+
+
+import java.io.InputStream;
+
+
+/**
+ * This interface defines an object that implements a parser and a writer for 
+ * the 'server.xml' file. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerXmlIO
+{
+    /**
+     * Indicates whether or not the given input stream is a valid 'server.xml' 
+     * file.
+     *
+     * @param is
+     *      the input stream to use
+     * @return
+     *      <code>true</code> if the given input stream is a valid 
+     *      'server.xml' file, <code>false</code> if not
+     */
+    public boolean isValid( InputStream is );
+
+
+    /**
+     * Parses the given input and returns the corresponding server configuration.
+     *
+     * @param is
+     *      the input stream to use
+     * @return
+     *      the corresponding server configuration
+     * @throws ServerXmlIOException
+     *      if an error occurs when parsing the 
+     */
+    public ServerConfiguration parse( InputStream is ) throws ServerXmlIOException;
+
+
+    /**
+     * Converts the given server configuration to its corresponding XML representation.
+     *
+     * @param serverConfiguration
+     *      the server configuration
+     * @return
+     *      the corresponding XML representation
+     */
+    public String toXml( ServerConfiguration serverConfiguration );
+}

Copied: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIOException.java (from r653343, directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParserException.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIOException.java?p2=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIOException.java&p1=directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParserException.java&r1=653343&r2=655491&rev=655491&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationParserException.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlIOException.java Mon May 12 05:39:53 2008
@@ -27,7 +27,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerConfigurationParserException extends Exception
+public class ServerXmlIOException extends Exception
 {
     /** The Serial Version UID */
     private static final long serialVersionUID = 7274953743060751973L;
@@ -40,7 +40,7 @@
      *      the detail message (which is saved for later retrieval by the 
      *      getMessage() method).
      */
-    public ServerConfigurationParserException( String message )
+    public ServerXmlIOException( String message )
     {
         super( message );
     }
@@ -57,7 +57,7 @@
      *      method). (A null value is permitted, and indicates that the cause 
      *      is nonexistent or unknown.)
      */
-    public ServerConfigurationParserException( String message, Throwable cause )
+    public ServerXmlIOException( String message, Throwable cause )
     {
         super( message, cause );
     }

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV150IO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV150IO.java?rev=655491&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV150IO.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerXmlV150IO.java Mon May 12 05:39:53 2008
@@ -0,0 +1,1079 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration.model;
+
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.xml.transform.TransformerException;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+
+
+/**
+ * This class implements a parser and a writer for the 'server.xml' file of 
+ * Apache Directory Server version 1.5.0.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerXmlV150IO extends AbstractServerXmlIO implements ServerXmlIO
+{
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO#isValid(java.io.InputStream)
+     */
+    public boolean isValid( InputStream is )
+    {
+        try
+        {
+            SAXReader saxReader = new SAXReader();
+
+            return isValid( saxReader.read( is ) );
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Checks if the InputStream is valid.
+     *
+     * @param inputStream
+     *      the InputStream
+     * @return
+     *      true if the InputStream is valid, false if not
+     */
+    public boolean isValid( Reader reader )
+    {
+        try
+        {
+            SAXReader saxReader = new SAXReader();
+
+            return isValid( saxReader.read( reader ) );
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Checks if the Document is valid.
+     *
+     * @param document
+     *      the Document
+     * @return
+     *      true if the Document is valid, false if not
+     */
+    private boolean isValid( Document document )
+    {
+        for ( Iterator<?> i = document.getRootElement().elementIterator( "bean" ); i.hasNext(); )
+        {
+            Element element = ( Element ) i.next();
+            org.dom4j.Attribute classAttribute = element.attribute( "class" );
+            if ( classAttribute != null
+                && ( classAttribute.getValue()
+                    .equals( "org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration" ) ) )
+            {
+                String partitionName = readBeanProperty( "name", element );
+
+                if ( partitionName != null )
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO#parse(java.io.InputStream)
+     */
+    public ServerConfiguration parse( InputStream is ) throws ServerXmlIOException
+    {
+        try
+        {
+            SAXReader reader = new SAXReader();
+            Document document = reader.read( is );
+
+            ServerConfiguration serverConfiguration = new ServerConfiguration();
+
+            parse( document, serverConfiguration );
+
+            return serverConfiguration;
+        }
+        catch ( Exception e )
+        {
+            if ( e instanceof ServerXmlIOException )
+            {
+                throw ( ServerXmlIOException ) e;
+            }
+            else
+            {
+                ServerXmlIOException exception = new ServerXmlIOException( e.getMessage(), e.getCause() );
+                exception.setStackTrace( e.getStackTrace() );
+                throw exception;
+            }
+        }
+    }
+
+
+    /**
+     * Parses the Document.
+     *
+     * @param document
+     *      the Document
+     * @param serverConfiguration
+     *      the Server Configuration
+     * @throws NumberFormatException
+     * @throws BooleanFormatException
+     * @throws ServerXmlIOException 
+     */
+    private void parse( Document document, ServerConfiguration serverConfiguration ) throws NumberFormatException,
+        BooleanFormatException, ServerXmlIOException
+    {
+        // Reading the 'Environment' Bean
+        readEnvironmentBean( document, serverConfiguration );
+
+        // Reading the 'Configuration' Bean
+        readConfigurationBean( document, serverConfiguration );
+    }
+
+
+    /**
+     * Reads the "Environment" Bean and store its values in the given ServerConfiguration.
+     *
+     * @param document
+     *      the document to use
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void readEnvironmentBean( Document document, ServerConfiguration serverConfiguration )
+    {
+        Element environmentBean = getBeanElementById( document, "environment" );
+
+        // Principal
+        String principal = readEnvironmentBeanProperty( "java.naming.security.principal", environmentBean );
+        if ( principal != null )
+        {
+            serverConfiguration.setPrincipal( principal );
+        }
+
+        // Password
+        String password = readEnvironmentBeanProperty( "java.naming.security.credentials", environmentBean );
+        if ( password != null )
+        {
+            serverConfiguration.setPassword( password );
+        }
+
+        // Binary Attributes
+        String binaryAttributes = readEnvironmentBeanProperty( "java.naming.ldap.attributes.binary", environmentBean );
+        if ( binaryAttributes != null )
+        {
+            String[] attributes = binaryAttributes.split( " " );
+
+            for ( String attribute : attributes )
+            {
+                serverConfiguration.addBinaryAttribute( attribute );
+            }
+        }
+    }
+
+
+    /**
+     * Reads the given property in the 'Environment' Bean and returns it.
+     *
+     * @param property
+     *      the property
+     * @param element
+     *      the Environment Bean Element
+     * @return
+     *      the value of the property, or null if the property has not been found
+     */
+    private String readEnvironmentBeanProperty( String property, Element element )
+    {
+        Element propertyElement = element.element( "property" );
+        if ( propertyElement != null )
+        {
+            Element propsElement = propertyElement.element( "props" );
+            if ( propsElement != null )
+            {
+                for ( Iterator<?> i = propsElement.elementIterator( "prop" ); i.hasNext(); )
+                {
+                    Element propElement = ( Element ) i.next();
+                    org.dom4j.Attribute keyAttribute = propElement.attribute( "key" );
+                    if ( keyAttribute != null && ( keyAttribute.getValue().equals( property ) ) )
+                    {
+                        return propElement.getText();
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads the "Configuration" Bean and store its values in the given ServerConfiguration.
+     *
+     * @param document
+     *      the document to use
+     * @param serverConfiguration
+     *      the Server Configuration
+     * @throws NumberFormatException
+     * @throws BooleanFormatException 
+     * @throws ServerXmlIOException 
+     */
+    private void readConfigurationBean( Document document, ServerConfiguration serverConfiguration )
+        throws NumberFormatException, BooleanFormatException, ServerXmlIOException
+    {
+        Element configurationBean = getBeanElementById( document, "configuration" );
+
+        // LdapPort
+        String ldapPort = readBeanProperty( "ldapPort", configurationBean );
+        if ( ldapPort != null )
+        {
+            serverConfiguration.setLdapPort( Integer.parseInt( ldapPort ) );
+        }
+
+        // SynchPeriodMillis
+        String synchPeriodMillis = readBeanProperty( "synchPeriodMillis", configurationBean );
+        if ( synchPeriodMillis != null )
+        {
+            serverConfiguration.setSynchronizationPeriod( Long.parseLong( synchPeriodMillis ) );
+        }
+
+        // MaxTimeLimit
+        String maxTimeLimit = readBeanProperty( "maxTimeLimit", configurationBean );
+        if ( maxTimeLimit != null )
+        {
+            serverConfiguration.setMaxTimeLimit( Integer.parseInt( maxTimeLimit ) );
+        }
+
+        // MaxSizeLimit
+        String maxSizeLimit = readBeanProperty( "maxSizeLimit", configurationBean );
+        if ( maxSizeLimit != null )
+        {
+            serverConfiguration.setMaxSizeLimit( Integer.parseInt( maxSizeLimit ) );
+        }
+
+        // MaxThreads
+        String maxThreads = readBeanProperty( "maxThreads", configurationBean );
+        if ( maxThreads != null )
+        {
+            serverConfiguration.setMaxThreads( Integer.parseInt( maxThreads ) );
+        }
+
+        // AllowAnonymousAccess
+        String allowAnonymousAccess = readBeanProperty( "allowAnonymousAccess", configurationBean );
+        if ( allowAnonymousAccess != null )
+        {
+            serverConfiguration.setAllowAnonymousAccess( parseBoolean( allowAnonymousAccess ) );
+        }
+
+        // AccessControlEnabled
+        String accessControlEnabled = readBeanProperty( "accessControlEnabled", configurationBean );
+        if ( accessControlEnabled != null )
+        {
+            serverConfiguration.setEnableAccessControl( parseBoolean( accessControlEnabled ) );
+        }
+
+        // EnableNtp
+        String enableNtp = readBeanProperty( "enableNtp", configurationBean );
+        if ( enableNtp != null )
+        {
+            serverConfiguration.setEnableNtp( parseBoolean( enableNtp ) );
+        }
+
+        // EnableKerberos
+        String enableKerberos = readBeanProperty( "enableKerberos", configurationBean );
+        if ( enableKerberos != null )
+        {
+            serverConfiguration.setEnableKerberos( parseBoolean( enableKerberos ) );
+        }
+
+        // EnableChangePassword
+        String enableChangePassword = readBeanProperty( "enableChangePassword", configurationBean );
+        if ( enableChangePassword != null )
+        {
+            serverConfiguration.setEnableChangePassword( parseBoolean( enableChangePassword ) );
+        }
+
+        // EnableChangePassword
+        String denormalizeOpAttrsEnabled = readBeanProperty( "denormalizeOpAttrsEnabled", configurationBean );
+        if ( denormalizeOpAttrsEnabled != null )
+        {
+            serverConfiguration.setDenormalizeOpAttr( parseBoolean( denormalizeOpAttrsEnabled ) );
+        }
+
+        // SystemPartition
+        String systemPartitionConfiguration = readBeanProperty( "systemPartitionConfiguration", configurationBean );
+        if ( systemPartitionConfiguration != null )
+        {
+            Partition systemPartition = readPartition( document, systemPartitionConfiguration, true );
+            if ( systemPartition != null )
+            {
+                serverConfiguration.addPartition( systemPartition );
+            }
+        }
+        else
+        {
+            throw new ServerXmlIOException(
+                "The Server Configuration does not contain a 'systemPartitionConfiguration' property." );
+        }
+
+        // Other Partitions
+        readOtherPartitions( configurationBean, serverConfiguration );
+
+        // Interceptors
+        readInterceptors( configurationBean, serverConfiguration );
+
+        // ExtendedOperations
+        readExtendedOperations( configurationBean, serverConfiguration );
+    }
+
+
+    /**
+     * Reads and adds Partitions (other than the SystemPartition) to the Server Configuration.
+     *
+     * @param configurationBean
+     *      the Configuration Bean Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     * @throws BooleanFormatException 
+     * @throws NumberFormatException 
+     */
+    private void readOtherPartitions( Element configurationBean, ServerConfiguration serverConfiguration )
+        throws NumberFormatException, BooleanFormatException
+    {
+        Element propertyElement = getBeanPropertyElement( "partitionConfigurations", configurationBean );
+        if ( propertyElement != null )
+        {
+            Element setElement = propertyElement.element( "set" );
+            if ( setElement != null )
+            {
+                for ( Iterator<?> i = setElement.elementIterator( "ref" ); i.hasNext(); )
+                {
+                    Element element = ( Element ) i.next();
+                    org.dom4j.Attribute beanAttribute = element.attribute( "bean" );
+                    if ( beanAttribute != null )
+                    {
+                        Partition partition = readPartition( configurationBean.getDocument(), beanAttribute.getValue(),
+                            false );
+                        if ( partition != null )
+                        {
+                            serverConfiguration.addPartition( partition );
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Reads the partition associated with the given Bean ID and return it.
+     *
+     * @param document
+     *      the document
+     * @param id
+     *      the Bean ID of the partition
+     * @param isSystemPartition
+     *      true if this partition is the System Partition
+     * @return
+     *      the partition associated with the given Bean ID
+     * @throws BooleanFormatException 
+     */
+    private Partition readPartition( Document document, String id, boolean isSystemPartition )
+        throws BooleanFormatException, NumberFormatException
+    {
+        Element partitionBean = getBeanElementById( document, id );
+        if ( partitionBean != null )
+        {
+            Partition partition = new Partition();
+            partition.setSystemPartition( isSystemPartition );
+
+            // Name
+            String name = readBeanProperty( "name", partitionBean );
+            if ( name != null )
+            {
+                partition.setId( name );
+            }
+
+            // CacheSize
+            String cacheSize = readBeanProperty( "cacheSize", partitionBean );
+            if ( cacheSize != null )
+            {
+                partition.setCacheSize( Integer.parseInt( cacheSize ) );
+            }
+
+            // Suffix
+            String suffix = readBeanProperty( "suffix", partitionBean );
+            if ( suffix != null )
+            {
+                partition.setSuffix( suffix );
+            }
+
+            // OptimizerEnabled
+            String optimizerEnabled = readBeanProperty( "optimizerEnabled", partitionBean );
+            if ( optimizerEnabled != null )
+            {
+                partition.setEnableOptimizer( parseBoolean( optimizerEnabled ) );
+            }
+
+            // SynchOnWrite
+            String synchOnWrite = readBeanProperty( "synchOnWrite", partitionBean );
+            if ( synchOnWrite != null )
+            {
+                partition.setSynchronizationOnWrite( parseBoolean( synchOnWrite ) );
+            }
+
+            // IndexedAttributes
+            partition.setIndexedAttributes( readPartitionIndexedAttributes( partitionBean ) );
+
+            // ContextEntry
+            partition.setContextEntry( readPartitionContextEntry( partitionBean ) );
+
+            return partition;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads the Indexed Attributes of the given Partition Bean Element
+     *
+     * @param partitionBean
+     *      the Partition Bean Element
+     * @return
+     *      the Indexed Attributes
+     */
+    private List<IndexedAttribute> readPartitionIndexedAttributes( Element partitionBean ) throws NumberFormatException
+    {
+        List<IndexedAttribute> indexedAttributes = new ArrayList<IndexedAttribute>();
+
+        Element propertyElement = getBeanPropertyElement( "indexedAttributes", partitionBean );
+        if ( propertyElement != null )
+        {
+            Element setElement = propertyElement.element( "set" );
+            if ( setElement != null )
+            {
+                for ( Iterator<?> i = setElement.elementIterator( "bean" ); i.hasNext(); )
+                {
+                    Element beanElement = ( Element ) i.next();
+                    IndexedAttribute ia = readIndexedAttribute( beanElement );
+                    if ( ia != null )
+                    {
+                        indexedAttributes.add( ia );
+                    }
+                }
+            }
+        }
+
+        return indexedAttributes;
+    }
+
+
+    /**
+     * Reads an Indexed Attribute.
+     *
+     * @param beanElement
+     *      the Bean Element of the Indexed Attribute
+     * @return
+     *      the corresponding Indexed Attribute or null if it could not be parsed
+     * @throws NumberFormatException
+     */
+    private IndexedAttribute readIndexedAttribute( Element beanElement ) throws NumberFormatException
+    {
+        org.dom4j.Attribute classAttribute = beanElement.attribute( "class" );
+        if ( classAttribute != null
+            && classAttribute.getValue().equals(
+                "org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration" ) )
+        {
+            String attributeId = readBeanProperty( "attributeId", beanElement );
+            String cacheSize = readBeanProperty( "cacheSize", beanElement );
+            if ( ( attributeId != null ) && ( cacheSize != null ) )
+            {
+                return new IndexedAttribute( attributeId, Integer.parseInt( cacheSize ) );
+            }
+
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads the Context Entry of the given Partition Bean Element
+     *
+     * @param partitionBean
+     *      the Partition Bean Element
+     * @return
+     *      the Context Entry
+     */
+    private Attributes readPartitionContextEntry( Element partitionBean )
+    {
+        Element propertyElement = getBeanPropertyElement( "contextEntry", partitionBean );
+        if ( propertyElement != null )
+        {
+            Element valueElement = propertyElement.element( "value" );
+            if ( valueElement != null )
+            {
+                return readContextEntry( valueElement.getText() );
+            }
+        }
+
+        return new BasicAttributes( true );
+    }
+
+
+    /**
+     * Reads and adds the Interceptors to the Server Configuration.
+     *
+     * @param configurationBean
+     *      the Configuration Bean Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void readInterceptors( Element configurationBean, ServerConfiguration serverConfiguration )
+    {
+        Element propertyElement = getBeanPropertyElement( "interceptorConfigurations", configurationBean );
+        if ( propertyElement != null )
+        {
+            Element listElement = propertyElement.element( "list" );
+            if ( listElement != null )
+            {
+                for ( Iterator<?> i = listElement.elementIterator( "bean" ); i.hasNext(); )
+                {
+                    Interceptor interceptor = readInterceptor( ( Element ) i.next() );
+                    if ( interceptor != null )
+                    {
+                        serverConfiguration.addInterceptor( interceptor );
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Reads an Interceptor.
+     *
+     * @param element
+     *      the Interceptor Element
+     * @return
+     *      the Interceptor or null if it could not be parsed
+     */
+    private Interceptor readInterceptor( Element element )
+    {
+        org.dom4j.Attribute classAttribute = element.attribute( "class" );
+        if ( classAttribute != null
+            && classAttribute.getValue().equals(
+                "org.apache.directory.server.core.configuration.MutableInterceptorConfiguration" ) )
+        {
+            String name = readBeanProperty( "name", element );
+
+            for ( Iterator<?> i = element.elementIterator( "property" ); i.hasNext(); )
+            {
+                Element propertyElement = ( Element ) i.next();
+                org.dom4j.Attribute nameAttribute = propertyElement.attribute( "name" );
+                if ( nameAttribute != null && ( nameAttribute.getValue().equals( "interceptor" ) ) )
+                {
+                    Element beanElement = propertyElement.element( "bean" );
+                    if ( beanElement != null )
+                    {
+                        org.dom4j.Attribute beanClassAttribute = beanElement.attribute( "class" );
+                        if ( beanClassAttribute != null )
+                        {
+                            Interceptor interceptor = new Interceptor( name );
+                            interceptor.setClassType( beanClassAttribute.getValue() );
+                            return interceptor;
+                        }
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads and adds the ExtendedOperations to the Server Configuration.
+     *
+     * @param configurationBean
+     *      the Configuration Bean Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void readExtendedOperations( Element configurationBean, ServerConfiguration serverConfiguration )
+    {
+        Element propertyElement = getBeanPropertyElement( "extendedOperationHandlers", configurationBean );
+        if ( propertyElement != null )
+        {
+            Element listElement = propertyElement.element( "list" );
+            if ( listElement != null )
+            {
+                for ( Iterator<?> i = listElement.elementIterator( "bean" ); i.hasNext(); )
+                {
+                    ExtendedOperation extendedOperation = readExtendedOperation( ( Element ) i.next() );
+                    if ( extendedOperation != null )
+                    {
+                        serverConfiguration.addExtendedOperation( extendedOperation );
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Reads an Extended Operation.
+     *
+     * @param element
+     *      the Extended Operation Element
+     * @return
+     *      the Extended Operation or null if it could not be parsed
+     */
+    private ExtendedOperation readExtendedOperation( Element element )
+    {
+        org.dom4j.Attribute classAttribute = element.attribute( "class" );
+        if ( classAttribute != null )
+        {
+            return new ExtendedOperation( classAttribute.getValue() );
+        }
+
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO#toXml(org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration)
+     */
+    public String toXml( ServerConfiguration serverConfiguration )
+    {
+        Document document = DocumentHelper.createDocument();
+        Element root = document.addElement( "beans" );
+
+        // Environment Bean
+        createEnvironmentBean( root, serverConfiguration );
+
+        // Configuration Bean
+        createConfigurationBean( root, serverConfiguration );
+
+        // System Partition Configuration Bean
+        createSystemPartitionConfigurationBean( root, serverConfiguration );
+
+        // User Partitions Beans
+        createUserPartitionsConfigurationsBean( root, serverConfiguration );
+
+        // CustomEditors Bean
+        createCustomEditorsBean( root );
+
+        Document stylizedDocument = null;
+        try
+        {
+            stylizedDocument = styleDocument( document );
+        }
+        catch ( TransformerException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        stylizedDocument.addDocType( "beans", "-//SPRING//DTD BEAN//EN",
+            "http://www.springframework.org/dtd/spring-beans.dtd" );
+
+        return stylizedDocument.asXML();
+    }
+
+
+    /**
+     * Creates the Environment Bean
+     *
+     * @param root
+     *      the root Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void createEnvironmentBean( Element root, ServerConfiguration serverConfiguration )
+    {
+        Element environmentBean = root.addElement( "bean" );
+        environmentBean.addAttribute( "id", "environment" );
+        environmentBean.addAttribute( "class", "org.springframework.beans.factory.config.PropertiesFactoryBean" );
+
+        Element propertyElement = environmentBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "properties" );
+        Element propsElement = propertyElement.addElement( "props" );
+
+        // Key 'java.naming.security.authentication'
+        Element propElement = propsElement.addElement( "prop" );
+        propElement.addAttribute( "key", "java.naming.security.authentication" );
+        propElement.setText( "simple" );
+
+        // Key 'java.naming.security.principal'
+        propElement = propsElement.addElement( "prop" );
+        propElement.addAttribute( "key", "java.naming.security.principal" );
+        propElement.setText( serverConfiguration.getPrincipal() );
+
+        // Key 'java.naming.security.credentials'
+        propElement = propsElement.addElement( "prop" );
+        propElement.addAttribute( "key", "java.naming.security.credentials" );
+        propElement.setText( serverConfiguration.getPassword() );
+
+        // Key 'java.naming.ldap.attributes.binary'
+        if ( !serverConfiguration.getBinaryAttributes().isEmpty() )
+        {
+            propElement = propsElement.addElement( "prop" );
+            propElement.addAttribute( "key", "java.naming.ldap.attributes.binary" );
+            StringBuffer sb = new StringBuffer();
+            for ( String attribute : serverConfiguration.getBinaryAttributes() )
+            {
+                sb.append( attribute );
+                sb.append( " " );
+            }
+            String attributes = sb.toString();
+            propElement.setText( attributes.substring( 0, attributes.length() - 1 ) );
+        }
+
+    }
+
+
+    /**
+     * Creates the Configuration Bean.
+     *
+     * @param root
+     *      the root Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void createConfigurationBean( Element root, ServerConfiguration serverConfiguration )
+    {
+        Element configurationBean = root.addElement( "bean" );
+        configurationBean.addAttribute( "id", "configuration" );
+        configurationBean.addAttribute( "class",
+            "org.apache.directory.server.configuration.MutableServerStartupConfiguration" );
+
+        // Working directory
+        Element propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "workingDirectory" );
+        propertyElement.addAttribute( "value", "example.com" ); // Ask Alex about this value.
+
+        // SynchPeriodMillis
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "synchPeriodMillis" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.getSynchronizationPeriod() );
+
+        // MaxTimeLimit
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "maxTimeLimit" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.getMaxTimeLimit() );
+
+        // MaxSizeLimit
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "maxSizeLimit" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.getMaxSizeLimit() );
+
+        // MaxThreads
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "maxThreads" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.getMaxThreads() );
+
+        // AllowAnonymousAccess
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "allowAnonymousAccess" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isAllowAnonymousAccess() );
+
+        // AccessControlEnabled
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "accessControlEnabled" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isEnableAccessControl() );
+
+        // Enable NTP
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "enableNtp" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isEnableNtp() );
+
+        // EnableKerberos
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "enableKerberos" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isEnableKerberos() );
+
+        // EnableChangePassword
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "enableChangePassword" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isEnableChangePassword() );
+
+        // DenormalizeOpAttrsEnabled
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "denormalizeOpAttrsEnabled" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.isDenormalizeOpAttr() );
+
+        // LdapPort
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "ldapPort" );
+        propertyElement.addAttribute( "value", "" + serverConfiguration.getLdapPort() );
+
+        // SystemPartitionConfiguration
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "systemPartitionConfiguration" );
+        propertyElement.addAttribute( "ref", "systemPartitionConfiguration" );
+
+        // PartitionConfigurations
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "partitionConfigurations" );
+        if ( serverConfiguration.getPartitions().size() > 1 )
+        {
+            Element setElement = propertyElement.addElement( "set" );
+            int partitionCounter = 1;
+            for ( Partition partition : serverConfiguration.getPartitions() )
+            {
+                if ( !partition.isSystemPartition() )
+                {
+                    setElement.addElement( "ref" ).addAttribute( "bean", "partition-" + partitionCounter );
+                    partitionCounter++;
+                }
+            }
+        }
+
+        // ExtendedOperationHandlers
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "extendedOperationHandlers" );
+        if ( serverConfiguration.getExtendedOperations().size() > 1 )
+        {
+            Element listElement = propertyElement.addElement( "list" );
+            for ( ExtendedOperation extendedOperation : serverConfiguration.getExtendedOperations() )
+            {
+                listElement.addElement( "bean" ).addAttribute( "class", extendedOperation.getClassType() );
+            }
+        }
+
+        // InterceptorConfigurations
+        propertyElement = configurationBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "interceptorConfigurations" );
+        if ( serverConfiguration.getInterceptors().size() > 1 )
+        {
+            Element listElement = propertyElement.addElement( "list" );
+            for ( Interceptor interceptor : serverConfiguration.getInterceptors() )
+            {
+                Element interceptorBeanElement = listElement.addElement( "bean" );
+                interceptorBeanElement.addAttribute( "class",
+                    "org.apache.directory.server.core.configuration.MutableInterceptorConfiguration" );
+
+                Element interceptorPropertyElement = interceptorBeanElement.addElement( "property" );
+                interceptorPropertyElement.addAttribute( "name", "name" );
+                interceptorPropertyElement.addAttribute( "value", interceptor.getName() );
+
+                interceptorPropertyElement = interceptorBeanElement.addElement( "property" );
+                interceptorPropertyElement.addAttribute( "name", "interceptor" );
+                interceptorPropertyElement.addElement( "bean" ).addAttribute( "class",
+                    ( interceptor.getClassType() == null ? "" : interceptor.getClassType() ) );
+            }
+        }
+
+    }
+
+
+    /**
+     * Creates the SystemPartitionConfiguration Bean.
+     *
+     * @param root
+     *      the root Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void createSystemPartitionConfigurationBean( Element root, ServerConfiguration serverConfiguration )
+    {
+        Partition systemPartition = null;
+        for ( Partition partition : serverConfiguration.getPartitions() )
+        {
+            if ( partition.isSystemPartition() )
+            {
+                systemPartition = partition;
+                break;
+            }
+        }
+
+        if ( systemPartition != null )
+        {
+            createPartitionConfigurationBean( root, systemPartition, "systemPartitionConfiguration" );
+        }
+    }
+
+
+    /**
+     * Creates the UserPartitionConfigurations Bean.
+     *
+     * @param root
+     *      the root Element
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    private void createUserPartitionsConfigurationsBean( Element root, ServerConfiguration serverConfiguration )
+    {
+        int counter = 1;
+        for ( Partition partition : serverConfiguration.getPartitions() )
+        {
+            if ( !partition.isSystemPartition() )
+            {
+                createPartitionConfigurationBean( root, partition, "partition-" + counter );
+                counter++;
+            }
+        }
+    }
+
+
+    /**
+     * Creates a Partition Configuration Bean.
+     *
+     * @param root
+     *      the root Element
+     * @param partition
+     *      the Partition
+     * @param name
+     *      the name to use
+     */
+    private void createPartitionConfigurationBean( Element root, Partition partition, String name )
+    {
+        Element partitionBean = root.addElement( "bean" );
+        partitionBean.addAttribute( "id", name );
+        partitionBean.addAttribute( "class",
+            "org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration" );
+
+        // Name
+        Element propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "name" );
+        propertyElement.addAttribute( "value", partition.getId() );
+
+        // CacheSize
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "cacheSize" );
+        propertyElement.addAttribute( "value", "" + partition.getCacheSize() );
+
+        // Suffix
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "suffix" );
+        propertyElement.addAttribute( "value", partition.getSuffix() );
+
+        // OptimizerEnabled
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "optimizerEnabled" );
+        propertyElement.addAttribute( "value", "" + partition.isEnableOptimizer() );
+
+        // SynchOnWrite
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "synchOnWrite" );
+        propertyElement.addAttribute( "value", "" + partition.isSynchronizationOnWrite() );
+
+        // Indexed Attributes
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "indexedAttributes" );
+        if ( partition.getIndexedAttributes().size() > 1 )
+        {
+            Element setElement = propertyElement.addElement( "set" );
+            for ( IndexedAttribute indexedAttribute : partition.getIndexedAttributes() )
+            {
+                Element beanElement = setElement.addElement( "bean" );
+                beanElement.addAttribute( "class",
+                    "org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration" );
+
+                // AttributeID
+                Element beanPropertyElement = beanElement.addElement( "property" );
+                beanPropertyElement.addAttribute( "name", "attributeId" );
+                beanPropertyElement.addAttribute( "value", indexedAttribute.getAttributeId() );
+
+                // CacheSize
+                beanPropertyElement = beanElement.addElement( "property" );
+                beanPropertyElement.addAttribute( "name", "cacheSize" );
+                beanPropertyElement.addAttribute( "value", "" + indexedAttribute.getCacheSize() );
+            }
+        }
+
+        // ContextEntry
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "contextEntry" );
+        if ( partition.getContextEntry() != null )
+        {
+            Element valueElement = propertyElement.addElement( "value" );
+
+            Attributes contextEntry = partition.getContextEntry();
+            StringBuffer sb = new StringBuffer();
+            NamingEnumeration<? extends Attribute> ne = contextEntry.getAll();
+            while ( ne.hasMoreElements() )
+            {
+                Attribute attribute = ( Attribute ) ne.nextElement();
+                try
+                {
+                    NamingEnumeration<?> values = attribute.getAll();
+                    while ( values.hasMoreElements() )
+                    {
+                        sb.append( attribute.getID() + ": " + values.nextElement() + "\n" );
+                    }
+                }
+                catch ( NamingException e )
+                {
+                }
+            }
+
+            valueElement.setText( sb.toString() );
+        }
+    }
+
+
+    /**
+     * Creates the Custom Editors Bean.
+     *
+     * @param root
+     *      the root Element
+     */
+    private void createCustomEditorsBean( Element root )
+    {
+        Element customEditorsBean = root.addElement( "bean" );
+        customEditorsBean.addAttribute( "class", "org.springframework.beans.factory.config.CustomEditorConfigurer" );
+        Element propertyElement = customEditorsBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "customEditors" );
+        Element mapElement = propertyElement.addElement( "map" );
+        Element entryElement = mapElement.addElement( "entry" );
+        entryElement.addAttribute( "key", "javax.naming.directory.Attributes" );
+        Element entryBeanElement = entryElement.addElement( "bean" );
+        entryBeanElement.addAttribute( "class",
+            "org.apache.directory.server.core.configuration.AttributesPropertyEditor" );
+    }
+
+}



Mime
View raw message