| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | /** |
| | | * The panel where the user can import the contents of an LDIF file to the |
| | | * server. |
| | | * |
| | | */ |
| | | public class ImportLDIFPanel extends InclusionExclusionPanel |
| | | { |
| | |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_IMPORT_LDIF_TITLE.get(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return file; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toBeDisplayed(boolean visible) |
| | | { |
| | | if (visible) |
| | |
| | | lFile.setLabelFor(file); |
| | | documentListener = new DocumentListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void changedUpdate(DocumentEvent ev) |
| | | { |
| | | String text = file.getText().trim(); |
| | | setEnabledOK((text != null) && (text.length() > 0) && |
| | | !errorPane.isVisible()); |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeUpdate(DocumentEvent ev) |
| | | { |
| | | changedUpdate(ev); |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void insertUpdate(DocumentEvent ev) |
| | | { |
| | | changedUpdate(ev); |
| | |
| | | add(append, gbc); |
| | | append.addChangeListener(new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void stateChanged(ChangeEvent ev) |
| | | { |
| | | replaceEntries.setEnabled(append.isSelected()); |
| | |
| | | |
| | | ChangeListener changeListener = new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void stateChanged(ChangeEvent ev) |
| | | { |
| | | rejectsFile.setEnabled(writeRejects.isSelected()); |
| | |
| | | |
| | | changeListener = new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void stateChanged(ChangeEvent ev) |
| | | { |
| | | skipsFile.setEnabled(writeSkips.isSelected()); |
| | |
| | | |
| | | changeListener = new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void stateChanged(ChangeEvent ev) |
| | | { |
| | | if (ev.getSource() == overwriteSkipsFile) |
| | |
| | | addBottomGlue(gbc); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | ServerDescriptor desc = ev.getNewDescriptor(); |
| | |
| | | INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname())); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | lRemoteFileHelp.setVisible(!isLocal()); |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void checkOKButtonEnable() |
| | | { |
| | | documentListener.changedUpdate(null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | setPrimaryValid(lBackend); |
| | |
| | | } |
| | | |
| | | String ldifPath = file.getText(); |
| | | if ((ldifPath == null) || (ldifPath.trim().equals(""))) |
| | | if (ldifPath == null || "".equals(ldifPath.trim())) |
| | | { |
| | | errors.add(INFO_NO_LDIF_PATH.get()); |
| | | setPrimaryInvalid(lFile); |
| | |
| | | if (writeRejects.isSelected()) |
| | | { |
| | | String rejectPath = rejectsFile.getText(); |
| | | if ((rejectPath == null) || (rejectPath.trim().equals(""))) |
| | | if (rejectPath == null || "".equals(rejectPath.trim())) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_REJECTS_FILE_REQUIRED.get()); |
| | | setPrimaryInvalid(lRejectsFile); |
| | |
| | | if (writeSkips.isSelected()) |
| | | { |
| | | String skipPath = skipsFile.getText(); |
| | | if ((skipPath == null) || (skipPath.trim().equals(""))) |
| | | if (skipPath == null || "".equals(skipPath.trim())) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_SKIPS_FILE_REQUIRED.get()); |
| | | setPrimaryInvalid(lSkipsFile); |
| | |
| | | } |
| | | } |
| | | } |
| | | if ((errors.isEmpty()) && confirmed) |
| | | if (errors.isEmpty() && confirmed) |
| | | { |
| | | newTask.setInitializeAll(initializeAll); |
| | | launchOperation(newTask, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void cancelClicked() |
| | | { |
| | | setPrimaryValid(lBackend); |
| | |
| | | this.initializeAll = initializeAll; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Type getType() |
| | | { |
| | | return Type.IMPORT_LDIF; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTaskDescription() |
| | | { |
| | | return INFO_CTRL_PANEL_IMPORT_TASK_DESCRIPTION.get(fileName, |
| | | backendSet.iterator().next()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean canLaunch(Task taskToBeLaunched, |
| | | Collection<LocalizableMessage> incompatibilityReasons) |
| | | { |
| | |
| | | return canLaunch; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ArrayList<String> getCommandLineArguments() |
| | | { |
| | | ArrayList<String> args = new ArrayList<String>(); |
| | |
| | | return args; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected String getCommandLinePath() |
| | | { |
| | | return getCommandLinePath("import-ldif"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void runTask() |
| | | { |
| | | state = State.RUNNING; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getBackends() |
| | | { |
| | | return backendSet; |
| | |
| | | |
| | | private void initializeAll() throws ReplicationCliException |
| | | { |
| | | ReplicationCliMain repl = new ReplicationCliMain(outPrintStream, |
| | | errorPrintStream, System.in); |
| | | ReplicationCliMain repl = new ReplicationCliMain(outPrintStream, errorPrintStream); |
| | | getProgressDialog().appendProgressHtml( |
| | | UIFactory.HTML_SEPARATOR+"<br><br>"); |
| | | |
| | |
| | | LocalizableMessage msg = INFO_PROGRESS_INITIALIZING_SUFFIX.get(baseDN, |
| | | ConnectionUtils.getHostPort(getInfo().getDirContext())); |
| | | getProgressDialog().appendProgressHtml(Utilities.applyFont( |
| | | msg.toString()+"<br>", ColorAndFontConstants.progressFont)); |
| | | repl.initializeAllSuffix(baseDN.toString(), getInfo().getDirContext(), |
| | | true); |
| | | msg + "<br>", ColorAndFontConstants.progressFont)); |
| | | repl.initializeAllSuffix(baseDN.toString(), getInfo().getDirContext(), true); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return Task.getEquivalentCommandLine(cmdLineName, args); |
| | | } |
| | | }; |
| | | } |
| | | } |