From commits-return-48626-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Sun Sep 3 22:23:50 2017 Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DE4719A49 for ; Sun, 3 Sep 2017 22:23:50 +0000 (UTC) Received: (qmail 96283 invoked by uid 500); 3 Sep 2017 22:23:50 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 96235 invoked by uid 500); 3 Sep 2017 22:23:49 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 96226 invoked by uid 99); 3 Sep 2017 22:23:49 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Sep 2017 22:23:49 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 16B663A009A for ; Sun, 3 Sep 2017 22:23:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1807175 - /directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java Date: Sun, 03 Sep 2017 22:23:44 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170903222348.16B663A009A@svn01-us-west.apache.org> Author: elecharny Date: Sun Sep 3 22:23:44 2017 New Revision: 1807175 URL: http://svn.apache.org/viewvc?rev=1807175&view=rev Log: o Added the code to process the configuration when we create a new one. o Simplified the getConfiguration method Modified: directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java Modified: directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java?rev=1807175&r1=1807174&r2=1807175&view=diff ============================================================================== --- directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java (original) +++ directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/jobs/LoadConfigurationRunnable.java Sun Sep 3 22:23:44 2017 @@ -29,7 +29,9 @@ import org.eclipse.ui.IEditorInput; import org.apache.directory.studio.openldap.config.editor.ConnectionServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.DirectoryServerConfigurationInput; +import org.apache.directory.studio.openldap.config.editor.NewServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.OpenLDAPServerConfigurationEditor; +import org.apache.directory.studio.openldap.config.model.OlcGlobal; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.io.ConfigurationReader; @@ -113,7 +115,8 @@ public class LoadConfigurationRunnable i /** - * Gets the configuration from the input. + * Gets the configuration from the input. It may come from an existing connection, + * or from an existing file/directory on the disk, or a brand new configuration * * @param input the editor input * @param monitor the studio progress monitor @@ -122,57 +125,28 @@ public class LoadConfigurationRunnable i */ public OpenLdapConfiguration getConfiguration( IEditorInput input, StudioProgressMonitor monitor ) throws Exception { - // If the input is a ConnectionServerConfigurationInput, then we - // read the server configuration from the selected connection if ( input instanceof ConnectionServerConfigurationInput ) { - return readConfiguration( ( ConnectionServerConfigurationInput ) input, monitor ); + // If the input is a ConnectionServerConfigurationInput, then we + // read the server configuration from the selected connection + ConfigurationReader.readConfiguration( ( ConnectionServerConfigurationInput ) input ); } - // If the input is a DirectoryServerConfigurationInput, then we - // read the server configuration from the selected 'slapd.d' directory. else if ( input instanceof DirectoryServerConfigurationInput ) { - return readConfiguration( ( DirectoryServerConfigurationInput ) input, monitor ); - } - - return null; - } - - - /** - * Reads the configuration from the given connection. - * - * @param input the editor input - * @param monitor the studio progress monitor - * @return the associated configuration bean - * @throws Exception - */ - private OpenLdapConfiguration readConfiguration( ConnectionServerConfigurationInput input, - StudioProgressMonitor monitor ) throws Exception - { - if ( input != null ) - { - return ConfigurationReader.readConfiguration( input ); - } - - return null; - } - - - /** - * Reads the configuration from the given connection. - * - * @param input the editor input - * @param monitor the studio progress monitor - * @return the associated configuration bean - * @throws Exception - */ - private OpenLdapConfiguration readConfiguration( DirectoryServerConfigurationInput input, - StudioProgressMonitor monitor ) throws Exception - { - if ( input != null ) - { - return ConfigurationReader.readConfiguration( input ); + // If the input is a DirectoryServerConfigurationInput, then we + // read the server configuration from the selected 'slapd.d' directory. + return ConfigurationReader.readConfiguration( ( DirectoryServerConfigurationInput ) input ); + } + else if ( input instanceof NewServerConfigurationInput ) + { + // If the input is a NewServerConfigurationInput, then we only + // need to create a server configuration and return. + // The new configuration will be pretty empty, with just + // the main container (and the olcGlobal instance + OpenLdapConfiguration configuration = new OpenLdapConfiguration(); + configuration.setGlobal( new OlcGlobal() ); + + return configuration; } return null;