Improvements suggested by UCDetector: remove dead code, add final keywords, change visibilities
| | |
| | | * @return <CODE>true</CODE> if we must search base DN information and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean searchBaseDNInformation() |
| | | boolean searchBaseDNInformation() |
| | | { |
| | | return searchBaseDNInformation; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if we must search monitoring information and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean searchMonitoringInformation() |
| | | boolean searchMonitoringInformation() |
| | | { |
| | | return searchMonitoringInformation; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if the filter specifies to search for all the |
| | | * base DNs and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean searchAllBaseDNs() |
| | | boolean searchAllBaseDNs() |
| | | { |
| | | return baseDNs.isEmpty(); |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if we are connected and read the configuration |
| | | * and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean connectedAsAdministrativeUser(InitialLdapContext ctx) |
| | | static boolean connectedAsAdministrativeUser(InitialLdapContext ctx) |
| | | { |
| | | try |
| | | { |
| | |
| | | * @param conn the connection we retrieve the information from. |
| | | * @return a preferred connection object. |
| | | */ |
| | | public static PreferredConnection getPreferredConnection(ConnectionWrapper conn) |
| | | private static PreferredConnection getPreferredConnection(ConnectionWrapper conn) |
| | | { |
| | | InitialLdapContext ctx = conn.getLdapContext(); |
| | | String ldapUrl = ConnectionUtils.getLdapUrl(ctx); |
| | |
| | | |
| | | private SearchResult localEntry; |
| | | private SearchResult remoteEntry; |
| | | LDAPURL remoteUrl; |
| | | private LDAPURL remoteUrl; |
| | | private boolean isLeafNode; |
| | | private final List<SearchResult> childEntries = new ArrayList<>(); |
| | | final boolean differential; |
| | | Exception exception; |
| | | Object exceptionArg; |
| | | private final boolean differential; |
| | | private Exception exception; |
| | | private Object exceptionArg; |
| | | |
| | | /** |
| | | * The constructor of the refresher object. |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | /** Abstract class used to describe the configuration of an index. */ |
| | | public abstract class AbstractIndexDescriptor |
| | | implements Comparable<AbstractIndexDescriptor> |
| | | { |
| | | private String name; |
| | | private final String name; |
| | | private BackendDescriptor backend; |
| | | |
| | | /** |
| | | * Constructor. |
| | | * @param name the name of the index. |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.messages.AdminToolMessages; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.messages.AdminToolMessages; |
| | | |
| | | /** |
| | | * Table Model used to store information about indexes. It is used basically |
| | |
| | | implements Comparator<AbstractIndexDescriptor> |
| | | { |
| | | private static final long serialVersionUID = -5131878622200568636L; |
| | | private Set<AbstractIndexDescriptor> data = new HashSet<>(); |
| | | private ArrayList<String[]> dataArray = new ArrayList<>(); |
| | | private ArrayList<AbstractIndexDescriptor> indexArray = new ArrayList<>(); |
| | | private final Set<AbstractIndexDescriptor> data = new HashSet<>(); |
| | | private final List<String[]> dataArray = new ArrayList<>(); |
| | | private final List<AbstractIndexDescriptor> indexArray = new ArrayList<>(); |
| | | private final String[] COLUMN_NAMES = getColumnNames(); |
| | | /** The sort column of the table. */ |
| | | protected int sortColumn; |
| | |
| | | */ |
| | | class AddressConnectionHandlerDescriptor |
| | | { |
| | | private ConnectionHandlerDescriptor ch; |
| | | private InetAddress address; |
| | | private CustomSearchResult monitoringEntry; |
| | | private int hashCode; |
| | | private final ConnectionHandlerDescriptor ch; |
| | | private final InetAddress address; |
| | | private final CustomSearchResult monitoringEntry; |
| | | private final int hashCode; |
| | | |
| | | /** |
| | | * Constructor of this data structure. |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | |
| | | /** Policy to follow to choose the protocol to be used. */ |
| | | /** Policy to follow to choose the protocol to be used. */ |
| | | public enum ConnectionProtocolPolicy |
| | | { |
| | | /** Force to use Start TLS. */ |
| | |
| | | USE_MOST_SECURE_AVAILABLE, |
| | | /** Use the less secure available (LDAP, and then LDAPs). */ |
| | | USE_LESS_SECURE_AVAILABLE; |
| | | |
| | | /** |
| | | * Returns the ConnectionProtocolPolicy to be used with the parameters |
| | | * provided by the user. |
| | | * @param useSSL whether the user asked to use SSL or not. |
| | | * @param useStartTLS whether the user asked to use Start TLS or not. |
| | | * @return the ConnectionProtocolPolicy to be used with the parameters |
| | | * provided by the user. |
| | | */ |
| | | public static ConnectionProtocolPolicy getConnectionPolicy(boolean useSSL, |
| | | boolean useStartTLS) |
| | | { |
| | | ConnectionProtocolPolicy policy; |
| | | if (useStartTLS) |
| | | { |
| | | policy = ConnectionProtocolPolicy.USE_STARTTLS; |
| | | } |
| | | else if (useSSL) |
| | | { |
| | | policy = ConnectionProtocolPolicy.USE_LDAPS; |
| | | } |
| | | else |
| | | { |
| | | policy = ConnectionProtocolPolicy.USE_LESS_SECURE_AVAILABLE; |
| | | } |
| | | return policy; |
| | | } |
| | | } |
| | |
| | | private static boolean mustDeregisterConfig; |
| | | private static ControlPanelInfo instance; |
| | | |
| | | private Set<Task> tasks = new HashSet<>(); |
| | | private final Set<Task> tasks = new HashSet<>(); |
| | | private ConnectionWrapper connWrapper; |
| | | private InitialLdapContext userDataCtx; |
| | | private final LDAPConnectionPool connectionPool = new LDAPConnectionPool(); |
| | |
| | | * Unregisters a task. |
| | | * @param task the task to be unregistered. |
| | | */ |
| | | public void unregisterTask(Task task) |
| | | private void unregisterTask(Task task) |
| | | { |
| | | tasks.remove(task); |
| | | } |
| | |
| | | * the index listeners that an index has been modified. |
| | | * @param modifiedIndex the modified index. |
| | | */ |
| | | public void indexModified(AbstractIndexDescriptor modifiedIndex) |
| | | private void indexModified(AbstractIndexDescriptor modifiedIndex) |
| | | { |
| | | IndexModifiedEvent ev = new IndexModifiedEvent(modifiedIndex); |
| | | for (IndexModifiedListener listener : indexListeners) |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | */ |
| | | public class RebuildIndexTask extends IndexTask |
| | | { |
| | | private SortedSet<AbstractIndexDescriptor> indexes = new TreeSet<>(); |
| | | private final SortedSet<AbstractIndexDescriptor> indexes = new TreeSet<>(); |
| | | |
| | | /** |
| | | * The indexes that must not be specified in the command-line. |
| | |
| | | * @return the command line arguments required to rebuild the indexes in the |
| | | * specified base DN. |
| | | */ |
| | | protected List<String> getCommandLineArguments(String baseDN) |
| | | private List<String> getCommandLineArguments(String baseDN) |
| | | { |
| | | List<String> args = new ArrayList<>(); |
| | | |
| | |
| | | */ |
| | | public abstract class Task |
| | | { |
| | | private static String localHostName = UserData.getDefaultHostName(); |
| | | private String binDir; |
| | | private static final String localHostName = UserData.getDefaultHostName(); |
| | | private static final int MAX_BINARY_LENGTH_TO_DISPLAY = 1024; |
| | | |
| | | /** The different task types. */ |
| | | public enum Type |
| | |
| | | * a bug, because of the way the contents of logs is updated, using |
| | | * StringBuffer instead of StringBuilder is required. |
| | | */ |
| | | private StringBuffer logs = new StringBuffer(); |
| | | private final StringBuffer logs = new StringBuffer(); |
| | | /** The error logs of the task. */ |
| | | private StringBuilder errorLogs = new StringBuilder(); |
| | | private final StringBuilder errorLogs = new StringBuilder(); |
| | | /** The standard output logs of the task. */ |
| | | private StringBuilder outputLogs = new StringBuilder(); |
| | | private final StringBuilder outputLogs = new StringBuilder(); |
| | | /** The print stream for the error logs. */ |
| | | protected ApplicationPrintStream errorPrintStream = |
| | | new ApplicationPrintStream(); |
| | | protected final ApplicationPrintStream errorPrintStream = new ApplicationPrintStream(); |
| | | /** The print stream for the standard output logs. */ |
| | | protected ApplicationPrintStream outPrintStream = |
| | | new ApplicationPrintStream(); |
| | | protected final ApplicationPrintStream outPrintStream = new ApplicationPrintStream(); |
| | | |
| | | /** |
| | | * The process (if any) that the task launched. For instance if this is a |
| | |
| | | * command-line. |
| | | */ |
| | | private Process process; |
| | | private ControlPanelInfo info; |
| | | |
| | | private ServerDescriptor server; |
| | | |
| | | private ProgressDialog progressDialog; |
| | | |
| | | private ArrayList<ConfigurationElementCreatedListener> confListeners = new ArrayList<>(); |
| | | |
| | | private static int MAX_BINARY_LENGTH_TO_DISPLAY = 1024; |
| | | private final ControlPanelInfo info; |
| | | private final ServerDescriptor server; |
| | | private String binDir; |
| | | private final ProgressDialog progressDialog; |
| | | private final List<ConfigurationElementCreatedListener> confListeners = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Constructor of the task. |
| | |
| | | * @return the obfuscated String representing the attribute value to be |
| | | * displayed in the logs of the user. |
| | | */ |
| | | protected String obfuscateAttributeStringValue(String attrName, Object o) |
| | | private String obfuscateAttributeStringValue(String attrName, Object o) |
| | | { |
| | | if (Utilities.mustObfuscate(attrName, |
| | | getInfo().getServerDescriptor().getSchema())) |
| | |
| | | * Returns the binary/script directory. |
| | | * @return the binary/script directory. |
| | | */ |
| | | protected String getBinaryDir() |
| | | private String getBinaryDir() |
| | | { |
| | | if (binDir == null) |
| | | { |
| | |
| | | * @param mods the modifications. |
| | | * @param useAdminCtx use the administration connector. |
| | | */ |
| | | protected void printEquivalentCommandToModify(String dn, |
| | | private void printEquivalentCommandToModify(String dn, |
| | | Collection<ModificationItem> mods, boolean useAdminCtx) |
| | | { |
| | | ArrayList<String> args = new ArrayList<>(getObfuscatedCommandLineArguments( |
| | |
| | | * @return <CODE>true</CODE> if the attribute must be displayed using base 64 |
| | | * and <CODE>false</CODE> otherwise. |
| | | */ |
| | | protected boolean displayBase64(String attrName) |
| | | private boolean displayBase64(String attrName) |
| | | { |
| | | Schema schema = null; |
| | | if (getInfo() != null) |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | * when the user can choose a set of entries (for instance when the user adds a |
| | | * member to a group in the 'New Group' dialog). |
| | | */ |
| | | public abstract class AbstractBrowseEntriesPanel extends StatusGenericPanel implements BackendPopulatedListener |
| | | abstract class AbstractBrowseEntriesPanel extends StatusGenericPanel implements BackendPopulatedListener |
| | | { |
| | | private static final long serialVersionUID = -6063927039968115236L; |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | private Object lastSelectedBaseDN; |
| | | private boolean ignoreBaseDNEvents; |
| | | |
| | | private List<DN> otherBaseDns = new ArrayList<>(); |
| | | private final List<DN> otherBaseDns = new ArrayList<>(); |
| | | |
| | | /** Default constructor. */ |
| | | public AbstractBrowseEntriesPanel() |
| | |
| | | @Override |
| | | public void treeNodesChanged(TreeModelEvent e) |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | @Override |
| | |
| | | * left. The class simply handles this particular case to not to have that |
| | | * inset for the 'All Base DNs' item. |
| | | */ |
| | | class CustomComboBoxCellRenderer extends CustomListCellRenderer |
| | | private class CustomComboBoxCellRenderer extends CustomListCellRenderer |
| | | { |
| | | private LocalizableMessage ALL_BASE_DNS_STRING = INFO_CTRL_PANEL_ALL_BASE_DNS.get(); |
| | | private final LocalizableMessage ALL_BASE_DNS_STRING = INFO_CTRL_PANEL_ALL_BASE_DNS.get(); |
| | | |
| | | /** |
| | | * The constructor. |
| | |
| | | * @param combo |
| | | * the combo box to be rendered. |
| | | */ |
| | | CustomComboBoxCellRenderer(JComboBox<?> combo) |
| | | private CustomComboBoxCellRenderer(JComboBox<?> combo) |
| | | { |
| | | super(combo); |
| | | } |
| | |
| | | * before updating the number of entries and with this approach there is |
| | | * hardly no impact on the reactivity of the UI. |
| | | */ |
| | | protected class NumberOfEntriesUpdater extends Thread |
| | | private class NumberOfEntriesUpdater extends Thread |
| | | { |
| | | private boolean recalculate; |
| | | |
| | | /** Notifies that the number of entries in the browser has changed. */ |
| | | public void recalculate() |
| | | private void recalculate() |
| | | { |
| | | recalculate = true; |
| | | } |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // ignore |
| | | } |
| | | if (recalculate) |
| | | { |
| | |
| | | * @return <CODE>true</CODE> if the schema must be checked and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | protected boolean checkSchema() |
| | | private boolean checkSchema() |
| | | { |
| | | return getInfo().getServerDescriptor().isSchemaEnabled(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The refreshing list message, displayed when the list of backups is refreshed. */ |
| | | protected static final LocalizableMessage REFRESHING_LIST = INFO_CTRL_PANEL_REFRESHING_LIST_SUMMARY.get(); |
| | | private static final LocalizableMessage REFRESHING_LIST = INFO_CTRL_PANEL_REFRESHING_LIST_SUMMARY.get(); |
| | | |
| | | /** The message informing that no backups where found. */ |
| | | protected static final LocalizableMessage NO_BACKUPS_FOUND = INFO_CTRL_PANEL_NO_BACKUPS_FOUND.get(); |
| | | private static final LocalizableMessage NO_BACKUPS_FOUND = INFO_CTRL_PANEL_NO_BACKUPS_FOUND.get(); |
| | | |
| | | private static final String DUMMY_PARENT_PATH = "/local/OpenDJ-X.X.X/bak"; |
| | | |
| | |
| | | } |
| | | |
| | | /** Class that launches the backup. */ |
| | | protected class BackupTask extends Task |
| | | private class BackupTask extends Task |
| | | { |
| | | private Set<String> backendSet; |
| | | private String dir; |
| | |
| | | * @param info the control panel info. |
| | | * @param dlg the progress dialog that shows the progress of the task. |
| | | */ |
| | | public BackupTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private BackupTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendSet = new HashSet<>(); |
| | |
| | | * user provides a path value through the JFileChooser associated with the |
| | | * browse button. |
| | | */ |
| | | class CustomBrowseActionListener extends BrowseActionListener |
| | | private class CustomBrowseActionListener extends BrowseActionListener |
| | | { |
| | | /** |
| | | * Constructor of this listener. |
| | |
| | | * @param parent the parent component to be used as reference to display |
| | | * the file chooser dialog. |
| | | */ |
| | | public CustomBrowseActionListener(JTextComponent field, BrowseType type, |
| | | private CustomBrowseActionListener(JTextComponent field, BrowseType type, |
| | | Component parent) |
| | | { |
| | | super(field, type, parent); |
| | |
| | | import javax.swing.event.TreeSelectionListener; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.browser.NodeRefresher; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes; |
| | | import org.opends.guitools.controlpanel.util.LDAPEntryReader; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | } |
| | | |
| | | /** The specific menu bar of this panel. */ |
| | | class BrowseMenuBar extends GenericMenuBar |
| | | private class BrowseMenuBar extends GenericMenuBar |
| | | { |
| | | private static final long serialVersionUID = 505187832236882370L; |
| | | JMenuItem deleteMenuItem; |
| | | JMenuItem copyDNMenuItem; |
| | | JMenuItem addToGroupMenuItem; |
| | | JMenuItem resetPasswordMenuItem; |
| | | JMenuItem newUserMenuItem; |
| | | JMenuItem newGroupMenuItem; |
| | | JMenuItem newOUMenuItem; |
| | | JMenuItem newOrganizationMenuItem; |
| | | JMenuItem newDomainMenuItem; |
| | | JMenuItem newEntryFromLDIFMenuItem; |
| | | JMenuItem duplicateEntryMenuItem; |
| | | JMenuItem deleteBaseDNMenuItem; |
| | | JMenuItem deleteBackendMenuItem; |
| | | private JMenuItem deleteMenuItem; |
| | | private JMenuItem copyDNMenuItem; |
| | | private JMenuItem addToGroupMenuItem; |
| | | private JMenuItem resetPasswordMenuItem; |
| | | private JMenuItem newUserMenuItem; |
| | | private JMenuItem newGroupMenuItem; |
| | | private JMenuItem newOUMenuItem; |
| | | private JMenuItem newOrganizationMenuItem; |
| | | private JMenuItem newDomainMenuItem; |
| | | private JMenuItem newEntryFromLDIFMenuItem; |
| | | private JMenuItem duplicateEntryMenuItem; |
| | | private JMenuItem deleteBaseDNMenuItem; |
| | | private JMenuItem deleteBackendMenuItem; |
| | | |
| | | /** |
| | | * Constructor. |
| | | * @param info the control panel info. |
| | | */ |
| | | public BrowseMenuBar(ControlPanelInfo info) |
| | | private BrowseMenuBar(ControlPanelInfo info) |
| | | { |
| | | super(info); |
| | | add(createFileMenuBar()); |
| | |
| | | * Creates the view menu bar. |
| | | * @return the view menu bar. |
| | | */ |
| | | protected JMenu createViewMenuBar() |
| | | private JMenu createViewMenuBar() |
| | | { |
| | | JMenu menu = Utilities.createMenu( |
| | | INFO_CTRL_PANEL_VIEW_MENU.get(), |
| | |
| | | * Creates the entries menu bar. |
| | | * @return the entries menu bar. |
| | | */ |
| | | protected JMenu createEntriesMenuBar() |
| | | private JMenu createEntriesMenuBar() |
| | | { |
| | | JMenu menu = Utilities.createMenu( |
| | | INFO_CTRL_PANEL_ENTRIES_MENU.get(), |
| | |
| | | import java.awt.event.ItemListener; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.DefaultComboBoxModel; |
| | |
| | | import javax.swing.tree.TreeNode; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.event.*; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedEvent; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.IndexModifiedEvent; |
| | | import org.opends.guitools.controlpanel.event.IndexModifiedListener; |
| | | import org.opends.guitools.controlpanel.event.IndexSelectionEvent; |
| | | import org.opends.guitools.controlpanel.event.IndexSelectionListener; |
| | | import org.opends.guitools.controlpanel.task.DeleteIndexTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.ui.components.CustomTree; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.TreeCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** The pane that is displayed when the user clicks on 'Browse Indexes'. */ |
| | | public class BrowseIndexPanel extends StatusGenericPanel |
| | | class BrowseIndexPanel extends StatusGenericPanel |
| | | implements IndexModifiedListener |
| | | { |
| | | private static final long serialVersionUID = 4560020571983291585L; |
| | | |
| | | private JComboBox backends; |
| | | private JComboBox<String> backends; |
| | | private JLabel lNoBackendsFound; |
| | | |
| | | private IndexBrowserRightPanel entryPane; |
| | |
| | | private JButton newIndex; |
| | | private JButton newVLVIndex; |
| | | |
| | | private CategoryTreeNode standardIndexes = new CategoryTreeNode( |
| | | private final CategoryTreeNode standardIndexes = new CategoryTreeNode( |
| | | INFO_CTRL_PANEL_INDEXES_CATEGORY_NODE.get()); |
| | | private CategoryTreeNode vlvIndexes = new CategoryTreeNode( |
| | | private final CategoryTreeNode vlvIndexes = new CategoryTreeNode( |
| | | INFO_CTRL_PANEL_VLV_INDEXES_CATEGORY_NODE.get()); |
| | | |
| | | private AbstractIndexDescriptor lastCreatedIndex; |
| | | |
| | | private TreePath lastIndexTreePath; |
| | | |
| | | private CategoryTreeNode[] categoryNodes = { |
| | | private final CategoryTreeNode[] categoryNodes = { |
| | | standardIndexes, vlvIndexes |
| | | }; |
| | | |
| | |
| | | add(lBackend, gbc); |
| | | |
| | | backends = Utilities.createComboBox(); |
| | | backends.setModel(new DefaultComboBoxModel(new String[]{})); |
| | | backends.setModel(new DefaultComboBoxModel<>(new String[] {})); |
| | | ItemListener comboListener = new ItemListener() |
| | | { |
| | | @Override |
| | |
| | | { |
| | | ignoreSelectionEvents = true; |
| | | ServerDescriptor desc = ev.getNewDescriptor(); |
| | | updateSimpleBackendComboBoxModel(backends, lNoBackendsFound, |
| | | desc); |
| | | refreshContents(desc); |
| | | updateSimpleBackendComboBoxModel(backends, lNoBackendsFound, desc); |
| | | refreshContents(); |
| | | } |
| | | |
| | | /** Adds a pop up menu. */ |
| | |
| | | |
| | | /** |
| | | * Refresh the contents of the tree. |
| | | * @param desc the descriptor containing the index configuration. |
| | | */ |
| | | private void refreshContents(final ServerDescriptor desc) |
| | | private void refreshContents() |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | |
| | | @Override |
| | | public void indexModified(IndexModifiedEvent ev) |
| | | { |
| | | refreshContents(getInfo().getServerDescriptor()); |
| | | refreshContents(); |
| | | } |
| | | |
| | | @Override |
| | | public void backendIndexesModified(IndexModifiedEvent ev) |
| | | { |
| | | refreshContents(getInfo().getServerDescriptor()); |
| | | refreshContents(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | private HashMap<Object, ImageIcon> hmCategoryImages = new HashMap<>(); |
| | | private HashMap<Class<?>, ImageIcon> hmImages = new HashMap<>(); |
| | | private final Map<Object, ImageIcon> hmCategoryImages = new HashMap<>(); |
| | | private final Map<Class<?>, ImageIcon> hmImages = new HashMap<>(); |
| | | { |
| | | Object[] nodes = {standardIndexes, vlvIndexes}; |
| | | String[] paths = {"ds-idx-folder.png", "ds-vlv-idx-folder.png"}; |
| | |
| | | } |
| | | |
| | | /** Specific class used to render the nodes in the tree. It uses specific icons for the nodes. */ |
| | | protected class IndexTreeCellRenderer extends TreeCellRenderer |
| | | private class IndexTreeCellRenderer extends TreeCellRenderer |
| | | { |
| | | private ImageIcon readOnlyIndexIcon = |
| | | Utilities.createImageIcon(IconPool.IMAGE_PATH+"/ds-idx-ro.png"); |
| | |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.table.DefaultTableCellRenderer; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel. |
| | | ConnectionHandlersMonitoringTableModel; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor.Protocol; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor.State; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlersMonitoringTableModel; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor. |
| | | Protocol; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor. |
| | | State; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.ui.renderer. |
| | | NoLeftInsetCategoryComboBoxRenderer; |
| | | import org.opends.guitools.controlpanel.ui.renderer.NoLeftInsetCategoryComboBoxRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | /** Class that displays the monitoring information of connection handlers. */ |
| | | public class ConnectionHandlerMonitoringPanel extends StatusGenericPanel |
| | | class ConnectionHandlerMonitoringPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -6462932160985559830L; |
| | | |
| | | private MonitoringAttributesViewPanel<MonitoringAttributes> |
| | | operationViewPanel; |
| | | private MonitoringAttributesViewPanel<MonitoringAttributes> operationViewPanel; |
| | | private GenericDialog operationViewDlg; |
| | | |
| | | private JComboBox connectionHandlers; |
| | | private JComboBox<String> connectionHandlers; |
| | | |
| | | private JTable connectionHandlersTable; |
| | | private JScrollPane connectionHandlersScroll; |
| | | private ConnectionHandlersMonitoringTableModel connectionHandlersTableModel; |
| | | |
| | | private JLabel lNoConnectionHandlers = Utilities.createPrimaryLabel( |
| | | private final JLabel lNoConnectionHandlers = Utilities.createPrimaryLabel( |
| | | INFO_CTRL_PANEL_NO_CONNECTION_HANDLER_FOUND.get()); |
| | | |
| | | private boolean firstRealDataSet; |
| | |
| | | chOperations.add(BasicMonitoringAttributes.MOD_DN_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.SEARCH_REQUESTS); |
| | | } |
| | | private LinkedHashSet<MonitoringAttributes> allowedChOperations = new LinkedHashSet<>(); |
| | | private final LinkedHashSet<MonitoringAttributes> allowedChOperations = new LinkedHashSet<>(); |
| | | { |
| | | allowedChOperations.addAll(chOperations); |
| | | allowedChOperations.add(BasicMonitoringAttributes.ADD_RESPONSES); |
| | |
| | | allowedChOperations.add(BasicMonitoringAttributes.UNBIND_REQUESTS); |
| | | } |
| | | |
| | | private LocalizableMessage ALL_CONNECTION_HANDLERS = |
| | | private static final LocalizableMessage ALL_CONNECTION_HANDLERS = |
| | | INFO_CTRL_PANEL_ALL_CONNECTION_HANDLERS.get(); |
| | | |
| | | /** Default constructor. */ |
| | |
| | | viewOptions.add(l, gbc); |
| | | gbc.insets.left = 5; |
| | | gbc.insets.right = 10; |
| | | connectionHandlers = new JComboBox( |
| | | new DefaultComboBoxModel(new String[]{"fakeconnectionhandlername"})); |
| | | connectionHandlers = new JComboBox<String>( |
| | | new DefaultComboBoxModel<>(new String[]{"fakeconnectionhandlername"})); |
| | | connectionHandlers.addItemListener( |
| | | new IgnoreItemListener(connectionHandlers)); |
| | | connectionHandlers.addItemListener(new ItemListener() |
| | |
| | | newElements.add(new CategorizedComboBoxElement( |
| | | connectionHandlerLabel, CategorizedComboBoxElement.Type.REGULAR)); |
| | | } |
| | | updateComboBoxModel(newElements, |
| | | (DefaultComboBoxModel)connectionHandlers.getModel()); |
| | | updateComboBoxModel(newElements, (DefaultComboBoxModel<String>) connectionHandlers.getModel()); |
| | | |
| | | boolean displayErrorPane = false; |
| | | LocalizableMessage errorTitle = LocalizableMessage.EMPTY; |
| | |
| | | if (!server.isAuthenticated()) |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_AUTH_REQUIRED_TO_SEE_TRAFFIC_MONITORING_SUMMARY. |
| | | get()); |
| | | mb.append(INFO_CTRL_PANEL_AUTH_REQUIRED_TO_SEE_TRAFFIC_MONITORING_SUMMARY.get()); |
| | | mb.append("<br><br>").append(getAuthenticateHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | errorTitle = INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get(); |
| | |
| | | } |
| | | |
| | | /** The specific menu bar of this panel. */ |
| | | class ConnectionHandlerMonitoringMenuBar extends MainMenuBar |
| | | private class ConnectionHandlerMonitoringMenuBar extends MainMenuBar |
| | | { |
| | | private static final long serialVersionUID = 505187831116443370L; |
| | | |
| | |
| | | * Constructor. |
| | | * @param info the control panel info. |
| | | */ |
| | | public ConnectionHandlerMonitoringMenuBar(ControlPanelInfo info) |
| | | private ConnectionHandlerMonitoringMenuBar(ControlPanelInfo info) |
| | | { |
| | | super(info); |
| | | } |
| | |
| | | } |
| | | |
| | | /** Creates the layout of the panel (but the contents are not populated here). */ |
| | | protected void createLayout() |
| | | private void createLayout() |
| | | { |
| | | JPanel p = new JPanel(new GridBagLayout()); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | |
| | | * @param c the container where all the components will be layed out. |
| | | * @param gbc the grid bag constraints. |
| | | */ |
| | | protected void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | private void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | { |
| | | SuperiorObjectClassesChangedListener listener = |
| | | new SuperiorObjectClassesChangedListener() |
| | |
| | | } |
| | | |
| | | /** The class that performs the export. */ |
| | | protected class ExportTask extends InclusionExclusionTask |
| | | private class ExportTask extends InclusionExclusionTask |
| | | { |
| | | private Set<String> backendSet; |
| | | private String fileName; |
| | |
| | | * @param info the control panel info. |
| | | * @param dlg the progress dialog that shows the progress of the task. |
| | | */ |
| | | public ExportTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private ExportTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendSet = new HashSet<>(); |
| | |
| | | private JButton okButton; |
| | | |
| | | /** The close button. */ |
| | | protected JButton closeButton; |
| | | private JButton closeButton; |
| | | private JButton cancelButton; |
| | | /** The panel contained in the dialog. */ |
| | | protected StatusGenericPanel panel; |
| | |
| | | private JButton okButton; |
| | | |
| | | /** The close button. */ |
| | | protected JButton closeButton; |
| | | private JButton closeButton; |
| | | private JButton cancelButton; |
| | | /** The panel contained in the frame. */ |
| | | protected StatusGenericPanel panel; |
| | | private StatusGenericPanel panel; |
| | | private Component lastComponentWithFocus; |
| | | |
| | | /** |
| | |
| | | private ControlPanelInfo info; |
| | | |
| | | /** The URL to the administration guide. */ |
| | | protected final String ADMINISTRATION_GUIDE_URL = |
| | | private final String ADMINISTRATION_GUIDE_URL = |
| | | Utils.getCustomizedObject("ADMINISTRATION_GUIDE_URL", |
| | | DynamicConstants.ADMINISTRATION_GUIDE_URL, String.class); |
| | | |
| | | /** The URL to the wiki main page. */ |
| | | protected final String DOC_REFERENCE_WIKI = |
| | | private final String DOC_REFERENCE_WIKI = |
| | | Utils.getCustomizedObject("DOC_REFERENCE_WIKI", |
| | | DynamicConstants.DOC_REFERENCE_WIKI, String.class); |
| | | |
| | |
| | | * Tries to display a URL in the systems default WEB browser. |
| | | * @param url the URL to be displayed. |
| | | */ |
| | | protected void displayURL(final String url) |
| | | private void displayURL(final String url) |
| | | { |
| | | BackgroundTask<Void> worker = new BackgroundTask<Void>() |
| | | { |
| | |
| | | } |
| | | |
| | | /** The class that performs the import. */ |
| | | protected class ImportTask extends InclusionExclusionTask |
| | | private class ImportTask extends InclusionExclusionTask |
| | | { |
| | | private Set<String> backendSet; |
| | | private String fileName; |
| | |
| | | * @param info the control panel info. |
| | | * @param dlg the progress dialog that shows the progress of the task. |
| | | */ |
| | | public ImportTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private ImportTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendSet = new HashSet<>(); |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.isDN; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | { |
| | | private static final long serialVersionUID = -3826176895778069011L; |
| | | /** The DNs to exclude. */ |
| | | protected JTextArea dnsToExclude; |
| | | private JTextArea dnsToExclude; |
| | | /** The attributes to exclude. */ |
| | | protected JTextField attributesToExclude; |
| | | private JTextField attributesToExclude; |
| | | /** The exclusion filter. */ |
| | | protected JTextField exclusionFilter; |
| | | private JTextField exclusionFilter; |
| | | /** The DNs to include. */ |
| | | protected JTextArea dnsToInclude; |
| | | private JTextArea dnsToInclude; |
| | | /** The attributes to include. */ |
| | | protected JTextField attributesToInclude; |
| | | private JTextField attributesToInclude; |
| | | /** The inclusion filter. */ |
| | | protected JTextField inclusionFilter; |
| | | private JTextField inclusionFilter; |
| | | |
| | | /** The DNs to include. */ |
| | | protected JLabel lDnsToInclude; |
| | | private JLabel lDnsToInclude; |
| | | /** The attributes to include. */ |
| | | protected JLabel lAttributesToInclude; |
| | | private JLabel lAttributesToInclude; |
| | | /** The inclusion filter label. */ |
| | | protected JLabel lInclusionFilter; |
| | | private JLabel lInclusionFilter; |
| | | /** The DNs to exclude label. */ |
| | | protected JLabel lDnsToExclude; |
| | | private JLabel lDnsToExclude; |
| | | /** The attributes to exclude label. */ |
| | | protected JLabel lAttributesToExclude; |
| | | private JLabel lAttributesToExclude; |
| | | /** The exclusion filter label. */ |
| | | protected JLabel lExclusionFilter; |
| | | private JLabel lExclusionFilter; |
| | | |
| | | @Override |
| | | public void cancelClicked() |
| | |
| | | * The panel that displays an existing index (it appears on the right of the |
| | | * 'Manage Indexes' dialog). |
| | | */ |
| | | public class IndexPanel extends AbstractIndexPanel |
| | | class IndexPanel extends AbstractIndexPanel |
| | | { |
| | | private static final long serialVersionUID = 1439500626486823366L; |
| | | |
| | |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** |
| | |
| | | * selection of the index should be canceled) and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean mustCheckUnsavedChanges() |
| | | boolean mustCheckUnsavedChanges() |
| | | { |
| | | return index != null && |
| | | saveChanges.isVisible() && saveChanges.isEnabled(); |
| | |
| | | * panel, to not save them or simply cancelled the selection change in |
| | | * the tree. |
| | | */ |
| | | public UnsavedChangesDialog.Result checkUnsavedChanges() |
| | | UnsavedChangesDialog.Result checkUnsavedChanges() |
| | | { |
| | | UnsavedChangesDialog.Result result; |
| | | UnsavedChangesDialog unsavedChangesDlg = new UnsavedChangesDialog(Utilities.getParentDialog(this), getInfo()); |
| | |
| | | * @param index |
| | | * the index descriptor to be used to update the panel. |
| | | */ |
| | | public void update(IndexDescriptor index) |
| | | void update(IndexDescriptor index) |
| | | { |
| | | ignoreCheckSave = true; |
| | | setPrimaryValid(lEntryLimit); |
| | |
| | | } |
| | | |
| | | /** The task in charge of modifying the index. */ |
| | | protected class ModifyIndexTask extends Task |
| | | private class ModifyIndexTask extends Task |
| | | { |
| | | private Set<String> backendSet; |
| | | private String attributeName; |
| | | private String backendName; |
| | | private int entryLimitValue; |
| | | private IndexDescriptor indexToModify; |
| | | private SortedSet<IndexType> indexTypes = new TreeSet<>(); |
| | | private final Set<String> backendSet; |
| | | private final String attributeName; |
| | | private final String backendName; |
| | | private final int entryLimitValue; |
| | | private final IndexDescriptor indexToModify; |
| | | private final SortedSet<IndexType> indexTypes; |
| | | private IndexDescriptor modifiedIndex; |
| | | |
| | | /** |
| | |
| | | * @param dlg |
| | | * the progress dialog that shows the progress of the task. |
| | | */ |
| | | public ModifyIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private ModifyIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendName = index.getBackend().getBackendID(); |
| | |
| | | { |
| | | return getCommandLinePath("dsconfig"); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | * @return <CODE>true</CODE> if the provided DN corresponds to a read-only |
| | | * entry and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isReadOnly(String sDn) |
| | | private boolean isReadOnly(String sDn) |
| | | { |
| | | boolean isReadOnly = false; |
| | | try |
| | |
| | | * @param panel the panel that will be contained in the frame. |
| | | * @return the frame to be displayed using the provided panel. |
| | | */ |
| | | protected GenericFrame createFrame(StatusGenericPanel panel) |
| | | private GenericFrame createFrame(StatusGenericPanel panel) |
| | | { |
| | | return new GenericFrame(panel); |
| | | } |
| | |
| | | * Creates the categories contained by this panel. |
| | | * @return the categories contained by this panel. |
| | | */ |
| | | protected ArrayList<Category> createCategories() |
| | | private ArrayList<Category> createCategories() |
| | | { |
| | | ArrayList<Category> categories = new ArrayList<>(); |
| | | LocalizableMessage[][] labels; |
| | |
| | | import javax.swing.JMenu; |
| | | import javax.swing.JMenuItem; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** The menu bar that appears on the main panel. */ |
| | | public class MainMenuBar extends GenericMenuBar |
| | |
| | | * Creates the File menu bar. |
| | | * @return the File menu bar. |
| | | */ |
| | | protected JMenu createFileMenuBar() |
| | | private JMenu createFileMenuBar() |
| | | { |
| | | JMenu menu = Utilities.createMenu(INFO_CTRL_PANEL_FILE_MENU.get(), |
| | | INFO_CTRL_PANEL_FILE_MENU_DESCRIPTION.get()); |
| | |
| | | } |
| | | |
| | | /** The method called when the user clicks on 'Refresh Options'. */ |
| | | protected void refreshOptionsClicked() |
| | | private void refreshOptionsClicked() |
| | | { |
| | | if (panel == null) |
| | | { |
| | |
| | | } |
| | | |
| | | /** The method called when the user clicks on 'Connect to Server...'. */ |
| | | protected void connectToServerClicked() |
| | | private void connectToServerClicked() |
| | | { |
| | | Set<String> runningTasks = new HashSet<>(); |
| | | for (Task task : getInfo().getTasks()) |
| | |
| | | * the attributes definition and objectclasses in the schema of the server. |
| | | * TODO: move somewhere better. |
| | | */ |
| | | public static Entry getEntry(CustomSearchResult csr) throws OpenDsException |
| | | private static Entry getEntry(CustomSearchResult csr) throws OpenDsException |
| | | { |
| | | DN dn = DN.valueOf(csr.getDN()); |
| | | Map<ObjectClass,String> objectClasses = new HashMap<>(); |
| | |
| | | } |
| | | |
| | | /** The specific menu bar of this panel. */ |
| | | class ManageTasksMenuBar extends MainMenuBar |
| | | private class ManageTasksMenuBar extends MainMenuBar |
| | | { |
| | | private static final long serialVersionUID = 5051878116443370L; |
| | | |
| | |
| | | * Constructor. |
| | | * @param info the control panel info. |
| | | */ |
| | | public ManageTasksMenuBar(ControlPanelInfo info) |
| | | private ManageTasksMenuBar(ControlPanelInfo info) |
| | | { |
| | | super(info); |
| | | } |
| | |
| | | import javax.swing.JPanel; |
| | | import javax.swing.JScrollPane; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * The panel that allows the user to select which attributes must be displayed |
| | |
| | | * @param <T> the type of the objects that this panel manages. For now it only |
| | | * manages String and MonitoringAttribute objects. |
| | | */ |
| | | public class MonitoringAttributesViewPanel<T> extends StatusGenericPanel |
| | | class MonitoringAttributesViewPanel<T> extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = 6462932163745559L; |
| | | |
| | | private LinkedHashSet<T> selectedAttributes = new LinkedHashSet<>(); |
| | | private Set<T> monitoringAttributes; |
| | | private final LinkedHashSet<T> selectedAttributes = new LinkedHashSet<>(); |
| | | private final Set<T> monitoringAttributes; |
| | | private boolean isCanceled = true; |
| | | |
| | | /** |
| | |
| | | * @param attributes the list of possible attributes. |
| | | * @return an instance of this panel that uses String as attributes. |
| | | */ |
| | | public static MonitoringAttributesViewPanel<String> createStringInstance(LinkedHashSet<String> attributes) |
| | | static MonitoringAttributesViewPanel<String> createStringInstance(LinkedHashSet<String> attributes) |
| | | { |
| | | return new MonitoringAttributesViewPanel<>(attributes); |
| | | } |
| | |
| | | * @return an instance of this panel that uses MonitoringAttributes as |
| | | * attributes. |
| | | */ |
| | | public static MonitoringAttributesViewPanel<MonitoringAttributes> |
| | | static MonitoringAttributesViewPanel<MonitoringAttributes> |
| | | createMonitoringAttributesInstance(LinkedHashSet<MonitoringAttributes> attributes) |
| | | { |
| | | return new MonitoringAttributesViewPanel<>(attributes); |
| | |
| | | * @param attributes the list of possible attributes. |
| | | * @return an instance of this panel that uses LocalizableMessage as attributes. |
| | | */ |
| | | public static MonitoringAttributesViewPanel<LocalizableMessage> |
| | | static MonitoringAttributesViewPanel<LocalizableMessage> |
| | | createMessageInstance(LinkedHashSet<LocalizableMessage> attributes) |
| | | { |
| | | return new MonitoringAttributesViewPanel<>(attributes); |
| | |
| | | * Default constructor. |
| | | * @param attributes the attributes that will be proposed to the user. |
| | | */ |
| | | protected MonitoringAttributesViewPanel(LinkedHashSet<T> attributes) |
| | | private MonitoringAttributesViewPanel(LinkedHashSet<T> attributes) |
| | | { |
| | | monitoringAttributes = new LinkedHashSet<>(attributes); |
| | | createLayout(); |
| | |
| | | * @param attribute the attribute. |
| | | * @return the message for the provided attribute. |
| | | */ |
| | | protected LocalizableMessage getMessage(T attribute) |
| | | private LocalizableMessage getMessage(T attribute) |
| | | { |
| | | if (attribute instanceof MonitoringAttributes) |
| | | { |
| | |
| | | } |
| | | |
| | | /** The task in charge of creating the base DN (and if required, the backend). */ |
| | | protected class NewBaseDNTask extends Task |
| | | private class NewBaseDNTask extends Task |
| | | { |
| | | private final Set<String> backendSet; |
| | | private final String newBaseDN; |
| | |
| | | * @param dlg |
| | | * the progress dialog that shows the progress of the task. |
| | | */ |
| | | public NewBaseDNTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private NewBaseDNTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendSet = new HashSet<>(); |
| | |
| | | private JLabel dn = Utilities.createDefaultLabel(); |
| | | |
| | | /** An array containing the fields of this panel. */ |
| | | protected final JTextField[] fields = {name, description, filter, |
| | | referenceGroup}; |
| | | private final JTextField[] fields = { name, description, filter, referenceGroup }; |
| | | |
| | | /** Default constructor. */ |
| | | public NewGroupPanel() |
| | |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.text.html.HTMLDocument; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event.PrintStreamListener; |
| | | import org.opends.guitools.controlpanel.ui.components.BasicExpander; |
| | | import org.opends.guitools.controlpanel.util.ApplicationPrintStream; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** The dialog that is used to display progress in a task. */ |
| | | public class ProgressDialog extends GenericDialog |
| | |
| | | } |
| | | |
| | | /** The panel contained in the progress dialog. */ |
| | | static class ProgressPanel extends StatusGenericPanel |
| | | private static class ProgressPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -364496083928260306L; |
| | | private BasicExpander details; |
| | |
| | | * will have a new-line char at the end (is similar to println()). |
| | | * @param msg the HTML formatted text to be appended. |
| | | */ |
| | | public void appendErrorLine(String msg) |
| | | private void appendErrorLine(String msg) |
| | | { |
| | | msg = filterForBugID4988885(msg+"<br>"); |
| | | msg = Utilities.applyFont(msg, ColorAndFontConstants.progressFont); |
| | |
| | | * will be preceded by a new line (is similar to println()). |
| | | * @param msg the HTML formatted text to be appended. |
| | | */ |
| | | public void appendOutputLine(String msg) |
| | | private void appendOutputLine(String msg) |
| | | { |
| | | appendErrorLine(msg); |
| | | } |
| | |
| | | * will be appended as it is (is similar to print()). |
| | | * @param msg the HTML formatted text to be appended. |
| | | */ |
| | | public void appendHtml(String msg) |
| | | private void appendHtml(String msg) |
| | | { |
| | | HTMLDocument doc = (HTMLDocument)logs.getDocument(); |
| | | |
| | |
| | | } |
| | | |
| | | /** Resets the contents of the logs (Details) section. */ |
| | | public void resetLogs() |
| | | private void resetLogs() |
| | | { |
| | | logs.setText(INIT_TEXT); |
| | | } |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import javax.swing.event.ListSelectionEvent; |
| | | import javax.swing.event.ListSelectionListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackupDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.tools.RestoreDB; |
| | | |
| | | /** The panel that appears when the user wants to restore from a backup. */ |
| | | public class RestorePanel extends BackupListPanel |
| | | implements BackupCreatedListener |
| | | class RestorePanel extends BackupListPanel implements BackupCreatedListener |
| | | { |
| | | private static final long serialVersionUID = -205585323128518051L; |
| | | private ListSelectionListener listener; |
| | |
| | | } |
| | | |
| | | /** The task in charge of restoring or verifying the backup. */ |
| | | protected class RestoreTask extends Task |
| | | private class RestoreTask extends Task |
| | | { |
| | | private Set<String> backendSet; |
| | | private String dir; |
| | | private String backupID; |
| | | private boolean verify; |
| | | private final Set<String> backendSet; |
| | | private final String dir; |
| | | private final String backupID; |
| | | private final boolean verify; |
| | | |
| | | /** |
| | | * The constructor of the task. |
| | |
| | | * @param verify whether this is an actual restore or a verify of the |
| | | * backup. |
| | | */ |
| | | public RestoreTask(ControlPanelInfo info, ProgressDialog dlg, |
| | | private RestoreTask(ControlPanelInfo info, ProgressDialog dlg, |
| | | boolean verify) |
| | | { |
| | | super(info, dlg); |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JList; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** The panel that displays a standard attribute definition. */ |
| | | public class StandardAttributePanel extends SchemaElementPanel |
| | | class StandardAttributePanel extends SchemaElementPanel |
| | | { |
| | | private static final long serialVersionUID = -7922968631524763675L; |
| | | private TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, |
| | | LocalizableMessage.EMPTY); |
| | | private JLabel name = Utilities.createDefaultLabel(); |
| | | private JLabel parent = Utilities.createDefaultLabel(); |
| | | private JLabel oid = Utilities.createDefaultLabel(); |
| | | private JLabel aliases = Utilities.createDefaultLabel(); |
| | | private JLabel origin = Utilities.createDefaultLabel(); |
| | | private JLabel description = Utilities.createDefaultLabel(); |
| | | private JLabel usage = Utilities.createDefaultLabel(); |
| | | private JLabel syntax = Utilities.createDefaultLabel(); |
| | | private JLabel approximate = Utilities.createDefaultLabel(); |
| | | private JLabel equality = Utilities.createDefaultLabel(); |
| | | private JLabel ordering = Utilities.createDefaultLabel(); |
| | | private JLabel substring = Utilities.createDefaultLabel(); |
| | | private JLabel type = Utilities.createDefaultLabel(); |
| | | private JList requiredBy = new JList(new DefaultListModel()); |
| | | private JList optionalBy = new JList(new DefaultListModel()); |
| | | private final TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY); |
| | | private final JLabel name = Utilities.createDefaultLabel(); |
| | | private final JLabel parent = Utilities.createDefaultLabel(); |
| | | private final JLabel oid = Utilities.createDefaultLabel(); |
| | | private final JLabel aliases = Utilities.createDefaultLabel(); |
| | | private final JLabel origin = Utilities.createDefaultLabel(); |
| | | private final JLabel description = Utilities.createDefaultLabel(); |
| | | private final JLabel usage = Utilities.createDefaultLabel(); |
| | | private final JLabel syntax = Utilities.createDefaultLabel(); |
| | | private final JLabel approximate = Utilities.createDefaultLabel(); |
| | | private final JLabel equality = Utilities.createDefaultLabel(); |
| | | private final JLabel ordering = Utilities.createDefaultLabel(); |
| | | private final JLabel substring = Utilities.createDefaultLabel(); |
| | | private final JLabel type = Utilities.createDefaultLabel(); |
| | | private final JList<String> requiredBy = new JList<>(new DefaultListModel<String>()); |
| | | private final JList<String> optionalBy = new JList<>(new DefaultListModel<String>()); |
| | | |
| | | /** Default constructor of the panel. */ |
| | | public StandardAttributePanel() |
| | |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** Creates the layout of the panel (but the contents are not populated here). */ |
| | | protected void createLayout() |
| | | private void createLayout() |
| | | { |
| | | createBasicLayout(this, new GridBagConstraints()); |
| | | setBorder(PANEL_BORDER); |
| | |
| | | * @param c the container where all the components will be layed out. |
| | | * @param gbc the grid bag constraints. |
| | | */ |
| | | protected void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | private void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | { |
| | | requiredBy.setVisibleRowCount(5); |
| | | optionalBy.setVisibleRowCount(9); |
| | |
| | | INFO_CTRL_PANEL_REQUIRED_BY_LABEL.get(), |
| | | INFO_CTRL_PANEL_ALLOWED_BY_LABEL.get() |
| | | }; |
| | | JList[] lists = {requiredBy, optionalBy}; |
| | | JList<?>[] lists = { requiredBy, optionalBy }; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | for (int i=0; i<2; i++) |
| | | { |
| | |
| | | c.add(Utilities.createScrollPane(lists[i]), gbc); |
| | | gbc.gridy ++; |
| | | |
| | | final JList list = lists[i]; |
| | | final JList<?> list = lists[i]; |
| | | MouseAdapter clickListener = new MouseAdapter() |
| | | { |
| | | @Override |
| | |
| | | titlePanel.setDetails(LocalizableMessage.raw(n)); |
| | | name.setText(n); |
| | | AttributeType superior = attr.getSuperiorType(); |
| | | if (superior == null) |
| | | { |
| | | n = null; |
| | | } |
| | | else |
| | | { |
| | | n = superior.getNameOrOID(); |
| | | } |
| | | n = superior != null ? superior.getNameOrOID() : null; |
| | | parent.setText(n); |
| | | oid.setText(attr.getOID()); |
| | | origin.setText(StandardObjectClassPanel.getOrigin(new SomeSchemaElement(attr)).toString()); |
| | |
| | | n = NOT_APPLICABLE.toString(); |
| | | } |
| | | description.setText(n); |
| | | if (attr.getUsage() == null) |
| | | { |
| | | n = NOT_APPLICABLE.toString(); |
| | | } |
| | | else |
| | | { |
| | | n = attr.getUsage().toString(); |
| | | } |
| | | n = attr.getUsage() != null ? attr.getUsage().toString() : NOT_APPLICABLE.toString(); |
| | | usage.setText(n); |
| | | Set<String> aliases = getAliases(attr); |
| | | if (!aliases.isEmpty()) |
| | |
| | | } |
| | | } |
| | | |
| | | DefaultListModel model = (DefaultListModel)requiredBy.getModel(); |
| | | DefaultListModel<String> model = (DefaultListModel<String>) requiredBy.getModel(); |
| | | model.clear(); |
| | | for (String oc : requiredByOcs) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | model = (DefaultListModel)optionalBy.getModel(); |
| | | model = (DefaultListModel<String>) optionalBy.getModel(); |
| | | model.clear(); |
| | | for (String oc : optionalByOcs) |
| | | { |
| | |
| | | static LocalizableMessage getTypeValue(AttributeType attr) |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | Boolean[] props = {attr.isOperational(), attr.isSingleValue(), |
| | | boolean[] props = {attr.isOperational(), attr.isSingleValue(), |
| | | attr.isNoUserModification(), attr.isCollective(), |
| | | attr.isObsolete()}; |
| | | LocalizableMessage[][] values = { |
| | |
| | | {INFO_CTRL_PANEL_ATTRIBUTE_COLLECTIVE_LABEL.get(), null}, |
| | | {INFO_CTRL_PANEL_ATTRIBUTE_OBSOLETE_LABEL.get(), null}}; |
| | | int i = 0; |
| | | for (Boolean prop : props) |
| | | for (boolean prop : props) |
| | | { |
| | | LocalizableMessage value = prop ? values[i][0] : values[i][1]; |
| | | if (value != null) |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JList; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | |
| | | } |
| | | |
| | | /** Creates the layout of the panel (but the contents are not populated here). */ |
| | | protected void createLayout() |
| | | private void createLayout() |
| | | { |
| | | createBasicLayout(this, new GridBagConstraints()); |
| | | setBorder(PANEL_BORDER); |
| | |
| | | * @param c the container where all the components will be layed out. |
| | | * @param gbc the grid bag constraints. |
| | | */ |
| | | protected void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | private void createBasicLayout(Container c, GridBagConstraints gbc) |
| | | { |
| | | |
| | | requiredAttributes.setVisibleRowCount(5); |
| | |
| | | import javax.swing.JTable; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNTableModel; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener; |
| | | import org.opends.guitools.controlpanel.ui.components. |
| | | SelectableLabelWithHelpIcon; |
| | | import org.opends.guitools.controlpanel.ui.components.SelectableLabelWithHelpIcon; |
| | | import org.opends.guitools.controlpanel.ui.renderer.BaseDNCellRenderer; |
| | | import org.opends.guitools.controlpanel.ui.renderer.CustomCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | /** |
| | | * The panel displaying the general status of the server (started/stopped), |
| | |
| | | * Updates the contents of the panel with the provided ServerDescriptor. |
| | | * @param desc the ServerDescriptor. |
| | | */ |
| | | public void updateContents(ServerDescriptor desc) |
| | | private void updateContents(ServerDescriptor desc) |
| | | { |
| | | JScrollPane scroll = Utilities.getContainingScroll(this); |
| | | ViewPositions pos; |
| | |
| | | } |
| | | |
| | | /** The task in charge of modifying the VLV index. */ |
| | | protected class ModifyVLVIndexTask extends Task |
| | | private class ModifyVLVIndexTask extends Task |
| | | { |
| | | private final Set<String> backendSet; |
| | | private final String indexName; |
| | |
| | | * @param dlg |
| | | * the progress dialog that shows the progress of the task. |
| | | */ |
| | | public ModifyVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private ModifyVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendID = index.getBackend().getBackendID(); |
| | |
| | | } |
| | | |
| | | /** The task in charge of verifying the index. */ |
| | | protected class VerifyIndexTask extends IndexTask |
| | | private class VerifyIndexTask extends IndexTask |
| | | { |
| | | private String baseDN; |
| | | |
| | |
| | | * @param dlg |
| | | * the progress dialog that shows the progress of the task. |
| | | */ |
| | | public VerifyIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private VerifyIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg, getSelectedBaseDN()); |
| | | this.baseDN = getSelectedBaseDN(); |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.tools.ConfigureWindowsService; |
| | | |
| | | /** The panel that displays the Windows Service panel configuration for the server. */ |
| | |
| | | } |
| | | |
| | | /** The task in charge of updating the windows service configuration. */ |
| | | protected class WindowsServiceTask extends Task |
| | | private class WindowsServiceTask extends Task |
| | | { |
| | | Set<String> backendSet; |
| | | private Set<String> backendSet; |
| | | private boolean enableService; |
| | | /** |
| | | * The constructor of the task. |
| | |
| | | * @param enableService whether the windows service must be enabled or |
| | | * disabled. |
| | | */ |
| | | public WindowsServiceTask(ControlPanelInfo info, ProgressDialog dlg, |
| | | private WindowsServiceTask(ControlPanelInfo info, ProgressDialog dlg, |
| | | boolean enableService) |
| | | { |
| | | super(info, dlg); |
| | |
| | | class WorkQueueMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563700069830L; |
| | | static final List<BasicMonitoringAttributes> attributes = CollectionUtils.newArrayList( |
| | | private static final List<BasicMonitoringAttributes> attributes = CollectionUtils.newArrayList( |
| | | BasicMonitoringAttributes.AVERAGE_REQUEST_BACKLOG, |
| | | BasicMonitoringAttributes.MAX_REQUEST_BACKLOG, |
| | | BasicMonitoringAttributes.CURRENT_REQUEST_BACKLOG, |
| | |
| | | * Mask used as display option. If the provided display options contain |
| | | * this mask, the panel will display the remove all button. |
| | | */ |
| | | public static final int DISPLAY_REMOVE_ALL = 0x001; |
| | | private static final int DISPLAY_REMOVE_ALL = 0x001; |
| | | |
| | | /** |
| | | * Mask used as display option. If the provided display options contain |
| | | * this mask, the panel will display the add all button. |
| | | */ |
| | | public static final int DISPLAY_ADD_ALL = 0x010; |
| | | private static final int DISPLAY_ADD_ALL = 0x010; |
| | | |
| | | |
| | | /** |
| | |
| | | * @param displayOptions the display options. |
| | | * @param theClass the class of the objects in the panel. |
| | | */ |
| | | public AddRemovePanel(int displayOptions, Class<T> theClass) |
| | | private AddRemovePanel(int displayOptions, Class<T> theClass) |
| | | { |
| | | super(new GridBagLayout()); |
| | | setOpaque(false); |
| | |
| | | private CategoryButton expandButton; |
| | | private boolean expanded = true; |
| | | |
| | | static final Border categoryBorder = new AccordionElementBorder(); |
| | | private static final Border categoryBorder = new AccordionElementBorder(); |
| | | |
| | | /** |
| | | * Constructor the the panel. |
| | |
| | | public class DoubleAddRemovePanel<T> extends JPanel |
| | | { |
| | | private static final long serialVersionUID = 6881453848780359594L; |
| | | private SortableListModel<T> availableListModel; |
| | | private SortableListModel<T> selectedListModel1; |
| | | private SortableListModel<T> selectedListModel2; |
| | | private JLabel selectedLabel1; |
| | | private JLabel selectedLabel2; |
| | | private JLabel availableLabel; |
| | | private JButton add1; |
| | | private JButton remove1; |
| | | private JButton add2; |
| | | private JButton remove2; |
| | | private JButton addAll1; |
| | | private JButton removeAll1; |
| | | private JButton addAll2; |
| | | private JButton removeAll2; |
| | | private JScrollPane availableScroll; |
| | | private JScrollPane selectedScroll1; |
| | | private JScrollPane selectedScroll2; |
| | | private JList availableList; |
| | | private JList<T> selectedList1; |
| | | private JList<T> selectedList2; |
| | | private Class<T> theClass; |
| | | private Collection<T> unmovableItems = new ArrayList<>(); |
| | | private final SortableListModel<T> availableListModel; |
| | | private final SortableListModel<T> selectedListModel1; |
| | | private final SortableListModel<T> selectedListModel2; |
| | | private final JLabel selectedLabel1; |
| | | private final JLabel selectedLabel2; |
| | | private final JLabel availableLabel; |
| | | private final JButton add1; |
| | | private final JButton remove1; |
| | | private final JButton add2; |
| | | private final JButton remove2; |
| | | private final JButton addAll1; |
| | | private final JButton removeAll1; |
| | | private final JButton addAll2; |
| | | private final JButton removeAll2; |
| | | private final JScrollPane availableScroll; |
| | | private final JScrollPane selectedScroll1; |
| | | private final JScrollPane selectedScroll2; |
| | | private final JList availableList; |
| | | private final JList<T> selectedList1; |
| | | private final JList<T> selectedList2; |
| | | private final Class<T> theClass; |
| | | private final Collection<T> unmovableItems = new ArrayList<>(); |
| | | private boolean ignoreListEvents; |
| | | |
| | | /** |
| | | * Mask used as display option. If the provided display options contain |
| | | * this mask, the panel will display the remove all button. |
| | | */ |
| | | public static final int DISPLAY_REMOVE_ALL = 0x001; |
| | | private static final int DISPLAY_REMOVE_ALL = 0x001; |
| | | |
| | | /** |
| | | * Mask used as display option. If the provided display options contain |
| | | * this mask, the panel will display the add all button. |
| | | */ |
| | | public static final int DISPLAY_ADD_ALL = 0x010; |
| | | |
| | | |
| | | /** |
| | | * Constructor of the default double add remove panel (including 'Add All' and |
| | | * 'Remove All' buttons). |
| | | * The class is required to avoid warnings in compilation. |
| | | * @param theClass the class of the objects in the panel. |
| | | */ |
| | | public DoubleAddRemovePanel(Class<T> theClass) |
| | | { |
| | | this(DISPLAY_REMOVE_ALL | DISPLAY_ADD_ALL, theClass); |
| | | } |
| | | private static final int DISPLAY_ADD_ALL = 0x010; |
| | | |
| | | /** |
| | | * Constructor of the double add remove panel allowing the user to provide |
| | |
| | | gbc.gridy ++; |
| | | add(addAll1, gbc); |
| | | } |
| | | else |
| | | { |
| | | addAll1 = null; |
| | | } |
| | | |
| | | remove1 = Utilities.createButton( |
| | | INFO_CTRL_PANEL_ADDREMOVE_REMOVE_BUTTON.get()); |
| | |
| | | gbc.insets.top = 5; |
| | | add(removeAll1, gbc); |
| | | } |
| | | else |
| | | { |
| | | removeAll1 = null; |
| | | } |
| | | |
| | | |
| | | gbc.weighty = 1.0; |
| | |
| | | gbc.gridy ++; |
| | | add(addAll2, gbc); |
| | | } |
| | | else |
| | | { |
| | | addAll2 = null; |
| | | } |
| | | |
| | | remove2 = Utilities.createButton( |
| | | INFO_CTRL_PANEL_ADDREMOVE_REMOVE_BUTTON.get()); |
| | |
| | | gbc.insets.top = 5; |
| | | add(removeAll2, gbc); |
| | | } |
| | | else |
| | | { |
| | | removeAll2 = null; |
| | | } |
| | | |
| | | |
| | | gbc.weighty = 1.0; |
| | |
| | | /** The label with the text. */ |
| | | protected JLabel label = Utilities.createDefaultLabel(); |
| | | /** The label with the icon. */ |
| | | protected JLabel iconLabel = new JLabel(icon); |
| | | private JLabel iconLabel = new JLabel(icon); |
| | | private static final ImageIcon icon = |
| | | Utilities.createImageIcon("org/opends/quicksetup/images/help_small.gif"); |
| | | |
| | | |
| | | /** The left inset of the help icon. */ |
| | | protected final int INSET_WITH_ICON= 3; |
| | | private final int INSET_WITH_ICON = 3; |
| | | |
| | | /** |
| | | * The constructor of this panel. |
| | |
| | | import javax.swing.JPanel; |
| | | import javax.swing.KeyStroke; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | | import org.opends.guitools.controlpanel.datamodel.ObjectClassValue; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | /** |
| | | * A simple panel used in the LDAP entry viewers to display the object class |
| | |
| | | public class ObjectClassCellPanel extends JPanel |
| | | { |
| | | private static final long serialVersionUID = -2362754512894888888L; |
| | | private JLabel label; |
| | | private CellEditorButton editButton; |
| | | private final JLabel label; |
| | | private final CellEditorButton editButton; |
| | | private ObjectClassValue value; |
| | | private JLabel lockLabel = Utilities.createDefaultLabel(); |
| | | private final JLabel lockLabel = Utilities.createDefaultLabel(); |
| | | |
| | | private ImageIcon lockIcon = |
| | | private final ImageIcon lockIcon = |
| | | Utilities.createImageIcon(IconPool.IMAGE_PATH+"/field-locked.png"); |
| | | |
| | | /** Default constructor. */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** Explicitly request the focus for the edit button of this panel. */ |
| | | public void requestFocusForButton() |
| | | { |
| | | editButton.requestFocusInWindow(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Adds an action listener to this panel. The action listener will be |
| | | * invoked when the user clicks on the 'Edit' button. |
| | |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.ui.GenericDialog; |
| | | import org.opends.guitools.controlpanel.ui.SelectObjectClassesPanel; |
| | | import org.opends.guitools.controlpanel.ui.renderer. |
| | | SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | { |
| | | private static final long serialVersionUID = 123123973933568L; |
| | | |
| | | private Set<ObjectClass> toExclude = new HashSet<>(); |
| | | private JComboBox singleSuperior = Utilities.createComboBox(); |
| | | private JLabel multipleSuperiors = Utilities.createDefaultLabel(); |
| | | private JButton bSpecifyMultiple = Utilities.createButton( |
| | | private final Set<ObjectClass> toExclude = new HashSet<>(); |
| | | private final JComboBox<ObjectClass> singleSuperior = Utilities.createComboBox(); |
| | | private final JLabel multipleSuperiors = Utilities.createDefaultLabel(); |
| | | private final JButton bSpecifyMultiple = Utilities.createButton( |
| | | INFO_CTRL_PANEL_SPECIFY_MULTIPLE_SUPERIORS_LABEL.get()); |
| | | private JButton bUpdateMultiple = Utilities.createButton( |
| | | private final JButton bUpdateMultiple = Utilities.createButton( |
| | | INFO_CTRL_PANEL_UPDATE_MULTIPLE_SUPERIORS_LABEL.get()); |
| | | |
| | | private SelectObjectClassesPanel superiorsPanel; |
| | | private GenericDialog superiorsDialog; |
| | | |
| | | private String MULTIPLE = "Multiple"; |
| | | private String SINGLE = "Single"; |
| | | private static final String MULTIPLE = "Multiple"; |
| | | private static final String SINGLE = "Single"; |
| | | |
| | | private CardLayout cardLayout = new CardLayout(); |
| | | private final CardLayout cardLayout; |
| | | |
| | | private boolean isMultiple; |
| | | |
| | | private Set<ObjectClass> selectedMultipleSuperiors = new HashSet<>(); |
| | | private Set<SuperiorObjectClassesChangedListener> listeners = new HashSet<>(); |
| | | private final Set<ObjectClass> selectedMultipleSuperiors = new HashSet<>(); |
| | | private final Set<SuperiorObjectClassesChangedListener> listeners = new HashSet<>(); |
| | | |
| | | private Schema schema; |
| | | |
| | |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * Constructor for this panel. |
| | | * @param schema a non {@code null} schema object. |
| | | */ |
| | | public SuperiorObjectClassesEditor(Schema schema) |
| | | { |
| | | this(); |
| | | updateWithSchema(schema); |
| | | } |
| | | |
| | | /** Creates the layout of this panel. */ |
| | | private void createLayout() |
| | | { |
| | |
| | | }); |
| | | SchemaElementComboBoxCellRenderer renderer = new |
| | | SchemaElementComboBoxCellRenderer(singleSuperior); |
| | | DefaultComboBoxModel model = new DefaultComboBoxModel(); |
| | | singleSuperior.setModel(model); |
| | | singleSuperior.setModel(new DefaultComboBoxModel<ObjectClass>()); |
| | | singleSuperior.setRenderer(renderer); |
| | | ItemListener itemListener = new ItemListener() |
| | | { |
| | |
| | | { |
| | | newParents.add(objectClassNameMap.get(key)); |
| | | } |
| | | Utilities.updateComboBoxModel(newParents, |
| | | (DefaultComboBoxModel)singleSuperior.getModel()); |
| | | Utilities.updateComboBoxModel(newParents, (DefaultComboBoxModel<ObjectClass>) singleSuperior.getModel()); |
| | | |
| | | if (this.schema == null) |
| | | { |
| | | // Select the values. |
| | | ObjectClass topClass = schema.getObjectClass("top"); |
| | | singleSuperior.setSelectedItem(topClass); |
| | | singleSuperior.setSelectedItem(schema.getObjectClass("top")); |
| | | } |
| | | this.schema = schema; |
| | | } |
| | |
| | | listeners.add(listener); |
| | | } |
| | | |
| | | /** |
| | | * Removes the provided listener. |
| | | * @param listener the listener to be removed. |
| | | */ |
| | | public void removeParentObjectClassesChangedListener( |
| | | SuperiorObjectClassesChangedListener listener) |
| | | { |
| | | listeners.remove(listener); |
| | | } |
| | | |
| | | private void specifyMultipleClicked() |
| | | { |
| | | updateMultipleClicked(); |
| | |
| | | import javax.swing.Icon; |
| | | import javax.swing.tree.DefaultMutableTreeNode; |
| | | |
| | | import org.opends.guitools.controlpanel.browser.BasicNodeError; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.opends.guitools.controlpanel.browser.BasicNodeError; |
| | | import org.opends.server.types.LDAPURL; |
| | | |
| | | /** The basic node used to render entries in the 'Manage Entries' tree. */ |
| | | public class BasicNode extends DefaultMutableTreeNode { |
| | |
| | | * or not. |
| | | * @return the RDN value from the DN. |
| | | */ |
| | | public static String extractRDN(String dn, boolean showAttributeName) { |
| | | private static String extractRDN(String dn, boolean showAttributeName) |
| | | { |
| | | String result; |
| | | if (dn == null) |
| | | { |
| | |
| | | * @param dn the DN. |
| | | * @return the RDN value from the DN. |
| | | */ |
| | | public static String extractRDN(String dn) { |
| | | private static String extractRDN(String dn) |
| | | { |
| | | return extractRDN(dn, false); |
| | | } |
| | | |
| | |
| | | public static final DataFlavor INFO_FLAVOR = |
| | | new DataFlavor(BrowserNodeInfo.class, "Browse Node Information"); |
| | | |
| | | static DataFlavor[] FLAVORS = {INFO_FLAVOR }; |
| | | private static DataFlavor[] FLAVORS = { INFO_FLAVOR }; |
| | | |
| | | private BrowserNodeInfo[] nodes; |
| | | |
| | |
| | | |
| | | import javax.swing.JTree; |
| | | |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | |
| | |
| | | public class BrowserCellRenderer extends TreeCellRenderer { |
| | | |
| | | private static final long serialVersionUID = 6756291700611741513L; |
| | | Font defaultFont = ColorAndFontConstants.treeFont; |
| | | Font italicFont = defaultFont.deriveFont(Font.ITALIC); |
| | | Font boldFont = defaultFont.deriveFont(Font.BOLD); |
| | | Font italicBoldFont = defaultFont.deriveFont(Font.ITALIC|Font.BOLD); |
| | | BasicNode inspectedNode; |
| | | private final Font defaultFont = ColorAndFontConstants.treeFont; |
| | | private final Font italicFont = defaultFont.deriveFont(Font.ITALIC); |
| | | private final Font boldFont = defaultFont.deriveFont(Font.BOLD); |
| | | private final Font italicBoldFont = defaultFont.deriveFont(Font.ITALIC | Font.BOLD); |
| | | private BasicNode inspectedNode; |
| | | |
| | | /** |
| | | * Sets which is the inspected node. This method simply marks the selected |
| | |
| | | setFont(newFont); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the row height for the provided browser controller. |
| | | * @param controller the browser controller. |
| | | * @return the row height for the provided browser controller. |
| | | */ |
| | | public static int calculateRowHeight(BrowserController controller) { |
| | | return 16; |
| | | } |
| | | } |
| | |
| | | import javax.swing.table.DefaultTableCellRenderer; |
| | | import javax.swing.table.TableCellRenderer; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.ui.components.LabelWithHelpIcon; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** Class used to render the tables. */ |
| | | public class CustomCellRenderer extends LabelWithHelpIcon |
| | |
| | | { |
| | | private static final long serialVersionUID = -8604332267021523835L; |
| | | /** The border of the first column. */ |
| | | protected static final Border column0Border = |
| | | private static final Border column0Border = |
| | | BorderFactory.createCompoundBorder( |
| | | BorderFactory.createMatteBorder(0, 1, 0, 0, |
| | | ColorAndFontConstants.gridColor), |
| | |
| | | { |
| | | private ListCellRenderer defaultRenderer; |
| | | /** The separator used to render a non-selectable separator in the combo box. */ |
| | | protected Component separator; |
| | | private Component separator; |
| | | /** The default font. */ |
| | | protected Font defaultFont; |
| | | /** The category font. */ |
| | | protected Font categoryFont; |
| | | private Font categoryFont; |
| | | |
| | | /** |
| | | * Constructor of a renderer to be used with a combo box. |
| | |
| | | { |
| | | private static final long serialVersionUID = -84332267021523835L; |
| | | /** The border of the first column. TODO: modify CustomCellRenderer to make this public. */ |
| | | protected static final Border column0Border = |
| | | private static final Border column0Border = |
| | | BorderFactory.createCompoundBorder( |
| | | BorderFactory.createMatteBorder(0, 1, 0, 0, |
| | | ColorAndFontConstants.gridColor), |
| | | BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
| | | /** The default border. */ |
| | | public static final Border defaultBorder = CustomCellRenderer.defaultBorder; |
| | | private static final Border defaultBorder = CustomCellRenderer.defaultBorder; |
| | | |
| | | /** Default constructor. */ |
| | | public TaskCellRenderer() |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; |
| | | import org.opends.guitools.controlpanel.task.OnlineUpdateException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.client.AdministrationConnectorCfgClient; |
| | | import org.forgerock.opendj.server.config.client.BackendCfgClient; |
| | | import org.forgerock.opendj.server.config.client.BackendIndexCfgClient; |
| | |
| | | import org.forgerock.opendj.server.config.client.RootDNUserCfgClient; |
| | | import org.forgerock.opendj.server.config.client.SNMPConnectionHandlerCfgClient; |
| | | import org.forgerock.opendj.server.config.client.TaskBackendCfgClient; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; |
| | | import org.opends.guitools.controlpanel.task.OnlineUpdateException; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.tasks.TaskEntry; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | |
| | | private final Map<String, CustomSearchResult> hmConnectionHandlersMonitor = new HashMap<>(); |
| | | |
| | | /** The monitor root entry DN. */ |
| | | protected DN monitorDN = DN.rootDN(); |
| | | private DN monitorDN = DN.rootDN(); |
| | | /** The JVM memory usage monitoring entry DN. */ |
| | | protected DN jvmMemoryUsageDN = DN.rootDN(); |
| | | private DN jvmMemoryUsageDN = DN.rootDN(); |
| | | /** The system information monitoring entry DN. */ |
| | | protected DN systemInformationDN = DN.rootDN(); |
| | | private DN systemInformationDN = DN.rootDN(); |
| | | /**The entry cache monitoring entry DN. */ |
| | | protected DN entryCachesDN = DN.rootDN(); |
| | | private DN entryCachesDN = DN.rootDN(); |
| | | /** The work queue monitoring entry DN. */ |
| | | protected DN workQueueDN = DN.rootDN(); |
| | | private DN workQueueDN = DN.rootDN(); |
| | | /** The version monitoring entry DN. */ |
| | | protected DN versionDN = DN.rootDN(); |
| | | private DN versionDN = DN.rootDN(); |
| | | |
| | | { |
| | | try |
| | |
| | | * |
| | | * @return an array of monitoring attributes to be returned in the request. |
| | | */ |
| | | protected String[] getMonitoringAttributes() |
| | | private String[] getMonitoringAttributes() |
| | | { |
| | | return new String[] {"*"}; |
| | | } |
| | |
| | | * @throws NamingException |
| | | * if there is an error retrieving the values of the search result. |
| | | */ |
| | | protected void handleMonitoringSearchResult(SearchResult sr, |
| | | String searchBaseDN) |
| | | throws NamingException |
| | | private void handleMonitoringSearchResult(SearchResult sr, String searchBaseDN) throws NamingException |
| | | { |
| | | if (javaVersion == null) |
| | | { |
| | |
| | | protected List<Exception> exceptions = Collections.emptyList(); |
| | | |
| | | /** Whether the configuration has already been read or not. */ |
| | | protected boolean configRead; |
| | | private boolean configRead; |
| | | |
| | | /** The set of connection listeners. */ |
| | | protected Set<ConnectionHandlerDescriptor> listeners = Collections.emptySet(); |
| | |
| | | |
| | | import java.awt.Point; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.JScrollPane; |
| | | |
| | |
| | | */ |
| | | public class ViewPositions |
| | | { |
| | | private ArrayList<JScrollPane> scrolls = new ArrayList<>(); |
| | | private ArrayList<Point> points = new ArrayList<>(); |
| | | private final List<JScrollPane> scrolls = new ArrayList<>(); |
| | | private final List<Point> points = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Returns the size of the lists. |
| | | * @return the size of the lists. |
| | | */ |
| | | public int size() |
| | | int size() |
| | | { |
| | | return scrolls.size(); |
| | | } |
| | |
| | | * @param scroll the scroll bar. |
| | | * @param p the point. |
| | | */ |
| | | public void add(JScrollPane scroll, Point p) |
| | | void add(JScrollPane scroll, Point p) |
| | | { |
| | | scrolls.add(scroll); |
| | | points.add(p); |
| | | } |
| | | |
| | | /** Clears the contents of both lists. */ |
| | | public void clear() |
| | | { |
| | | scrolls.clear(); |
| | | points.clear(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the point at the provided index. |
| | | * @param index the index. |
| | | * @return the point at the provided index. |
| | | */ |
| | | public Point getPoint(int index) |
| | | Point getPoint(int index) |
| | | { |
| | | return points.get(index); |
| | | } |
| | |
| | | * @param index the index. |
| | | * @return the scroll at the provided index. |
| | | */ |
| | | public JScrollPane getScrollPane(int index) |
| | | JScrollPane getScrollPane(int index) |
| | | { |
| | | return scrolls.get(index); |
| | | } |
| | |
| | | * |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | protected void disableWindowsService() throws ApplicationException { |
| | | private void disableWindowsService() throws ApplicationException { |
| | | notifyListeners(getFormattedWithPoints( |
| | | INFO_PROGRESS_DISABLING_WINDOWS_SERVICE.get())); |
| | | int code = disableService(System.out, System.err); |
| | |
| | | |
| | | switch (code) { |
| | | case SERVICE_DISABLE_SUCCESS: |
| | | break; |
| | | case SERVICE_ALREADY_DISABLED: |
| | | break; |
| | | default: |
| | |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | import org.opends.admin.ads.util.ServerLoader; |
| | | import org.opends.quicksetup.event.ProgressNotifier; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.ui.GuiApplication; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.UIKeyStore; |
| | | import org.opends.quicksetup.util.Utils; |
| | |
| | | protected ProgressMessageFormatter formatter; |
| | | |
| | | /** Handler for listeners and event firing. */ |
| | | protected ProgressUpdateListenerDelegate listenerDelegate; |
| | | private ProgressUpdateListenerDelegate listenerDelegate; |
| | | |
| | | private ErrorPrintStream err = new ErrorPrintStream(); |
| | | private OutputPrintStream out = new OutputPrintStream(); |
| | | private final ErrorPrintStream err = new ErrorPrintStream(); |
| | | private final OutputPrintStream out = new OutputPrintStream(); |
| | | |
| | | /** Temporary log file where messages will be logged. */ |
| | | protected TempLogFile tempLogFile; |
| | | |
| | | /** |
| | | * Creates an application by instantiating the Application class |
| | | * denoted by the System property |
| | | * <code>org.opends.quicksetup.Application.class</code>. |
| | | * @return Application object that was newly instantiated |
| | | * @throws RuntimeException if there was a problem |
| | | * creating the new Application object |
| | | */ |
| | | public static GuiApplication create() throws RuntimeException { |
| | | GuiApplication app; |
| | | String appClassName = |
| | | System.getProperty("org.opends.quicksetup.Application.class"); |
| | | if (appClassName != null) { |
| | | Class<?> appClass = null; |
| | | try { |
| | | appClass = Class.forName(appClassName); |
| | | app = (GuiApplication) appClass.newInstance(); |
| | | } catch (ClassNotFoundException e) { |
| | | logger.info(LocalizableMessage.raw("error creating quicksetup application", e)); |
| | | String msg = "Application class " + appClass + " not found"; |
| | | throw new RuntimeException(msg, e); |
| | | } catch (IllegalAccessException e) { |
| | | logger.info(LocalizableMessage.raw("error creating quicksetup application", e)); |
| | | String msg = "Could not access class " + appClass; |
| | | throw new RuntimeException(msg, e); |
| | | } catch (InstantiationException e) { |
| | | logger.info(LocalizableMessage.raw("error creating quicksetup application", e)); |
| | | String msg = "Error instantiating class " + appClass; |
| | | throw new RuntimeException(msg, e); |
| | | } catch (ClassCastException e) { |
| | | String msg = "The class indicated by the system property " + |
| | | "'org.opends.quicksetup.Application.class' must " + |
| | | " must be of type Application"; |
| | | throw new RuntimeException(msg, e); |
| | | } |
| | | } else { |
| | | String msg = "System property 'org.opends.quicksetup.Application.class'" + |
| | | " must specify class quicksetup application"; |
| | | throw new RuntimeException(msg); |
| | | } |
| | | return app; |
| | | } |
| | | |
| | | /** |
| | | * Sets this instances user data. |
| | | * @param userData UserData this application will use |
| | | * when executing |
| | |
| | | */ |
| | | public void checkAbort() throws ApplicationException |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected void applicationPrintStreamReceived(String message) |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** |
| | |
| | | * This class is used to notify the ProgressUpdateListeners of events |
| | | * that are written to the standard streams. |
| | | */ |
| | | protected abstract class ApplicationPrintStream extends PrintStream { |
| | | private abstract class ApplicationPrintStream extends PrintStream |
| | | { |
| | | |
| | | private boolean isFirstLine; |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.util.Set; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | /** |
| | | * Represents the contents of an OpenDS configuration file. |
| | |
| | | |
| | | private String contents; |
| | | private String lowerCaseContents; |
| | | private Installation install; |
| | | private File file; |
| | | private final Installation install; |
| | | private final File file; |
| | | |
| | | /** |
| | | * Create a Configuration from a file. |
| | |
| | | * Loads the contents of the configuration file into memory. |
| | | * @throws IOException if there were problems loading the file |
| | | */ |
| | | public void load() throws IOException { |
| | | private void load() throws IOException |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | FileReader reader = new FileReader(file); |
| | | BufferedReader in = new BufferedReader(reader); |
| | |
| | | /** The relative path where all the UNIX binaries (scripts) are. */ |
| | | public static final String UNIX_BINARIES_PATH_RELATIVE = "bin"; |
| | | /** The relative path where all the MacOS X Applications are. */ |
| | | public static final String MAC_APPLICATIONS_PATH_RELATIVE = "bin"; |
| | | private static final String MAC_APPLICATIONS_PATH_RELATIVE = "bin"; |
| | | /** The relative path where all the libraries (jar files) are. */ |
| | | public static final String LIBRARIES_PATH_RELATIVE = SetupUtils.LIBRARIES_PATH_RELATIVE; |
| | | /** The relative path where the resources directory (to customize the product) is. */ |
| | | public static final String RESOURCES_PATH_RELATIVE = "resources"; |
| | | private static final String RESOURCES_PATH_RELATIVE = "resources"; |
| | | /** The relative path where customer classes are. */ |
| | | public static final String CLASSES_PATH_RELATIVE = "classes"; |
| | | private static final String CLASSES_PATH_RELATIVE = "classes"; |
| | | /** The relative path where the database files are. */ |
| | | public static final String DATABASES_PATH_RELATIVE = "db"; |
| | | private static final String DATABASES_PATH_RELATIVE = "db"; |
| | | /** The relative path where the log files are. */ |
| | | public static final String LOGS_PATH_RELATIVE = "logs"; |
| | | private static final String LOGS_PATH_RELATIVE = "logs"; |
| | | /** The relative path where the LDIF files are. */ |
| | | public static final String LDIFS_PATH_RELATIVE = "ldif"; |
| | | private static final String LDIFS_PATH_RELATIVE = "ldif"; |
| | | /** The relative path where the backup files are. */ |
| | | public static final String BACKUPS_PATH_RELATIVE = "bak"; |
| | | /** The relative path where the config files are. */ |
| | | public static final String CONFIG_PATH_RELATIVE = "config"; |
| | | /** The relative path where the config files are. */ |
| | | public static final String HISTORY_PATH_RELATIVE = "history"; |
| | | private static final String HISTORY_PATH_RELATIVE = "history"; |
| | | /** Path to the config/upgrade directory where upgrade base files are stored. */ |
| | | public static final String UPGRADE_PATH = "upgrade"; |
| | | private static final String UPGRADE_PATH = "upgrade"; |
| | | /** Relative path to the locks directory. */ |
| | | public static final String LOCKS_PATH_RELATIVE = "locks"; |
| | | /** Relative path to the locks directory. */ |
| | | public static final String TMP_PATH_RELATIVE = "tmp"; |
| | | private static final String TMP_PATH_RELATIVE = "tmp"; |
| | | /** The relative path to the current Configuration LDIF file. */ |
| | | public static final String CURRENT_CONFIG_FILE_NAME = "config.ldif"; |
| | | private static final String CURRENT_CONFIG_FILE_NAME = "config.ldif"; |
| | | /** The relative path to the current Configuration LDIF file. */ |
| | | public static final String BASE_CONFIG_FILE_PREFIX = "config.ldif."; |
| | | private static final String BASE_CONFIG_FILE_PREFIX = "config.ldif."; |
| | | /** The relative path to the instance.loc file. */ |
| | | public static final String INSTANCE_LOCATION_PATH_RELATIVE = "instance.loc"; |
| | | /** The path to the instance.loc file. */ |
| | | public static final String INSTANCE_LOCATION_PATH = "/etc/opendj/" |
| | | + INSTANCE_LOCATION_PATH_RELATIVE; |
| | | /** The relative path to tmpl_instance. */ |
| | | public static final String TEMPLATE_RELATIVE_PATH = "template"; |
| | | private static final String TEMPLATE_RELATIVE_PATH = "template"; |
| | | /** The relative path to buildinfo file. */ |
| | | public static final String BUILDINFO_RELATIVE_PATH = "buildinfo"; |
| | | private static final String BUILDINFO_RELATIVE_PATH = "buildinfo"; |
| | | /** The UNIX setup script file name. */ |
| | | public static final String UNIX_SETUP_FILE_NAME = "setup"; |
| | | /** The Windows setup batch file name. */ |
| | | public static final String WINDOWS_SETUP_FILE_NAME = "setup.bat"; |
| | | private static final String WINDOWS_SETUP_FILE_NAME = "setup.bat"; |
| | | /** The UNIX uninstall script file name. */ |
| | | public static final String UNIX_UNINSTALL_FILE_NAME = "uninstall"; |
| | | /** The Windows uninstall batch file name. */ |
| | |
| | | * consuming |
| | | * @return BuildInformation object describing this instance |
| | | */ |
| | | public BuildInformation getInstanceBuildInformation(boolean useCachedVersion) |
| | | private BuildInformation getInstanceBuildInformation(boolean useCachedVersion) |
| | | { |
| | | if (instanceInformation == null || !useCachedVersion) |
| | | { |
| | |
| | | * @param defaultJavaArguments the default values for the java arguments. |
| | | * @return the message representing a java arguments object. |
| | | */ |
| | | public static LocalizableMessage getMessage(JavaArguments javaArguments, |
| | | private static LocalizableMessage getMessage(JavaArguments javaArguments, |
| | | JavaArguments defaultJavaArguments) |
| | | { |
| | | LocalizableMessage msg; |
| | |
| | | */ |
| | | package org.opends.quicksetup; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import com.forgerock.opendj.cli.ArgumentParser; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.server.util.DynamicConstants.PRINTABLE_VERSION_STRING; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | |
| | | import java.io.PrintStream; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentParser; |
| | | |
| | | /** |
| | | * Responsible for providing initial evaluation of command line arguments |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Arguments with which this launcher was invoked. */ |
| | | protected String[] args; |
| | | protected final String[] args; |
| | | |
| | | /** The temporary log file which will be kept if an error occurs. */ |
| | | protected final TempLogFile tempLogFile; |
| | |
| | | * @param toStdErr whether the message must be printed to the standard error |
| | | * or the standard output. |
| | | */ |
| | | protected void printUsage(String i18nMsg, boolean toStdErr) { |
| | | private void printUsage(String i18nMsg, boolean toStdErr) |
| | | { |
| | | if (toStdErr) |
| | | { |
| | | System.err.println(i18nMsg); |
| | |
| | | * @return 0 if everything worked fine, and an error code if something wrong |
| | | * occurred. |
| | | */ |
| | | protected int launchCli(CliApplication cliApp) |
| | | private int launchCli(CliApplication cliApp) |
| | | { |
| | | System.setProperty(Constants.CLI_JAVA_PROPERTY, "true"); |
| | | QuickSetupCli cli = new QuickSetupCli(cliApp, this); |
| | |
| | | } |
| | | |
| | | /** Prints the version statement to standard output terminal. */ |
| | | protected void printVersion() |
| | | private void printVersion() |
| | | { |
| | | System.out.print(PRINTABLE_VERSION_STRING); |
| | | } |
| | |
| | | * @param toStdErr whether the message must be printed to the standard error |
| | | * or the standard output. |
| | | */ |
| | | protected void printUsage(boolean toStdErr) { |
| | | private void printUsage(boolean toStdErr) |
| | | { |
| | | try |
| | | { |
| | | ArgumentParser argParser = getArgumentParser(); |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.wrapText; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | /** Class used by Launcher to start a CLI application. */ |
| | | public class QuickSetupCli { |
| | | |
| | | /** Arguments passed in the command line. */ |
| | | protected Launcher launcher; |
| | | |
| | | private CliApplication cliApp; |
| | | |
| | | private UserData userData; |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Arguments passed in the command line. */ |
| | | private final Launcher launcher; |
| | | private final CliApplication cliApp; |
| | | private UserData userData; |
| | | |
| | | /** |
| | | * Creates a QuickSetupCli instance. |
| | | * @param cliApp the application to be run |
| | |
| | | * @return the return code (SUCCESSFUL, CANCELLED, USER_DATA_ERROR, |
| | | * ERROR_ACCESSING_FILE_SYSTEM, ERROR_STOPPING_SERVER or BUG. |
| | | */ |
| | | public ReturnCode run() |
| | | ReturnCode run() |
| | | { |
| | | ReturnCode returnValue; |
| | | // Parse the arguments |
| | |
| | | /** Return code for errors that are non-specified. */ |
| | | public static final ReturnCode UNKNOWN = new ReturnCode(100); |
| | | |
| | | private int code; |
| | | private final int code; |
| | | |
| | | /** |
| | | * Creates a new parameterized instance. |
| | | * |
| | | * @param code to return |
| | | */ |
| | | public ReturnCode(int code) { |
| | | private ReturnCode(int code) |
| | | { |
| | | this.code = code; |
| | | } |
| | | |
| | |
| | | private CertificateType certificateType; |
| | | private String keyStorePath; |
| | | private String keyStorePassword; |
| | | private Set<String> aliasesToUse = new TreeSet<>(); |
| | | private final Set<String> aliasesToUse = new TreeSet<>(); |
| | | |
| | | private SecurityOptions() |
| | | { |
| | |
| | | * @return a new instance of a SecurityOptions using a self-signed |
| | | * certificate. |
| | | */ |
| | | public static SecurityOptions createSelfSignedCertificateOptions(boolean enableSSL, boolean enableStartTLS, |
| | | private static SecurityOptions createSelfSignedCertificateOptions(boolean enableSSL, boolean enableStartTLS, |
| | | int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | |
| | | * Sets the certificates aliases name. |
| | | * @param aliasesToUse the certificates aliases name. |
| | | */ |
| | | void setAliasToUse(Collection<String> aliasesToUse) |
| | | private void setAliasToUse(Collection<String> aliasesToUse) |
| | | { |
| | | this.aliasesToUse.clear(); |
| | | this.aliasesToUse.addAll(aliasesToUse); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.installer; |
| | | |
| | | import java.util.HashSet; |
| | |
| | | * Class used to know what has been modified in the configuration of a |
| | | * replication domain. |
| | | * This class provides a read only view of what has been configured. |
| | | * |
| | | */ |
| | | class ConfiguredDomain |
| | | { |
| | | private String domainName; |
| | | private boolean isCreated; |
| | | Set<String> addedReplicationServers; |
| | | private final String domainName; |
| | | private final boolean isCreated; |
| | | private final Set<String> addedReplicationServers; |
| | | |
| | | /** |
| | | * Constructor of the ConfiguredDomain object. |
| | |
| | | * @return the free port of type X989 if it is available and we can use and -1 |
| | | * if not. |
| | | */ |
| | | static int getDefaultReplicationPort() |
| | | private static int getDefaultReplicationPort() |
| | | { |
| | | int defaultPort = -1; |
| | | |
| | |
| | | private TopologyCache lastLoadedCache; |
| | | |
| | | /** Indicates that we've detected that there is something installed. */ |
| | | boolean forceToDisplaySetup; |
| | | private boolean forceToDisplaySetup; |
| | | |
| | | /** When true indicates that the user has canceled this operation. */ |
| | | protected boolean canceled; |
| | | |
| | | private boolean canceled; |
| | | private boolean javaVersionCheckFailed; |
| | | |
| | | /** Map containing information about what has been configured remotely. */ |
| | | private final Map<ServerDescriptor, ConfiguredReplication> hmConfiguredRemoteReplication = new HashMap<>(); |
| | | |
| | | /** Set of progress steps that have been completed. */ |
| | | protected Set<InstallProgressStep> completedProgress = new HashSet<>(); |
| | | |
| | | private final List<WizardStep> lstSteps = new ArrayList<>(); |
| | | |
| | | private final Set<WizardStep> SUBSTEPS = new HashSet<>(); |
| | | { |
| | | SUBSTEPS.add(Step.CREATE_GLOBAL_ADMINISTRATOR); |
| | | SUBSTEPS.add(Step.SUFFIXES_OPTIONS); |
| | | SUBSTEPS.add(Step.NEW_SUFFIX_OPTIONS); |
| | | SUBSTEPS.add(Step.REMOTE_REPLICATION_PORTS); |
| | | } |
| | | private final Set<InstallProgressStep> completedProgress = new HashSet<>(); |
| | | private final List<WizardStep> listSteps = new ArrayList<>(); |
| | | private final Set<WizardStep> SUBSTEPS = CollectionUtils.<WizardStep> newHashSet( |
| | | Step.CREATE_GLOBAL_ADMINISTRATOR, |
| | | Step.SUFFIXES_OPTIONS, |
| | | Step.NEW_SUFFIX_OPTIONS, |
| | | Step.REMOTE_REPLICATION_PORTS); |
| | | |
| | | private final Map<WizardStep, WizardStep> hmPreviousSteps = new HashMap<>(); |
| | | |
| | |
| | | private String lastImportProgress; |
| | | |
| | | /** Aliases of self-signed certificates. */ |
| | | protected static final String SELF_SIGNED_CERT_ALIASES[] = new String[] { |
| | | private static final String[] SELF_SIGNED_CERT_ALIASES = { |
| | | SecurityOptions.SELF_SIGNED_CERT_ALIAS, |
| | | SecurityOptions.SELF_SIGNED_EC_CERT_ALIAS }; |
| | | SecurityOptions.SELF_SIGNED_EC_CERT_ALIAS |
| | | }; |
| | | |
| | | /** |
| | | * The threshold in minutes used to know whether we must display a warning |
| | |
| | | /** Creates a default instance. */ |
| | | public Installer() |
| | | { |
| | | addStepsInOrder(lstSteps, LicenseFile.exists()); |
| | | addStepsInOrder(listSteps, LicenseFile.exists()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public Set<? extends WizardStep> getWizardSteps() |
| | | { |
| | | return Collections.unmodifiableSet(new HashSet<WizardStep>(lstSteps)); |
| | | return Collections.unmodifiableSet(new HashSet<WizardStep>(listSteps)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | else |
| | | { |
| | | int i = lstSteps.indexOf(step); |
| | | if (i != -1 && i + 1 < lstSteps.size()) |
| | | int i = listSteps.indexOf(step); |
| | | if (i != -1 && i + 1 < listSteps.size()) |
| | | { |
| | | return lstSteps.get(i + 1); |
| | | return listSteps.get(i + 1); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | public LinkedHashSet<WizardStep> getOrderedSteps() |
| | | { |
| | | LinkedHashSet<WizardStep> orderedSteps = new LinkedHashSet<>(); |
| | | addStepsInOrder(orderedSteps, lstSteps.contains(LICENSE)); |
| | | addStepsInOrder(orderedSteps, listSteps.contains(LICENSE)); |
| | | return orderedSteps; |
| | | } |
| | | |
| | |
| | | |
| | | if (prev == null) |
| | | { |
| | | int i = lstSteps.indexOf(step); |
| | | int i = listSteps.indexOf(step); |
| | | if (i != -1 && i > 0) |
| | | { |
| | | prev = lstSteps.get(i - 1); |
| | | prev = listSteps.get(i - 1); |
| | | } |
| | | } |
| | | return prev; |
| | |
| | | * Uninstalls installed services. This is to be used when the user has elected |
| | | * to cancel an installation. |
| | | */ |
| | | protected void uninstallServices() |
| | | private void uninstallServices() |
| | | { |
| | | if (completedProgress.contains(InstallProgressStep.ENABLING_WINDOWS_SERVICE)) |
| | | { |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void configureServer() throws ApplicationException |
| | | private void configureServer() throws ApplicationException |
| | | { |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CONFIGURING.get())); |
| | | copyTemplateInstance(); |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void createReplicatedBackendsIfRequired() throws ApplicationException |
| | | private void createReplicatedBackendsIfRequired() throws ApplicationException |
| | | { |
| | | if (FIRST_IN_TOPOLOGY == getUserData().getReplicationOptions().getType()) |
| | | { |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void configureReplication() throws ApplicationException |
| | | private void configureReplication() throws ApplicationException |
| | | { |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CONFIGURING_REPLICATION.get())); |
| | | |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void enableWindowsService() throws ApplicationException |
| | | private void enableWindowsService() throws ApplicationException |
| | | { |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_ENABLING_WINDOWS_SERVICE.get())); |
| | | InstallerHelper helper = new InstallerHelper(); |
| | |
| | | * @param isCli |
| | | * a boolean to indicate if the install is using CLI or GUI |
| | | */ |
| | | protected void initSummaryMap(Map<ProgressStep, LocalizableMessage> hmSummary, boolean isCli) |
| | | private void initSummaryMap(Map<ProgressStep, LocalizableMessage> hmSummary, boolean isCli) |
| | | { |
| | | put(hmSummary, NOT_STARTED, INFO_SUMMARY_INSTALL_NOT_STARTED); |
| | | put(hmSummary, CONFIGURING_SERVER, INFO_SUMMARY_CONFIGURING); |
| | |
| | | * @param isCli |
| | | * a boolean to indicate if the install is using CLI or GUI |
| | | */ |
| | | protected void updateSummaryWithServerState(Map<ProgressStep, LocalizableMessage> hmSummary, Boolean isCli) |
| | | private void updateSummaryWithServerState(Map<ProgressStep, LocalizableMessage> hmSummary, Boolean isCli) |
| | | { |
| | | Installation installation = getInstallation(); |
| | | String cmd = getPath(installation.getControlPanelCommandFile()); |
| | |
| | | * @param currentProgressStep |
| | | * the current progress step of the installation process. |
| | | */ |
| | | protected void setCurrentProgressStep(InstallProgressStep currentProgressStep) |
| | | private void setCurrentProgressStep(InstallProgressStep currentProgressStep) |
| | | { |
| | | if (currentProgressStep != null) |
| | | { |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void createData() throws ApplicationException |
| | | private void createData() throws ApplicationException |
| | | { |
| | | if (createNotReplicatedSuffix() |
| | | && NewSuffixOptions.Type.LEAVE_DATABASE_EMPTY != getUserData().getNewSuffixOptions().getType()) |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void initializeSuffixes() throws ApplicationException |
| | | private void initializeSuffixes() throws ApplicationException |
| | | { |
| | | ConnectionWrapper conn = null; |
| | | try |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | protected void updateADS() throws ApplicationException |
| | | private void updateADS() throws ApplicationException |
| | | { |
| | | DataReplicationOptions repl = getUserData().getReplicationOptions(); |
| | | boolean isRemoteServer = repl.getType() == DataReplicationOptions.Type.IN_EXISTING_TOPOLOGY; |
| | |
| | | * |
| | | * @return {@code true} if we must create a new suffix and {@code false} otherwise. |
| | | */ |
| | | protected boolean createNotReplicatedSuffix() |
| | | private boolean createNotReplicatedSuffix() |
| | | { |
| | | DataReplicationOptions repl = getUserData().getReplicationOptions(); |
| | | |
| | |
| | | * |
| | | * @return {@code true} if we must configure replication and {@code false} otherwise. |
| | | */ |
| | | protected boolean mustConfigureReplication() |
| | | private boolean mustConfigureReplication() |
| | | { |
| | | return getUserData().getReplicationOptions().getType() != DataReplicationOptions.Type.STANDALONE; |
| | | } |
| | |
| | | * |
| | | * @return {@code true} if we must create the ADS and {@code false} otherwise. |
| | | */ |
| | | protected boolean mustCreateAds() |
| | | private boolean mustCreateAds() |
| | | { |
| | | return getUserData().getReplicationOptions().getType() != DataReplicationOptions.Type.STANDALONE; |
| | | } |
| | |
| | | * |
| | | * @return {@code true} if we must start the server and {@code false} otherwise. |
| | | */ |
| | | protected boolean mustStart() |
| | | private boolean mustStart() |
| | | { |
| | | return getUserData().getStartServer() || mustCreateAds(); |
| | | } |
| | |
| | | * |
| | | * @return {@code true} if the start server must be launched in verbose mode and {@code false} otherwise. |
| | | */ |
| | | protected boolean isStartVerbose() |
| | | private boolean isStartVerbose() |
| | | { |
| | | if (isVerbose()) |
| | | { |
| | |
| | | * |
| | | * @return {@code true} if we must stop the server and {@code false} otherwise. |
| | | */ |
| | | protected boolean mustStop() |
| | | private boolean mustStop() |
| | | { |
| | | return !getUserData().getStartServer() && mustCreateAds(); |
| | | } |
| | |
| | | * |
| | | * @return {@code true} if we must initialize suffixes and {@code false} otherwise. |
| | | */ |
| | | protected boolean mustInitializeSuffixes() |
| | | private boolean mustInitializeSuffixes() |
| | | { |
| | | return getUserData().getReplicationOptions().getType() == DataReplicationOptions.Type.IN_EXISTING_TOPOLOGY; |
| | | } |
| | |
| | | private void updateUserDataForServerSettingsPanel(QuickSetup qs) throws UserDataException |
| | | { |
| | | List<LocalizableMessage> errorMsgs = new ArrayList<>(); |
| | | LocalizableMessage confirmationMsg = null; |
| | | |
| | | // Check the host is not empty. |
| | | // TODO: check that the host name is valid... |
| | |
| | | { |
| | | throw new UserDataException(Step.SERVER_SETTINGS, getMessageFromCollection(errorMsgs, "\n")); |
| | | } |
| | | if (confirmationMsg != null) |
| | | { |
| | | throw new UserDataConfirmationException(Step.SERVER_SETTINGS, confirmationMsg); |
| | | } |
| | | } |
| | | |
| | | private LocalizableMessage getCannotBindErrorMessage(int port) |
| | |
| | | { |
| | | host = getHostNameForLdapUrl(host); |
| | | HostPort hostPort = new HostPort(host, port); |
| | | ConnectionWrapper conn = null; |
| | | |
| | | ApplicationTrustManager trustManager = getTrustManager(); |
| | | trustManager.setHost(host); |
| | | trustManager.resetLastRefusedItems(); |
| | | try |
| | | try (ConnectionWrapper conn = newConnectionWrapper(dn, pwd, effectiveDn, hostPort, trustManager)) |
| | | { |
| | | effectiveDn[0] = dn; |
| | | try |
| | | { |
| | | conn = new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | if (!isCertificateException(t)) |
| | | { |
| | | // Try using a global administrator |
| | | dn = ADSContext.getAdministratorDN(dn); |
| | | effectiveDn[0] = dn; |
| | | conn = new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | | else |
| | | { |
| | | throw t; |
| | | } |
| | | } |
| | | ADSContext adsContext = new ADSContext(conn); |
| | | if (adsContext.hasAdminData()) |
| | | { |
| | |
| | | throw new UserDataCertificateException(Step.REPLICATION_OPTIONS, INFO_CERTIFICATE_EXCEPTION.get(host, port), |
| | | t, host, port, trustManager.getLastRefusedChain(), trustManager.getLastRefusedAuthType(), excType); |
| | | } |
| | | else |
| | | { |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_HOST, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PORT, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true); |
| | | errorMsgs.add(INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(host + ":" + port, t)); |
| | | } |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_HOST, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PORT, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true); |
| | | errorMsgs.add(INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(host + ":" + port, t)); |
| | | } |
| | | else if (t instanceof NamingException) |
| | | { |
| | |
| | | throw new UserDataException(Step.REPLICATION_OPTIONS, getThrowableMsg(INFO_BUG_MSG.get(), t)); |
| | | } |
| | | } |
| | | finally |
| | | } |
| | | |
| | | private ConnectionWrapper newConnectionWrapper(String dn, String pwd, String[] effectiveDn, HostPort hostPort, |
| | | ApplicationTrustManager trustManager) throws Throwable |
| | | { |
| | | try |
| | | { |
| | | StaticUtils.close(conn); |
| | | effectiveDn[0] = dn; |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | if (isCertificateException(t)) |
| | | { |
| | | throw t; |
| | | } |
| | | // Try using a global administrator |
| | | dn = ADSContext.getAdministratorDN(dn); |
| | | effectiveDn[0] = dn; |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return the keystore path to be used for generating a self-signed |
| | | * certificate. |
| | | */ |
| | | protected String getSelfSignedKeystorePath() |
| | | private String getSelfSignedKeystorePath() |
| | | { |
| | | return getPath2("keystore"); |
| | | } |
| | |
| | | * |
| | | * @return the self-signed certificate password used for this session. |
| | | */ |
| | | protected String getSelfSignedCertificatePwd() |
| | | private String getSelfSignedCertificatePwd() |
| | | { |
| | | if (selfSignedCertPw == null) |
| | | { |
| | |
| | | * the ServerDescriptor. |
| | | * @return the host port string representation of the provided server. |
| | | */ |
| | | protected HostPort getHostPort(ServerDescriptor server) |
| | | private HostPort getHostPort(ServerDescriptor server) |
| | | { |
| | | HostPort hostPort = null; |
| | | |
| | |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | protected int getConnectTimeout() |
| | | private int getConnectTimeout() |
| | | { |
| | | return getUserData().getConnectTimeout(); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Deletes a backend on the server. |
| | | * @param connWrapper the connection to the server. |
| | | * @param backendName the name of the backend to be deleted. |
| | | * @param serverDisplay the server display. |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | public void deleteBackend(ConnectionWrapper connWrapper, String backendName, String serverDisplay) |
| | | throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | connWrapper.getRootConfiguration().removeBackend(backendName); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | throw new ApplicationException( |
| | | ReturnCode.CONFIGURATION_ERROR, |
| | | INFO_ERROR_CONFIGURING_REMOTE_GENERIC.get(serverDisplay, t), |
| | | t); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Deletes a backend on the server. It assumes the server is stopped. |
| | | * @param backendName the name of the backend to be deleted. |
| | | * @throws ApplicationException if something goes wrong. |
| | |
| | | RootCfgClient root = conn.getRootConfiguration(); |
| | | BackendCfgClient backend = root.createBackend(backendType, backendName, null); |
| | | backend.setEnabled(true); |
| | | backend.setBaseDN(toByteStrings(baseDNs)); |
| | | backend.setBaseDN(toDNs(baseDNs)); |
| | | backend.setBackendId(backendName); |
| | | backend.setWritabilityMode(BackendCfgDefn.WritabilityMode.ENABLED); |
| | | backend.commit(); |
| | |
| | | } |
| | | } |
| | | |
| | | private Set<DN> toByteStrings(Set<String> strings) throws DirectoryException |
| | | private Set<DN> toDNs(Set<String> strings) throws DirectoryException |
| | | { |
| | | Set<DN> results = new HashSet<>(); |
| | | for (String s : strings) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets the base DNs on a given backend. |
| | | * @param connWrapper the connection to the server. |
| | | * @param backendName the name of the backend where the base Dns must be |
| | | * defined. |
| | | * @param baseDNs the list of base DNs to be defined on the server. |
| | | * @param serverDisplay the server display. |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | public void setBaseDns(ConnectionWrapper connWrapper, String backendName, Set<String> baseDNs, String serverDisplay) |
| | | throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | BackendCfgClient backend = connWrapper.getRootConfiguration().getBackend(backendName); |
| | | backend.setBaseDN(toByteStrings(baseDNs)); |
| | | backend.commit(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | throw new ApplicationException( |
| | | ReturnCode.CONFIGURATION_ERROR, |
| | | INFO_ERROR_CONFIGURING_REMOTE_GENERIC.get(serverDisplay, t), |
| | | t); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Configures the replication on a given server. |
| | | * @param conn the connection to the server where we want to configure |
| | | * the replication. |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | |
| | | } |
| | | private static final long serialVersionUID = -8989965057591475064L; |
| | | private ReturnType returnValue = ReturnType.NOT_ACCEPTED; |
| | | private UserDataCertificateException ce; |
| | | private final UserDataCertificateException ce; |
| | | private JButton doNotAcceptButton; |
| | | private JComponent certificateDetails; |
| | | private JEditorPane explanationPane; |
| | |
| | | p.setLayout(new GridBagLayout()); |
| | | if (ce.getChain() != null && ce.getChain().length > 0) |
| | | { |
| | | final JComboBox combo = new JComboBox(); |
| | | final JComboBox<String> combo = new JComboBox<String>(); |
| | | combo.setToolTipText( |
| | | INFO_CERTIFICATE_CHAIN_COMBO_TOOLTIP.get().toString()); |
| | | final CardLayout cl = new CardLayout(); |
| | |
| | | * @param cert the certificate object. |
| | | * @return the LocalizableMessage representation of the SHA1 fingerprint. |
| | | */ |
| | | public static LocalizableMessage getSHA1FingerPrint(X509Certificate cert) |
| | | private static LocalizableMessage getSHA1FingerPrint(X509Certificate cert) |
| | | { |
| | | return getFingerPrint(cert, "SHA1"); |
| | | } |
| | |
| | | * @param cert the certificate object. |
| | | * @return the LocalizableMessage representation of the MD5 fingerprint. |
| | | */ |
| | | public static LocalizableMessage getMD5FingerPrint(X509Certificate cert) |
| | | private static LocalizableMessage getMD5FingerPrint(X509Certificate cert) |
| | | { |
| | | return getFingerPrint(cert, "MD5"); |
| | | } |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import javax.swing.JButton; |
| | | import javax.swing.text.Element; |
| | |
| | | /** Class used to be able to detect events in the button inside an HTML pane. */ |
| | | public class CustomHTMLEditorKit extends HTMLEditorKit |
| | | { |
| | | private HashSet<ActionListener> listeners = new HashSet<>(); |
| | | private final Set<ActionListener> listeners = new HashSet<>(); |
| | | private static final long serialVersionUID = 298103926252426388L; |
| | | |
| | | /** Default constructor. */ |
| | |
| | | } |
| | | |
| | | /** Class used to be able to detect events in the button inside an HTML pane. */ |
| | | class MyHTMLFactory extends HTMLFactory |
| | | private class MyHTMLFactory extends HTMLFactory |
| | | { |
| | | @Override |
| | | public View create(Element elem) |
| | |
| | | } |
| | | |
| | | /** Class used to be able to detect events in the button inside an HTML pane. */ |
| | | class MyFormView extends FormView |
| | | private class MyFormView extends FormView |
| | | { |
| | | /** |
| | | * Creates a new FormView object. |
| | | * |
| | | * @param elem the element to decorate |
| | | */ |
| | | MyFormView(Element elem) |
| | | private MyFormView(Element elem) |
| | | { |
| | | super(elem); |
| | | } |
| | |
| | | */ |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.quicksetup.*; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.HtmlProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.BackgroundTask; |
| | | import org.opends.server.util.SetupUtils; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | import static com.forgerock.opendj.cli.Utils.getThrowableMsg; |
| | | |
| | | import javax.swing.*; |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | |
| | | import java.awt.Cursor; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import java.util.logging.Handler; |
| | | import java.util.Map; |
| | | import java.util.logging.Handler; |
| | | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.CurrentInstallStatus; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | import org.opends.quicksetup.ProgressStep; |
| | | import org.opends.quicksetup.Step; |
| | | import org.opends.quicksetup.UserDataCertificateException; |
| | | import org.opends.quicksetup.UserDataConfirmationException; |
| | | import org.opends.quicksetup.UserDataException; |
| | | import org.opends.quicksetup.WizardStep; |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.util.BackgroundTask; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | /** |
| | | * This class is responsible for doing the following: |
| | |
| | | */ |
| | | public class QuickSetup implements ButtonActionListener, ProgressUpdateListener |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private GuiApplication application; |
| | | |
| | | private CurrentInstallStatus installStatus; |
| | | |
| | | private WizardStep currentStep; |
| | | |
| | | private QuickSetupDialog dialog; |
| | | |
| | | private LocalizableMessageBuilder progressDetails = new LocalizableMessageBuilder(); |
| | | |
| | | private final LocalizableMessageBuilder progressDetails = new LocalizableMessageBuilder(); |
| | | private ProgressDescriptor lastDescriptor; |
| | | |
| | | private ProgressDescriptor lastDisplayedDescriptor; |
| | | |
| | | private ProgressDescriptor descriptorToDisplay; |
| | | |
| | | /** Update period of the dialogs. */ |
| | |
| | | private static final String MAC_APPLICATIONS_OPENER = "/usr/bin/open"; |
| | | |
| | | /** |
| | | * This method creates the install/uninstall dialogs and to check the current |
| | | * install status. This method must be called outside the event thread because |
| | | * it can perform long operations which can make the user think that the UI is |
| | | * blocked. |
| | | * |
| | | * @param tempLogFile |
| | | * temporary log file where messages will be logged. |
| | | * @param args |
| | | * for the moment this parameter is not used but we keep it in order |
| | | * to (in case of need) pass parameters through the command line. |
| | | */ |
| | | public void initialize(final TempLogFile tempLogFile, String[] args) |
| | | { |
| | | ProgressMessageFormatter formatter = new HtmlProgressMessageFormatter(); |
| | | |
| | | installStatus = new CurrentInstallStatus(); |
| | | |
| | | application = Application.create(); |
| | | application.setProgressMessageFormatter(formatter); |
| | | application.setCurrentInstallStatus(installStatus); |
| | | application.setTempLogFile(tempLogFile); |
| | | if (args != null) |
| | | { |
| | | application.setUserArguments(args); |
| | | } |
| | | else |
| | | { |
| | | application.setUserArguments(new String[] {}); |
| | | } |
| | | try |
| | | { |
| | | initLookAndFeel(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // This is likely a bug. |
| | | t.printStackTrace(); |
| | | } |
| | | |
| | | /* In the calls to setCurrentStep the dialog will be created */ |
| | | setCurrentStep(application.getFirstWizardStep()); |
| | | } |
| | | |
| | | /** This method displays the setup dialog. This method must be called from the event thread. */ |
| | | public void display() |
| | | { |
| | | getDialog().packAndShow(); |
| | | } |
| | | |
| | | /** |
| | | * ButtonActionListener implementation. It assumes that we are called in the |
| | | * event thread. |
| | | * |
| | |
| | | getDialog().displayFieldInvalid(fieldName, invalid); |
| | | } |
| | | |
| | | /** A method to initialize the look and feel. */ |
| | | private void initLookAndFeel() throws Throwable |
| | | { |
| | | UIFactory.initialize(); |
| | | } |
| | | |
| | | /** |
| | | * A methods that creates an ProgressDescriptor based on the value of a |
| | | * ProgressUpdateEvent. |
| | |
| | | try |
| | | { |
| | | application.updateUserData(cStep, QuickSetup.this); |
| | | return null; |
| | | } |
| | | catch (UserDataException uide) |
| | | { |
| | |
| | | { |
| | | throw new UserDataException(cStep, getThrowableMsg(INFO_BUG_MSG.get(), t)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | import java.awt.event.WindowAdapter; |
| | | import java.awt.event.WindowEvent; |
| | | import java.util.HashSet; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import java.util.Set; |
| | | |
| | | import javax.swing.JButton; |
| | | import javax.swing.JFrame; |
| | |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.WindowConstants; |
| | | |
| | | import org.opends.quicksetup.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.ButtonName; |
| | | import org.opends.quicksetup.CurrentInstallStatus; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | import org.opends.quicksetup.ProgressStep; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.WizardStep; |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.event.MinimumSizeComponentListener; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | /** |
| | | * This class represents the dialog used by quicksetup applications. |
| | | * |
| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private JFrame frame; |
| | | private final JFrame frame; |
| | | private QuickSetupErrorPanel installedPanel; |
| | | private JPanel framePanel; |
| | | private StepsPanel stepsPanel; |
| | | private CurrentStepPanel currentStepPanel; |
| | | private ButtonsPanel buttonsPanel; |
| | | |
| | | private WizardStep displayedStep; |
| | | |
| | | private CurrentInstallStatus installStatus; |
| | | |
| | | private HashSet<ButtonActionListener> buttonListeners = new HashSet<>(); |
| | | |
| | | private GuiApplication application; |
| | | |
| | | private QuickSetup quickSetup; |
| | | |
| | | private final CurrentInstallStatus installStatus; |
| | | private final Set<ButtonActionListener> buttonListeners = new HashSet<>(); |
| | | private final GuiApplication application; |
| | | private final QuickSetup quickSetup; |
| | | private boolean forceToDisplay; |
| | | |
| | | /** |
| | |
| | | Utilities.setFrameIcon(frame); |
| | | } |
| | | |
| | | /** Packs and displays this dialog. */ |
| | | public void packAndShow() |
| | | { |
| | | frame.pack(); |
| | | int minWidth = (int) frame.getPreferredSize().getWidth(); |
| | | int minHeight = (int) frame.getPreferredSize().getHeight(); |
| | | Utilities.centerOnScreen(frame); |
| | | setFocusOnButton(application.getInitialFocusButtonName()); |
| | | frame.addComponentListener(new MinimumSizeComponentListener(frame, |
| | | minWidth, minHeight)); |
| | | |
| | | frame.setVisible(true); |
| | | } |
| | | |
| | | /** |
| | | * This method is called when we detected that there is something installed |
| | | * we inform of this to the user and the user wants to proceed with the |
| | |
| | | } |
| | | |
| | | /** |
| | | * Notification telling that the installation/uninstallation is finished. |
| | | * @param successful a boolean telling whether the setup was successful or |
| | | * not. |
| | | */ |
| | | public void finished(boolean successful) |
| | | { |
| | | setButtonEnabled(ButtonName.CLOSE, true); |
| | | if (!successful) |
| | | { |
| | | // Do nothing... all the error messages |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the frame containing the dialog. |
| | | * @return the frame containing the dialog. |
| | | */ |
| | |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.Component; |
| | |
| | | |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.opends.quicksetup.UserData; |
| | | |
| | | /** This class is an abstract class that provides some commodity methods. */ |
| | | abstract class QuickSetupPanel extends JPanel |
| | | { |
| | | private static final long serialVersionUID = 2096518919339628055L; |
| | | |
| | | private GuiApplication application; |
| | | |
| | | private final GuiApplication application; |
| | | private QuickSetup quickSetup; |
| | | |
| | | /** |
| | |
| | | protected GuiApplication getApplication() { |
| | | return this.application; |
| | | } |
| | | |
| | | /** |
| | | * Gets the user data associated with the current application. |
| | | * @return UserData user specified data |
| | | */ |
| | | protected UserData getUserData() { |
| | | return application.getUserData(); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | import java.awt.CardLayout; |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JEditorPane; |
| | |
| | | import javax.swing.event.HyperlinkEvent; |
| | | import javax.swing.event.HyperlinkListener; |
| | | |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.util.HtmlProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.URLWorker; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This is an abstract class that is extended by all the classes that are in |
| | |
| | | private JPanel inputContainer; |
| | | private Component inputPanel; |
| | | |
| | | private HashSet<ButtonActionListener> buttonListeners = new HashSet<>(); |
| | | private final Set<ButtonActionListener> buttonListeners = new HashSet<>(); |
| | | |
| | | private ProgressMessageFormatter formatter; |
| | | |
| | |
| | | * We can use a HashMap (not multi-thread safe) because all |
| | | * the calls to this object are done in the event-thread. |
| | | */ |
| | | private HashMap<String, URLWorker> hmURLWorkers = new HashMap<>(); |
| | | private final Map<String, URLWorker> hmURLWorkers = new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a default instance. |
| | |
| | | */ |
| | | public void beginDisplay(UserData data) |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** Called just after the panel is shown: used to set focus properly. */ |
| | | public void endDisplay() |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void displayProgress(ProgressDescriptor descriptor) |
| | | { |
| | | // no-op |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | /** Creates the layout of the panel. */ |
| | | protected void createLayout() |
| | | private void createLayout() |
| | | { |
| | | setLayout(new GridBagLayout()); |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Map; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.WizardStep; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * This class displays the different steps of the wizard. It appears on the |
| | |
| | | * |
| | | * The current step is highlighted using a different label style and an icon. |
| | | * The current displayed step can be changed calling the method setCurrentStep. |
| | | * |
| | | */ |
| | | public class StepsPanel extends QuickSetupPanel |
| | | class StepsPanel extends QuickSetupPanel |
| | | { |
| | | private static final long serialVersionUID = -2003945907121690657L; |
| | | |
| | | HashMap<WizardStep, JLabel> hmLabels = new HashMap<>(); |
| | | HashMap<WizardStep, JLabel> hmIcons = new HashMap<>(); |
| | | HashMap<WizardStep, JPanel> hmSubPanels = new HashMap<>(); |
| | | private final Map<WizardStep, JLabel> hmLabels = new HashMap<>(); |
| | | private final Map<WizardStep, JLabel> hmIcons = new HashMap<>(); |
| | | private final Map<WizardStep, JPanel> hmSubPanels = new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a StepsPanel. |
| | |
| | | import javax.swing.text.html.HTMLEditorKit; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | /** |
| | | * This class provides constants an methods to create Swing objects and to |
| | |
| | | */ |
| | | public class UIFactory |
| | | { |
| | | private static boolean initialized; |
| | | private static String parentPackagePath; |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Specifies the horizontal insets between buttons. */ |
| | | public static final int HORIZONTAL_INSET_BETWEEN_BUTTONS = 5; |
| | |
| | | /** Specifies the dialog border. */ |
| | | public static final Border DIALOG_PANEL_BORDER = BorderFactory.createMatteBorder(0, 0, 2, 0, PANEL_BORDER_COLOR); |
| | | |
| | | private static Font DEFAULT_FONT; |
| | | static |
| | | private static final Font DEFAULT_FONT = getDefaultFont(); |
| | | |
| | | private static Font getDefaultFont() |
| | | { |
| | | try |
| | | { |
| | | DEFAULT_FONT = UIManager.getFont("Label.font").deriveFont(Font.PLAIN).deriveFont(12f); |
| | | return UIManager.getFont("Label.font").deriveFont(Font.PLAIN).deriveFont(12f); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | DEFAULT_FONT = Font.decode("SansSerif-PLAIN-12"); |
| | | return Font.decode("SansSerif-PLAIN-12"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * This method initialize the look and feel and UI settings specific to quick |
| | | * setup. |
| | | * |
| | | * @throws Throwable |
| | | * if there is a problem initializing the look and feel. |
| | | */ |
| | | public static void initialize() throws Throwable |
| | | { |
| | | if (!initialized) |
| | | { |
| | | try |
| | | { |
| | | UIManager.put("OptionPane.background", getColor(INFO_OPTIONPANE_BACKGROUND_COLOR.get())); |
| | | UIManager.put("Panel.background", getColor(INFO_PANEL_BACKGROUND_COLOR.get())); |
| | | UIManager.put("ComboBox.background", getColor(INFO_COMBOBOX_BACKGROUND_COLOR.get())); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // This might occur when we do not get the display |
| | | logger.warn(LocalizableMessage.raw("Error updating UIManager: " + t, t)); |
| | | } |
| | | initializeLookAndFeel(); |
| | | initialized = true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates a new JPanel. |
| | | * |
| | | * @return JPanel newly created |
| | |
| | | * @return a read only JEditorPane containing the provided text with the |
| | | * provided font. |
| | | */ |
| | | public static JEditorPane makeHtmlPane(LocalizableMessage text, HTMLEditorKit ek, Font font) |
| | | private static JEditorPane makeHtmlPane(LocalizableMessage text, HTMLEditorKit ek, Font font) |
| | | { |
| | | JEditorPane pane = new JEditorPane(); |
| | | if (ek != null) { |
| | |
| | | * @return a string that represents the original HTML with the font specified |
| | | * as parameter. |
| | | */ |
| | | public static String applyFontToHtmlWithDiv(String html, Font font) |
| | | private static String applyFontToHtmlWithDiv(String html, Font font) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | |
| | | buf.append("<div style=\"").append(getFontStyle(font)).append("\">").append(html).append(DIV_CLOSE); |
| | | |
| | | return buf.toString(); |
| | | return "<div style=\"" + getFontStyle(font) + "\">" + html + DIV_CLOSE; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void focusLost(FocusEvent e) |
| | | { |
| | | // no-op |
| | | } |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import java.awt.*; |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.Toolkit; |
| | | import java.awt.Window; |
| | | import java.util.StringTokenizer; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JButton; |
| | | import javax.swing.JFrame; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JOptionPane; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * A set of utilities specific to GUI QuickSetup applications. |
| | | */ |
| | |
| | | * @param width the maximum width of the column. |
| | | * @return the wrapped message. |
| | | */ |
| | | public static String wrapMsg(String msg, int width) |
| | | private static String wrapMsg(String msg, int width) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringTokenizer lineTokenizer = new StringTokenizer(msg, "\n", true); |
| | |
| | | import static org.opends.admin.ads.util.ConnectionUtils.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.quicksetup.Installation.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | |
| | | import java.io.BufferedOutputStream; |
| | |
| | | import java.io.InputStreamReader; |
| | | import java.io.PrintStream; |
| | | import java.io.PrintWriter; |
| | | import java.io.RandomAccessFile; |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.server.tools.BackendTypeHelper; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentConstants; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | |
| | | * @throws IOException |
| | | * if something goes wrong |
| | | */ |
| | | public static boolean createFile(File f) throws IOException |
| | | static boolean createFile(File f) throws IOException |
| | | { |
| | | if (f != null) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the parent directory for the provided path |
| | | * exists and <CODE>false</CODE> otherwise. |
| | | * |
| | | * @param path |
| | | * the path that we are analyzing. |
| | | * @return <CODE>true</CODE> if the parent directory for the provided path |
| | | * exists and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean parentDirectoryExists(String path) |
| | | { |
| | | File f = new File(path); |
| | | File parentFile = f.getParentFile(); |
| | | return parentFile != null && parentFile.isDirectory(); |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the the provided path is a file and exists and |
| | | * <CODE>false</CODE> otherwise. |
| | | * |
| | |
| | | * @return boolean indicating whether or not the input <code>f</code> has a |
| | | * parent after this method is invoked. |
| | | */ |
| | | public static boolean ensureParentsExist(File f) |
| | | static boolean ensureParentsExist(File f) |
| | | { |
| | | final File parent = f.getParentFile(); |
| | | return parent.exists() || parent.mkdirs(); |
| | |
| | | /** |
| | | * Creates the a directory in the provided path. |
| | | * |
| | | * @param path |
| | | * the path. |
| | | * @return <CODE>true</CODE> if the path was created or already existed (and |
| | | * was a directory) and <CODE>false</CODE> otherwise. |
| | | * @throws IOException |
| | | * if something goes wrong. |
| | | */ |
| | | public static boolean createDirectory(String path) throws IOException |
| | | { |
| | | return createDirectory(new File(path)); |
| | | } |
| | | |
| | | /** |
| | | * Creates the a directory in the provided path. |
| | | * |
| | | * @param f |
| | | * the path. |
| | | * @return <CODE>true</CODE> if the path was created or already existed (and |
| | |
| | | * @throws IOException |
| | | * if something goes wrong. |
| | | */ |
| | | public static boolean createDirectory(File f) throws IOException |
| | | static boolean createDirectory(File f) throws IOException |
| | | { |
| | | if (f.exists()) |
| | | { |
| | |
| | | * @throws IOException |
| | | * if something goes wrong. |
| | | */ |
| | | public static void createFile(File path, InputStream is) throws IOException |
| | | static void createFile(File path, InputStream is) throws IOException |
| | | { |
| | | FileOutputStream out; |
| | | BufferedOutputStream dest; |
| | | byte[] data = new byte[BUFFER_SIZE]; |
| | | int count; |
| | | |
| | | out = new FileOutputStream(path); |
| | | |
| | | dest = new BufferedOutputStream(out); |
| | | |
| | | while ((count = is.read(data, 0, BUFFER_SIZE)) != -1) |
| | | try (FileOutputStream out = new FileOutputStream(path); |
| | | BufferedOutputStream dest = new BufferedOutputStream(out)) |
| | | { |
| | | dest.write(data, 0, count); |
| | | byte[] data = new byte[BUFFER_SIZE]; |
| | | int count; |
| | | while ((count = is.read(data, 0, BUFFER_SIZE)) != -1) |
| | | { |
| | | dest.write(data, 0, count); |
| | | } |
| | | } |
| | | dest.flush(); |
| | | dest.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if there is more disk space in the provided path |
| | | * than what is specified with the bytes parameter. |
| | | * |
| | | * @param directoryPath |
| | | * the path. |
| | | * @param bytes |
| | | * the disk space. |
| | | * @return <CODE>true</CODE> if there is more disk space in the provided path |
| | | * than what is specified with the bytes parameter. |
| | | */ |
| | | public static synchronized boolean hasEnoughSpace(String directoryPath, long bytes) |
| | | { |
| | | // TODO This does not work with quotas etc. but at least it seems that |
| | | // we do not write all data on disk if it fails. |
| | | boolean hasEnoughSpace = false; |
| | | File file = null; |
| | | RandomAccessFile raf = null; |
| | | File directory = new File(directoryPath); |
| | | boolean deleteDirectory = false; |
| | | if (!directory.exists()) |
| | | { |
| | | deleteDirectory = directory.mkdir(); |
| | | } |
| | | |
| | | try |
| | | { |
| | | file = File.createTempFile("temp" + System.nanoTime(), ".tmp", directory); |
| | | raf = new RandomAccessFile(file, "rw"); |
| | | raf.setLength(bytes); |
| | | hasEnoughSpace = true; |
| | | } |
| | | catch (IOException ex) |
| | | { /* do nothing */ |
| | | } |
| | | finally |
| | | { |
| | | StaticUtils.close(raf); |
| | | if (file != null) |
| | | { |
| | | file.delete(); |
| | | } |
| | | } |
| | | |
| | | if (deleteDirectory) |
| | | { |
| | | directory.delete(); |
| | | } |
| | | |
| | | return hasEnoughSpace; |
| | | } |
| | | |
| | | /** |
| | | * Gets a localized representation of the provide TopologyCacheException. |
| | | * |
| | | * @param te |
| | |
| | | * @throws InterruptedException |
| | | * if the Runtime.exec method is interrupted. |
| | | */ |
| | | public static int setPermissionsUnix(List<String> paths, String permissions) throws IOException, |
| | | static int setPermissionsUnix(List<String> paths, String permissions) throws IOException, |
| | | InterruptedException |
| | | { |
| | | String[] args = new String[paths.size() + 2]; |
| | |
| | | * @throws InterruptedException |
| | | * if the Runtime.exec method is interrupted. |
| | | */ |
| | | public static int setPermissionsUnix(String path, String permissions) throws IOException, InterruptedException |
| | | static int setPermissionsUnix(String path, String permissions) throws IOException, InterruptedException |
| | | { |
| | | String[] args = new String[] { "chmod", permissions, path }; |
| | | Process p = Runtime.getRuntime().exec(args); |
| | |
| | | { |
| | | String line = reader.readLine(); |
| | | File instanceLoc = new File(line.trim()); |
| | | if (instanceLoc.isAbsolute()) |
| | | { |
| | | return getCanonicalPath(instanceLoc); |
| | | } |
| | | else |
| | | { |
| | | return getCanonicalPath(new File(installPath + File.separator + instanceLoc.getPath())); |
| | | } |
| | | return getCanonicalPath(instanceLoc.isAbsolute() |
| | | ? instanceLoc |
| | | : new File(installPath + File.separator + instanceLoc.getPath())); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the number of entries contained in the zip file. This is used to |
| | | * update properly the progress bar ratio. |
| | | * |
| | | * @return the number of entries contained in the zip file. |
| | | */ |
| | | public static int getNumberZipEntries() |
| | | { |
| | | // TODO we should get this dynamically during build |
| | | return 165; |
| | | } |
| | | |
| | | /** |
| | | * Creates a string consisting of the string representation of the elements in |
| | | * the <code>list</code> separated by <code>separator</code>. |
| | | * |
| | | * @param list |
| | | * the list to print |
| | | * @param separator |
| | | * to use in separating elements |
| | | * @param prefix |
| | | * prepended to each individual element in the list before adding to |
| | | * the returned string. |
| | | * @param suffix |
| | | * appended to each individual element in the list before adding to |
| | | * the returned string. |
| | | * @return String representing the list |
| | | */ |
| | | public static String listToString(List<?> list, String separator, String prefix, String suffix) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < list.size(); i++) |
| | | { |
| | | if (prefix != null) |
| | | { |
| | | sb.append(prefix); |
| | | } |
| | | sb.append(list.get(i)); |
| | | if (suffix != null) |
| | | { |
| | | sb.append(suffix); |
| | | } |
| | | if (i < list.size() - 1) |
| | | { |
| | | sb.append(separator); |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the file system permissions for a file. |
| | | * |
| | | * @param file |
| | | * the file for which we want the file permissions. |
| | | * @return the file system permissions for the file. |
| | | */ |
| | | public static String getFileSystemPermissions(File file) |
| | | static String getFileSystemPermissions(File file) |
| | | { |
| | | String name = file.getName(); |
| | | if (file.getParent().endsWith(File.separator + Installation.WINDOWS_BINARIES_PATH_RELATIVE) |
| | |
| | | */ |
| | | public static String breakHtmlString(CharSequence cs, int maxll) |
| | | { |
| | | if (cs != null) |
| | | { |
| | | String d = cs.toString(); |
| | | int len = d.length(); |
| | | if (len <= 0) |
| | | { |
| | | return d; |
| | | } |
| | | if (len > maxll) |
| | | { |
| | | // First see if there are any tags that would cause a |
| | | // natural break in the line. If so start line break |
| | | // point evaluation from that point. |
| | | for (String tag : Constants.BREAKING_TAGS) |
| | | { |
| | | int p = d.lastIndexOf(tag, maxll); |
| | | if (p > 0 && p < len) |
| | | { |
| | | return d.substring(0, p + tag.length()) + breakHtmlString(d.substring(p + tag.length()), maxll); |
| | | } |
| | | } |
| | | |
| | | // Now look for spaces in which to insert a break. |
| | | // First see if there are any spaces counting backward |
| | | // from the max line length. If there aren't any, then |
| | | // use the first space encountered after the max line |
| | | // length. |
| | | int p = d.lastIndexOf(' ', maxll); |
| | | if (p <= 0) |
| | | { |
| | | p = d.indexOf(' ', maxll); |
| | | } |
| | | if (p > 0 && p < len) |
| | | { |
| | | return d.substring(0, p) + Constants.HTML_LINE_BREAK + breakHtmlString(d.substring(p + 1), maxll); |
| | | } |
| | | else |
| | | { |
| | | return d; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return d; |
| | | } |
| | | } |
| | | else |
| | | if (cs == null) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts existing HTML break tags to native line separators. |
| | | * |
| | | * @param s |
| | | * string to convert |
| | | * @return converted string |
| | | */ |
| | | public static String convertHtmlBreakToLineSeparator(String s) |
| | | { |
| | | return s.replaceAll("<br>", Constants.LINE_SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * Strips any potential HTML markup from a given string. |
| | | * |
| | | * @param s |
| | | * string to strip |
| | | * @return resulting string |
| | | */ |
| | | public static String stripHtml(String s) |
| | | { |
| | | if (s != null) |
| | | String d = cs.toString(); |
| | | int len = d.length(); |
| | | if (len <= 0 || len <= maxll) |
| | | { |
| | | // This is not a comprehensive solution but addresses the few tags |
| | | // that we have in Resources.properties at the moment. |
| | | // Note that the following might strip out more than is intended for non-tags |
| | | // like '<your name here>' or for funky tags like '<tag attr="1 > 0">'. |
| | | // See test class for cases that might cause problems. |
| | | return s.replaceAll("<.*?>", ""); |
| | | return d; |
| | | } |
| | | return null; |
| | | |
| | | // First see if there are any tags that would cause a natural break in the line. |
| | | // If so start line break point evaluation from that point. |
| | | for (String tag : Constants.BREAKING_TAGS) |
| | | { |
| | | int p = d.lastIndexOf(tag, maxll); |
| | | if (p > 0 && p < len) |
| | | { |
| | | return d.substring(0, p + tag.length()) + breakHtmlString(d.substring(p + tag.length()), maxll); |
| | | } |
| | | } |
| | | |
| | | // Now look for spaces in which to insert a break. |
| | | // First see if there are any spaces counting backward from the max line length. |
| | | // If there aren't any, then use the first space encountered after the max line length. |
| | | int p = d.lastIndexOf(' ', maxll); |
| | | if (p <= 0) |
| | | { |
| | | p = d.indexOf(' ', maxll); |
| | | } |
| | | if (0 < p && p < len) |
| | | { |
| | | return d.substring(0, p) + Constants.HTML_LINE_BREAK + breakHtmlString(d.substring(p + 1), maxll); |
| | | } |
| | | return d; |
| | | } |
| | | |
| | | /** |
| | |
| | | * String to test |
| | | * @return true if the string contains HTML |
| | | */ |
| | | public static boolean containsHtml(String text) |
| | | static boolean containsHtml(String text) |
| | | { |
| | | return text != null && text.indexOf('<') != -1 && text.indexOf('>') != -1; |
| | | } |
| | |
| | | public static List<String> getSetupEquivalentCommandLine(final UserData userData) |
| | | { |
| | | List<String> cmdLine = new ArrayList<>(); |
| | | cmdLine.add(getInstallDir(userData) + getSetupFileName()); |
| | | cmdLine.add(getInstallDir() + getSetupFileName()); |
| | | cmdLine.add("--cli"); |
| | | |
| | | final ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType = |
| | |
| | | /** |
| | | * Returns the full path of the command-line for a given script name. |
| | | * |
| | | * @param userData |
| | | * the user data. |
| | | * @param scriptBasicName |
| | | * the script basic name (with no extension). |
| | | * @return the full path of the command-line for a given script name. |
| | | */ |
| | | private static String getCommandLinePath(UserData userData, String scriptBasicName) |
| | | private static String getCommandLinePath(String scriptBasicName) |
| | | { |
| | | String installDir = getInstallDir(userData); |
| | | String installDir = getInstallDir(); |
| | | if (isWindows()) |
| | | { |
| | | return installDir + WINDOWS_BINARIES_PATH_RELATIVE + File.separatorChar + scriptBasicName + ".bat"; |
| | |
| | | * |
| | | * @return the installation directory. |
| | | */ |
| | | private static String getInstallDir(UserData userData) |
| | | private static String getInstallDir() |
| | | { |
| | | if (installDir == null) |
| | | { |
| | |
| | | installDir += File.separatorChar; |
| | | } |
| | | } |
| | | |
| | | return installDir; |
| | | } |
| | | |
| | |
| | | Set<String> baseDNs, ServerDescriptor server) |
| | | { |
| | | List<String> cmdLine = new ArrayList<>(); |
| | | String cmdName = getCommandLinePath(userData, "dsreplication"); |
| | | String cmdName = getCommandLinePath("dsreplication"); |
| | | cmdLine.add(cmdName); |
| | | cmdLine.add(subcommand); |
| | | |
| | |
| | | public static List<List<String>> getDsConfigReplicationEnableEquivalentCommandLines(UserData userData) |
| | | { |
| | | final List<List<String>> cmdLines = new ArrayList<>(); |
| | | final String cmdName = getCommandLinePath(userData, "dsconfig"); |
| | | final String cmdName = getCommandLinePath("dsconfig"); |
| | | |
| | | List<String> connectionArgs = new ArrayList<>(); |
| | | connectionArgs.add("--hostName"); |
| | | connectionArgs.add(userData.getHostName()); |
| | | connectionArgs.add("--port"); |
| | | connectionArgs.add(String.valueOf(userData.getAdminConnectorPort())); |
| | | connectionArgs.add("--bindDN"); |
| | | connectionArgs.add(userData.getDirectoryManagerDn()); |
| | | connectionArgs.add("--bindPassword"); |
| | | connectionArgs.add(OBFUSCATED_VALUE); |
| | | connectionArgs.add("--trustAll"); |
| | | connectionArgs.add("--no-prompt"); |
| | | connectionArgs.add("--noPropertiesFile"); |
| | | List<String> connectionArgs = newArrayList( |
| | | "--hostName", userData.getHostName(), |
| | | "--port", String.valueOf(userData.getAdminConnectorPort()), |
| | | "--bindDN", userData.getDirectoryManagerDn(), |
| | | "--bindPassword", OBFUSCATED_VALUE, |
| | | "--trustAll", |
| | | "--no-prompt", |
| | | "--noPropertiesFile"); |
| | | |
| | | List<String> cmdReplicationServer = new ArrayList<>(); |
| | | cmdReplicationServer.add(cmdName); |
| | | cmdReplicationServer.add("create-replication-server"); |
| | | cmdReplicationServer.add("--provider-name"); |
| | | cmdReplicationServer.add("Multimaster Synchronization"); |
| | | cmdReplicationServer.add("--set"); |
| | | cmdReplicationServer.add("replication-port:" + userData.getReplicationOptions().getReplicationPort()); |
| | | cmdReplicationServer.add("--set"); |
| | | cmdReplicationServer.add("replication-server-id:1"); |
| | | cmdReplicationServer.add("--type"); |
| | | cmdReplicationServer.add("generic"); |
| | | List<String> cmdReplicationServer = newArrayList( |
| | | cmdName, |
| | | "create-replication-server", |
| | | "--provider-name", "Multimaster Synchronization", |
| | | "--set", "replication-port:" + userData.getReplicationOptions().getReplicationPort(), |
| | | "--set", "replication-server-id:1", |
| | | "--type", "generic"); |
| | | cmdReplicationServer.addAll(connectionArgs); |
| | | |
| | | cmdLines.add(cmdReplicationServer); |
| | |
| | | * @throws FileNotFoundException if the specified file does not exist |
| | | * @throws IllegalArgumentException if the zip file is not a zip file |
| | | */ |
| | | public ZipExtractor(File zipFile, int minRatio, int maxRatio, |
| | | private ZipExtractor(File zipFile, int minRatio, int maxRatio, |
| | | int numberZipEntries, |
| | | Application app) |
| | | throws FileNotFoundException, IllegalArgumentException |
| | |
| | | * @param zipFileName name of the input zip file |
| | | * @param app application to be notified about progress |
| | | */ |
| | | public ZipExtractor(InputStream is, int minRatio, int maxRatio, |
| | | private ZipExtractor(InputStream is, int minRatio, int maxRatio, |
| | | int numberZipEntries, |
| | | String zipFileName, |
| | | Application app) { |
| | |
| | | * @param destination File where the zip file will be extracted |
| | | * @throws ApplicationException if something goes wrong |
| | | */ |
| | | public void extract(String destination) throws ApplicationException { |
| | | private void extract(String destination) throws ApplicationException |
| | | { |
| | | extract(destination, true); |
| | | } |
| | | |
| | |
| | | * directory as 'some_file'. |
| | | * @throws ApplicationException if something goes wrong |
| | | */ |
| | | public void extract(String destDir, boolean removeFirstPath) |
| | | private void extract(String destDir, boolean removeFirstPath) |
| | | throws ApplicationException |
| | | { |
| | | ZipInputStream zipIn = new ZipInputStream(is); |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The root connection. */ |
| | | private InternalClientConnection internalConnection; |
| | | private final InternalClientConnection internalConnection; |
| | | |
| | | /** The attribute name used to store the port. TODO Use the default one. */ |
| | | private static final String LDAP_PORT = "ds-cfg-listen-port"; |
| | |
| | | */ |
| | | package org.opends.server.admin.client.cli; |
| | | |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.ReturnCode.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentParser; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ArgumentParser; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.CliConstants; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | |
| | | private boolean configurationInitialized; |
| | | |
| | | /** Defines if the CLI always use the SSL connection type. */ |
| | | private boolean alwaysSSL; |
| | | private final boolean alwaysSSL; |
| | | |
| | | /** |
| | | * Creates a new instance of secure arguments. |
| | |
| | | * the LocalizableMessageBuilder to write the error messages. |
| | | * @return return code. |
| | | */ |
| | | public int validateGlobalOptions(LocalizableMessageBuilder buf) |
| | | int validateGlobalOptions(LocalizableMessageBuilder buf) |
| | | { |
| | | final List<LocalizableMessage> errors = new ArrayList<>(); |
| | | addErrorMessageIfArgumentsConflict(errors, bindPasswordArg, bindPasswordFileArg); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | * @param buffer The buffer to which the information should be |
| | | * appended. |
| | | */ |
| | | public final void toString(StringBuilder buffer) |
| | | private final void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("( "); |
| | | buffer.append(getOID()); |
| | |
| | | |
| | | private final ServerContext serverContext; |
| | | /** Lock to update the maps. */ |
| | | final ReadWriteLock lock = new ReentrantReadWriteLock(); |
| | | private final ReadWriteLock lock = new ReentrantReadWriteLock(); |
| | | private final Lock exclusiveLock = lock.writeLock(); |
| | | private final Lock sharedLock = lock.readLock(); |
| | | |
| | |
| | | return size; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the size of the internal map. Used for testing purposes only. |
| | | * |
| | | * @return The size of the internal map. |
| | | */ |
| | | int getMapSize() |
| | | { |
| | | return ditCacheMap.size(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.api.plugin; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DisconnectReason; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.DisconnectReason; |
| | | |
| | | /** |
| | | * This class defines a data structure that holds information about |
| | | * the result of processing by a plugin. |
| | |
| | | public final class PluginResult |
| | | { |
| | | /** Contract for operation results. */ |
| | | public static interface OperationResult |
| | | public interface OperationResult |
| | | { |
| | | /** |
| | | * Indicates whether processing on the associated operation should continue. |
| | |
| | | /** An message explaining why startup should stop. */ |
| | | private final LocalizableMessage errorMessage; |
| | | |
| | | private static Startup DEFAULT_RESULT = |
| | | private static final Startup DEFAULT_RESULT = |
| | | new Startup(true, true, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static PreParse DEFAULT_RESULT = |
| | | private static final PreParse DEFAULT_RESULT = |
| | | new PreParse(true, true, null, null, null, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static PreOperation DEFAULT_RESULT = |
| | | private static final PreOperation DEFAULT_RESULT = |
| | | new PreOperation(true, true, null, null, null, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static PostOperation DEFAULT_RESULT = |
| | | private static final PostOperation DEFAULT_RESULT = |
| | | new PostOperation(true, null, null, null, null); |
| | | |
| | | /** |
| | |
| | | /** Whether to invoke the rest of the plugins. */ |
| | | private final boolean continuePluginProcessing; |
| | | |
| | | private static PostResponse DEFAULT_RESULT = |
| | | private static final PostResponse DEFAULT_RESULT = |
| | | new PostResponse(true); |
| | | |
| | | /** |
| | |
| | | /** An message explaining why processing should stop. */ |
| | | private final LocalizableMessage errorMessage; |
| | | |
| | | private static ImportLDIF DEFAULT_RESULT = |
| | | private static final ImportLDIF DEFAULT_RESULT = |
| | | new ImportLDIF(true, true, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static SubordinateModifyDN DEFAULT_RESULT = |
| | | private static final SubordinateModifyDN DEFAULT_RESULT = |
| | | new SubordinateModifyDN(true, true, null, null, null, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static SubordinateDelete DEFAULT_RESULT = |
| | | private static final SubordinateDelete DEFAULT_RESULT = |
| | | new SubordinateDelete(true, true, null, null, null, null); |
| | | |
| | | /** |
| | |
| | | /** The result code for this result. */ |
| | | private final ResultCode resultCode; |
| | | |
| | | private static IntermediateResponse DEFAULT_RESULT = |
| | | private static final IntermediateResponse DEFAULT_RESULT = |
| | | new IntermediateResponse(true, true, true, null, null, null, |
| | | null); |
| | | |
| | |
| | | /** Whether to send a disconnect notification to the client. */ |
| | | private final boolean sendDisconnectNotification; |
| | | |
| | | private static PostConnect DEFAULT_RESULT = |
| | | private static final PostConnect DEFAULT_RESULT = |
| | | new PostConnect(true, true, null, null, false); |
| | | |
| | | /** |
| | |
| | | /** Whether to invoke the rest of the plugins. */ |
| | | private final boolean continuePluginProcessing; |
| | | |
| | | private static PostDisconnect DEFAULT_RESULT = |
| | | private static final PostDisconnect DEFAULT_RESULT = |
| | | new PostDisconnect(true); |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api.plugin; |
| | | |
| | |
| | | } |
| | | |
| | | /** The name for this plugin type. */ |
| | | private String name; |
| | | private final String name; |
| | | |
| | | /** |
| | | * Creates a new plugin type instance with the specified name. |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | /** |
| | | * The TargAttrFilters class represents a targattrfilters rule of an ACI. |
| | |
| | | * A valid targattrfilters rule may have two TargFilterlist parts -- the |
| | | * first one is required. |
| | | */ |
| | | private TargAttrFilterList firstFilterList; |
| | | private final TargAttrFilterList firstFilterList; |
| | | private TargAttrFilterList secondFilterList; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Regular expression used to check for valid expression separator. |
| | | */ |
| | | private static final |
| | | String secondOpSeparator="\\)" + ZERO_OR_MORE_WHITESPACE + ","; |
| | | private static final Pattern secondOpSeparator = Pattern.compile("\\)" + ZERO_OR_MORE_WHITESPACE + ","); |
| | | |
| | | /** |
| | | * Regular expression used to match the second operation of the filter list. |
| | | * If the first was "add" this must be "del", if the first was "del" this |
| | | * must be "add". |
| | | */ |
| | | public static final String secondOp = |
| | | private static final Pattern secondOp = Pattern.compile( |
| | | "[,]{1}" + ZERO_OR_MORE_WHITESPACE + "del|add" + |
| | | ZERO_OR_MORE_WHITESPACE + EQUAL_SIGN + ZERO_OR_MORE_WHITESPACE; |
| | | ZERO_OR_MORE_WHITESPACE + EQUAL_SIGN + ZERO_OR_MORE_WHITESPACE); |
| | | |
| | | /** |
| | | * Regular expression used to match the first targFilterList, it must exist |
| | | * or an exception is thrown. |
| | | */ |
| | | private static final String firstOp = "^" + ADD_OR_DEL_KEYWORD_GROUP + |
| | | ZERO_OR_MORE_WHITESPACE + EQUAL_SIGN + ZERO_OR_MORE_WHITESPACE; |
| | | private static final Pattern firstOp = Pattern.compile("^" + ADD_OR_DEL_KEYWORD_GROUP + |
| | | ZERO_OR_MORE_WHITESPACE + EQUAL_SIGN + ZERO_OR_MORE_WHITESPACE); |
| | | |
| | | /** |
| | | * Regular expression used to group the remainder of a partially parsed |
| | | * rule. Any character one or more times. |
| | | */ |
| | | private static String restOfExpression = "(.+)"; |
| | | private final static String restOfExpression = "(.+)"; |
| | | |
| | | /** |
| | | * Regular expression used to match the first operation keyword and the |
| | | * rest of the expression. |
| | | */ |
| | | private static String keywordFullPattern = firstOp + restOfExpression; |
| | | private final static String keywordFullPattern = firstOp + restOfExpression; |
| | | |
| | | /** |
| | | * The enumeration representing the operation. |
| | | */ |
| | | private EnumTargetOperator op; |
| | | private final EnumTargetOperator op; |
| | | |
| | | /** |
| | | * A mask used to denote if the rule has add, del or both operations in the |
| | |
| | | * Check that there are not too many filter lists. There can only |
| | | * be either one or two. |
| | | */ |
| | | String[] filterLists = subExpression.split(secondOp, -1); |
| | | String[] filterLists = secondOp.split(subExpression, -1); |
| | | if(filterLists.length > 2) { |
| | | throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_MAX_FILTER_LISTS.get(expression)); |
| | | } else if (filterLists.length == 1) { |
| | | //Check if the there is something like ") , deel=". A bad token |
| | | //that the regular expression didn't pick up. |
| | | String [] filterList2=subExpression.split(secondOpSeparator); |
| | | String[] filterList2 = secondOpSeparator.split(subExpression); |
| | | if(filterList2.length == 2) { |
| | | throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.get(expression)); |
| | | } |
| | |
| | | private boolean enabled; |
| | | |
| | | /** The set of listeners for this connection handler. */ |
| | | private List<HostPort> listeners = new LinkedList<>(); |
| | | private final List<HostPort> listeners = new LinkedList<>(); |
| | | |
| | | /** The HTTP server embedded in OpenDJ. */ |
| | | private HttpServer httpServer; |
| | |
| | | * ensure no concurrent reads/writes can happen and adds/removes are fast. We |
| | | * only use the keys, so it does not matter what value is put there. |
| | | */ |
| | | private Map<ClientConnection, ClientConnection> clientConnections = new ConcurrentHashMap<>(); |
| | | private final Map<ClientConnection, ClientConnection> clientConnections = new ConcurrentHashMap<>(); |
| | | |
| | | /** The set of statistics collected for this connection handler. */ |
| | | private HTTPStatistics statTracker; |
| | |
| | | return protocol; |
| | | } |
| | | |
| | | /** |
| | | * Returns the SSL engine configured for this connection handler if SSL is |
| | | * enabled, null otherwise. |
| | | * |
| | | * @return the SSL engine if SSL is enabled, null otherwise |
| | | */ |
| | | SSLEngine getSSLEngine() |
| | | { |
| | | return sslEngineConfigurator.createSSLEngine(); |
| | | } |
| | | |
| | | @Override |
| | | public String getShutdownListenerName() |
| | | { |
| | |
| | | */ |
| | | public class HTTPStatistics extends LDAPStatistics |
| | | { |
| | | |
| | | /** |
| | | * Map containing the total number of requests per HTTP methods. |
| | | * <p> |
| | |
| | | * The keys are static because they need to be listed in the schema which is |
| | | * static. |
| | | */ |
| | | private Map<String, AtomicInteger> requestMethodsTotalCount = new HashMap<>(); |
| | | private final Map<String, AtomicInteger> requestMethodsTotalCount = new HashMap<>(); |
| | | /** |
| | | * Map containing the total execution time for the requests per HTTP methods. |
| | | * <p> |
| | |
| | | * The keys are static because they need to be listed in the schema which is |
| | | * static. |
| | | */ |
| | | private Map<String, AtomicLong> requestMethodsTotalTime = new HashMap<>(); |
| | | private final Map<String, AtomicLong> requestMethodsTotalTime = new HashMap<>(); |
| | | /** |
| | | * Total number of requests. The total number may be different than the sum of |
| | | * the supported HTTP methods above because clients could use unsupported HTTP |
| | | * methods. |
| | | */ |
| | | private AtomicInteger requestsTotalCount = new AtomicInteger(0); |
| | | private final AtomicInteger requestsTotalCount = new AtomicInteger(0); |
| | | |
| | | /** |
| | | * Constructor for this class. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds a request to the stats using the provided HTTP method. |
| | | * |
| | | * @param httpMethod |
| | | * the method of the HTTP request to add to the stats |
| | | * @throws NullPointerException |
| | | * if the httpMethod is null |
| | | */ |
| | | public void addRequest(String httpMethod) throws NullPointerException |
| | | { |
| | | AtomicInteger nb = |
| | | this.requestMethodsTotalCount.get(httpMethod.toLowerCase()); |
| | | if (nb != null) |
| | | { |
| | | nb.incrementAndGet(); |
| | | } // else this is an unsupported HTTP method |
| | | // always count any requests regardless of whether the method is supported |
| | | this.requestsTotalCount.incrementAndGet(); |
| | | } |
| | | |
| | | /** |
| | | * Adds to the total time of an HTTP request method. |
| | | * |
| | | * @param httpMethod |
| | |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ByteString.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | |
| | | import org.opends.server.util.ModifyChangeRecordEntry; |
| | | import org.opends.server.util.ModifyDNChangeRecordEntry; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ByteString.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a pseudo-connection object that can be used for |
| | | * performing internal operations. |
| | |
| | | ByteString.valueOfUtf8(password), null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal bind operation with the provided |
| | | * information. Note that regardless of whether the bind is |
| | | * successful, the authentication state for this internal connection |
| | | * will not be altered in any way. |
| | | * |
| | | * @param rawBindDN The bind DN for the operation. |
| | | * @param password The bind password for the operation. |
| | | * @param controls The set of controls to include in the |
| | | * request. |
| | | * |
| | | * @return A reference to the bind operation that was processed and |
| | | * contains information about the result of the processing. |
| | | */ |
| | | public BindOperation processSimpleBind(String rawBindDN, |
| | | String password, |
| | | List<Control> controls) |
| | | { |
| | | return processSimpleBind(ByteString.valueOfUtf8(rawBindDN), |
| | | ByteString.valueOfUtf8(password), controls); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal bind operation with the provided |
| | | * information. Note that regardless of whether the bind is |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes an internal compare operation with the provided information. |
| | | * |
| | | * @param entryDN |
| | | * The entry DN for the compare operation. |
| | | * @param attributeDescription |
| | | * The attribute description for the compare operation. |
| | | * @param assertionValue |
| | | * The assertion value for the compare operation. |
| | | * @param controls |
| | | * The set of controls to include in the request. |
| | | * @return A reference to the compare operation that was processed and contains information about |
| | | * the result of the processing. |
| | | */ |
| | | public CompareOperation processCompare(DN entryDN, |
| | | AttributeDescription attributeDescription, |
| | | ByteString assertionValue, |
| | | List<Control> controls) |
| | | { |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis(this, nextOperationID(), |
| | | nextMessageID(), controls, entryDN, |
| | | attributeDescription, assertionValue); |
| | | compareOperation.setInternalOperation(true); |
| | | |
| | | compareOperation.run(); |
| | | return compareOperation; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal delete operation with the provided |
| | | * information. |
| | | * |
| | |
| | | return processDelete(ByteString.valueOfUtf8(rawEntryDN), null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal delete operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawEntryDN The entry DN for the delete operation. |
| | | * @param controls The set of controls to include in the |
| | | * request. |
| | | * |
| | | * @return A reference to the delete operation that was processed |
| | | * and contains information about the result of the |
| | | * processing. |
| | | */ |
| | | public DeleteOperation processDelete(String rawEntryDN, |
| | | List<Control> controls) |
| | | { |
| | | return processDelete(ByteString.valueOfUtf8(rawEntryDN), controls); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal delete operation with the provided |
| | | * information. |
| | |
| | | ByteString.valueOfUtf8(rawNewSuperior), null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal modify DN operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawEntryDN The current DN of the entry to rename. |
| | | * @param rawNewRDN The new RDN to use for the entry. |
| | | * @param deleteOldRDN The flag indicating whether the old RDN |
| | | * value is to be removed from the entry. |
| | | * @param rawNewSuperior The new superior for the modify DN |
| | | * operation, or <CODE>null</CODE> if the |
| | | * entry will remain below the same parent. |
| | | * @param controls The set of controls to include in the |
| | | * request. |
| | | * |
| | | * @return A reference to the modify DN operation that was |
| | | * processed and contains information about the result of |
| | | * the processing. |
| | | */ |
| | | public ModifyDNOperation processModifyDN(String rawEntryDN, |
| | | String rawNewRDN, |
| | | boolean deleteOldRDN, |
| | | String rawNewSuperior, |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), |
| | | ByteString.valueOfUtf8(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOfUtf8(rawNewSuperior), controls); |
| | | } |
| | | |
| | | /** |
| | | * Processes an internal modify DN operation with the provided |
| | | * information. |
| | |
| | | |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Reject; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a new search request using the provided distinguished name, |
| | | * scope, and filter, decoded using the default schema. |
| | | * |
| | | * @param name |
| | | * The distinguished name of the base entry relative to which the |
| | | * search is to be performed. |
| | | * @param scope |
| | | * The scope of the search. |
| | | * @param filter |
| | | * The filter that defines the conditions that must be fulfilled |
| | | * in order for an entry to be returned. |
| | | * @param attributeDescriptions |
| | | * The names of the attributes to be included with each entry. |
| | | * @return The new search request. |
| | | * @throws DirectoryException |
| | | * If a problem occurs while decoding the provided string as a |
| | | * search filter. |
| | | * @throws LocalizedIllegalArgumentException |
| | | * If {@code name} could not be decoded using the default |
| | | * schema, or if {@code filter} is not a valid LDAP string |
| | | * representation of a filter. |
| | | * @throws NullPointerException |
| | | * If the {@code name}, {@code scope}, or {@code filter} were |
| | | * {@code null}. |
| | | */ |
| | | public static SearchRequest newSearchRequest(final String name, final SearchScope scope, |
| | | final String filter, final String... attributeDescriptions) |
| | | throws NullPointerException, LocalizedIllegalArgumentException, DirectoryException { |
| | | Reject.ifNull(name, scope, filter); |
| | | SearchFilter f = "(objectclass=*)".equals(filter.toLowerCase()) |
| | | ? SearchFilter.objectClassPresent() |
| | | : SearchFilter.createFilterFromString(filter); |
| | | final SearchRequest request = new SearchRequest(DN.valueOf(name), scope, f); |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | request.addAttribute(attributeDescription); |
| | | } |
| | | return request; |
| | | } |
| | | |
| | | /** |
| | | * Return a new search request object. |
| | | * |
| | | * @param name |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.quicksetup.util; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import org.testng.annotations.*; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | |
| | | /** |
| | | * Utils Tester. |
| | | */ |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** Utils Tester. */ |
| | | @Test(sequential=true) |
| | | @SuppressWarnings("javadoc") |
| | | public class UtilsTest extends DirectoryServerTestCase { |
| | | |
| | | @DataProvider(name = "breakHtmlStringData") |
| | |
| | | assertEquals(Utils.breakHtmlString(s, maxll), expectedValue); |
| | | } |
| | | |
| | | @DataProvider(name = "stripHtmlData") |
| | | public Object[][] stripHtmlData() { |
| | | return new Object[][]{ |
| | | {"Hi <i>Ho</i>", "Hi Ho"}, |
| | | {"Hi <b>Ho</b>", "Hi Ho"}, |
| | | {"Hi<br> Ho", "Hi Ho"}, |
| | | {"Hi<br/> Ho", "Hi Ho"}, |
| | | {"Hi<input value=\"abc\"/> Ho", "Hi Ho"}, |
| | | {"Hi<input value=\"abc\"></input> Ho", "Hi Ho"}, |
| | | // {"Hi<tag attr=\"1 > 0\"> Ho", "Hi Ho"}, // broken case |
| | | // {"Hi <your name here>", "Hi <your name here>"} // broken case |
| | | }; |
| | | } |
| | | |
| | | @Test(enabled = false, dataProvider = "stripHtmlData") |
| | | public void testStripHtml(String html, String expectedResult) { |
| | | assertEquals(expectedResult, Utils.stripHtml(html)); |
| | | } |
| | | |
| | | @DataProvider(name = "containsHtmlData") |
| | | public Object[][] containsHtmlData() { |
| | | return new Object[][]{ |