mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
17.54.2015 866cc640d33ce92abbd907d35d4c1b62f2328959
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
 
package org.opends.guitools.controlpanel.ui;
 
import static org.opends.messages.AdminToolMessages.*;
 
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
 
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.SwingUtilities;
 
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.OfflineUpdateException;
import org.opends.guitools.controlpanel.task.OnlineUpdateException;
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ServerConstants;
 
import com.forgerock.opendj.cli.CommandBuilder;
 
/**
 * Panel that appears when the user defines a new index.
 */
public class NewIndexPanel extends AbstractIndexPanel
{
  private static final long serialVersionUID = -3516011638125862137L;
 
  private Component relativeComponent;
 
  private Schema schema;
 
  private IndexDescriptor newIndex;
 
  /**
   * Constructor of the panel.
   * @param backendName the backend where the index will be created.
   * @param relativeComponent the component relative to which the dialog
   * containing this panel will be centered.
   */
  public NewIndexPanel(String backendName, Component relativeComponent)
  {
    super();
    this.backendName.setText(backendName);
    this.relativeComponent = relativeComponent;
    createLayout();
  }
 
  /** {@inheritDoc} */
  public LocalizableMessage getTitle()
  {
    return INFO_CTRL_PANEL_NEW_INDEX_TITLE.get();
  }
 
  /** {@inheritDoc} */
  public Component getPreferredFocusComponent()
  {
    return attributes;
  }
 
  /**
   * Updates the contents of the panel with the provided backend.
   * @param backend the backend where the index will be created.
   */
  public void update(BackendDescriptor backend)
  {
    backendName.setText(backend.getBackendID());
  }
 
  /** {@inheritDoc} */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    final ServerDescriptor desc = ev.getNewDescriptor();
 
    Schema s = desc.getSchema();
    final boolean[] repack = {false};
    final boolean[] error = {false};
    if (s != null)
    {
      schema = s;
      repack[0] = attributes.getItemCount() == 0;
      LinkedHashSet<CategorizedComboBoxElement> newElements =
        new LinkedHashSet<CategorizedComboBoxElement>();
 
//    Check that the index does not exist
      BackendDescriptor backend = null;
      for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends())
      {
        if (b.getBackendID().equalsIgnoreCase(backendName.getText()))
        {
          backend = b;
          break;
        }
      }
 
      TreeSet<String> standardAttrNames = new TreeSet<String>();
      TreeSet<String> configurationAttrNames = new TreeSet<String>();
      TreeSet<String> customAttrNames = new TreeSet<String>();
      for (AttributeType attr : schema.getAttributeTypes().values())
      {
        String name = attr.getPrimaryName();
        boolean defined = false;
        if (backend != null)
        {
          for (IndexDescriptor index : backend.getIndexes())
          {
            if (index.getName().equalsIgnoreCase(name))
            {
              defined = true;
              break;
            }
          }
        }
        if (!defined)
        {
          if (Utilities.isStandard(attr))
          {
            standardAttrNames.add(name);
          }
          else if (Utilities.isConfiguration(attr))
          {
            configurationAttrNames.add(name);
          }
          else
          {
            customAttrNames.add(name);
          }
        }
      }
      if (customAttrNames.size() > 0)
      {
        newElements.add(new CategorizedComboBoxElement(
            CUSTOM_ATTRIBUTES,
            CategorizedComboBoxElement.Type.CATEGORY));
        for (String attrName : customAttrNames)
        {
          newElements.add(new CategorizedComboBoxElement(
              attrName,
              CategorizedComboBoxElement.Type.REGULAR));
        }
      }
      if (standardAttrNames.size() > 0)
      {
        newElements.add(new CategorizedComboBoxElement(
            STANDARD_ATTRIBUTES,
            CategorizedComboBoxElement.Type.CATEGORY));
        for (String attrName : standardAttrNames)
        {
          newElements.add(new CategorizedComboBoxElement(
              attrName,
              CategorizedComboBoxElement.Type.REGULAR));
        }
      }
      // Ignore configuration attr names
      /*
        if (configurationAttrNames.size() > 0)
        {
          newElements.add(new CategorizedComboBoxDescriptor(
              "Configuration Attributes",
              CategorizedComboBoxDescriptor.Type.CATEGORY));
          for (String attrName : configurationAttrNames)
          {
            newElements.add(new CategorizedComboBoxDescriptor(
                attrName,
                CategorizedComboBoxDescriptor.Type.REGULAR));
          }
        }
       */
      DefaultComboBoxModel model =
        (DefaultComboBoxModel)attributes.getModel();
      updateComboBoxModel(newElements, model);
    }
    else
    {
      updateErrorPane(errorPane,
          ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(),
          ColorAndFontConstants.errorTitleFont,
          ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(),
          ColorAndFontConstants.defaultFont);
      repack[0] = true;
      error[0] = true;
    }
 
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        setEnabledOK(!error[0]);
        errorPane.setVisible(error[0]);
        if (repack[0])
        {
          packParentDialog();
          if (relativeComponent != null)
          {
            Utilities.centerGoldenMean(
                Utilities.getParentDialog(NewIndexPanel.this),
                relativeComponent);
          }
        }
      }
    });
    if (!error[0])
    {
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
       isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
  }
 
  /** {@inheritDoc} */
  public void okClicked()
  {
    setPrimaryValid(lAttribute);
    setPrimaryValid(lEntryLimit);
    setPrimaryValid(lType);
    ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>();
    String attrName = getAttributeName();
    if (attrName == null)
    {
      errors.add(ERR_INFO_CTRL_ATTRIBUTE_NAME_REQUIRED.get());
      setPrimaryInvalid(lAttribute);
    }
 
    String v = entryLimit.getText();
    try
    {
      int n = Integer.parseInt(v);
      if ((n < MIN_ENTRY_LIMIT) || (n > MAX_ENTRY_LIMIT))
      {
        errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(
            MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
        setPrimaryInvalid(lEntryLimit);
      }
    }
    catch (Throwable t)
    {
      errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(
          MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
      setPrimaryInvalid(lEntryLimit);
    }
 
    boolean somethingSelected = false;
    for (JCheckBox type : types)
    {
      somethingSelected = type.isSelected() && type.isVisible();
      if (somethingSelected)
      {
        break;
      }
    }
    if (!somethingSelected)
    {
      errors.add(ERR_INFO_ONE_INDEX_TYPE_MUST_BE_SELECTED.get());
      setPrimaryInvalid(lType);
    }
    ProgressDialog dlg = new ProgressDialog(
        Utilities.createFrame(),
        Utilities.getParentDialog(this), INFO_CTRL_PANEL_NEW_INDEX_TITLE.get(),
        getInfo());
    NewIndexTask newTask = new NewIndexTask(getInfo(), dlg);
    for (Task task : getInfo().getTasks())
    {
      task.canLaunch(newTask, errors);
    }
    if (errors.size() == 0)
    {
      launchOperation(newTask,
          INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUMMARY.get(attrName),
          INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUCCESSFUL_SUMMARY.get(),
          INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUCCESSFUL_DETAILS.get(attrName),
          ERR_CTRL_PANEL_CREATING_NEW_INDEX_ERROR_SUMMARY.get(),
          ERR_CTRL_PANEL_CREATING_NEW_INDEX_ERROR_DETAILS.get(),
          null,
          dlg);
      dlg.setVisible(true);
      Utilities.getParentDialog(this).setVisible(false);
    }
    else
    {
      displayErrorDialog(errors);
    }
  }
 
 
  private String getAttributeName()
  {
    CategorizedComboBoxElement o = (CategorizedComboBoxElement) attributes.getSelectedItem();
    return o != null ? o.getValue().toString() : null;
  }
 
  /**
   * Creates the layout of the panel (but the contents are not populated here).
   */
  private void createLayout()
  {
    GridBagConstraints gbc = new GridBagConstraints();
 
    createBasicLayout(this, gbc, false);
 
    attributes.addItemListener(new ItemListener()
    {
      public void itemStateChanged(ItemEvent ev)
      {
        String n = getAttributeName();
        AttributeType attr = null;
        if (n != null)
        {
          attr = schema.getAttributeType(n.toLowerCase());
        }
        repopulateTypesPanel(attr);
      }
    });
    entryLimit.setText(String.valueOf(DEFAULT_ENTRY_LIMIT));
  }
 
  /**
   * The task in charge of creating the index.
   *
   */
  protected class NewIndexTask extends Task
  {
    private Set<String> backendSet;
    private String attributeName;
    private int entryLimitValue;
    private SortedSet<IndexTypeDescriptor> indexTypes;
 
    /**
     * The constructor of the task.
     * @param info the control panel info.
     * @param dlg the progress dialog that shows the progress of the task.
     */
    public NewIndexTask(ControlPanelInfo info, ProgressDialog dlg)
    {
      super(info, dlg);
      backendSet = new HashSet<String>();
      backendSet.add(backendName.getText());
      attributeName = getAttributeName();
      entryLimitValue = Integer.parseInt(entryLimit.getText());
      indexTypes = getTypes();
    }
 
    /** {@inheritDoc} */
    public Type getType()
    {
      return Type.NEW_INDEX;
    }
 
    /** {@inheritDoc} */
    public Set<String> getBackends()
    {
      return backendSet;
    }
 
    /** {@inheritDoc} */
    public LocalizableMessage getTaskDescription()
    {
      return INFO_CTRL_PANEL_NEW_INDEX_TASK_DESCRIPTION.get(
          attributeName, backendName.getText());
    }
 
    /** {@inheritDoc} */
    public boolean canLaunch(Task taskToBeLaunched,
        Collection<LocalizableMessage> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
        // has not a lot of impact.
        Set<String> backends =
          new TreeSet<String>(taskToBeLaunched.getBackends());
        backends.retainAll(getBackends());
        if (backends.size() > 0)
        {
          incompatibilityReasons.add(getIncompatibilityMessage(this,
              taskToBeLaunched));
          canLaunch = false;
        }
      }
      return canLaunch;
    }
 
    private void updateConfiguration() throws OpenDsException
    {
      boolean configHandlerUpdated = false;
      try
      {
        if (!isServerRunning())
        {
          configHandlerUpdated = true;
          getInfo().stopPooling();
          if (getInfo().mustDeregisterConfig())
          {
            DirectoryServer.deregisterBaseDN(DN.valueOf("cn=config"));
          }
          DirectoryServer.getInstance().initializeConfiguration(
              org.opends.server.extensions.ConfigFileHandler.class.getName(),
              ConfigReader.configFile);
          getInfo().setMustDeregisterConfig(true);
        }
        else
        {
          SwingUtilities.invokeLater(new Runnable()
          {
            /** {@inheritDoc} */
            public void run()
            {
              List<String> args = getObfuscatedCommandLineArguments(
                  getDSConfigCommandLineArguments());
              args.removeAll(getConfigCommandLineArguments());
              printEquivalentCommandLine(getConfigCommandLineName(),
                  args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_INDEX.get());
            }
          });
        }
        SwingUtilities.invokeLater(new Runnable()
        {
          /** {@inheritDoc} */
          public void run()
          {
            getProgressDialog().appendProgressHtml(
                Utilities.getProgressWithPoints(
                    INFO_CTRL_PANEL_CREATING_NEW_INDEX_PROGRESS.get(
                        attributeName),
                    ColorAndFontConstants.progressFont));
          }
        });
        if (isServerRunning())
        {
          // Create additional indexes and display the equivalent command.
          // Everything is done in the method createAdditionalIndexes
          createIndex(getInfo().getDirContext());
        }
        else
        {
          createIndex();
        }
        SwingUtilities.invokeLater(new Runnable()
        {
          /** {@inheritDoc} */
          public void run()
          {
            getProgressDialog().appendProgressHtml(
                Utilities.getProgressDone(ColorAndFontConstants.progressFont));
          }
        });
      }
      finally
      {
        if (configHandlerUpdated)
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling();
        }
      }
    }
 
    /**
     * Returns the LDIF representation of the index to be created.
     * @return the LDIF representation of the index to be created.
     */
    private String getIndexLDIF()
    {
      String dn = Utilities.getRDNString(
          "ds-cfg-backend-id", backendName.getText())+",cn=Backends,cn=config";
      ArrayList<String> lines = new ArrayList<String>();
      lines.add("dn: "+Utilities.getRDNString("ds-cfg-attribute",
          attributeName)+
          ",cn=Index,"+dn);
      lines.add("objectClass: ds-cfg-local-db-index");
      lines.add("objectClass: top");
      lines.add("ds-cfg-attribute: "+attributeName);
      lines.add("ds-cfg-index-entry-limit: "+entryLimitValue);
      for (IndexTypeDescriptor type : indexTypes)
      {
        lines.add("ds-cfg-index-type: " + type.toLocalDBIndexType());
      }
      StringBuilder sb = new StringBuilder();
      for (String line : lines)
      {
        sb.append(line).append(ServerConstants.EOL);
      }
      return sb.toString();
    }
 
    private void createIndex() throws OpenDsException
    {
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        String ldif = getIndexLDIF();
 
        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry backendConfigEntry;
        while ((backendConfigEntry = reader.readEntry()) != null)
        {
          DirectoryServer.getConfigHandler().addEntry(backendConfigEntry, null);
        }
        DirectoryServer.getConfigHandler().writeUpdatedConfig();
      }
      catch (IOException ioe)
      {
        throw new OfflineUpdateException(
            ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(ioe), ioe);
      }
      finally
      {
        if (ldifImportConfig != null)
        {
          ldifImportConfig.close();
        }
      }
    }
 
    private void createIndex(InitialLdapContext ctx) throws OpenDsException
    {
      // Instead of adding indexes using management framework, use this approach
      // so that we have to define the additional indexes only in the method
      // getBackendLdif.
      String ldif = getIndexLDIF();
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry indexEntry = reader.readEntry();
        Attributes attrs = new BasicAttributes();
 
        BasicAttribute oc = new BasicAttribute("objectClass");
        Iterator<ByteString> it =
          indexEntry.getObjectClassAttribute().iterator();
        while (it.hasNext())
        {
          oc.add(it.next().toString());
        }
        attrs.put(oc);
 
        List<Attribute> odsAttrs = indexEntry.getAttributes();
        for (Attribute odsAttr : odsAttrs)
        {
          String attrName = odsAttr.getName();
          BasicAttribute attr = new BasicAttribute(attrName);
          it = odsAttr.iterator();
          while (it.hasNext())
          {
            attr.add(it.next().toString());
          }
          attrs.put(attr);
        }
 
        final StringBuilder sb = new StringBuilder();
        sb.append(getConfigCommandLineName());
        Collection<String> args =
          getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
        for (String arg : args)
        {
          sb.append(" ").append(CommandBuilder.escapeValue(arg));
        }
 
        ctx.createSubcontext(indexEntry.getName().toString(), attrs);
      }
      catch (Throwable t)
      {
        throw new OnlineUpdateException(
            ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t), t);
      }
      finally
      {
        if (ldifImportConfig != null)
        {
          ldifImportConfig.close();
        }
      }
    }
 
    /** {@inheritDoc} */
    protected String getCommandLinePath()
    {
      return null;
    }
 
    /** {@inheritDoc} */
    protected ArrayList<String> getCommandLineArguments()
    {
      return new ArrayList<String>();
    }
 
    private String getConfigCommandLineName()
    {
      if (isServerRunning())
      {
        return getCommandLinePath("dsconfig");
      }
      else
      {
        return null;
      }
    }
 
    /** {@inheritDoc} */
    public void runTask()
    {
      state = State.RUNNING;
      lastException = null;
 
      try
      {
        updateConfiguration();
        for (BackendDescriptor backend :
          getInfo().getServerDescriptor().getBackends())
        {
          if (backend.getBackendID().equalsIgnoreCase(backendName.getText()))
          {
            newIndex = new IndexDescriptor(attributeName,
                schema.getAttributeType(attributeName.toLowerCase()), backend,
                indexTypes, entryLimitValue);
            getInfo().registerModifiedIndex(newIndex);
            notifyConfigurationElementCreated(newIndex);
            break;
          }
        }
        state = State.FINISHED_SUCCESSFULLY;
      }
      catch (Throwable t)
      {
        lastException = t;
        state = State.FINISHED_WITH_ERROR;
      }
    }
 
    /** {@inheritDoc} */
    public void postOperation()
    {
      if ((lastException == null) && (state == State.FINISHED_SUCCESSFULLY) &&
          (newIndex != null))
      {
        rebuildIndexIfNecessary(newIndex, getProgressDialog());
      }
    }
 
    private ArrayList<String> getDSConfigCommandLineArguments()
    {
      ArrayList<String> args = new ArrayList<String>();
      args.add("create-local-db-index");
      args.add("--backend-name");
      args.add(backendName.getText());
      args.add("--type");
      args.add("generic");
 
      args.add("--index-name");
      args.add(attributeName);
 
      for (IndexTypeDescriptor type : indexTypes)
      {
        args.add("--set");
        args.add("index-type:"+type.toLocalDBIndexType());
      }
      args.add("--set");
      args.add("index-entry-limit:"+entryLimitValue);
      args.addAll(getConnectionCommandLineArguments());
      args.add(getNoPropertiesFileArgument());
      args.add("--no-prompt");
      return args;
    }
  }
}