You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/08/27 08:57:23 UTC

svn commit: r689388 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/ ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ ldapbrowser-help/src/main/docbo...

Author: seelmann
Date: Tue Aug 26 23:57:21 2008
New Revision: 689388

URL: http://svn.apache.org/viewvc?rev=689388&view=rev
Log:
Fix for DIRSTUDIO-147 (Allow LDIF imports to overwrite existing entries), also applied this feature to the LDIF editor

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExecuteLdifRunnable.java
    directory/studio/trunk/ldapbrowser-help/src/main/docbook/2.45_tools_ldifimport_wizard.xml
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java
    directory/studio/trunk/ldifeditor-help/src/main/docbook/1_gettingstarted.xml
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorConstants.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorPreferencesInitializer.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/preferences/LdifEditorPreferencePage.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/ExecuteLdifAction.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java Tue Aug 26 23:57:21 2008
@@ -142,7 +142,7 @@
                 if ( record != null )
                 {
                     ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( selectedConnection, record
-                        .toFormattedString( LdifFormatParameters.DEFAULT ), false );
+                        .toFormattedString( LdifFormatParameters.DEFAULT ), false, false );
                     IStatus status = RunnableContextRunner.execute( runnable, getContainer(), true );
                     if ( !status.isOK() )
                     {

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExecuteLdifRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExecuteLdifRunnable.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExecuteLdifRunnable.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExecuteLdifRunnable.java Tue Aug 26 23:57:21 2008
@@ -54,6 +54,9 @@
     /** The LDIF to execute. */
     private String ldif;
 
+    /** The update if entry exists flag. */
+    private boolean updateIfEntryExists;
+
     /** The continue on error flag. */
     private boolean continueOnError;
 
@@ -65,11 +68,13 @@
      * @param ldif the LDIF to execute
      * @param continueOnError the continue on error flag
      */
-    public ExecuteLdifRunnable( IBrowserConnection browserConnection, String ldif, boolean continueOnError )
+    public ExecuteLdifRunnable( IBrowserConnection browserConnection, String ldif, boolean updateIfEntryExists,
+        boolean continueOnError )
     {
         this.browserConnection = browserConnection;
         this.ldif = ldif;
         this.continueOnError = continueOnError;
+        this.updateIfEntryExists = updateIfEntryExists;
     }
 
 
@@ -135,7 +140,8 @@
                 }
             };
 
-            ImportLdifJob.importLdif( browserConnection, enumeration, logWriter, false, continueOnError, monitor );
+            ImportLdifJob.importLdif( browserConnection, enumeration, logWriter, updateIfEntryExists, continueOnError,
+                monitor );
 
             logWriter.close();
             ldifReader.close();

Modified: directory/studio/trunk/ldapbrowser-help/src/main/docbook/2.45_tools_ldifimport_wizard.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-help/src/main/docbook/2.45_tools_ldifimport_wizard.xml?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-help/src/main/docbook/2.45_tools_ldifimport_wizard.xml (original)
+++ directory/studio/trunk/ldapbrowser-help/src/main/docbook/2.45_tools_ldifimport_wizard.xml Tue Aug 26 23:57:21 2008
@@ -212,6 +212,20 @@
 							<entry>off</entry>
 						</row>
 						<row>
+							<entry>Update if entry already exists</entry>
+							<entry>
+								This options applies for LDIF content records 
+								and LDIF add records. If enabled and the entry 
+								to add already exists it will be updated with 
+								the attributes defined in the LDIF record. In
+								detail a replace operation for each attribute
+								is performed. Attributes of the existing entry
+								that are not defined in the LDIF record remain
+								without modification.
+							</entry>
+							<entry>off</entry>
+						</row>
+						<row>
 							<entry>Continue on error</entry>
 							<entry>
 								If checked the import process continues
@@ -219,7 +233,7 @@
 								record. If not checked the import
 								process interrupts.
 							</entry>
-							<entry>on</entry>
+							<entry>off</entry>
 						</row>
 					</tbody>
 				</tgroup>

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java Tue Aug 26 23:57:21 2008
@@ -306,7 +306,7 @@
             3 );
         updateIfEntryExistsButton
             .setToolTipText( "This options applies for LDIF content records and LDIF add records. "
-                + "If enabled and the entry to add already exists it will be updated with the attributes defined in the LDIF." );
+                + "If enabled and the entry to add already exists it will be updated with the attributes defined in the LDIF record." );
         if ( BrowserUIPlugin.getDefault().getDialogSettings().get( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY ) == null )
         {
             BrowserUIPlugin.getDefault().getDialogSettings().put( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY, false );

Modified: directory/studio/trunk/ldifeditor-help/src/main/docbook/1_gettingstarted.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor-help/src/main/docbook/1_gettingstarted.xml?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor-help/src/main/docbook/1_gettingstarted.xml (original)
+++ directory/studio/trunk/ldifeditor-help/src/main/docbook/1_gettingstarted.xml Tue Aug 26 23:57:21 2008
@@ -876,6 +876,30 @@
 								</entry>
 								<entry>on</entry>
 							</row>
+							<row>
+								<entry>Update if entry already exists</entry>
+								<entry>
+									This options applies for LDIF content records 
+									and LDIF add records. If enabled and the entry 
+									to add already exists it will be updated with 
+									the attributes defined in the LDIF record. In
+									detail a replace operation for each attribute
+									is performed. Attributes of the existing entry
+									that are not defined in the LDIF record remain
+									without modification.
+								</entry>
+								<entry>off</entry>
+							</row>
+							<row>
+								<entry>Continue on error</entry>
+								<entry>
+									If checked the import process continues
+									if an error occurs while importing a
+									record. If not checked the import
+									process interrupts.
+								</entry>
+								<entry>on</entry>
+							</row>							
 						</tbody>
 					</tgroup>
 				</informaltable>

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorConstants.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorConstants.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorConstants.java Tue Aug 26 23:57:21 2008
@@ -19,6 +19,13 @@
  */
 package org.apache.directory.studio.ldifeditor;
 
+
+/**
+ * Constants for the LDIF editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface LdifEditorConstants
 {
 
@@ -44,6 +51,10 @@
 
     public static final String PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC = "ldifEditorCodeAssistInsertAttributeInModSpec";
 
+    public static final String PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS = "ldifEditorOptionsUpdateIfEntryExists";
+
+    public static final String PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR = "ldifEditorOptionsContinueOnError";
+
     public static final String PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX = "_RGB";
 
     public static final String PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX = "_STYLE";
@@ -111,13 +122,11 @@
     public static final String IMG_ENTRY = "resources/icons/entry.gif";
 
     public static final String IMG_TEMPLATE = "resources/icons/template.gif";
-    
+
     public static final String IMG_BROWSER_LDIFEDITOR = "resources/icons/browser_ldifeditor.gif";
 
     public static final String IMG_LDIFEDITOR_NEW = "resources/icons/ldifeditor_new.gif";
-    
-    public static final String IMG_EXECUTE = "resources/icons/execute.gif";
-
 
+    public static final String IMG_EXECUTE = "resources/icons/execute.gif";
 
 }

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorPreferencesInitializer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorPreferencesInitializer.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorPreferencesInitializer.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/LdifEditorPreferencesInitializer.java Tue Aug 26 23:57:21 2008
@@ -29,7 +29,7 @@
 
 
 /**
- * This class is used to set default preference values.
+ * This class is used to set default preference values for the LDIF editor.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -55,6 +55,9 @@
         store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_ENABLEAUTOACTIVATION, true );
         store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY, 200 );
         store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC, true );
+        store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS, false );
+        store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR, true );
+
         PreferenceConverter.setDefault( store, LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_COMMENT
             + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX, new RGB( 63, 127, 95 ) );// green
         store.setDefault( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_COMMENT

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/preferences/LdifEditorPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/preferences/LdifEditorPreferencePage.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/preferences/LdifEditorPreferencePage.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/preferences/LdifEditorPreferencePage.java Tue Aug 26 23:57:21 2008
@@ -43,24 +43,45 @@
 import org.eclipse.ui.dialogs.PreferencesUtil;
 
 
+/**
+ * The main preference page of the LDIF editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class LdifEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
 {
 
     // private Button autoWrapButton;
 
+    /** The enable folding button. */
     private Button enableFoldingButton;
 
+    /** The initially fold label. */
     private Label initiallyFoldLabel;
 
+    /** The initially fold comments button. */
     private Button initiallyFoldCommentsButton;
 
+    /** The initially fold records button. */
     private Button initiallyFoldRecordsButton;
 
+    /** The initially fold wrapped lines button. */
     private Button initiallyFoldWrappedLinesButton;
 
+    /** The use ldif double click button. */
     private Button useLdifDoubleClickButton;
 
+    /** The update if entry exists button. */
+    private Button updateIfEntryExistsButton;
 
+    /** The continue on error button. */
+    private Button continueOnErrorButton;
+
+
+    /**
+     * Creates a new instance of LdifEditorPreferencePage.
+     */
     public LdifEditorPreferencePage()
     {
         super( "LDIF Editor" );
@@ -68,11 +89,17 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void init( IWorkbench workbench )
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     protected Control createContents( Composite parent )
     {
         Composite composite = new Composite( parent, SWT.NONE );
@@ -145,12 +172,32 @@
         useLdifDoubleClickButton.setSelection( getPreferenceStore().getBoolean(
             LdifEditorConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) );
 
+        BaseWidgetUtils.createSpacer( composite, 1 );
+
+        // Options
+        Group optionsGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+            "Options", 1 );
+
+        updateIfEntryExistsButton = BaseWidgetUtils.createCheckbox( optionsGroup, "Update if entry already exists", 1 );
+        updateIfEntryExistsButton
+            .setToolTipText( "This options applies for LDIF content records and LDIF add records. "
+                + "If enabled and the entry to add already exists it will be updated with the attributes defined in the LDIF record." );
+        updateIfEntryExistsButton.setSelection( getPreferenceStore().getBoolean(
+            LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS ) );
+
+        continueOnErrorButton = BaseWidgetUtils.createCheckbox( optionsGroup, "Continue on error", 1 );
+        continueOnErrorButton.setSelection( getPreferenceStore().getBoolean(
+            LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR ) );
+
         checkEnabled();
 
         return composite;
     }
 
 
+    /**
+     * Enables/disables widgets dependent if options are selected.
+     */
     private void checkEnabled()
     {
         initiallyFoldLabel.setEnabled( enableFoldingButton.getSelection() );
@@ -160,19 +207,27 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean performOk()
     {
         getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE,
-            this.enableFoldingButton.getSelection() );
+            enableFoldingButton.getSelection() );
         getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS,
-            this.initiallyFoldCommentsButton.getSelection() );
+            initiallyFoldCommentsButton.getSelection() );
         getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS,
-            this.initiallyFoldRecordsButton.getSelection() );
+            initiallyFoldRecordsButton.getSelection() );
         getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES,
-            this.initiallyFoldWrappedLinesButton.getSelection() );
+            initiallyFoldWrappedLinesButton.getSelection() );
 
         getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK,
-            this.useLdifDoubleClickButton.getSelection() );
+            useLdifDoubleClickButton.getSelection() );
+
+        getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS,
+            updateIfEntryExistsButton.getSelection() );
+        getPreferenceStore().setValue( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR,
+            continueOnErrorButton.getSelection() );
 
         BrowserCorePlugin.getDefault().savePluginPreferences();
 
@@ -180,6 +235,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     protected void performDefaults()
     {
         enableFoldingButton.setSelection( getPreferenceStore().getDefaultBoolean(
@@ -194,6 +252,11 @@
         useLdifDoubleClickButton.setSelection( getPreferenceStore().getDefaultBoolean(
             LdifEditorConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) );
 
+        updateIfEntryExistsButton.setSelection( getPreferenceStore().getDefaultBoolean(
+            LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS ) );
+        continueOnErrorButton.setSelection( getPreferenceStore().getDefaultBoolean(
+            LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR ) );
+
         super.performDefaults();
 
         checkEnabled();

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/ExecuteLdifAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/ExecuteLdifAction.java?rev=689388&r1=689387&r2=689388&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/ExecuteLdifAction.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/ExecuteLdifAction.java Tue Aug 26 23:57:21 2008
@@ -27,6 +27,7 @@
 import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
 import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.IPreferenceStore;
 
 
 /**
@@ -62,7 +63,14 @@
         IBrowserConnection connection = editor.getConnection();
         String ldif = editor.getLdifModel().toRawString();
 
-        ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( connection, ldif, true );
+        IPreferenceStore preferenceStore = LdifEditorActivator.getDefault().getPreferenceStore();
+        boolean updateIfEntryExistsButton = preferenceStore
+            .getBoolean( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_UPDATEIFENTRYEXISTS );
+        boolean continueOnErrorButton = preferenceStore
+            .getBoolean( LdifEditorConstants.PREFERENCE_LDIFEDITOR_OPTIONS_CONTINUEONERROR );
+
+        ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( connection, ldif, updateIfEntryExistsButton,
+            continueOnErrorButton );
         StudioBrowserJob job = new StudioBrowserJob( runnable );
         job.execute();
     }