Exemplo n.º 1
0
  private void deleteObjectclass() {
    ArrayList<LocalizableMessage> errors = new ArrayList<>();
    ProgressDialog dlg =
        new ProgressDialog(
            Utilities.createFrame(),
            Utilities.getParentDialog(this),
            INFO_CTRL_PANEL_DELETE_OBJECTCLASS_TITLE.get(),
            getInfo());
    LinkedHashSet<ObjectClass> ocsToDelete = new LinkedHashSet<>();
    ocsToDelete.add(objectClass);
    LinkedHashSet<AttributeType> attrsToDelete = new LinkedHashSet<>(0);

    DeleteSchemaElementsTask newTask =
        new DeleteSchemaElementsTask(getInfo(), dlg, ocsToDelete, attrsToDelete);
    for (Task task : getInfo().getTasks()) {
      task.canLaunch(newTask, errors);
    }
    Schema schema = getInfo().getServerDescriptor().getSchema();
    ArrayList<String> childClasses = new ArrayList<>();
    if (schema != null) {
      for (ObjectClass o : schema.getObjectClasses().values()) {
        for (ObjectClass superior : o.getSuperiorClasses()) {
          if (objectClass.equals(superior)) {
            childClasses.add(o.getNameOrOID());
          }
        }
      }
    } else {
      errors.add(ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get());
    }
    if (errors.isEmpty()) {
      LocalizableMessageBuilder mb = new LocalizableMessageBuilder();

      if (!childClasses.isEmpty()) {
        mb.append(
            INFO_OBJECTCLASS_IS_SUPERIOR.get(
                ocName, Utilities.getStringFromCollection(childClasses, ", ")));
        mb.append("<br>");
      }
      LocalizableMessage confirmationMessage =
          INFO_CTRL_PANEL_CONFIRMATION_DELETE_OBJECTCLASS_DETAILS.get(ocName);
      mb.append(confirmationMessage);
      if (displayConfirmationDialog(
          INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), confirmationMessage)) {
        launchOperation(
            newTask,
            INFO_CTRL_PANEL_DELETING_OBJECTCLASS_SUMMARY.get(ocName),
            INFO_CTRL_PANEL_DELETING_OBJECTCLASS_COMPLETE.get(),
            INFO_CTRL_PANEL_DELETING_OBJECTCLASS_SUCCESSFUL.get(ocName),
            ERR_CTRL_PANEL_DELETING_OBJECTCLASS_ERROR_SUMMARY.get(),
            ERR_CTRL_PANEL_DELETING_OBJECTCLASS_ERROR_DETAILS.get(ocName),
            null,
            dlg);
        dlg.setVisible(true);
      }
    } else {
      displayErrorDialog(errors);
    }
  }
Exemplo n.º 2
0
 private void deleteClicked() {
   ArrayList<Message> errors = new ArrayList<Message>();
   TreePath[] paths = treePane.getTree().getSelectionPaths();
   ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>();
   ArrayList<String> indexesNames = new ArrayList<String>();
   if (paths != null) {
     for (TreePath path : paths) {
       Object node = path.getLastPathComponent();
       if (node instanceof IndexTreeNode) {
         indexesToDelete.add(((IndexTreeNode) node).getIndex());
       } else if (node instanceof VLVIndexTreeNode) {
         indexesToDelete.add(((VLVIndexTreeNode) node).getIndex());
       }
     }
   } else {
     errors.add(ERR_CTRL_PANEL_NO_INDEX_SELECTED.get());
   }
   for (AbstractIndexDescriptor index : indexesToDelete) {
     indexesNames.add(index.getName());
   }
   String nameLabel = Utilities.getStringFromCollection(indexesNames, ", ");
   String backendName = indexesToDelete.get(0).getBackend().getBackendID();
   if (errors.isEmpty()) {
     ProgressDialog dlg =
         new ProgressDialog(
             Utilities.createFrame(),
             Utilities.getParentDialog(this),
             INFO_CTRL_PANEL_DELETE_INDEXES_TITLE.get(),
             getInfo());
     DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete);
     for (Task task : getInfo().getTasks()) {
       task.canLaunch(newTask, errors);
     }
     if (errors.isEmpty()) {
       if (displayConfirmationDialog(
           INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(),
           INFO_CTRL_PANEL_CONFIRMATION_INDEXES_DELETE_DETAILS.get(nameLabel, backendName))) {
         launchOperation(
             newTask,
             INFO_CTRL_PANEL_DELETING_INDEXES_SUMMARY.get(),
             INFO_CTRL_PANEL_DELETING_INDEXES_COMPLETE.get(),
             INFO_CTRL_PANEL_DELETING_INDEXES_SUCCESSFUL.get(nameLabel, backendName),
             ERR_CTRL_PANEL_DELETING_INDEXES_ERROR_SUMMARY.get(),
             ERR_CTRL_PANEL_DELETING_INDEXES_ERROR_DETAILS.get(nameLabel),
             null,
             dlg);
         dlg.setVisible(true);
       }
     }
   }
   if (!errors.isEmpty()) {
     displayErrorDialog(errors);
   }
 }
Exemplo n.º 3
0
  /**
   * Saves the index modifications.
   *
   * @param modal whether the progress dialog for the task must be modal or not.
   */
  private void saveIndex(boolean modal) {
    newModifyTask = null;
    if (!isModified()) {
      return;
    }

    List<LocalizableMessage> errors = getErrors();

    if (errors.isEmpty()) {
      ProgressDialog dlg =
          new ProgressDialog(
              Utilities.getFrame(this),
              Utilities.getFrame(this),
              INFO_CTRL_PANEL_MODIFYING_INDEX_TITLE.get(),
              getInfo());
      dlg.setModal(modal);
      newModifyTask = new ModifyIndexTask(getInfo(), dlg);
      for (Task task : getInfo().getTasks()) {
        task.canLaunch(newModifyTask, errors);
      }
      if (errors.isEmpty()) {
        String attributeName = index.getName();
        String backendName = index.getBackend().getBackendID();
        launchOperation(
            newModifyTask,
            INFO_CTRL_PANEL_MODIFYING_INDEX_SUMMARY.get(attributeName),
            INFO_CTRL_PANEL_MODIFYING_INDEX_COMPLETE.get(),
            INFO_CTRL_PANEL_MODIFYING_INDEX_SUCCESSFUL.get(attributeName, backendName),
            ERR_CTRL_PANEL_MODIFYING_INDEX_ERROR_SUMMARY.get(),
            ERR_CTRL_PANEL_MODIFYING_INDEX_ERROR_DETAILS.get(attributeName),
            null,
            dlg);
        saveChanges.setEnabled(false);
        dlg.setVisible(true);
      }
    }

    if (!errors.isEmpty()) {
      displayErrorDialog(errors);
    }
  }
Exemplo n.º 4
0
  private void deleteIndex() {
    List<LocalizableMessage> errors = new ArrayList<>();
    ProgressDialog dlg =
        new ProgressDialog(
            Utilities.createFrame(),
            Utilities.getParentDialog(this),
            INFO_CTRL_PANEL_DELETE_INDEX_TITLE.get(),
            getInfo());
    ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<>();
    indexesToDelete.add(index);
    DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete);
    for (Task task : getInfo().getTasks()) {
      task.canLaunch(newTask, errors);
    }

    if (errors.isEmpty()) {
      String indexName = index.getName();
      String backendName = index.getBackend().getBackendID();
      if (displayConfirmationDialog(
          INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(),
          INFO_CTRL_PANEL_CONFIRMATION_INDEX_DELETE_DETAILS.get(indexName, backendName))) {
        launchOperation(
            newTask,
            INFO_CTRL_PANEL_DELETING_INDEX_SUMMARY.get(),
            INFO_CTRL_PANEL_DELETING_INDEX_COMPLETE.get(),
            INFO_CTRL_PANEL_DELETING_INDEX_SUCCESSFUL.get(indexName, backendName),
            ERR_CTRL_PANEL_DELETING_INDEX_ERROR_SUMMARY.get(),
            ERR_CTRL_PANEL_DELETING_INDEX_ERROR_DETAILS.get(indexName),
            null,
            dlg);
        dlg.setVisible(true);
      }
    } else {
      displayErrorDialog(errors);
    }
  }
  /** {@inheritDoc} */
  public void okClicked() {
    setPrimaryValid(lBaseDN);
    setSecondaryValid(addRemove.getSelectedLabel());

    final LinkedHashSet<Message> errors = new LinkedHashSet<Message>();

    String baseDN = getSelectedBaseDN();

    if (baseDN == null) {
      setPrimaryInvalid(lBaseDN);
      if (baseDNs.getItemCount() == 0) {
        errors.add(ERR_CTRL_PANEL_NO_BASE_DNS_DEFINED_LABEL.get());
      } else {
        errors.add(ERR_CTRL_PANEL_MUST_SELECT_BASE_DN.get());
      }
    }

    SortableListModel<AbstractIndexDescriptor> model = addRemove.getSelectedListModel();
    if (model.getSize() == 0) {
      setSecondaryInvalid(addRemove.getSelectedLabel());
      errors.add(ERR_CTRL_PANEL_MUST_SELECT_INDEX_TO_REBUILD.get());
    }

    if (errors.isEmpty()) {
      ProgressDialog progressDialog =
          new ProgressDialog(
              Utilities.createFrame(), Utilities.getParentDialog(this), getTitle(), getInfo());
      HashSet<String> baseDNs = new HashSet<String>();
      baseDNs.add(getSelectedBaseDN());
      RebuildIndexTask newTask =
          new RebuildIndexTask(
              getInfo(), progressDialog, baseDNs, addRemove.getSelectedListModel().getData());
      for (Task task : getInfo().getTasks()) {
        task.canLaunch(newTask, errors);
      }
      boolean confirmed = true;

      if ((errors.isEmpty()) && isServerRunning()) {
        String backendName = newTask.getBackends().iterator().next();
        confirmed =
            displayConfirmationDialog(
                INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(),
                INFO_CTRL_PANEL_CONFIRM_REBUILD_INDEX_DETAILS.get(backendName));
      }
      if ((errors.isEmpty()) && confirmed) {
        launchOperation(
            newTask,
            INFO_CTRL_PANEL_REBUILDING_INDEXES_SUMMARY.get(baseDN),
            INFO_CTRL_PANEL_REBUILDING_INDEXES_SUCCESSFUL_SUMMARY.get(),
            INFO_CTRL_PANEL_REBUILDING_INDEXES_SUCCESSFUL_DETAILS.get(),
            ERR_CTRL_PANEL_REBUILDING_INDEXES_ERROR_SUMMARY.get(),
            null,
            ERR_CTRL_PANEL_REBUILDING_INDEXES_ERROR_DETAILS,
            progressDialog);
        progressDialog.setVisible(true);
        Utilities.getParentDialog(this).setVisible(false);
      }
    }
    if (errors.size() > 0) {
      displayErrorDialog(errors);
    }
  }
Exemplo n.º 6
0
  private void saveChanges(boolean modal, ArrayList<LocalizableMessage> errors) {
    for (JLabel label : labels) {
      setPrimaryValid(label);
    }
    String n = getObjectClassName();
    LocalizableMessageBuilder err = new LocalizableMessageBuilder();
    if (n.length() == 0) {
      errors.add(ERR_CTRL_PANEL_OBJECTCLASS_NAME_REQUIRED.get());
      setPrimaryInvalid(lName);
    } else if (!n.equalsIgnoreCase(objectClass.getNameOrOID())) {
      if (!StaticUtils.isValidSchemaElement(n, 0, n.length(), err)) {
        errors.add(ERR_CTRL_PANEL_INVALID_OBJECTCLASS_NAME.get(err));
        setPrimaryInvalid(lName);
        err = new LocalizableMessageBuilder();
      } else {
        LocalizableMessage elementType = NewAttributePanel.getSchemaElementType(n, schema);
        if (elementType != null) {
          errors.add(ERR_CTRL_PANEL_OBJECTCLASS_NAME_ALREADY_IN_USE.get(n, elementType));
          setPrimaryInvalid(lName);
        }
      }
    }
    n = oid.getText().trim();
    if (n.length() > 0 && !n.equalsIgnoreCase(objectClass.getOID())) {
      if (!StaticUtils.isValidSchemaElement(n, 0, n.length(), err)) {
        errors.add(ERR_CTRL_PANEL_OID_NOT_VALID.get(err));
        setPrimaryInvalid(lOID);
        err = new LocalizableMessageBuilder();
      } else {
        LocalizableMessage elementType = NewAttributePanel.getSchemaElementType(n, schema);
        if (elementType != null) {
          errors.add(ERR_CTRL_PANEL_OID_ALREADY_IN_USE.get(n, elementType));
          setPrimaryInvalid(lOID);
        }
      }
    }

    Collection<String> aliases = getAliases();
    Collection<String> oldAliases = getAliases(objectClass);

    if (!aliases.equals(oldAliases)) {
      for (String alias : aliases) {
        if (alias.trim().length() == 0) {
          errors.add(ERR_CTRL_PANEL_EMPTY_ALIAS.get());
          setPrimaryInvalid(lAliases);
        } else {
          boolean notPreviouslyDefined = true;
          for (String oldAlias : oldAliases) {
            if (oldAlias.equalsIgnoreCase(alias)) {
              notPreviouslyDefined = false;
              break;
            }
          }
          if (notPreviouslyDefined) {
            LocalizableMessage elementType = NewAttributePanel.getSchemaElementType(alias, schema);
            if (elementType != null) {
              errors.add(ERR_CTRL_PANEL_ALIAS_ALREADY_IN_USE.get(n, elementType));
              setPrimaryInvalid(lAliases);
            }
          }
        }
      }
    }

    // validate the superiority.
    for (ObjectClass superior : getObjectClassSuperiors()) {
      validateSuperiority(superior, errors);
    }
    checkCompatibleSuperiors(getObjectClassSuperiors(), getObjectClassType(), errors);

    if (errors.isEmpty()) {
      ProgressDialog dlg =
          new ProgressDialog(
              Utilities.createFrame(),
              Utilities.getParentDialog(this),
              INFO_CTRL_PANEL_MODIFY_ATTRIBUTE_TITLE.get(),
              getInfo());

      ModifyObjectClassTask newTask =
          new ModifyObjectClassTask(getInfo(), dlg, objectClass, getNewObjectClass());
      for (ConfigurationElementCreatedListener listener :
          getConfigurationElementCreatedListeners()) {
        newTask.addConfigurationElementCreatedListener(listener);
      }
      for (Task task : getInfo().getTasks()) {
        task.canLaunch(newTask, errors);
      }
      if (errors.isEmpty()) {
        launchOperation(
            newTask,
            INFO_CTRL_PANEL_MODIFYING_OBJECTCLASS_SUMMARY.get(ocName),
            INFO_CTRL_PANEL_MODIFYING_OBJECTCLASS_COMPLETE.get(),
            INFO_CTRL_PANEL_MODIFYING_OBJECTCLASS_SUCCESSFUL.get(ocName),
            ERR_CTRL_PANEL_MODIFYING_OBJECTCLASS_ERROR_SUMMARY.get(),
            ERR_CTRL_PANEL_MODIFYING_OBJECTCLASS_ERROR_DETAILS.get(ocName),
            null,
            dlg);
        dlg.setVisible(true);
      }
    }

    if (!errors.isEmpty()) {
      displayErrorDialog(errors);
    }
  }