You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/01 03:01:43 UTC
svn commit: r1670531 [2/14] - in
/directory/studio/trunk/plugins/openldap.config.editor: ./ resources/icons/
src/main/java/org/apache/directory/studio/openldap/config/
src/main/java/org/apache/directory/studio/openldap/config/actions/
src/main/java/org...
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,153 @@
+/*
+ * 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.openldap.config.editor;
+
+
+import java.io.File;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+
+
+/**
+ * This class represents the Directory Server Configuration Input.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DirectoryServerConfigurationInput extends AbstractServerConfigurationInput
+{
+ /** The directory */
+ private File directory;
+
+
+ /**
+ * Creates a new instance of DirectoryServerConfigurationInput.
+ *
+ * @param directory
+ * the directory
+ */
+ public DirectoryServerConfigurationInput( File directory )
+ {
+ this.directory = directory;
+ }
+
+
+ /**
+ * Gets the directory.
+ *
+ * @return
+ * the directory
+ */
+ public File getDirectory()
+ {
+ return directory;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getToolTipText()
+ {
+ if ( directory != null )
+ {
+ return directory.toString();
+ }
+
+ return getName();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ if ( directory != null )
+ {
+ return directory.getName();
+ }
+
+ return "OpenLDAP Configuration";
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists()
+ {
+ return directory != null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_EDITOR );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj == null )
+ {
+ return false;
+ }
+
+ if ( obj instanceof DirectoryServerConfigurationInput )
+ {
+ DirectoryServerConfigurationInput input = ( DirectoryServerConfigurationInput ) obj;
+ if ( input.exists() && exists() )
+ {
+ File inputDirectory = input.getDirectory();
+
+ if ( inputDirectory != null )
+ {
+ return inputDirectory.equals( directory );
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode()
+ {
+ if ( directory != null )
+ {
+ return directory.hashCode();
+ }
+
+ return super.hashCode();
+ }
+}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ErrorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ErrorPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ErrorPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ErrorPage.java Wed Apr 1 01:01:42 2015
@@ -43,6 +43,8 @@ import org.eclipse.ui.forms.widgets.Scro
/**
* This class represents the Error Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ErrorPage extends FormPage
{
@@ -102,8 +104,7 @@ public class ErrorPage extends FormPage
toolkit.decorateFormHeading( form.getForm() );
// Error Label
- Label errorLabel = toolkit.createLabel( parent,
- NLS.bind( "Could not open the editor: {0}", exception.getMessage() ) );
+ Label errorLabel = toolkit.createLabel( parent, "" );
errorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Details Button
@@ -112,12 +113,22 @@ public class ErrorPage extends FormPage
detailsButton.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) );
detailsButton.addSelectionListener( new SelectionAdapter()
{
- @Override
public void widgetSelected( SelectionEvent e )
{
showOrHideDetailsView();
}
} );
+
+ // Initializing with the exception
+ if ( exception == null )
+ {
+ errorLabel.setText( "Could not open the editor." );
+ detailsButton.setVisible( false );
+ }
+ else
+ {
+ errorLabel.setText( NLS.bind( "Could not open the editor: {0}", exception.getMessage() ) ); //$NON-NLS-1$
+ }
}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/LoadingPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/LoadingPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/LoadingPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/LoadingPage.java Wed Apr 1 01:01:42 2015
@@ -35,6 +35,8 @@ import org.eclipse.ui.forms.widgets.Scro
/**
* This class represents the Loading Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LoadingPage extends FormPage
{
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OptionsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OptionsPage.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OptionsPage.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OptionsPage.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,880 @@
+/*
+ * 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.openldap.config.editor;
+
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+import org.apache.directory.studio.openldap.config.model.OlcGlobal;
+
+
+/**
+ * This class represents the Otptions Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OptionsPage extends ServerConfigurationEditorPage
+{
+ /** The Page ID*/
+ public static final String ID = OptionsPage.class.getName(); //$NON-NLS-1$
+
+ /** The Page Title */
+ private static final String TITLE = "Options";
+
+ // UI Controls
+ private Text logFileText;
+ private Text logLevelText;
+ private Text maxPduSizeAnonymousSessionsText;
+ private Text maxPduSizeAuthenticatedSessionsText;
+ private Text tcpBufferSizeText;
+ private Text maxPendingRequestsAnonymousSessionText;
+ private Text maxPendingRequestsAuthenticatedSessionText;
+ private Text numberSecondsClosingIdleConnectionText;
+ private Text numberSecondsClosingConnectionWithOutstandingWriteText;
+ private Text levelOfConcurrencyText;
+ private Text maximumNumberOfThreadsText;
+ private Text maximumNumberOfThreadsInToolModeText;
+ private Text authenticationAuxpropPluginsText;
+ private Text saslHostText;
+ private Text saslRealmText;
+ private Text saslSecurityPropertiesText;
+ private Text certificateAuthoritiesFileText;
+ private Text certificateAuthoritiesPathText;
+ private Text serverCertificateFileText;
+ private Text serverPrivateKeyFileText;
+ private Text cipherSuiteText;
+ private Text certificateRevocationListFileText;
+ private Text certificateRevocationListLevelText;
+ private Text diffieHellmanParametersFileText;
+ private Text randomBitsFileText;
+ private Text incomingCertificatesVerificationLevelText;
+ private Text keyLengthForOrderedIntegerIndicesText;
+ private Text maximumLengthForSubinitialAndSubfinalIndicesText;
+ private Text minimumLengthForSubinitialAndSubfinalIndicesText;
+ private Text lengthUsedForSubanyIndicesText;
+ private Text stepsUsedInSubanyIndexLookupsText;
+ private Text authUsernamesToDnRewriteRuleText;
+ private Text proxyAuthorizationPolicyText;
+ private Text authzUsernamesToDnRegexpText;
+
+
+ /**
+ * Creates a new instance of GeneralPage.
+ *
+ * @param editor
+ * the associated editor
+ */
+ public OptionsPage( ServerConfigurationEditor editor )
+ {
+ super( editor, ID, TITLE );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createFormContent( Composite parent, FormToolkit toolkit )
+ {
+ TableWrapLayout twl = new TableWrapLayout();
+ twl.numColumns = 2;
+ twl.makeColumnsEqualWidth = true;
+ parent.setLayout( twl );
+
+ Composite leftComposite = toolkit.createComposite( parent );
+ leftComposite.setLayout( new GridLayout() );
+ TableWrapData leftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
+ leftCompositeTableWrapData.grabHorizontal = true;
+ leftComposite.setLayoutData( leftCompositeTableWrapData );
+
+ Composite rightComposite = toolkit.createComposite( parent );
+ rightComposite.setLayout( new GridLayout() );
+ TableWrapData rightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
+ rightCompositeTableWrapData.grabHorizontal = true;
+ rightComposite.setLayoutData( rightCompositeTableWrapData );
+
+ createLogsSection( toolkit, leftComposite );
+ createAuthenticationAndAuthorizationSection( toolkit, leftComposite );
+ createConnectionLimitsSection( toolkit, leftComposite );
+ createIndicesSection( toolkit, leftComposite );
+ createSaslSection( toolkit, rightComposite );
+ createSocketAndBufferLimitsSection( toolkit, rightComposite );
+ createThreadsSection( toolkit, rightComposite );
+ createTlsSection( toolkit, rightComposite );
+
+ refreshUI();
+ }
+
+
+ /**
+ * Creates the Logs section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createLogsSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Logs" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Log File Text
+ toolkit.createLabel( composite, "Log File:" );
+ logFileText = toolkit.createText( composite, "" );
+ logFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Log Level Text
+ toolkit.createLabel( composite, "Log Level:" );
+ logLevelText = toolkit.createText( composite, "" );
+ logLevelText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the Socket & Buffer Limits section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createSocketAndBufferLimitsSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Socket & Buffer Limits" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Max PDU Size Anonymous Sessions Text
+ toolkit.createLabel( composite, "Maximum incoming LDAP PDU size for anonymous sessions:" );
+ maxPduSizeAnonymousSessionsText = toolkit.createText( composite, "" );
+ maxPduSizeAnonymousSessionsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Max PDU Size Authenticated Sessions Text
+ toolkit.createLabel( composite, "Maximum incoming LDAP PDU size for authenticated sessions:" );
+ maxPduSizeAuthenticatedSessionsText = toolkit.createText( composite, "" );
+ maxPduSizeAuthenticatedSessionsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // TCP Buffer Size Text
+ toolkit.createLabel( composite, "TCP Buffer Size:" );
+ tcpBufferSizeText = toolkit.createText( composite, "" );
+ tcpBufferSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the Connection Limits section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createConnectionLimitsSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Connection Limits" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Max Pending Requests Anonymous Session Text
+ toolkit.createLabel( composite, "Maximum number of pending requests for an anonymous session:" );
+ maxPendingRequestsAnonymousSessionText = toolkit.createText( composite, "" );
+ maxPendingRequestsAnonymousSessionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Max Pending Requests Authenticated Session Text
+ toolkit.createLabel( composite, "Maximum number of pending requests for an authenticated session:" );
+ maxPendingRequestsAuthenticatedSessionText = toolkit.createText( composite, "" );
+ maxPendingRequestsAuthenticatedSessionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Number Seconds Closing Idle Connection Text
+ toolkit.createLabel( composite, "Number of seconds before closing an idle connection:" );
+ numberSecondsClosingIdleConnectionText = toolkit.createText( composite, "" );
+ numberSecondsClosingIdleConnectionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Number Seconds Closing Connection With Outstanding Write Text
+ toolkit.createLabel( composite, "Number of seconds before closing a connection with an outstanding write:" );
+ numberSecondsClosingConnectionWithOutstandingWriteText = toolkit.createText( composite, "" );
+ numberSecondsClosingConnectionWithOutstandingWriteText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true,
+ false ) );
+ }
+
+
+ /**
+ * Creates the Threads section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createThreadsSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Threads" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Level Of Concurrency Text
+ toolkit.createLabel( composite, "Level of concurrency:" );
+ levelOfConcurrencyText = toolkit.createText( composite, "" );
+ levelOfConcurrencyText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Maximum Number Of Threads
+ toolkit.createLabel( composite, "Maximum number of threads:" );
+ maximumNumberOfThreadsText = toolkit.createText( composite, "" );
+ maximumNumberOfThreadsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Maximum Number Of Threads In Tool Mode Text
+ toolkit.createLabel( composite, "Maximum number of threads in tool mode:" );
+ maximumNumberOfThreadsInToolModeText = toolkit.createText( composite, "" );
+ maximumNumberOfThreadsInToolModeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the SASL section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createSaslSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "SASL" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Authentication Auxprop Plugins Text
+ toolkit.createLabel( composite, "Authentication auxprop plugins:" );
+ authenticationAuxpropPluginsText = toolkit.createText( composite, "" );
+ authenticationAuxpropPluginsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // SASL Host Text
+ toolkit.createLabel( composite, "SASL host:" );
+ saslHostText = toolkit.createText( composite, "" );
+ saslHostText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // SASL Realm Text
+ toolkit.createLabel( composite, "SASL realm:" );
+ saslRealmText = toolkit.createText( composite, "" );
+ saslRealmText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // SASL Security Properties Text
+ toolkit.createLabel( composite, "SASL security properties:" );
+ saslSecurityPropertiesText = toolkit.createText( composite, "" );
+ saslSecurityPropertiesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the TLS section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createTlsSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "TLS" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Certificate Authorities File Text
+ toolkit.createLabel( composite, "Certificate Authorities file:" );
+ certificateAuthoritiesFileText = toolkit.createText( composite, "" );
+ certificateAuthoritiesFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Certificate Authorities Path Text
+ toolkit.createLabel( composite, "Certificate Authorities path:" );
+ certificateAuthoritiesPathText = toolkit.createText( composite, "" );
+ certificateAuthoritiesPathText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Server Certificate File Text
+ toolkit.createLabel( composite, "Server certificate file:" );
+ serverCertificateFileText = toolkit.createText( composite, "" );
+ serverCertificateFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Server Private Key File Text
+ toolkit.createLabel( composite, "Server private key file:" );
+ serverPrivateKeyFileText = toolkit.createText( composite, "" );
+ serverPrivateKeyFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Cipher Suite Text
+ toolkit.createLabel( composite, "Cipher suite:" );
+ cipherSuiteText = toolkit.createText( composite, "" );
+ cipherSuiteText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Certificate Revocation List File Text
+ toolkit.createLabel( composite, "Certificate revocation list file:" );
+ certificateRevocationListFileText = toolkit.createText( composite, "" );
+ certificateRevocationListFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Certificate Revocation List Level Text
+ toolkit.createLabel( composite, "Certificate revocation list level:" );
+ certificateRevocationListLevelText = toolkit.createText( composite, "" );
+ certificateRevocationListLevelText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Diffie-Hellman Parameters File Text
+ toolkit.createLabel( composite, "Diffie-Hellman parameters file:" );
+ diffieHellmanParametersFileText = toolkit.createText( composite, "" );
+ diffieHellmanParametersFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Random Bits File Text
+ toolkit.createLabel( composite, "Certificate revocation list level:" );
+ randomBitsFileText = toolkit.createText( composite, "" );
+ randomBitsFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Incoming Certificates Verification Level Text
+ toolkit.createLabel( composite, "Incoming certificates verification level:" );
+ incomingCertificatesVerificationLevelText = toolkit.createText( composite, "" );
+ incomingCertificatesVerificationLevelText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the Indices section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createIndicesSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Indices" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Key Length for Ordered Integer Indices Text
+ toolkit.createLabel( composite, "Key length for ordered integer indices:" );
+ keyLengthForOrderedIntegerIndicesText = toolkit.createText( composite, "" );
+ keyLengthForOrderedIntegerIndicesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Maximum Length For Subinitial And Subfinal Indices Text
+ toolkit.createLabel( composite, "Maximum length for subinitial and subfinal indices:" );
+ maximumLengthForSubinitialAndSubfinalIndicesText = toolkit.createText( composite, "" );
+ maximumLengthForSubinitialAndSubfinalIndicesText
+ .setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Minimum Length For Subinitial And Subfinal Indices Text
+ toolkit.createLabel( composite, "Minimum length for subinitial and subfinal indices:" );
+ minimumLengthForSubinitialAndSubfinalIndicesText = toolkit.createText( composite, "" );
+ minimumLengthForSubinitialAndSubfinalIndicesText
+ .setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Length Used For Subany Indices Text
+ toolkit.createLabel( composite, "Length used for subany indices:" );
+ lengthUsedForSubanyIndicesText = toolkit.createText( composite, "" );
+ lengthUsedForSubanyIndicesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Steps Used In Subany Index Lookups Text
+ toolkit.createLabel( composite, "Steps used in subany index lookups:" );
+ stepsUsedInSubanyIndexLookupsText = toolkit.createText( composite, "" );
+ stepsUsedInSubanyIndexLookupsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates the Authentication & Authorization section.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ */
+ private void createAuthenticationAndAuthorizationSection( FormToolkit toolkit, Composite parent )
+ {
+ Section section = createSection( toolkit, parent, "Authentication & Authorization" );
+ Composite composite = createSectionComposite( toolkit, section, 2, false );
+
+ // Authentication Usernames To DN Rewrite Rule Text
+ toolkit.createLabel( composite, "Authentication rewrite rule to convert simple user names to an LDAP DN:" );
+ authUsernamesToDnRewriteRuleText = toolkit.createText( composite, "" );
+ authUsernamesToDnRewriteRuleText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Proxy Authorization Policy Text
+ toolkit.createLabel( composite, "Proxy authorization policy text:" );
+ proxyAuthorizationPolicyText = toolkit.createText( composite, "" );
+ proxyAuthorizationPolicyText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Authorization Usernames To DN Regexp Text
+ toolkit.createLabel( composite, "Authorization Regexp to convert simple user names to an LDAP DN:" );
+ authzUsernamesToDnRegexpText = toolkit.createText( composite, "" );
+ authzUsernamesToDnRegexpText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Creates a section with the given text.
+ *
+ * @param toolkit the toolkit
+ * @param parent the parent composite
+ * @param text the text
+ * @return a section with the given text
+ */
+ private Section createSection( FormToolkit toolkit, Composite parent, String text )
+ {
+ Section section = toolkit.createSection( parent, Section.TITLE_BAR );
+ section.setText( text );
+ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ return section;
+ }
+
+
+ /**
+ * Creates a composite for the given section.
+ *
+ * @param toolkit the toolkit
+ * @param section the section
+ * @param numColumns the number of columns in the grid
+ * @param makeColumnsEqualWidth whether or not the columns will have equal width
+ *
+ * @return a composite for the given section.
+ */
+ private Composite createSectionComposite( FormToolkit toolkit, Section section, int numColumns,
+ boolean makeColumnsEqualWidth )
+ {
+ Composite composite = toolkit.createComposite( section );
+ toolkit.paintBordersFor( composite );
+ GridLayout gridLayout = new GridLayout( numColumns, makeColumnsEqualWidth );
+ gridLayout.marginHeight = gridLayout.marginWidth = 0;
+ composite.setLayout( gridLayout );
+ section.setClient( composite );
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void refreshUI()
+ {
+ if ( isInitialized() )
+ {
+ // Getting the global configuration object
+ OlcGlobal global = getConfiguration().getGlobal();
+
+ if ( global != null )
+ {
+ //
+ // Assigning values to UI Controls
+ //
+
+ // Log File Text
+ String logFile = global.getOlcLogFile();
+
+ if ( logFile != null )
+ {
+ logFileText.setText( logFile );
+ }
+ else
+ {
+ logFileText.setText( "" );
+ }
+
+ // Log Level Text
+ List<String> logLevel = global.getOlcLogLevel();
+
+ if ( logLevel != null )
+ {
+ logLevelText.setText( logLevel + "" );
+ }
+ else
+ {
+ logLevelText.setText( "" );
+ }
+
+ // Max PDU Size Anonymous Sessions Text
+ String maxPduSizeAnonymousSessions = global.getOlcSockbufMaxIncoming();
+
+ if ( maxPduSizeAnonymousSessions != null )
+ {
+ maxPduSizeAnonymousSessionsText.setText( maxPduSizeAnonymousSessions );
+ }
+ else
+ {
+ maxPduSizeAnonymousSessionsText.setText( "");
+ }
+
+ // Max PDU Size Authenticated Sessions Text
+ String maxPduSizeAuthenticatedSessions = global.getOlcSockbufMaxIncomingAuth();
+
+ if ( maxPduSizeAuthenticatedSessions != null )
+ {
+ maxPduSizeAuthenticatedSessionsText.setText( maxPduSizeAuthenticatedSessions );
+ }
+ else
+ {
+ maxPduSizeAuthenticatedSessionsText.setText( "");
+ }
+
+ // TCP Buffer Size Text
+ List<String> tcpBufferSize = global.getOlcTCPBuffer();
+
+ if ( maxPduSizeAuthenticatedSessions != null )
+ {
+ tcpBufferSizeText.setText( tcpBufferSize + "" );
+ }
+ else
+ {
+ tcpBufferSizeText.setText( "");
+ }
+
+ // Max Pending Requests Anonymous Session Text
+ Integer maxPendingRequestsAnonymousSession = global.getOlcConnMaxPending();
+
+ if ( maxPendingRequestsAnonymousSession != null )
+ {
+ maxPendingRequestsAnonymousSessionText.setText( maxPendingRequestsAnonymousSession + "" );
+ }
+ else
+ {
+ maxPendingRequestsAnonymousSessionText.setText( "");
+ }
+
+ // Max Pending Requests Authenticated Session Text
+ Integer maxPendingRequestsAuthenticatedSession = global.getOlcConnMaxPendingAuth();
+
+ if ( maxPendingRequestsAuthenticatedSession != null )
+ {
+ maxPendingRequestsAuthenticatedSessionText.setText( maxPendingRequestsAuthenticatedSession + "" );
+ }
+ else
+ {
+ maxPendingRequestsAuthenticatedSessionText.setText( "");
+ }
+
+ // Number Seconds Closing Idle Connection Text
+ Integer numberSecondsClosingIdleConnection = global.getOlcIdleTimeout();
+
+ if ( numberSecondsClosingIdleConnection != null )
+ {
+ numberSecondsClosingIdleConnectionText.setText( numberSecondsClosingIdleConnection + "" );
+ }
+ else
+ {
+ numberSecondsClosingIdleConnectionText.setText( "");
+ }
+
+ // Number Seconds Closing Connection With Outstanding Write Text
+ Integer numberSecondsClosingConnectionWithOutstandingWrite = global.getOlcWriteTimeout();
+
+ if ( numberSecondsClosingConnectionWithOutstandingWrite != null )
+ {
+ numberSecondsClosingConnectionWithOutstandingWriteText
+ .setText( numberSecondsClosingConnectionWithOutstandingWrite + "" );
+ }
+ else
+ {
+ numberSecondsClosingConnectionWithOutstandingWriteText.setText( "");
+ }
+
+ // Level Of Concurrency Text
+ Integer levelOfConcurrency = global.getOlcConcurrency();
+
+ if ( levelOfConcurrency != null )
+ {
+ levelOfConcurrencyText.setText( levelOfConcurrency + "" );
+ }
+ else
+ {
+
+ levelOfConcurrencyText.setText( "");
+ }
+
+ // Maximum Number Of Threads
+ Integer maximumNumberOfThreads = global.getOlcThreads();
+ if ( maximumNumberOfThreads != null )
+ {
+ maximumNumberOfThreadsText.setText( maximumNumberOfThreads + "" );
+ }
+ else
+ {
+ maximumNumberOfThreadsText.setText( "");
+ }
+
+ // Maximum Number Of Threads In Tool Mode Text
+ Integer maximumNumberOfThreadsInToolMode = global.getOlcToolThreads();
+
+ if ( maximumNumberOfThreadsInToolMode != null )
+ {
+ maximumNumberOfThreadsInToolModeText.setText( maximumNumberOfThreadsInToolMode + "" );
+ }
+ else
+ {
+ maximumNumberOfThreadsInToolModeText.setText( "");
+ }
+
+ // Authentication Auxprop Plugins Text
+ String authenticationAuxpropPlugins = global.getOlcSaslAuxprops();
+
+ if ( authenticationAuxpropPlugins != null )
+ {
+ authenticationAuxpropPluginsText.setText( authenticationAuxpropPlugins );
+ }
+ else
+ {
+ authenticationAuxpropPluginsText.setText( "");
+ }
+
+ // SASL Host Text
+ String saslHost = global.getOlcSaslHost();
+
+ if ( saslHost != null )
+ {
+ saslHostText.setText( saslHost );
+ }
+ else
+ {
+ saslHostText.setText( "");
+ }
+
+ // SASL Realm Text
+ String saslRealm = global.getOlcSaslRealm();
+
+ if ( saslRealm != null )
+ {
+ saslRealmText.setText( saslRealm );
+ }
+ else
+ {
+ saslRealmText.setText( "");
+ }
+
+ // SASL Security Properties Text
+ String saslSecurityProperties = global.getOlcSaslSecProps();
+
+ if ( saslSecurityProperties != null )
+ {
+ saslSecurityPropertiesText.setText( saslSecurityProperties );
+ }
+ else
+ {
+ saslSecurityPropertiesText.setText( "");
+ }
+
+ // Certificate Authorities File Text
+ String certificateAuthoritiesFile = global.getOlcTLSCACertificateFile();
+
+ if ( certificateAuthoritiesFile != null )
+ {
+ certificateAuthoritiesFileText.setText( certificateAuthoritiesFile );
+ }
+ else
+ {
+ certificateAuthoritiesFileText.setText( "");
+ }
+
+ // Certificate Authorities Path Text
+ String certificateAuthoritiesPath = global.getOlcTLSCACertificatePath();
+
+ if ( certificateAuthoritiesPath != null )
+ {
+ certificateAuthoritiesPathText.setText( certificateAuthoritiesPath );
+ }
+ else
+ {
+ certificateAuthoritiesPathText.setText( "");
+ }
+
+ // Server Certificate File Text
+ String serverCertificateFile = global.getOlcTLSCertificateFile();
+
+ if ( serverCertificateFile != null )
+ {
+ serverCertificateFileText.setText( serverCertificateFile );
+ }
+ else
+ {
+ serverCertificateFileText.setText( "");
+ }
+
+ // Server Private Key File Text
+ String serverPrivateKeyFile = global.getOlcTLSCertificateKeyFile();
+
+ if ( serverPrivateKeyFile != null )
+ {
+ serverPrivateKeyFileText.setText( serverPrivateKeyFile );
+ }
+ else
+ {
+ serverPrivateKeyFileText.setText( "");
+ }
+
+ // Cipher Suite Text
+ String cipherSuite = global.getOlcTLSCipherSuite();
+
+ if ( cipherSuite != null )
+ {
+ cipherSuiteText.setText( cipherSuite );
+ }
+ else
+ {
+ cipherSuiteText.setText( "");
+ }
+
+ // Certificate Revocation List File Text
+ String certificateRevocationListFile = global.getOlcTLSCRLFile();
+
+ if ( certificateRevocationListFile != null )
+ {
+ certificateRevocationListFileText.setText( certificateRevocationListFile );
+ }
+ else
+ {
+ certificateRevocationListFileText.setText( "" );
+ }
+
+ // Certificate Revocation List Level Text
+ String certificateRevocationListLevel = global.getOlcTLSCRLCheck();
+
+ if ( certificateRevocationListLevel != null )
+ {
+ certificateRevocationListLevelText.setText( certificateRevocationListLevel );
+ }
+ else
+ {
+ certificateRevocationListLevelText.setText( "");
+ }
+
+ // Diffie-Hellman Parameters File Text
+ String diffieHellmanParametersFile = global.getOlcTLSDHParamFile();
+
+ if ( diffieHellmanParametersFile != null )
+ {
+ diffieHellmanParametersFileText.setText( diffieHellmanParametersFile );
+ }
+ else
+ {
+ diffieHellmanParametersFileText.setText( "");
+ }
+
+ // Random Bits File Text
+ String randomBitsFile = global.getOlcTLSRandFile();
+
+ if ( randomBitsFile != null )
+ {
+ randomBitsFileText.setText( randomBitsFile );
+ }
+ else
+ {
+ randomBitsFileText.setText( "");
+ }
+
+ // Incoming Certificates Verification Level Text
+ String incomingCertificatesVerificationLevel = global.getOlcTLSVerifyClient();
+
+ if ( incomingCertificatesVerificationLevel != null )
+ {
+ incomingCertificatesVerificationLevelText.setText( incomingCertificatesVerificationLevel );
+ }
+ else
+ {
+ incomingCertificatesVerificationLevelText.setText( "");
+ }
+
+ // Key Length for Ordered Integer Indices Text
+ Integer keyLengthForOrderedIntegerIndices = global.getOlcIndexIntLen();
+
+ if ( keyLengthForOrderedIntegerIndices != null )
+ {
+ keyLengthForOrderedIntegerIndicesText.setText( keyLengthForOrderedIntegerIndices + "" );
+ }
+ else
+ {
+ keyLengthForOrderedIntegerIndicesText.setText( "");
+ }
+
+ // Maximum Length For Subinitial And Subfinal Indices Text
+ Integer maximumLengthForSubinitialAndSubfinalIndices = global.getOlcIndexSubstrIfMaxLen();
+
+ if ( maximumLengthForSubinitialAndSubfinalIndices != null )
+ {
+ maximumLengthForSubinitialAndSubfinalIndicesText
+ .setText( maximumLengthForSubinitialAndSubfinalIndices + "" );
+ }
+ else
+ {
+ maximumLengthForSubinitialAndSubfinalIndicesText.setText( "");
+ }
+
+ // Minimum Length For Subinitial And Subfinal Indices Text
+ Integer minimumLengthForSubinitialAndSubfinalIndices = global.getOlcIndexSubstrIfMinLen();
+
+ if ( minimumLengthForSubinitialAndSubfinalIndices != null )
+ {
+ minimumLengthForSubinitialAndSubfinalIndicesText
+ .setText( minimumLengthForSubinitialAndSubfinalIndices + "" );
+ }
+ else
+ {
+ minimumLengthForSubinitialAndSubfinalIndicesText.setText( "");
+ }
+
+ // Length Used For Subany Indices Text
+ Integer lengthUsedForSubanyIndices = global.getOlcIndexSubstrAnyLen();
+ if ( lengthUsedForSubanyIndices != null )
+ {
+ lengthUsedForSubanyIndicesText.setText( lengthUsedForSubanyIndices + "" );
+ }
+ else
+ {
+ lengthUsedForSubanyIndicesText.setText( "");
+ }
+
+ // Steps Used In Subany Index Lookups Text
+ Integer stepsUsedInSubanyIndexLookups = global.getOlcIndexSubstrAnyStep();
+
+ if ( stepsUsedInSubanyIndexLookups != null )
+ {
+ stepsUsedInSubanyIndexLookupsText.setText( stepsUsedInSubanyIndexLookups + "" );
+ }
+ else
+ {
+ stepsUsedInSubanyIndexLookupsText.setText( "");
+ }
+
+ // Authentication Usernames To DN Rewrite Rule Text
+ List<String> authUsernamesToDnRewriteRule = global.getOlcAuthIDRewrite();
+
+ if ( authUsernamesToDnRewriteRule != null )
+ {
+ authUsernamesToDnRewriteRuleText.setText( authUsernamesToDnRewriteRule + "" );
+ }
+ else
+ {
+ authUsernamesToDnRewriteRuleText.setText( "");
+ }
+
+ // Proxy Authorization Policy Text
+ String proxyAuthorizationPolicy = global.getOlcAuthzPolicy();
+
+ if ( proxyAuthorizationPolicy != null )
+ {
+ proxyAuthorizationPolicyText.setText( proxyAuthorizationPolicy );
+ }
+ else
+ {
+ proxyAuthorizationPolicyText.setText( "");
+ }
+
+ // Authorization Usernames To DN Regexp Text
+ List<String> authzUsernamesToDnRegexp = global.getOlcAuthzRegexp();
+
+ if ( authzUsernamesToDnRegexp != null )
+ {
+ authzUsernamesToDnRegexpText.setText( authzUsernamesToDnRegexp + "" );
+ }
+ else
+ {
+ authzUsernamesToDnRegexpText.setText( "");
+ }
+ }
+ }
+ }
+}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OverviewPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OverviewPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OverviewPage.java Wed Apr 1 01:01:42 2015
@@ -29,6 +29,8 @@ import org.eclipse.ui.forms.widgets.Tabl
/**
* This class represents the General Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OverviewPage extends ServerConfigurationEditorPage
{
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditor.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditor.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditor.java Wed Apr 1 01:01:42 2015
@@ -25,6 +25,7 @@ import java.util.Enumeration;
import org.apache.directory.studio.common.core.jobs.StudioJob;
import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
+import org.apache.directory.studio.connection.core.Connection;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
@@ -38,7 +39,6 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
import org.apache.directory.studio.openldap.config.editor.databases.DatabasesPage;
-import org.apache.directory.studio.openldap.config.editor.overlays.OverlaysPage;
import org.apache.directory.studio.openldap.config.jobs.LoadConfigurationRunnable;
import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration;
import org.apache.directory.studio.openldap.config.model.io.SaveConfigurationRunnable;
@@ -46,6 +46,8 @@ import org.apache.directory.studio.openl
/**
* This class implements the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ServerConfigurationEditor extends FormEditor implements IPageChangedListener
{
@@ -60,9 +62,8 @@ public class ServerConfigurationEditor e
// The pages
private LoadingPage loadingPage;
- private OverviewPage overviewPage;
private DatabasesPage databasesPage;
- private OverlaysPage overlaysPage;
+ private OptionsPage optionsPage;
/**
@@ -86,7 +87,7 @@ public class ServerConfigurationEditor e
{
// Creating and scheduling the job to load the configuration
StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
- new LoadConfigurationRunnable( this ) );
+ new LoadConfigurationRunnable( this ) );
job.schedule();
}
@@ -151,6 +152,10 @@ public class ServerConfigurationEditor e
*/
public void doSave( IProgressMonitor monitor )
{
+ // Saving pages
+ doSavePages( monitor );
+
+ // Saving the configuration using a job
StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
new SaveConfigurationRunnable( this ) );
job.schedule();
@@ -196,15 +201,16 @@ public class ServerConfigurationEditor e
* the monitor to use
* @throws Exception
*/
- public boolean doSaveAs( IProgressMonitor monitor ) throws Exception
+ public void doSaveAs( IProgressMonitor monitor ) throws Exception
{
+ // Saving pages
+ doSavePages( monitor );
+
// Saving the configuration as a new file and getting the associated new editor input
- IEditorInput newInput = null; //ServerConfigurationEditorUtils.saveAs( monitor, getSite().getShell(),
- //getEditorInput(), getConfigWriter() );
+ IEditorInput newInput = ServerConfigurationEditorUtils.saveAs( getConfiguration(), true );
// Checking if the 'save as' is successful
- boolean success = newInput != null;
- if ( success )
+ if ( newInput != null )
{
// Setting the new input to the editor
setInput( newInput );
@@ -221,8 +227,20 @@ public class ServerConfigurationEditor e
}
} );
}
+ }
- return success;
+
+ /**
+ * Saves the pages.
+ *
+ * @param monitor the monitor
+ */
+ private void doSavePages( IProgressMonitor monitor )
+ {
+ if ( databasesPage != null )
+ {
+ databasesPage.doSave( monitor );
+ }
}
@@ -300,13 +318,8 @@ public class ServerConfigurationEditor e
setDirty( true );
- overviewPage.refreshUI();
+ optionsPage.refreshUI();
databasesPage.refreshUI();
- overlaysPage.refreshUI();
- // ldapLdapsServersPage.refreshUI();
- // kerberosServerPage.refreshUI();
- // partitionsPage.refreshUI();
- // replicationPage.refreshUI();
}
@@ -353,17 +366,14 @@ public class ServerConfigurationEditor e
// Adding the configuration pages
try
{
- overviewPage = new OverviewPage( this );
- addPage( overviewPage );
databasesPage = new DatabasesPage( this );
addPage( databasesPage );
- overlaysPage = new OverlaysPage( this );
- addPage( overlaysPage );
+ optionsPage = new OptionsPage( this );
+ addPage( optionsPage );
}
catch ( PartInitException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ // Will never happen
}
// Activating the first page
@@ -410,7 +420,7 @@ public class ServerConfigurationEditor e
{
if ( pageClass != null )
{
- Enumeration<Object> enumeration = pages.elements();
+ Enumeration<?> enumeration = pages.elements();
while ( enumeration.hasMoreElements() )
{
Object page = enumeration.nextElement();
@@ -422,4 +432,22 @@ public class ServerConfigurationEditor e
}
}
}
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ public Connection getConnection()
+ {
+ IEditorInput editorInput = getEditorInput();
+
+ if ( editorInput instanceof ConnectionServerConfigurationInput )
+ {
+ return ( ( ConnectionServerConfigurationInput ) editorInput ).getConnection();
+ }
+
+ return null;
+ }
}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorPage.java Wed Apr 1 01:01:42 2015
@@ -44,16 +44,23 @@ import org.eclipse.ui.forms.editor.FormP
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.apache.directory.studio.openldap.config.actions.EditorExportConfigurationAction;
+import org.apache.directory.studio.openldap.config.actions.EditorImportConfigurationAction;
import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration;
/**
* This class represents the General Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class ServerConfigurationEditorPage extends FormPage
{
protected static final Color GRAY_COLOR = new Color( null, 120, 120, 120 );
protected static final String TABULATION = " ";
+
+ /** A flag to indicate if the page is initialized */
+ protected boolean isInitialized = false;
private ModifyListener dirtyModifyListener = new ModifyListener()
{
@@ -142,13 +149,15 @@ public abstract class ServerConfiguratio
ServerConfigurationEditor editor = ( ServerConfigurationEditor ) getEditor();
IToolBarManager toolbarManager = form.getToolBarManager();
- // toolbarManager.add( new EditorImportConfigurationAction( editor ) );
+ toolbarManager.add( new EditorImportConfigurationAction( editor ) );
toolbarManager.add( new Separator() );
- // toolbarManager.add( new EditorExportConfigurationAction( editor ) );
+ toolbarManager.add( new EditorExportConfigurationAction( editor ) );
toolbarManager.update( true );
createFormContent( parent, toolkit );
+
+ isInitialized = true;
}
@@ -167,6 +176,17 @@ public abstract class ServerConfiguratio
* Refreshes the UI.
*/
protected abstract void refreshUI();
+
+ /**
+ * Indicates if the page is initialized.
+ *
+ * @return <code>true</code> if the page is initialized,
+ * <code>false</code> if not.
+ */
+ public boolean isInitialized()
+ {
+ return isInitialized;
+ }
/**
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorUtils.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorUtils.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationEditorUtils.java Wed Apr 1 01:01:42 2015
@@ -20,46 +20,46 @@
package org.apache.directory.studio.openldap.config.editor;
-import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.List;
+import java.util.UUID;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.csn.CsnFactory;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.ObjectClass;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
-import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader;
-import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.api.ldap.model.schema.registries.ObjectClassRegistry;
+import org.apache.directory.api.ldap.util.tree.DnNode;
+import org.apache.directory.api.util.DateUtils;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.filesystem.PathEditorInput;
-import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPathEditorInput;
-import org.eclipse.ui.dialogs.SaveAsDialog;
-import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.PlatformUI;
-import org.apache.directory.studio.openldap.config.ConnectionSchemaLoader;
+import org.apache.directory.studio.openldap.config.ExpandedLdifUtils;
import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition;
import org.apache.directory.studio.openldap.config.jobs.PartitionsDiffComputer;
+import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration;
+import org.apache.directory.studio.openldap.config.model.io.ConfigurationException;
+import org.apache.directory.studio.openldap.config.model.io.ConfigurationReader;
+import org.apache.directory.studio.openldap.config.model.io.ConfigurationUtils;
import org.apache.directory.studio.openldap.config.model.io.ConfigurationWriter;
@@ -73,158 +73,129 @@ public class ServerConfigurationEditorUt
/**
* Performs the "Save as..." action.
*
- * @param monitor
- * the monitor
- * @param shell
- * the shell
- * @param input
- * the editor input
- * @param configurationWriter
- * the configuration writer
+ * @param configuration
+ * the configuration
+ * @param newInput
+ * a flag to indicate if a new input is required
* @return
* the new input for the editor
* @throws Exception
*/
- public static IEditorInput saveAs( IProgressMonitor monitor, Shell shell, IEditorInput input,
- ConfigurationWriter configurationWriter )
- throws Exception
+ public static IEditorInput saveAs( OpenLdapConfiguration configuration, boolean newInput ) throws Exception
{
- // detect IDE or RCP:
- // check if perspective org.eclipse.ui.resourcePerspective is available
- boolean isIDE = CommonUIUtils.isIDEEnvironment();
+ // The path of the directory
+ String path = null;
- if ( isIDE )
+ // Creating a dialog for directory selection
+ DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell(), SWT.SAVE );
+
+ while ( true )
{
- // Asking the user for the location where to 'save as' the file
- final SaveAsDialog dialog = new SaveAsDialog( shell );
+ // Opening the dialog
+ path = openDirectoryDialogInUIThread( dialog );
- String inputClassName = input.getClass().getName();
- if ( input instanceof FileEditorInput )
- // FileEditorInput class is used when the file is opened
- // from a project in the workspace.
+ // Checking the returned path
+ if ( path == null )
{
- dialog.setOriginalFile( ( ( FileEditorInput ) input ).getFile() );
- }
- else if ( input instanceof IPathEditorInput )
- {
- dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
- .getFile( ( ( IPathEditorInput ) input ).getPath() ) );
+ // Cancel button has been clicked
+ return null;
}
- else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" ) //$NON-NLS-1$
- || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) ) //$NON-NLS-1$
- // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
- // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
- // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
- // opening a file from the menu File > Open... in Eclipse 3.3.x
+
+ // Getting the directory indicated by the user
+ final File directory = new File( path );
+
+ // Checking if the directory exists
+ if ( !directory.exists() )
{
- dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
- .getFile( new Path( input.getToolTipText() ) ) );
+ CommonUIUtils.openErrorDialog( "The directory does not exist." );
+ continue;
}
- else
+
+ // Checking if the location is a directory
+ if ( !directory.isDirectory() )
{
- dialog.setOriginalName( "config.ldif" );
+ CommonUIUtils.openErrorDialog( "The location is not a directory." );
+ continue;
}
- // Open the dialog
- if ( openDialogInUIThread( dialog ) != Dialog.OK )
+ // Checking if the directory is writable
+ if ( !directory.canWrite() )
{
- return null;
+ CommonUIUtils.openErrorDialog( "The directory is not writable." );
+ continue;
}
- // Getting if the resulting file
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult() );
-
- // Creating the file if it does not exist
- if ( !file.exists() )
+ // Checking if the directory is empty
+ if ( !isEmpty( directory ) )
{
- file.create( new ByteArrayInputStream( "".getBytes() ), true, null ); //$NON-NLS-1$
+ CommonUIUtils.openErrorDialog( "The directory is not empty." );
+ continue;
}
- // Creating the new input for the editor
- FileEditorInput fei = new FileEditorInput( file );
+ // The directory meets all requirements
+ break;
+ }
- // Saving the file to disk
- saveConfiguration( fei, configurationWriter, monitor );
+ // Saving the file to disk
+ saveConfiguration( configuration, new File( path ) );
- return fei;
+ // Checking if a new input is required
+ if ( newInput )
+ {
+ // Creating the new input for the editor
+ return new PathEditorInput( new Path( path ) );
}
else
{
- boolean canOverwrite = false;
- String path = null;
+ return null;
+ }
+ }
- while ( !canOverwrite )
- {
- // Open FileDialog
- final FileDialog dialog = new FileDialog( shell, SWT.SAVE );
- path = openFileDialogInUIThread( dialog );
- if ( path == null )
- {
- return null;
- }
- // Check whether file exists and if so, confirm overwrite
- final File externalFile = new File( path );
- if ( externalFile.exists() )
- {
- String question = NLS.bind(
- "The file \"{0}\" already exists. Do you want to replace the existing file?", path ); //$NON-NLS-1$
- MessageDialog overwriteDialog = new MessageDialog( shell, "Question", null, question, //$NON-NLS-1$
- MessageDialog.QUESTION, new String[]
- { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 );
- int overwrite = openDialogInUIThread( overwriteDialog );
- switch ( overwrite )
- {
- case 0: // Yes
- canOverwrite = true;
- break;
- case 1: // No
- break;
- case 2: // Cancel
- default:
- return null;
- }
- }
- else
+ private static boolean isEmpty( File directory )
+ {
+ if ( directory != null )
+ {
+ String[] children = directory.list( new FilenameFilter()
+ {
+ public boolean accept( File dir, String name )
{
- canOverwrite = true;
+ // Only accept visible files (which don't start with a dot).
+ return !name.startsWith( "." );
}
- }
-
- // Saving the file to disk
- saveConfiguration( path, configurationWriter );
+ } );
- // Creating the new input for the editor
- PathEditorInput newInput = new PathEditorInput( new Path( path ) );
-
- return newInput;
+ return ( ( children == null ) || ( children.length == 0 ) );
}
+
+ return false;
}
/**
- * Opens a {@link Dialog} in the UI thread.
+ * Opens a {@link DirectoryDialog} in the UI thread.
*
* @param dialog
- * the dialog
+ * the directory dialog
* @return
* the result of the dialog
*/
- private static int openDialogInUIThread( final Dialog dialog )
+ private static String openDirectoryDialogInUIThread( final DirectoryDialog dialog )
{
// Defining our own encapsulating class for the result
class DialogResult
{
- private int result;
+ private String result;
- public int getResult()
+ public String getResult()
{
return result;
}
- public void setResult( int result )
+ public void setResult( String result )
{
this.result = result;
}
@@ -247,66 +218,106 @@ public class ServerConfigurationEditorUt
/**
- * Opens a {@link FileDialog} in the UI thread.
+ * Saves the configuration.
*
- * @param dialog
- * the file dialog
- * @return
- * the result of the dialog
+ * @param configuration
+ * the configuration
+ * @param directory
+ * the directory
+ * @throws Exception
*/
- private static String openFileDialogInUIThread( final FileDialog dialog )
+ public static void saveConfiguration( OpenLdapConfiguration configuration, File directory ) throws Exception
{
- // Defining our own encapsulating class for the result
- class DialogResult
- {
- private String result;
+ saveConfiguration( null, configuration, directory );
+ }
- public String getResult()
- {
- return result;
- }
+ /**
+ * Saves the configuration.
+ *
+ * @param browserConnection
+ * the browser connection
+ * @param configuration
+ * the configuration
+ * @param directory
+ * the directory
+ * @throws Exception
+ */
+ public static void saveConfiguration( IBrowserConnection browserConnection, OpenLdapConfiguration configuration,
+ File directory ) throws Exception
+ {
+ // Creating the configuration writer
+ ConfigurationWriter configurationWriter = new ConfigurationWriter( browserConnection, configuration );
+ // Converting the configuration beans to entries
+ List<LdifEntry> entries = configurationWriter.getConvertedLdifEntries( ConfigurationUtils
+ .getDefaultConfigurationDn() );
- public void setResult( String result )
- {
- this.result = result;
- }
- }
+ // Creating a tree to store entries
+ DnNode<Entry> tree = new DnNode<Entry>();
- // Creating an object to hold the result
- final DialogResult result = new DialogResult();
+ CsnFactory csnFactory = new CsnFactory( 1 );
- // Opening the dialog in the UI thread
- Display.getDefault().syncExec( new Runnable()
+ for ( LdifEntry entry : entries )
{
- public void run()
- {
- result.setResult( dialog.open() );
- }
- } );
+ // Getting the current generalized time
+ String currentgeGeneralizedTime = DateUtils.getGeneralizedTime();
- return result.getResult();
+ // 'createTimestamp' attribute
+ entry.addAttribute( "createTimestamp", currentgeGeneralizedTime );
+
+ // 'creatorsName' attribute
+ entry.addAttribute( "creatorsName", "cn=config" );
+
+ // 'entryCSN' attribute
+ entry.addAttribute( "entryCSN", csnFactory.newInstance().toString() );
+
+ // 'entryUUID' attribute
+ entry.addAttribute( "entryUUID", UUID.randomUUID().toString() );
+
+ // 'modifiersName' attribute
+ entry.addAttribute( "modifiersName", "cn=config" );
+
+ // 'modifyTimestamp' attribute
+ entry.addAttribute( "modifyTimestamp", currentgeGeneralizedTime );
+
+ // 'structuralObjectClass' attribute
+ entry.addAttribute( "structuralObjectClass", getStructuralObjectClass( entry ) );
+
+ // Adding the entry to tree
+ tree.add( entry.getDn(), entry.getEntry() );
+ }
+
+ ExpandedLdifUtils.write( tree, directory );
}
/**
- * Saves the configuration.
+ * Gets the structural object class of the entry.
*
- * @param input
- * the file editor input
- * @param configurationWriter
- * the configuration writer
- * @param monitor
- * the monitor
- * @throws Exception
+ * @param ldifEntry the LDIF entry
+ * @return the structural object class of the entry
+ * @throws ConfigurationException
*/
- public static void saveConfiguration( FileEditorInput input, ConfigurationWriter configurationWriter,
- IProgressMonitor monitor )
- throws Exception
+ private static Object getStructuralObjectClass( LdifEntry ldifEntry ) throws ConfigurationException
{
- input.getFile().setContents( new ByteArrayInputStream( configurationWriter.writeToString().getBytes() ), true,
- true, monitor );
+ if ( ldifEntry != null )
+ {
+ Entry entry = ldifEntry.getEntry();
+
+ if ( entry != null )
+ {
+ ObjectClass structuralObjectClass = ConfigurationReader
+ .getHighestStructuralObjectClass( entry.get( SchemaConstants.OBJECT_CLASS_AT ) );
+
+ if ( structuralObjectClass != null )
+ {
+ return structuralObjectClass.getName();
+ }
+ }
+ }
+
+ return SchemaConstants.TOP_OC;
}
@@ -315,8 +326,8 @@ public class ServerConfigurationEditorUt
*
* @param input
* the connection server configuration input
- * @param configurationWriter
- * the configuration writer
+ * @param editor
+ * the editor
* @param monitor
* the monitor
* @return
@@ -324,102 +335,114 @@ public class ServerConfigurationEditorUt
* <code>false</code> if not
* @throws Exception
*/
- public static void saveConfiguration( ConnectionServerConfigurationInput input,
- ConfigurationWriter configurationWriter, IProgressMonitor monitor ) throws Exception
+ public static void saveConfiguration( ConnectionServerConfigurationInput input, ServerConfigurationEditor editor,
+ IProgressMonitor monitor ) throws Exception
{
+ // Getting the browser connection associated with the connection in the input
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( input.getConnection() );
+
+ // Creating the configuration writer
+ ConfigurationWriter configurationWriter = new ConfigurationWriter( browserConnection, editor.getConfiguration() );
+
// Getting the original configuration partition and its schema manager
EntryBasedConfigurationPartition originalPartition = input.getOriginalPartition();
SchemaManager schemaManager = originalPartition.getSchemaManager();
- // Creating a new configuration partition
- EntryBasedConfigurationPartition newconfigurationPartition = createConfigurationPartition( schemaManager,
- originalPartition.getSuffixDn() );
- for ( LdifEntry ldifEntry : configurationWriter.getConvertedLdifEntries() )
- {
- newconfigurationPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
- }
+ // Suspends event firing in current thread.
+ ConnectionEventRegistry.suspendEventFiringInCurrentThread();
- // Comparing both partitions to get the list of modifications to be applied
- PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer( originalPartition,
- newconfigurationPartition );
- List<LdifEntry> modificationsList = partitionsDiffComputer.computeModifications( new String[]
- { SchemaConstants.ALL_USER_ATTRIBUTES } );
-
- // Building the resulting LDIF
- StringBuilder modificationsLdif = new StringBuilder();
- for ( LdifEntry ldifEntry : modificationsList )
+ try
{
- modificationsLdif.append( ldifEntry.toString() );
- }
+ // Creating a new configuration partition
+ EntryBasedConfigurationPartition newconfigurationPartition = createConfigurationPartition( schemaManager,
+ originalPartition.getSuffixDn() );
+ for ( LdifEntry ldifEntry : configurationWriter.getConvertedLdifEntries() )
+ {
+ newconfigurationPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
+ }
- // Getting the browser connection associated with the
- IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
- .getBrowserConnection( input.getConnection() );
+ // Comparing both partitions to get the list of modifications to be applied
+ PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer( originalPartition,
+ newconfigurationPartition );
+ List<LdifEntry> modificationsList = partitionsDiffComputer.computeModifications( new String[]
+ { SchemaConstants.ALL_USER_ATTRIBUTES } );
- // Creating a StudioProgressMonitor to run the LDIF with
- StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new NullProgressMonitor() );
+ // Building the resulting LDIF
+ StringBuilder modificationsLdif = new StringBuilder();
+ for ( LdifEntry ldifEntry : modificationsList )
+ {
+ modificationsLdif.append( ldifEntry.toString() );
+ }
- // Updating the configuration with the resulting LDIF
- ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(), true, true,
- studioProgressMonitor );
+ // Creating a StudioProgressMonitor to run the LDIF with
+ StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new NullProgressMonitor() );
- // Checking if there were errors during the execution of the LDIF
- if ( studioProgressMonitor.errorsReported() )
- {
- StringBuilder message = new StringBuilder();
- message.append( "Changes could not be saved to the connection." );
+ // Updating the configuration with the resulting LDIF
+ ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(), true, true,
+ studioProgressMonitor );
- Exception exception = studioProgressMonitor.getException();
- if ( exception != null )
+ // Checking if there were errors during the execution of the LDIF
+ if ( studioProgressMonitor.errorsReported() )
{
- message.append( "\n\n" );
- message.append( "Cause: " );
- message.append( exception.getMessage() );
+ StringBuilder message = new StringBuilder();
+ message.append( "Changes could not be saved to the connection." );
- throw new Exception( message.toString(), exception );
+ Exception exception = studioProgressMonitor.getException();
+ if ( exception != null )
+ {
+ message.append( "\n\n" );
+ message.append( "Cause: " );
+ message.append( exception.getMessage() );
+
+ throw new Exception( message.toString(), exception );
+ }
+ else
+ {
+ throw new Exception( message.toString() );
+ }
}
else
{
- throw new Exception( message.toString() );
+ // Swapping the new configuration partition
+ input.setOriginalPartition( newconfigurationPartition );
}
}
- else
+ finally
{
- // Swapping the new configuration partition
- input.setOriginalPartition( newconfigurationPartition );
+ // Resumes event firing in current thread.
+ ConnectionEventRegistry.resumeEventFiringInCurrentThread();
}
}
- /**
- * Saves the configuration.
- *
- * @param file
- * the file
- * @param configWriter
- * the configuration writer
- * @throws Exception
- */
- public static void saveConfiguration( File file, ConfigurationWriter configurationWriter ) throws Exception
- {
- configurationWriter.writeToFile( file );
- }
-
-
- /**
- * Saves the configuration.
- *
- * @param path
- * the path
- * @param configWriter
- * the configuration writer
- * @throws Exception
- */
- public static void saveConfiguration( String path, ConfigurationWriter configurationWriter ) throws Exception
- {
- saveConfiguration( new File( path ), configurationWriter );
- }
-
+ // /**
+ // * Saves the configuration.
+ // *
+ // * @param file
+ // * the file
+ // * @param configWriter
+ // * the configuration writer
+ // * @throws Exception
+ // */
+ // public static void saveConfiguration( File file, ConfigurationWriter configurationWriter ) throws Exception
+ // {
+ // configurationWriter.writeToFile( file );
+ // }
+
+ // /**
+ // * Saves the configuration.
+ // *
+ // * @param path
+ // * the path
+ // * @param configWriter
+ // * the configuration writer
+ // * @throws Exception
+ // */
+ // public static void saveConfiguration( String path, ConfigurationWriter configurationWriter ) throws Exception
+ // {
+ // saveConfiguration( new File( path ), configurationWriter );
+ // }
/**
* Creates a configuration partition to store configuration entries.
@@ -441,27 +464,41 @@ public class ServerConfigurationEditorUt
/**
- * Creates a schema manager for the given connection.
+ * Gets the object class for the given name.
*
- * @param connection the connection
- * @return a schema manager for the given connection
- * @throws Exception
+ * @param schemaManager the schema manager
+ * @param name the name
+ * @return the object class for the given name
*/
- public static SchemaManager createSchemaManager( Connection connection ) throws Exception
+ public static ObjectClass getObjectClass( SchemaManager schemaManager, String name )
{
- // Initializing the schema loader and schema manager
- SchemaLoader loader = new ConnectionSchemaLoader( connection );
- SchemaManager schemaManager = new DefaultSchemaManager( loader );
+ // Checking the schema manager and name
+ if ( ( schemaManager != null ) && ( name != null ) )
+ {
+ try
+ {
+ // Getting the object class registry
+ ObjectClassRegistry ocRegistry = schemaManager.getObjectClassRegistry();
- // Loading only the connection schema with its dependencies
- schemaManager.loadWithDeps( ConnectionSchemaLoader.CONNECTION_SCHEMA_NAME );
+ if ( ocRegistry != null )
+ {
+ // Getting the oid from the object class name
+ String oid = ocRegistry.getOidByName( name );
- // Checking if no error occurred when loading the schemas
- if ( schemaManager.getErrors().size() != 0 )
- {
- throw new Exception( "Could not load the schema correctly." );
+ if ( oid != null )
+ {
+ // Getting the object class from the oid
+ return ocRegistry.get( oid );
+ }
+ }
+ }
+ catch ( LdapException e )
+ {
+ // No OID found for the given name
+ return null;
+ }
}
- return schemaManager;
+ return null;
}
}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java Wed Apr 1 01:01:42 2015
@@ -20,70 +20,32 @@
package org.apache.directory.studio.openldap.config.editor;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
-import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition;
/**
- * This class represents the Non Existing Server Configuration Input.
+ * This class represents the Server Configuration Input.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ServerConfigurationInput implements IEditorInput
+public interface ServerConfigurationInput extends IEditorInput
{
/**
- * {@inheritDoc}
+ * Gets the original configuration partition.
+ *
+ * @return
+ * the original configuration partition
*/
- public String getToolTipText()
- {
- return getName();
- }
+ public EntryBasedConfigurationPartition getOriginalPartition();
/**
- * {@inheritDoc}
+ * Sets the original configuration partition.
+ *
+ * @param originalPartition
+ * the original configuration
*/
- public String getName()
- {
- return "ServerConfigurationInput";
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean exists()
- {
- return true;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public ImageDescriptor getImageDescriptor()
- {
- return OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
- OpenLdapConfigurationPluginConstants.IMG_EDITOR );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public IPersistableElement getPersistable()
- {
- return null;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Object getAdapter( Class adapter )
- {
- return null;
- }
+ public void setOriginalPartition( EntryBasedConfigurationPartition originalPartition );
}