You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2008/05/14 19:21:48 UTC

svn commit: r656336 [10/11] - in /directory/studio/trunk/apacheds-configuration: ./ resources/icons/ src/main/java/ src/main/java/org/apache/directory/studio/apacheds/configuration/ src/main/java/org/apache/directory/studio/apacheds/configuration/dialo...

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java Wed May 14 10:21:46 2008
@@ -0,0 +1,1108 @@
+/*
+ *  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.v152;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.configuration.model.AbstractServerConfiguration;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationVersionEnum;
+
+
+/**
+ * This class represents a Server Configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerConfigurationV152 extends AbstractServerConfiguration implements ServerConfiguration
+{
+    // LDAP Configuration
+
+    /** The port */
+    private int ldapPort;
+
+    /** The principal */
+    private String principal;
+
+    /** The password */
+    private String password;
+
+    // Limits
+
+    /** The Max Time Limit */
+    private int maxTimeLimit;
+
+    /** the Max Size Limit */
+    private int maxSizeLimit;
+
+    /** The Synchronization Period */
+    private long synchronizationPeriod;
+
+    /** The Maximum number of Threads */
+    private int maxThreads;
+
+    /** The Supported Mechanisms */
+    private List<String> supportedMechanisms;
+
+    // SASL Properties
+
+    /** The SASL Host */
+    private String saslHost;
+
+    /** The SASL Principal */
+    private String saslPrincipal;
+
+    /** The SASL QOP */
+    private List<String> saslQops;
+
+    /** The SASL Realms */
+    private List<String> saslRealms;
+
+    /** The Search Base DN */
+    private String searchBaseDn;
+
+    // Protocols
+
+    /** The flag for Enable Access Control */
+    private boolean enableAccessControl;
+
+    /** The flag for Enable Kerberos */
+    private boolean enableKerberos;
+
+    /** The port for Kerberos */
+    private int kerberosPort;
+
+    /** The flag for Enable NTP */
+    private boolean enableNtp;
+
+    /** The port for NTP */
+    private int ntpPort;
+
+    /** The flag for Enable DNS */
+    private boolean enableDns;
+
+    /** The port for DNS */
+    private int dnsPort;
+
+    /** The flag for Enable LDAPS */
+    private boolean enableLdaps;
+
+    /** The port for LDAPS */
+    private int ldapsPort;
+
+    /** The flag for Enable Change Password */
+    private boolean enableChangePassword;
+
+    /** The port for Change Password */
+    private int changePasswordPort;
+
+    // Options
+
+    /** The flag for Denormalize Operational Attributes */
+    private boolean denormalizeOpAttr;
+
+    /** The flag for Allow Anonymous Access */
+    private boolean allowAnonymousAccess;
+
+    // Other configuration elements
+
+    /** The Binary Attributes */
+    private List<String> binaryAttributes;
+
+    /** The Partitions */
+    private List<Partition> partitions;
+
+    /** The Interceptors */
+    private List<Interceptor> interceptors;
+
+    /** The Extended Operations */
+    private List<ExtendedOperation> extendedOperations;
+
+
+    /**
+     * Creates a new instance of ServerConfiguration.
+     */
+    public ServerConfigurationV152()
+    {
+        super( ServerConfigurationVersionEnum.VERSION_1_5_2 );
+
+        supportedMechanisms = new ArrayList<String>();
+        saslQops = new ArrayList<String>();
+        saslRealms = new ArrayList<String>();
+        partitions = new ArrayList<Partition>();
+        interceptors = new ArrayList<Interceptor>();
+        extendedOperations = new ArrayList<ExtendedOperation>();
+        binaryAttributes = new ArrayList<String>();
+    }
+
+
+    /**
+     * Adds a Binary Attribute.
+     *
+     * @param binaryAttribute
+     *      the Partition to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addBinaryAttribute( String binaryAttribute )
+    {
+        return binaryAttributes.add( binaryAttribute );
+    }
+
+
+    /**
+     * Adds an Extended Operation.
+     *
+     * @param extendedOperation
+     *      the Extended Operation to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addExtendedOperation( ExtendedOperation extendedOperation )
+    {
+        return extendedOperations.add( extendedOperation );
+    }
+
+
+    /**
+     * Adds an Interceptor.
+     *
+     * @param interceptor
+     *      the Interceptor to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addInterceptor( Interceptor interceptor )
+    {
+        return interceptors.add( interceptor );
+    }
+
+
+    /**
+     * Adds a Partition.
+     *
+     * @param partition
+     *      the Partition to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addPartition( Partition partition )
+    {
+        return partitions.add( partition );
+    }
+
+
+    /**
+     * Adds a SASL Quality Of Protection.
+     *
+     * @param saslQop
+     *      the SASL Quality Of Protection to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addSaslQop( String saslQop )
+    {
+        return saslQops.add( saslQop );
+    }
+
+
+    /**
+    * Adds a SASL Realm.
+    *
+    * @param qop
+    *      the SASL Realm to add
+    * @return
+    *      true (as per the general contract of the Collection.add method).
+    */
+    public boolean addSaslRealm( String saslRealm )
+    {
+        return saslRealms.add( saslRealm );
+    }
+
+
+    /**
+     * Adds a Supported Mechanism.
+     *
+     * @param supportedMechanism
+     *      the Supported Mechanism to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addSupportedMechanism( String supportedMechanism )
+    {
+        return supportedMechanisms.add( supportedMechanism );
+    }
+
+
+    /**
+     * Removes all Binary Attributes.
+     */
+    public void clearBinaryAttributes()
+    {
+        binaryAttributes.clear();
+    }
+
+
+    /**
+     * Removes all ExtendedOperations.
+     */
+    public void clearExtendedOperations()
+    {
+        extendedOperations.clear();
+    }
+
+
+    /**
+     * Removes all interceptors.
+     */
+    public void clearInterceptors()
+    {
+        interceptors.clear();
+    }
+
+
+    /**
+     * Removes all partitions.
+     */
+    public void clearPartitions()
+    {
+        partitions.clear();
+    }
+
+
+    /**
+     * Gets the Binary Attributes List.
+     *
+     * @return
+     *      the Binary Attributes  List
+     */
+    public List<String> getBinaryAttributes()
+    {
+        return binaryAttributes;
+    }
+
+
+    /**
+     * Gets the Change Password port.
+     *
+     * @return
+     *      the Change Password port
+     */
+    public int getChangePasswordPort()
+    {
+        return changePasswordPort;
+    }
+
+
+    /**
+     * Gets the DNS port.
+     *
+     * @return
+     *      the DNS port
+     */
+    public int getDnsPort()
+    {
+        return dnsPort;
+    }
+
+
+    /**
+     * Gets the Extended Operations List.
+     *
+     * @return
+     *      the Extended Operations List
+     */
+    public List<ExtendedOperation> getExtendedOperations()
+    {
+        return extendedOperations;
+    }
+
+
+    /**
+     * Gets the Interceptors List.
+     *
+     * @return
+     *      the Interceptors List
+     */
+    public List<Interceptor> getInterceptors()
+    {
+        return interceptors;
+    }
+
+
+    /**
+     * Gets the Kerberos port.
+     *
+     * @return
+     *      the Kerberos port
+     */
+    public int getKerberosPort()
+    {
+        return kerberosPort;
+    }
+
+
+    /**
+     * Gets the LDAPS port.
+     *
+     * @return
+     *      the LDAPS port
+     */
+    public int getLdapsPort()
+    {
+        return ldapsPort;
+    }
+
+
+    /**
+     * Gets the Maximum Size Limit.
+     *
+     * @return
+     *      the Maximum Size Limit
+     */
+    public int getMaxSizeLimit()
+    {
+        return maxSizeLimit;
+    }
+
+
+    /**
+     * Gets the Maximum number of Threads.
+     *
+     * @return
+     *      the Maximum number of Threads
+     */
+    public int getMaxThreads()
+    {
+        return maxThreads;
+    }
+
+
+    /**
+     * Gets the Maximum Time Limit.
+     *
+     * @return
+     *      the Maximum Time Limit
+     */
+    public int getMaxTimeLimit()
+    {
+        return maxTimeLimit;
+    }
+
+
+    /**
+     * Gets the NTP port.
+     *
+     * @return
+     *      the NTP port
+     */
+    public int getNtpPort()
+    {
+        return ntpPort;
+    }
+
+
+    /**
+     * Gets the Partitions List.
+     *
+     * @return
+     *      the Partitions List
+     */
+    public List<Partition> getPartitions()
+    {
+        return partitions;
+    }
+
+
+    /**
+     * Gets the password.
+     *
+     * @return
+     *      the password
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+
+    /**
+     * Gets the LDAP Port.
+     *
+     * @return
+     *      the LDAP Port
+     */
+    public int getLdapPort()
+    {
+        return ldapPort;
+    }
+
+
+    /**
+     * Gets the Principal
+     *
+     * @return
+     *      the Principal
+     */
+    public String getPrincipal()
+    {
+        return principal;
+    }
+
+
+    /**
+     * Gets the SASL Host.
+     *
+     * @return
+     *       the SASL Host
+     */
+    public String getSaslHost()
+    {
+        return saslHost;
+    }
+
+
+    /**
+     * Gets the SASL Principal.
+     *
+     * @return
+     *      the SASL Principal
+     */
+    public String getSaslPrincipal()
+    {
+        return saslPrincipal;
+    }
+
+
+    /**
+     * Gets the SASL Quality Of Protection List
+     *
+     * @return
+     *      the SASL Quality Of Protection List
+     */
+    public List<String> getSaslQops()
+    {
+        return saslQops;
+    }
+
+
+    /**
+     * Gets the SASL Realms List.
+     *
+     * @return
+     *      the SASL Realms List
+     */
+    public List<String> getSaslRealms()
+    {
+        return saslRealms;
+    }
+
+
+    /**
+     * Gets the Search Base DN.
+     *
+     * @return
+     *      the Search Base DN
+     */
+    public String getSearchBaseDn()
+    {
+        return searchBaseDn;
+    }
+
+
+    /**
+     * Gets the Supported Mechanisms List.
+     * 
+     * @return
+     *      the Supported Mechanisms List
+     */
+    public List<String> getSupportedMechanisms()
+    {
+        return supportedMechanisms;
+    }
+
+
+    /**
+     * Gets the Synchronization Period.
+     *
+     * @return
+     *      the Synchronization Period
+     */
+    public long getSynchronizationPeriod()
+    {
+        return synchronizationPeriod;
+    }
+
+
+    /**
+     * Gets the Allow Anonymous flag.
+     *
+     * @return
+     *      true if the server configuration allows Anonymous Access
+     */
+    public boolean isAllowAnonymousAccess()
+    {
+        return allowAnonymousAccess;
+    }
+
+
+    /**
+     * Gets the Denormalize Operational Attributes flag.
+     *
+     * @return
+     *      the Denormalize Operational Attributes flag
+     */
+    public boolean isDenormalizeOpAttr()
+    {
+        return denormalizeOpAttr;
+    }
+
+
+    /**
+     * Gets the Enable Access Control flag.
+     *
+     * @return
+     *      true if Access Control is enabled
+     */
+    public boolean isEnableAccessControl()
+    {
+        return enableAccessControl;
+    }
+
+
+    /**
+     * Gets the Enable Change Password flag.
+     *
+     * @return
+     *      true if Change Password is enabled
+     */
+    public boolean isEnableChangePassword()
+    {
+        return enableChangePassword;
+    }
+
+
+    /**
+     * Gets the Enable DNS flag.
+     *
+     * @return
+     *      true if DNS is enabled
+     */
+    public boolean isEnableDns()
+    {
+        return enableDns;
+    }
+
+
+    /**
+     * Gets the Enable Kerberos flag.
+     *
+     * @return
+     *      true if Kerberos is enabled
+     */
+    public boolean isEnableKerberos()
+    {
+        return enableKerberos;
+    }
+
+
+    /**
+     * Gets the Enable LDAPS flag.
+     *
+     * @return
+     *      true if LDAPS is enabled
+     */
+    public boolean isEnableLdaps()
+    {
+        return enableLdaps;
+    }
+
+
+    /**
+     * Gets the Enable NTP flag.
+     *
+     * @return
+     *      true if NTP is enabled
+     */
+    public boolean isEnableNtp()
+    {
+        return enableNtp;
+    }
+
+
+    /**
+     * Removes a Binary Attribute.
+     *
+     * @param binaryAttribute
+     *      the Binary Attribute to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeBinaryAttribute( String binaryAttribute )
+    {
+        return binaryAttributes.remove( binaryAttribute );
+    }
+
+
+    /**
+     * Removes an Extended Operation.
+     *
+     * @param extendedOperation
+     *      the Extended Operation to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeExtendedOperation( ExtendedOperation extendedOperation )
+    {
+        return extendedOperations.remove( extendedOperation );
+    }
+
+
+    /**
+     * Removes an Supported Mechanism.
+     *
+     * @param supportedMechanism
+     *      the Supported Mechanism to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeExtendedOperation( String supportedMechanism )
+    {
+        return supportedMechanisms.remove( supportedMechanism );
+    }
+
+
+    /**
+     * Removes an Interceptor.
+     *
+     * @param interceptor
+     *      the Interceptor to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeInterceptor( Interceptor interceptor )
+    {
+        return interceptors.remove( interceptor );
+    }
+
+
+    /**
+     * Removes a Partition.
+     *
+     * @param partition
+     *      the partition to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removePartition( Partition partition )
+    {
+        return partitions.remove( partition );
+    }
+
+
+    /**
+     * Removes a SASL Quality Of Protection.
+     *
+     * @param saslQop
+     *      the SASL Quality Of Protection to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeSaslQop( String saslQop )
+    {
+        return saslQops.remove( saslQop );
+    }
+
+
+    /**
+     * Removes a SASL Realm.
+     *
+     * @param saslRealm
+     *      the SASL Realm to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeSaslRealm( String saslRealm )
+    {
+        return saslRealms.remove( saslRealm );
+    }
+
+
+    /**
+     * Sets the Allow Anonymous flag.
+     *
+     * @param allowAnonymousAccess
+     *      the new value
+     */
+    public void setAllowAnonymousAccess( boolean allowAnonymousAccess )
+    {
+        this.allowAnonymousAccess = allowAnonymousAccess;
+    }
+
+
+    /**
+     * Sets the Binary Attributes  List.
+     *
+     * @param binaryAttributes
+     *      the new value
+     */
+    public void setBinaryAttributes( List<String> binaryAttributes )
+    {
+        this.binaryAttributes = binaryAttributes;
+    }
+
+
+    /**
+     * Sets the Change Password port.
+     *
+     * @param changePasswordPort
+     *      the Change Password port
+     */
+    public void setChangePasswordPort( int changePasswordPort )
+    {
+        this.changePasswordPort = changePasswordPort;
+    }
+
+
+    /**
+     * Sets the Denormalize Operational Attributes flag.
+     *
+     * @param denormalizeOpAttr
+     *      the new Denormalize Operational Attributes flag
+     */
+    public void setDenormalizeOpAttr( boolean denormalizeOpAttr )
+    {
+        this.denormalizeOpAttr = denormalizeOpAttr;
+    }
+
+
+    /**
+     * Sets the DNS port.
+     *
+     * @param dnsPort
+     *      the DNS port
+     */
+    public void setDnsPort( int dnsPort )
+    {
+        this.dnsPort = dnsPort;
+    }
+
+
+    /**
+     * Sets the Enable Access Control flag.
+     *
+     * @param enableAccessControl
+     *      the new value
+     */
+    public void setEnableAccessControl( boolean enableAccessControl )
+    {
+        this.enableAccessControl = enableAccessControl;
+    }
+
+
+    /**
+     * Sets the Enable Change Password flag.
+     *
+     * @param enableChangePassword
+     *      the new value
+     */
+    public void setEnableChangePassword( boolean enableChangePassword )
+    {
+        this.enableChangePassword = enableChangePassword;
+    }
+
+
+    /**
+     * Sets Enable DNS flag.
+     *
+     * @param enableDns
+     *      the new value
+     */
+    public void setEnableDns( boolean enableDns )
+    {
+        this.enableDns = enableDns;
+    }
+
+
+    /**
+     * Sets the Enable Kerberos flag.
+     *
+     * @param enableKerberos
+     *      the new value
+     */
+    public void setEnableKerberos( boolean enableKerberos )
+    {
+        this.enableKerberos = enableKerberos;
+    }
+
+
+    /**
+     * Sets the Enable LDAPS flag.
+     *
+     * @param enableLdaps
+     *      the new value
+     */
+    public void setEnableLdaps( boolean enableLdaps )
+    {
+        this.enableLdaps = enableLdaps;
+    }
+
+
+    /**
+     * Sets the Enable NTP flag.
+     *
+     * @param enableNtp
+     *      the new value
+     */
+    public void setEnableNtp( boolean enableNtp )
+    {
+        this.enableNtp = enableNtp;
+    }
+
+
+    /**
+     * Sets the Extended Operations List.
+     *
+     * @param extendedOperations
+     *      the new value
+     */
+    public void setExtendedOperations( List<ExtendedOperation> extendedOperations )
+    {
+        this.extendedOperations = extendedOperations;
+    }
+
+
+    /**
+     * Sets the Interceptors List.
+     *
+     * @param interceptors
+     *      the new value
+     */
+    public void setInterceptors( List<Interceptor> interceptors )
+    {
+        this.interceptors = interceptors;
+    }
+
+
+    /**
+     * Sets the Kerberos port.
+     *
+     * @param kerberosPort
+     *      the new value
+     */
+    public void setKerberosPort( int kerberosPort )
+    {
+        this.kerberosPort = kerberosPort;
+    }
+
+
+    /**
+     * Sets The LDAPS port.
+     *
+     * @param ldapsPort
+     */
+    public void setLdapsPort( int ldapsPort )
+    {
+        this.ldapsPort = ldapsPort;
+    }
+
+
+    /**
+     * Sets the Maximum Size Limit.
+     *
+     * @param maxSizeLimit
+     *      the new value
+     */
+    public void setMaxSizeLimit( int maxSizeLimit )
+    {
+        this.maxSizeLimit = maxSizeLimit;
+    }
+
+
+    /**
+     * Sets the Maximum number of Threads
+     *
+     * @param maxThreads
+     *      the new value
+     */
+    public void setMaxThreads( int maxThreads )
+    {
+        this.maxThreads = maxThreads;
+    }
+
+
+    /**
+     * Sets the Maximum Time Limit.
+     *
+     * @param maxTimeLimit
+     *      the new value
+     */
+    public void setMaxTimeLimit( int maxTimeLimit )
+    {
+        this.maxTimeLimit = maxTimeLimit;
+    }
+
+
+    /**
+     * Sets the NTP port.
+     *
+     * @param ntpPort
+     *      the new value
+     */
+    public void setNtpPort( int ntpPort )
+    {
+        this.ntpPort = ntpPort;
+    }
+
+
+    /**
+     * Sets the Partitions List.
+     *
+     * @param partitions
+     *      the new value
+     */
+    public void setPartitions( List<Partition> partitions )
+    {
+        this.partitions = partitions;
+    }
+
+
+    /**
+     * Sets the password.
+     *
+     * @param password
+     *      the new password
+     */
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+
+    /**
+     * Sets the LDAP Port
+     *
+     * @param ldapPort
+     *      the new value
+     */
+    public void setLdapPort( int ldapPort )
+    {
+        this.ldapPort = ldapPort;
+    }
+
+
+    /**
+     * Sets the Principal
+     *
+     * @param principal
+     *      the new value
+     */
+    public void setPrincipal( String principal )
+    {
+        this.principal = principal;
+    }
+
+
+    /**
+     * Sets the SASL Host.
+     *
+     * @param saslHost
+     *      the new value
+     */
+    public void setSaslHost( String saslHost )
+    {
+        this.saslHost = saslHost;
+    }
+
+
+    /**
+     * Sets the SASL Principal.
+     *
+     * @param saslPrincipal
+     *      the new value
+     */
+    public void setSaslPrincipal( String saslPrincipal )
+    {
+        this.saslPrincipal = saslPrincipal;
+    }
+
+
+    /**
+     * Sets the SASL Quality Of Protection List.
+     *
+     * @param saslQops
+     *      the new value
+     */
+    public void setSaslQops( List<String> saslQops )
+    {
+        this.saslQops = saslQops;
+    }
+
+
+    /**
+     * Sets the SASL Realms List.
+     * 
+     * @param saslRealms
+     *      the new value
+     */
+    public void setSaslRealms( List<String> saslRealms )
+    {
+        this.saslRealms = saslRealms;
+    }
+
+
+    /**
+     * Sets the Search Base DN
+     *
+     * @param searchBaseDn
+     *      the new value
+     */
+    public void setSearchBaseDn( String searchBaseDn )
+    {
+        this.searchBaseDn = searchBaseDn;
+    }
+
+
+    /**
+     * Sets the Supported Mechanisms List.
+     *
+     * @param supportedMechanisms
+     *      the new value
+     */
+    public void setSupportedMechanisms( List<String> supportedMechanisms )
+    {
+        this.supportedMechanisms = supportedMechanisms;
+    }
+
+
+    /**
+     * Sets the Synchonization Period.
+     *
+     * @param synchronizationPeriod
+     *      the new value
+     */
+    public void setSynchronizationPeriod( long synchronizationPeriod )
+    {
+        this.synchronizationPeriod = synchronizationPeriod;
+    }
+}

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java Wed May 14 10:21:46 2008
@@ -0,0 +1,1463 @@
+/*
+ *  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.v152;
+
+
+import java.io.InputStream;
+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.xml.transform.TransformerException;
+
+import org.apache.directory.studio.apacheds.configuration.model.AbstractServerXmlIO;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIOException;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+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.2.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerXmlIOV152 extends AbstractServerXmlIO implements ServerXmlIO
+{
+    private static final Namespace NAMESPACE_APACHEDS = new Namespace( null, "http://apacheds.org/config/1.0" );
+    private static final Namespace NAMESPACE_SPRINGFRAMEWORK = new Namespace( "s",
+        "http://www.springframework.org/schema/beans" );
+    private static final Namespace NAMESPACE_XBEAN_SPRING = new Namespace( "spring",
+        "http://xbean.apache.org/schemas/spring/1.0" );
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO#isValid(java.io.InputStream)
+     */
+    public boolean isValid( InputStream is )
+    {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO#parse(java.io.InputStream)
+     */
+    public ServerConfiguration parse( InputStream is ) throws ServerXmlIOException
+    {
+        try
+        {
+            // Reading and creating the document
+            SAXReader reader = new SAXReader();
+            Document document = reader.read( is );
+
+            // Parsing the document
+            ServerConfigurationV152 serverConfiguration = new ServerConfigurationV152();
+            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, ServerConfigurationV152 serverConfiguration ) throws NumberFormatException,
+        BooleanFormatException, ServerXmlIOException
+    {
+        Element rootElement = document.getRootElement();
+
+        // Reading the 'defaultDirectoryService' Bean
+        readDefaultDirectoryServiceBean( rootElement, serverConfiguration );
+
+        // Reading the 'changePasswordServer' Bean
+        readChangePasswordServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'kdcServer' Bean
+        readKdcServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'ntpServer' Bean
+        readNtpServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'dnsServer' Bean
+        readDnsServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'ldapsServer' Bean
+        readLdapsServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'LdapServer' Bean
+        readLdapServerBean( rootElement, serverConfiguration );
+
+        // Reading the 'apacheDS' Bean
+        readApacheDSBean( rootElement, serverConfiguration );
+    }
+
+
+    private void readDefaultDirectoryServiceBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws ServerXmlIOException, NumberFormatException, BooleanFormatException
+    {
+        Element defaultDirectoryServiceElement = element.element( "defaultDirectoryService" );
+        if ( defaultDirectoryServiceElement == null )
+        {
+            throw new ServerXmlIOException( "Unable to find the 'defaultDirectoryService' tag." );
+        }
+        else
+        {
+            // Allow Anonymous Access
+            //            Attribute allowAnonymousAccess = defaultDirectoryServiceElement.attribute( "allowAnonymousAccess" );
+            //            if ( allowAnonymousAccess == null )
+            //            {
+            //                // TODO throw an error
+            //            }
+            //            else
+            //            {
+            //                serverConfiguration.setAllowAnonymousAccess( parseBoolean( allowAnonymousAccess.getValue() ) );
+            //            }
+
+            // Access Control Enabled
+            org.dom4j.Attribute accessControlEnabledAttribute = defaultDirectoryServiceElement
+                .attribute( "accessControlEnabled" );
+            if ( accessControlEnabledAttribute == null )
+            {
+                // If the 'accessControlEnabled' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException(
+                    "Unable to find the 'accessControlEnabled' attribute for the default directory service bean." );
+            }
+            else
+            {
+                serverConfiguration.setEnableAccessControl( parseBoolean( accessControlEnabledAttribute.getValue() ) );
+            }
+
+            // Denormalize Op Attrs Enabled
+            org.dom4j.Attribute denormalizeOpAttrsEnabledAttribute = defaultDirectoryServiceElement
+                .attribute( "denormalizeOpAttrsEnabled" );
+            if ( denormalizeOpAttrsEnabledAttribute == null )
+            {
+                // If the 'denormalizeOpAttrsEnabled' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException(
+                    "Unable to find the 'denormalizeOpAttrsEnabled' attribute for the default directory service bean." );
+            }
+            else
+            {
+                serverConfiguration
+                    .setDenormalizeOpAttr( parseBoolean( denormalizeOpAttrsEnabledAttribute.getValue() ) );
+            }
+
+            // System partition
+            readSystemPartition( defaultDirectoryServiceElement, serverConfiguration );
+
+            // Other partitions
+            readPartitions( defaultDirectoryServiceElement, serverConfiguration );
+
+            // Interceptors
+            readInterceptors( defaultDirectoryServiceElement, serverConfiguration );
+        }
+    }
+
+
+    /**
+     * Reads the system partition
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws ServerXmlIOException
+     * @throws BooleanFormatException 
+     */
+    private void readSystemPartition( Element element, ServerConfigurationV152 serverConfiguration )
+        throws ServerXmlIOException, NumberFormatException, BooleanFormatException
+    {
+        // Getting the 'systemPartition' element
+        Element systemPartitionElement = element.element( "systemPartition" );
+        if ( systemPartitionElement == null )
+        {
+            // If the 'systemPartition' element does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'systemPartition' element." );
+        }
+        else
+        {
+            // Getting the 'jdbmPartition' element
+            Element jdbmPartitionElement = systemPartitionElement.element( "jdbmPartition" );
+            if ( jdbmPartitionElement == null )
+            {
+                // If the 'jdbmPartition' element does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException( "Unable to find the 'jdbmPartition' element for the system partition." );
+            }
+            else
+            {
+                // Creating the system partition
+                Partition systemPartition = new Partition();
+                systemPartition.setSystemPartition( true );
+
+                // Reading the partition
+                readPartition( jdbmPartitionElement, systemPartition );
+
+                // Adding the partition to the server configuration
+                serverConfiguration.addPartition( systemPartition );
+            }
+        }
+    }
+
+
+    /**
+     * Reads a partition.
+     *
+     * @param element
+     *      the partition element
+     * @param partition
+     *      the partition
+     * @throws ServerXmlIOException
+     * @throws NumberFormatException
+     * @throws BooleanFormatException
+     */
+    private void readPartition( Element element, Partition partition ) throws ServerXmlIOException,
+        NumberFormatException, BooleanFormatException
+    {
+        // Id
+        org.dom4j.Attribute idAttribute = element.attribute( "id" );
+        if ( idAttribute == null )
+        {
+            // If the 'id' attribute does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'id' attribute for a partition." );
+        }
+        else
+        {
+            partition.setId( idAttribute.getValue() );
+        }
+
+        // Cache Size
+        org.dom4j.Attribute cacheSizeAttribute = element.attribute( "cacheSize" );
+        if ( cacheSizeAttribute == null )
+        {
+            // If the 'cacheSize' attribute does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'cacheSize' attribute for a partition." );
+        }
+        else
+        {
+            partition.setCacheSize( Integer.parseInt( cacheSizeAttribute.getValue() ) );
+        }
+
+        // Suffix
+        org.dom4j.Attribute suffixAttribute = element.attribute( "suffix" );
+        if ( suffixAttribute == null )
+        {
+            // If the 'suffix' attribute does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'suffix' attribute for a partition." );
+        }
+        else
+        {
+            partition.setSuffix( suffixAttribute.getValue() );
+        }
+
+        // Optimizer Enabled
+        org.dom4j.Attribute optimizerEnabledAttribute = element.attribute( "optimizerEnabled" );
+        if ( optimizerEnabledAttribute == null )
+        {
+            // If the 'optimizeEnabled' attribute does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'OptimizerEnabled' attribute for a partition." );
+        }
+        else
+        {
+            partition.setEnableOptimizer( parseBoolean( optimizerEnabledAttribute.getValue() ) );
+        }
+
+        // Sync On Write
+        org.dom4j.Attribute syncOnWriteAttribute = element.attribute( "syncOnWrite" );
+        if ( syncOnWriteAttribute == null )
+        {
+            // If the 'syncOnWrite' attribute does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'syncOnWrite' attribute for a partition." );
+        }
+        else
+        {
+            partition.setSynchronizationOnWrite( parseBoolean( syncOnWriteAttribute.getValue() ) );
+        }
+
+        // Indexed attributes
+        partition.setIndexedAttributes( readIndexedAttributes( element ) );
+
+        // Context Entry
+        partition.setContextEntry( readContextEntry( element ) );
+    }
+
+
+    /**
+     * Reads and returns the indexed attributes.
+     *
+     * @param element
+     *      the element
+     * @return
+     *      the list of indexed attributes
+     * @throws NumberFormatException
+     */
+    private List<IndexedAttribute> readIndexedAttributes( Element element ) throws NumberFormatException
+    {
+        List<IndexedAttribute> indexedAttributes = new ArrayList<IndexedAttribute>();
+
+        // Getting the 'indexedAttributes' element
+        Element indexedAttributesElement = element.element( "indexedAttributes" );
+        if ( indexedAttributesElement != null )
+        {
+            // Looping on 'jdbmIndex' elements
+            for ( Iterator<?> i = indexedAttributesElement.elementIterator( "jdbmIndex" ); i.hasNext(); )
+            {
+                // Getting the 'jdbmIndex' element
+                Element jdbmIndexElement = ( Element ) i.next();
+
+                // Getting the 'attributeId' attribute
+                org.dom4j.Attribute attributeIdAttribute = jdbmIndexElement.attribute( "attributeId" );
+                if ( attributeIdAttribute != null )
+                {
+                    // Getting the 'cacheSize' attribute
+                    org.dom4j.Attribute cacheSizeAttribute = jdbmIndexElement.attribute( "cacheSize" );
+                    if ( cacheSizeAttribute != null )
+                    {
+                        // Adding a new indexed attribute to the list
+                        indexedAttributes.add( new IndexedAttribute( attributeIdAttribute.getValue(), Integer
+                            .parseInt( cacheSizeAttribute.getValue() ) ) );
+                    }
+                }
+            }
+        }
+
+        return indexedAttributes;
+    }
+
+
+    /**
+     * Read the context from a partition element.
+     *
+     * @param element
+     *      the partition element
+     * @return
+     *      the corresponding attributes
+     * @throws ServerXmlIOException 
+     */
+    private Attributes readContextEntry( Element element ) throws ServerXmlIOException
+    {
+        Element contextEntryElement = element.element( "contextEntry" );
+        if ( contextEntryElement == null )
+        {
+            // If the 'contextEntry' element does not exists,
+            // we throw an exception
+            throw new ServerXmlIOException( "Unable to find the 'contextEntry' element for a partition." );
+        }
+        else
+        {
+            // Getting the id of the linked bean
+            String linkedBeanId = contextEntryElement.getText().trim();
+
+            // Removing the '#' character at the beginning of the value
+            linkedBeanId = linkedBeanId.substring( 1, linkedBeanId.length() );
+
+            // Creating a 'foundBean' flag to check if we've found the associated bean
+            boolean foundBean = false;
+
+            // Looping on all 'bean' tags
+            for ( Iterator<?> i = element.getDocument().getRootElement().elementIterator( "bean" ); i.hasNext(); )
+            {
+                // Getting the bean element
+                Element beanElement = ( Element ) i.next();
+
+                // Getting the id attribute
+                org.dom4j.Attribute idAttribute = beanElement.attribute( "id" );
+                if ( idAttribute != null )
+                {
+                    // Checking if we've found the correct bean
+                    if ( linkedBeanId.equalsIgnoreCase( idAttribute.getValue() ) )
+                    {
+                        // Setting the 'foundBean' flag to true
+                        foundBean = true;
+
+                        // Creating a 'foundProperty' flag to check if we've found the associated bean
+                        boolean foundProperty = false;
+
+                        // Looping on all 'property' tags
+                        for ( Iterator<?> i2 = beanElement.elementIterator( "property" ); i2.hasNext(); )
+                        {
+                            // Getting the property element
+                            Element propertyElement = ( Element ) i2.next();
+
+                            // Getting the name attribute
+                            org.dom4j.Attribute nameAttribute = propertyElement.attribute( "name" );
+                            if ( nameAttribute != null )
+                            {
+                                if ( nameAttribute.getValue().equalsIgnoreCase( "arguments" ) )
+                                {
+                                    // Setting the 'foundProperty' flag to true
+                                    foundProperty = true;
+
+                                    // Getting the list element
+                                    Element listElement = propertyElement.element( "list" );
+                                    if ( listElement != null )
+                                    {
+                                        // Looping on all 'value' tags
+                                        for ( Iterator<?> i3 = listElement.elementIterator( "value" ); i3.hasNext(); )
+                                        {
+                                            // Getting the value element
+                                            Element valueElement = ( Element ) i3.next();
+
+                                            // Getting the text value
+                                            String value = valueElement.getText().trim();
+
+                                            // We are looking for LDIF, so let's look if the text value
+                                            // contains any ':'
+                                            if ( value.indexOf( ':' ) != -1 )
+                                            {
+                                                // Returning the LDIF converted to JNDI Attributes
+                                                return readContextEntry( valueElement.getText().trim() );
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+
+                        // Checking if we have found the associated property
+                        // If not, we throw an error
+                        if ( !foundProperty )
+                        {
+                            // If the correct property element does not exists,
+                            // we throw an exception
+                            throw new ServerXmlIOException( "Unable to find the property element named 'arguments'." );
+                        }
+                    }
+                }
+            }
+
+            // Checking if we have found the associated bean
+            // If not, we throw an error
+            if ( !foundBean )
+            {
+                // If the correct bean element does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException( "Unable to find the bean element named '" + linkedBeanId + "'." );
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Reads the partitions.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException
+     * @throws BooleanFormatException
+     */
+    private void readPartitions( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException, BooleanFormatException
+    {
+        // Getting the 'partitions'element
+        Element partitionsElement = element.element( "partitions" );
+        if ( partitionsElement != null )
+        {
+            // Looping on all 'jdbmPartition' tags
+            for ( Iterator<?> i = partitionsElement.elementIterator( "jdbmPartition" ); i.hasNext(); )
+            {
+                // Getting the 'jbdmPartition' element
+                Element jdbmPartitionElement = ( Element ) i.next();
+
+                // Creating the partition
+                Partition partition = new Partition();
+
+                // Reading the partition
+                readPartition( jdbmPartitionElement, partition );
+
+                // Adding the partition to the server configuration
+                serverConfiguration.addPartition( partition );
+            }
+        }
+    }
+
+
+    private void readInterceptors( Element element, ServerConfigurationV152 serverConfiguration )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    /**
+     * Reads the ChangePasswordServer Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     */
+    private void readChangePasswordServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException
+    {
+        // Getting the 'changePasswordServer' element
+        Element changePasswordServerElement = element.element( "changePasswordServer" );
+        if ( changePasswordServerElement != null )
+        {
+            // Enabling the Change Password protocol
+            serverConfiguration.setEnableChangePassword( true );
+
+            // Getting the 'ipPort' attribute
+            org.dom4j.Attribute ipPortAttribute = changePasswordServerElement.attribute( "ipPort" );
+            if ( ipPortAttribute == null )
+            {
+                // If the 'ipPort' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException(
+                    "Unable to find the 'ipPort' attribute for the 'changePasswordServer' bean." );
+            }
+            else
+            {
+                serverConfiguration.setChangePasswordPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+            }
+        }
+    }
+
+
+    /**
+     * Reads the KdcServer Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     */
+    private void readKdcServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException
+    {
+        // Getting the 'kdcServer' element
+        Element kdcServerElement = element.element( "kdcServer" );
+        if ( kdcServerElement != null )
+        {
+            // Enabling the Kerberos protocol
+            serverConfiguration.setEnableKerberos( true );
+
+            // Getting the 'ipPort' attribute
+            org.dom4j.Attribute ipPortAttribute = kdcServerElement.attribute( "ipPort" );
+            if ( ipPortAttribute == null )
+            {
+                // If the 'ipPort' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException( "Unable to find the 'ipPort' attribute for the 'kdcServer' bean." );
+            }
+            else
+            {
+                serverConfiguration.setKerberosPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+            }
+        }
+    }
+
+
+    /**
+     * Reads the NtpServer Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     */
+    private void readNtpServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException
+    {
+        // Getting the 'ntpServer' element
+        Element ntpServerElement = element.element( "ntpServer" );
+        if ( ntpServerElement != null )
+        {
+            // Enabling the NTP protocol
+            serverConfiguration.setEnableNtp( true );
+
+            // Getting the 'ipPort' attribute
+            org.dom4j.Attribute ipPortAttribute = ntpServerElement.attribute( "ipPort" );
+            if ( ipPortAttribute == null )
+            {
+                // If the 'ipPort' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException( "Unable to find the 'ipPort' attribute for the 'ntpServer' bean." );
+            }
+            else
+            {
+                serverConfiguration.setNtpPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+            }
+        }
+    }
+
+
+    /**
+     * Reads the DnsServer Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     */
+    private void readDnsServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException
+    {
+        // Getting the 'dnsServer' element
+        Element dnsServerElement = element.element( "dnsServer" );
+        if ( dnsServerElement != null )
+        {
+            // Enabling the DNS protocol
+            serverConfiguration.setEnableDns( true );
+
+            // Getting the 'ipPort' attribute
+            org.dom4j.Attribute ipPortAttribute = dnsServerElement.attribute( "ipPort" );
+            if ( ipPortAttribute == null )
+            {
+                // If the 'ipPort' attribute does not exists,
+                // we throw an exception
+                throw new ServerXmlIOException( "Unable to find the 'ipPort' attribute for the 'dnsServer' bean." );
+            }
+            else
+            {
+                serverConfiguration.setDnsPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+            }
+        }
+    }
+
+
+    /**
+     * Reads the LdapsSever Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     * @throws BooleanFormatException 
+     */
+    private void readLdapsServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException, BooleanFormatException
+    {
+        // Looping on all 'ldapServer' elements
+        for ( Iterator<?> i = element.getDocument().getRootElement().elementIterator( "ldapServer" ); i.hasNext(); )
+        {
+            // Getting the 'ldapServer' element
+            Element ldapServerElement = ( Element ) i.next();
+
+            // Getting the 'id' attribute
+            org.dom4j.Attribute idAttribute = ldapServerElement.attribute( "id" );
+            if ( idAttribute == null )
+            {
+                // TODO throw an error
+            }
+            else
+            {
+                // Checking if the 'ldapServer' element is the one for LDAPS
+                if ( "ldapsServer".equalsIgnoreCase( idAttribute.getValue() ) )
+                {
+                    // Getting the 'enableLdaps' attribute
+                    org.dom4j.Attribute enableLdapsAttribute = ldapServerElement.attribute( "enableLdaps" );
+                    if ( enableLdapsAttribute == null )
+                    {
+                        // Enabling by default
+                        serverConfiguration.setEnableLdaps( true );
+                    }
+                    else
+                    {
+                        serverConfiguration.setEnableLdaps( parseBoolean( enableLdapsAttribute.getValue() ) );
+                    }
+
+                    // Getting the 'ipPort' attribute
+                    org.dom4j.Attribute ipPortAttribute = ldapServerElement.attribute( "ipPort" );
+                    if ( ipPortAttribute == null )
+                    {
+                        // If the 'ipPort' attribute does not exists,
+                        // we throw an exception
+                        throw new ServerXmlIOException(
+                            "Unable to find the 'ipPort' attribute for the 'ldapsServer' bean." );
+                    }
+                    else
+                    {
+                        serverConfiguration.setLdapsPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+                    }
+
+                    return;
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Reads the LdapSever Bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     * @throws NumberFormatException
+     * @throws ServerXmlIOException 
+     * @throws BooleanFormatException 
+     */
+    private void readLdapServerBean( Element element, ServerConfigurationV152 serverConfiguration )
+        throws NumberFormatException, ServerXmlIOException, BooleanFormatException
+    {
+        // Looping on all 'ldapServer' elements
+        for ( Iterator<?> i = element.getDocument().getRootElement().elementIterator( "ldapServer" ); i.hasNext(); )
+        {
+            // Getting the 'ldapServer' element
+            Element ldapServerElement = ( Element ) i.next();
+
+            // Getting the 'id' attribute
+            org.dom4j.Attribute idAttribute = ldapServerElement.attribute( "id" );
+            if ( idAttribute == null )
+            {
+                // TODO throw an error
+            }
+            else
+            {
+                // Checking if the 'ldapServer' element is the one for LDAP
+                if ( "ldapServer".equalsIgnoreCase( idAttribute.getValue() ) )
+                {
+                    // Getting the 'ipPort' attribute
+                    org.dom4j.Attribute ipPortAttribute = ldapServerElement.attribute( "ipPort" );
+                    if ( ipPortAttribute == null )
+                    {
+                        // If the 'ipPort' attribute does not exists,
+                        // we throw an exception
+                        throw new ServerXmlIOException(
+                            "Unable to find the 'ipPort' attribute for the 'ldapsServer' bean." );
+                    }
+                    else
+                    {
+                        serverConfiguration.setLdapPort( Integer.parseInt( ipPortAttribute.getValue() ) );
+                    }
+
+                    // Allow Anonymous Access
+                    org.dom4j.Attribute allowAnonymousAccess = ldapServerElement.attribute( "allowAnonymousAccess" );
+                    if ( allowAnonymousAccess == null )
+                    {
+                        // If the 'allowAnonymousAccess' attribute does not exists,
+                        // we throw an exception
+                        throw new ServerXmlIOException(
+                            "Unable to find the 'allowAnonymousAccess' attribute for the 'ldapsServer' bean." );
+                    }
+                    else
+                    {
+                        serverConfiguration.setAllowAnonymousAccess( parseBoolean( allowAnonymousAccess.getValue() ) );
+                    }
+
+                    return;
+                }
+            }
+        }
+    }
+
+
+    private void readApacheDSBean( Element element, ServerConfiguration serverConfiguration )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    /* (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 )
+    {
+        // Creating the document
+        Document document = DocumentHelper.createDocument();
+
+        // Creating the root element with its namespaces definitions
+        Element root = document.addElement( new QName( "beans", NAMESPACE_XBEAN_SPRING ) );
+        root.add( NAMESPACE_SPRINGFRAMEWORK );
+        root.add( NAMESPACE_APACHEDS );
+
+        // DefaultDirectoryService Bean
+        createDefaultDirectoryServiceBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // Adding the 'standardThreadPool' element
+        Element standardThreadPoolElement = root.addElement( "standardThreadPool" );
+        standardThreadPoolElement.addAttribute( "id", "standardThreadPool" );
+        standardThreadPoolElement.addAttribute( "maxThreads", ""
+            + ( ( ServerConfigurationV152 ) serverConfiguration ).getMaxThreads() );
+
+        // Adding the 'datagramAcceptor' element
+        Element datagramAcceptorElement = root.addElement( "datagramAcceptor" );
+        datagramAcceptorElement.addAttribute( "id", "datagramAcceptor" );
+        datagramAcceptorElement.addAttribute( "logicExecutor", "#standardThreadPool" );
+
+        // Adding the 'socketAcceptor' element
+        Element socketAcceptorElement = root.addElement( "socketAcceptor" );
+        socketAcceptorElement.addAttribute( "id", "socketAcceptor" );
+        socketAcceptorElement.addAttribute( "logicExecutor", "#standardThreadPool" );
+
+        // ChangePasswordServer Bean
+        createChangePasswordServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // KdcServer Bean
+        createKdcServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // NtpServer Bean
+        createNtpServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // DnsServer Bean
+        createDnsServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // LdapsServer Bean
+        createLdapsServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // LdapServer Bean
+        createLdapServerBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // ApacheDS Bean
+        createApacheDSBean( root, ( ServerConfigurationV152 ) serverConfiguration );
+
+        // CustomEditorConfigurer Bean
+        createCustomEditorConfigurerBean( root );
+
+        Document stylizedDocument = null;
+        try
+        {
+            stylizedDocument = styleDocument( document );
+        }
+        catch ( TransformerException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        return stylizedDocument.asXML();
+    }
+
+
+    /**
+     * Creates the DefaultDirectoryService bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createDefaultDirectoryServiceBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        // Adding the 'defaultDirectoryService' element
+        Element defaultDirectoryServiceElement = root.addElement( "defaultDirectoryService" );
+
+        // Id
+        defaultDirectoryServiceElement.addAttribute( "id", "directoryService" );
+
+        // InstanceId
+        defaultDirectoryServiceElement.addAttribute( "instanceId", "default" );
+
+        // WorkingDirectory
+        defaultDirectoryServiceElement.addAttribute( "workingDirectory", "example.com" );
+
+        // AllowAnonymousAccess
+        defaultDirectoryServiceElement.addAttribute( "allowAnonymousAccess", ""
+            + serverConfiguration.isAllowAnonymousAccess() );
+
+        // AccessControlEnabled
+        defaultDirectoryServiceElement.addAttribute( "accessControlEnabled", ""
+            + serverConfiguration.isEnableAccessControl() );
+
+        // DenormalizeOpAttrsEnabled
+        defaultDirectoryServiceElement.addAttribute( "denormalizeOpAttrsEnabled", ""
+            + serverConfiguration.isDenormalizeOpAttr() );
+
+        // Adding the 'systemPartition' element
+        Element systemPartitionElement = defaultDirectoryServiceElement.addElement( "systemPartition" );
+
+        // Adding System Partition Bean
+        createSystemPartitionBean( systemPartitionElement, serverConfiguration );
+
+        // Adding the 'partitions' element
+        Element partitionsElement = defaultDirectoryServiceElement.addElement( "partitions" );
+
+        // Adding User Partitions Beans
+        createUserPartitions( partitionsElement, serverConfiguration );
+
+        // Adding the 'interceptors' element
+        Element interceptorsElement = defaultDirectoryServiceElement.addElement( "interceptors" );
+
+        // Adding Interceptors Beans
+        createInterceptors( interceptorsElement, serverConfiguration );
+    }
+
+
+    /**
+     * Creates the system partition bean.
+     *
+     * @param systemPartitionElement
+     *      the systemPartition element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createSystemPartitionBean( Element systemPartitionElement, ServerConfigurationV152 serverConfiguration )
+    {
+        // Looping on partitions to find the system partition
+        Partition systemPartition = null;
+        for ( Partition partition : serverConfiguration.getPartitions() )
+        {
+            if ( partition.isSystemPartition() )
+            {
+                systemPartition = partition;
+                break;
+            }
+        }
+
+        if ( systemPartition != null )
+        {
+            createPartition( systemPartitionElement, systemPartition );
+        }
+    }
+
+
+    /**
+     * Creates the user partition beans.
+     *
+     * @param partitionsElement
+     *      the partitions element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createUserPartitions( Element partitionsElement, ServerConfigurationV152 serverConfiguration )
+    {
+        // Looping on partitions
+        for ( Partition partition : serverConfiguration.getPartitions() )
+        {
+            if ( !partition.isSystemPartition() )
+            {
+                createPartition( partitionsElement, partition );
+            }
+        }
+    }
+
+
+    /**
+     * Creates the partition bean.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createPartition( Element element, Partition partition )
+    {
+        // Adding the 'jdbmPartition' element
+        Element jdbmPartitionElement = element.addElement( "jdbmPartition" );
+
+        // Id
+        jdbmPartitionElement.addAttribute( "id", partition.getId() );
+
+        // CacheSize
+        jdbmPartitionElement.addAttribute( "cacheSize", "" + partition.getCacheSize() );
+
+        // Suffix
+        jdbmPartitionElement.addAttribute( "suffix", partition.getSuffix() );
+
+        // OptimizerEnabled
+        jdbmPartitionElement.addAttribute( "optimizerEnabled", "" + partition.isEnableOptimizer() );
+
+        // SynchOnWrite
+        jdbmPartitionElement.addAttribute( "synchOnWrite", "" + partition.isSynchronizationOnWrite() );
+
+        // IndexedAttributes
+        createIndexedAttributes( jdbmPartitionElement, partition.getIndexedAttributes() );
+
+        // ContextEntry
+        createContextEntry( jdbmPartitionElement, partition.getContextEntry(), partition.getId(), partition.getSuffix() );
+    }
+
+
+    /**
+     * Creates the indexed attributes bean.
+     *
+     * @param element
+     *      the element
+     * @param indexedAttributes
+     *      the indexed attributes list
+     */
+    private void createIndexedAttributes( Element element, List<IndexedAttribute> indexedAttributes )
+    {
+        // Adding the 'indexedAttribute' element
+        Element indexedAttributeElement = element.addElement( "indexedAttribute" );
+
+        if ( indexedAttributes != null )
+        {
+            // Looping on indexed attributes
+            for ( IndexedAttribute indexedAttribute : indexedAttributes )
+            {
+                // Adding the 'jdbmIndex' element
+                Element jdbmIndexElement = indexedAttributeElement.addElement( "jdbmIndex" );
+                jdbmIndexElement.addAttribute( "attributeId", indexedAttribute.getAttributeId() );
+                jdbmIndexElement.addAttribute( "cacheSize", "" + indexedAttribute.getCacheSize() );
+            }
+        }
+    }
+
+
+    /**
+     * Creates the context entry bean.
+     *
+     * @param element
+     *      the element
+     * @param contextEntry
+     *      the attributes
+     * @param id
+     *      the partition id
+     * @param dn 
+     *      the dn
+     */
+    private void createContextEntry( Element element, Attributes contextEntry, String id, String dn )
+    {
+        // Adding the 'contextEntry' element
+        element.addElement( "contextEntry" ).setText( "#" + id + "ContextEntry" );
+
+        // Adding the 'bean' element
+        Element beanElement = element.getDocument().getRootElement().addElement(
+            new QName( "bean", NAMESPACE_XBEAN_SPRING ) );
+        beanElement.addAttribute( "id", id + "ContextEntry" );
+        beanElement.addAttribute( "class", "org.springframework.beans.factory.config.MethodInvokingFactoryBean" );
+
+        // Adding the targetObject 'property' element
+        Element targetObjectPropertyElement = beanElement.addElement( new QName( "property", NAMESPACE_XBEAN_SPRING ) );
+        targetObjectPropertyElement.addAttribute( "name", "targetObject" );
+
+        // Adding the targetObject 'ref' element
+        Element targetObjectRefElement = targetObjectPropertyElement.addElement( new QName( "ref",
+            NAMESPACE_XBEAN_SPRING ) );
+        targetObjectRefElement.addAttribute( "local", "directoryService" );
+
+        // Adding the targetMethod 'property' element
+        Element targetMethodPropertyElement = beanElement.addElement( new QName( "property", NAMESPACE_XBEAN_SPRING ) );
+        targetMethodPropertyElement.addAttribute( "name", "targetMethod" );
+
+        // Adding the targetMethod 'value' element
+        targetMethodPropertyElement.addElement( new QName( "value", NAMESPACE_XBEAN_SPRING ) ).setText( "newEntry" );
+
+        // Adding the arguments 'property' element
+        Element argumentsPropertyElement = beanElement.addElement( new QName( "property", NAMESPACE_XBEAN_SPRING ) );
+        argumentsPropertyElement.addAttribute( "name", "arguments" );
+
+        // Adding the arguments 'list' element
+        Element argumentsListElement = argumentsPropertyElement
+            .addElement( new QName( "list", NAMESPACE_XBEAN_SPRING ) );
+
+        // Adding the arguments attributes 'value' element
+        Element argumentsAttributesValueElement = argumentsListElement.addElement( new QName( "value", new Namespace(
+            "spring", "http://www.springframework.org/schema/beans" ) ) );
+
+        // Creating a string buffer to contain the LDIF data
+        StringBuffer sb = new StringBuffer();
+
+        // Looping on attributes
+        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 )
+            {
+            }
+        }
+
+        // Assigning the value to the element
+        argumentsAttributesValueElement.setText( sb.toString() );
+
+        // Adding the arguments dn 'value' element
+        argumentsListElement.addElement( new QName( "value", NAMESPACE_XBEAN_SPRING ) ).setText( dn );
+    }
+
+
+    /**
+     * Creates the interceptor beans.
+     *
+     * @param interceptorsElement
+     *      the interceptors element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createInterceptors( Element interceptorsElement, ServerConfigurationV152 serverConfiguration )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    /**
+     * Creates the ChangePasswordServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createChangePasswordServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        if ( serverConfiguration.isEnableChangePassword() )
+        {
+            // Adding the 'changePasswordServer' element
+            Element changePasswordServerElement = root.addElement( "changePasswordServer" );
+
+            // IpPort
+            changePasswordServerElement.addAttribute( "ipPort", "" + serverConfiguration.getChangePasswordPort() );
+
+            // Adding 'directoryService' element
+            changePasswordServerElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+            // Adding 'datagramAcceptor' element
+            changePasswordServerElement.addElement( "datagramAcceptor" ).setText( "#datagramAcceptor" );
+
+            // Adding 'socketAcceptor' element
+            changePasswordServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+        }
+    }
+
+
+    /**
+     * Creates the KdcServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createKdcServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        if ( serverConfiguration.isEnableKerberos() )
+        {
+            // Adding the 'kdcServer' element
+            Element kdcServerElement = root.addElement( "kdcServer" );
+
+            // IpPort
+            kdcServerElement.addAttribute( "ipPort", "" + serverConfiguration.getKerberosPort() );
+
+            // Adding 'directoryService' element
+            kdcServerElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+            // Adding 'datagramAcceptor' element
+            kdcServerElement.addElement( "datagramAcceptor" ).setText( "#datagramAcceptor" );
+
+            // Adding 'socketAcceptor' element
+            kdcServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+        }
+    }
+
+
+    /**
+     * Creates the NtpServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createNtpServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        if ( serverConfiguration.isEnableNtp() )
+        {
+            // Adding the 'ntpServer' element
+            Element ntpServerElement = root.addElement( "ntpServer" );
+
+            // IpPort
+            ntpServerElement.addAttribute( "ipPort", "" + serverConfiguration.getNtpPort() );
+
+            // Adding 'datagramAcceptor' element
+            ntpServerElement.addElement( "datagramAcceptor" ).setText( "#datagramAcceptor" );
+
+            // Adding 'socketAcceptor' element
+            ntpServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+        }
+    }
+
+
+    /**
+     * Creates the DnsServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createDnsServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        if ( serverConfiguration.isEnableDns() )
+        {
+            // Adding the 'dnsServer' element
+            Element dnsServerElement = root.addElement( "dnsServer" );
+
+            // IpPort
+            dnsServerElement.addAttribute( "ipPort", "" + serverConfiguration.getDnsPort() );
+
+            // Adding 'directoryService' element
+            dnsServerElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+            // Adding 'datagramAcceptor' element
+            dnsServerElement.addElement( "datagramAcceptor" ).setText( "#datagramAcceptor" );
+
+            // Adding 'socketAcceptor' element
+            dnsServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+        }
+    }
+
+
+    /**
+     * Creates the LdapsServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createLdapsServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        if ( serverConfiguration.isEnableLdaps() )
+        {
+            // Adding the 'ldapServer' element
+            Element ldapServerElement = root.addElement( "ldapServer" );
+
+            // Id
+            ldapServerElement.addAttribute( "id", "ldapsServer" );
+
+            // IpPort
+            ldapServerElement.addAttribute( "ipPort", "" + serverConfiguration.getLdapsPort() );
+
+            // Enable
+            ldapServerElement.addAttribute( "enable", "" + "true" );
+
+            // EnableLdaps
+            ldapServerElement.addAttribute( "enableLdaps", "" + "true" );
+
+            // Adding 'directoryService' element
+            ldapServerElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+            // Adding 'socketAcceptor' element
+            ldapServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+        }
+    }
+
+
+    /**
+     * Creates the LdapServer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createLdapServerBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        // Adding the 'ldapServer' element
+        Element ldapServerElement = root.addElement( "ldapServer" );
+
+        // Id
+        ldapServerElement.addAttribute( "id", "ldapServer" );
+
+        // IpPort
+        ldapServerElement.addAttribute( "ipPort", "" + serverConfiguration.getLdapPort() );
+
+        // AllowAnonymousAccess
+        ldapServerElement.addAttribute( "allowAnonymousAccess", "" + serverConfiguration.isAllowAnonymousAccess() );
+
+        // SaslHost
+        ldapServerElement.addAttribute( "saslHost", "" + serverConfiguration.getSaslHost() );
+
+        // SaslPrincipal
+        ldapServerElement.addAttribute( "saslPrincipal", "" + serverConfiguration.getSaslPrincipal() );
+
+        // SearchBaseDn
+        ldapServerElement.addAttribute( "searchBaseDn", "ou=users,ou=system" );
+
+        // MaxTimeLimit
+        ldapServerElement.addAttribute( "maxTimeLimit", "" + serverConfiguration.getMaxTimeLimit() );
+
+        // MaxSizeLimit
+        ldapServerElement.addAttribute( "maxSizeLimit", "" + serverConfiguration.getMaxSizeLimit() );
+
+        // Adding 'directoryService' element
+        ldapServerElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+        // Adding 'socketAcceptor' element
+        ldapServerElement.addElement( "socketAcceptor" ).setText( "#socketAcceptor" );
+
+        // Adding 'supportedMechanisms' element
+        Element supportedMechanismsElement = ldapServerElement.addElement( "supportedMechanisms" );
+
+        // Adding each supported mechanism
+        for ( String supportedMechanism : serverConfiguration.getSupportedMechanisms() )
+        {
+            supportedMechanismsElement.addElement( new QName( "value", NAMESPACE_SPRINGFRAMEWORK ) ).setText(
+                supportedMechanism );
+        }
+
+        // Adding 'SaslQop' element
+        Element saslQopElement = ldapServerElement.addElement( "saslQop" );
+
+        // Adding each SaslQop item
+        for ( String saslQop : serverConfiguration.getSaslQops() )
+        {
+            saslQopElement.addElement( new QName( "value", NAMESPACE_SPRINGFRAMEWORK ) ).setText( saslQop );
+        }
+
+        // Adding 'SaslRealms' element
+        Element saslRealmsElement = ldapServerElement.addElement( "saslRealms" );
+
+        // Adding each SaslRealm item
+        for ( String saslRealm : serverConfiguration.getSaslRealms() )
+        {
+            saslRealmsElement.addElement( new QName( "value", NAMESPACE_SPRINGFRAMEWORK ) ).setText( saslRealm );
+        }
+
+        // TODO Add Extended Operations
+    }
+
+
+    /**
+     * Creates the ApacheDS bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createApacheDSBean( Element root, ServerConfigurationV152 serverConfiguration )
+    {
+        // Adding the 'apacheDS' element
+        Element apacheDSElement = root.addElement( "apacheDS" );
+
+        // Id
+        apacheDSElement.addAttribute( "id", "apacheDS" );
+
+        // SyncPeriodMillis
+        apacheDSElement.addAttribute( "syncPeriodMillis", "" + serverConfiguration.getSynchronizationPeriod() );
+
+        // AllowAnonymousAccess
+        apacheDSElement.addAttribute( "allowAnonymousAccess", "" + serverConfiguration.isAllowAnonymousAccess() );
+
+        // Adding 'directoryService' element
+        apacheDSElement.addElement( "directoryService" ).setText( "#directoryService" );
+
+        // Adding 'ldapServer' element
+        apacheDSElement.addElement( "ldapServer" ).setText( "#ldapServer" );
+
+        // LDAP Protocol
+        if ( serverConfiguration.isEnableLdaps() )
+        {
+            // Adding 'ldapsServer' element
+            apacheDSElement.addElement( "ldapsServer" ).setText( "#ldapsServer" );
+        }
+
+        // LDAPS Protocol
+        if ( serverConfiguration.isEnableLdaps() )
+        {
+            // Adding 'ldapsServer' element
+            apacheDSElement.addElement( "ldapsServer" ).setText( "#ldapsServer" );
+        }
+    }
+
+
+    /**
+     * Creates the CustomEditorConfigurer bean.
+     *
+     * @param root
+     *      the root element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void createCustomEditorConfigurerBean( Element root )
+    {
+        // Adding the 'bean' element
+        Element beanElement = root.addElement( new QName( "bean", NAMESPACE_XBEAN_SPRING ) );
+        beanElement.addAttribute( "class", "org.springframework.beans.factory.config.CustomEditorConfigurer" );
+
+        // Adding the 'property' element
+        Element propertyElement = beanElement.addElement( new QName( "property", NAMESPACE_XBEAN_SPRING ) );
+        propertyElement.addAttribute( "name", "customEditors" );
+
+        // Adding the 'map' element
+        Element mapElement = propertyElement.addElement( new QName( "map", NAMESPACE_XBEAN_SPRING ) );
+
+        // Adding the 'entry' element
+        Element entryElement = mapElement.addElement( new QName( "entry", NAMESPACE_XBEAN_SPRING ) );
+        entryElement.addAttribute( "key", "javax.naming.directory.Attributes" );
+
+        // Adding the inner 'bean' element
+        Element innerBeanElement = entryElement.addElement( new QName( "entry", NAMESPACE_XBEAN_SPRING ) );
+        innerBeanElement.addAttribute( "class",
+            "org.apache.directory.server.core.configuration.AttributesPropertyEditor" );
+    }
+}

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java?rev=656336&r1=656335&r2=656336&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java (original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java Wed May 14 10:21:46 2008
@@ -24,8 +24,11 @@
 import org.apache.directory.studio.apacheds.configuration.editor.NonExistingServerConfigurationInput;
 import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIO;
 import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIOException;
-import org.apache.directory.studio.apacheds.configuration.model.ServerXmlV151IO;
+import org.apache.directory.studio.apacheds.configuration.model.v150.ServerXmlIOV150;
+import org.apache.directory.studio.apacheds.configuration.model.v151.ServerXmlIOV151;
+import org.apache.directory.studio.apacheds.configuration.model.v152.ServerXmlIOV152;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.swt.SWT;
@@ -49,6 +52,19 @@
     /** The window */
     private IWorkbenchWindow window;
 
+    /** The page */
+    private NewApacheDSConfigurationFileWizardPage page;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        page = new NewApacheDSConfigurationFileWizardPage();
+        addPage( page );
+    }
+
 
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
@@ -57,9 +73,32 @@
     {
         try
         {
-            ServerXmlV151IO serverXmlIO = new ServerXmlV151IO();
-            ServerConfiguration serverConfiguration = serverXmlIO.parse( ApacheDSConfigurationPlugin.class
-                .getResourceAsStream( "default-server.xml" ) );
+            // Getting the default server configuration for the target version
+            ServerConfiguration serverConfiguration = null;
+            ServerXmlIO serverXmlIO = null;
+            switch ( page.getTargetVersion() )
+            {
+                case VERSION_1_5_2:
+                    serverXmlIO = new ServerXmlIOV152();
+                    serverConfiguration = serverXmlIO.parse( ApacheDSConfigurationPlugin.class
+                        .getResourceAsStream( "default-server-1.5.2.xml" ) );
+                    break;
+                case VERSION_1_5_1:
+                    serverXmlIO = new ServerXmlIOV151();
+                    serverConfiguration = serverXmlIO.parse( ApacheDSConfigurationPlugin.class
+                        .getResourceAsStream( "default-server-1.5.1.xml" ) );
+                    break;
+                case VERSION_1_5_0:
+                    serverXmlIO = new ServerXmlIOV150();
+                    serverConfiguration = serverXmlIO.parse( ApacheDSConfigurationPlugin.class
+                        .getResourceAsStream( "default-server-1.5.0.xml" ) );
+                    break;
+                default:
+                    serverXmlIO = new ServerXmlIOV152();
+                    serverConfiguration = serverXmlIO.parse( ApacheDSConfigurationPlugin.class
+                        .getResourceAsStream( "default-server-1.5.2.xml" ) );
+                    break;
+            }
 
             IWorkbenchPage page = window.getActivePage();
             page.openEditor( new NonExistingServerConfigurationInput( serverConfiguration ),