Converted use of Collection.size() to Collection.isEmpty().
ConnectionHandlerTableModel.java:
In getAddressPortString(), inverted if statement.
IndexTask.java, RebuildIndexTask.java, StatusPanel.java, TableViewEntryPanel.java:
Extracted methods.
ControlPanelInfo.java:
Removed duplicated logic by inverting inner and outer if statements.
BaseDNPanel.java:
In okClicked(), simplified the code.
LDAPEntryPanel.java:
In saveChanges(), In okClicked(), simplified the code.
SimplifiedViewEntryPanel.java:
In getValues(), simplified code.
| | |
| | | if (suffixes != null |
| | | && suffixes.remove(DN.valueOf(ADSContext.getAdministrationSuffixDN()))) |
| | | { |
| | | if (suffixes.size() > 0) |
| | | if (!suffixes.isEmpty()) |
| | | { |
| | | backend.setBaseDN(suffixes); |
| | | backend.commit(); |
| | |
| | | if (port == -1) |
| | | { |
| | | adsProperties.put(adsProps[i][0], "false"); |
| | | if (p.size() > 0) |
| | | if (!p.isEmpty()) |
| | | { |
| | | port = (Integer)p.iterator().next(); |
| | | } |
| | |
| | | errorMessages.add(message); |
| | | } |
| | | |
| | | if (errorMessages.size() > 0) |
| | | if (!errorMessages.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get( |
| | | Utils.getMessageFromCollection(errorMessages, |
| | | Constants.LINE_SEPARATOR)); |
| | | throw new ArgumentException(message); |
| | | throw new ArgumentException(ERR_CANNOT_INITIALIZE_ARGS.get( |
| | | Utils.getMessageFromCollection(errorMessages, Constants.LINE_SEPARATOR))); |
| | | } |
| | | } |
| | | |
| | |
| | | ImageIcon result; |
| | | |
| | | // Find the icon associated to the object class |
| | | if (objectClasses == null || objectClasses.size() == 0) { |
| | | if (objectClasses == null || objectClasses.isEmpty()) { |
| | | result = getDefaultContainerIcon(); |
| | | } |
| | | else { |
| | |
| | | private String getAddressPortString(ConnectionHandlerDescriptor desc) |
| | | { |
| | | Set<InetAddress> addresses = desc.getAddresses(); |
| | | String returnValue; |
| | | if (addresses.size() == 0) |
| | | { |
| | | if (desc.getPort() > 0) |
| | | { |
| | | returnValue = String.valueOf(desc.getPort()); |
| | | } |
| | | else |
| | | { |
| | | returnValue = INFO_NOT_APPLICABLE_LABEL.get().toString(); |
| | | } |
| | | } |
| | | else |
| | | if (!addresses.isEmpty()) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | buf.append("<html>"); |
| | |
| | | buf.append(":").append(desc.getPort()); |
| | | } |
| | | } |
| | | returnValue = buf.toString(); |
| | | return buf.toString(); |
| | | } |
| | | return returnValue; |
| | | |
| | | if (desc.getPort() > 0) |
| | | { |
| | | return String.valueOf(desc.getPort()); |
| | | } |
| | | return INFO_NOT_APPLICABLE_LABEL.get().toString(); |
| | | } |
| | | |
| | | private String getProtocolString(ConnectionHandlerDescriptor desc) |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import java.io.File; |
| | |
| | | private static String getURL(ServerDescriptor server, |
| | | ConnectionHandlerDescriptor.Protocol protocol) |
| | | { |
| | | String sProtocol = toString(protocol); |
| | | |
| | | String url = null; |
| | | |
| | | String sProtocol = null; |
| | | switch (protocol) |
| | | { |
| | | case LDAP: |
| | | sProtocol = "ldap"; |
| | | break; |
| | | case LDAPS: |
| | | sProtocol = "ldaps"; |
| | | break; |
| | | case LDAP_STARTTLS: |
| | | sProtocol = "ldap"; |
| | | break; |
| | | case JMX: |
| | | sProtocol = "jmx"; |
| | | break; |
| | | case JMXS: |
| | | sProtocol = "jmxs"; |
| | | break; |
| | | } |
| | | |
| | | for (ConnectionHandlerDescriptor desc : server.getConnectionHandlers()) |
| | | { |
| | | if ((desc.getState() == ConnectionHandlerDescriptor.State.ENABLED) && |
| | | (desc.getProtocol() == protocol)) |
| | | { |
| | | int port = desc.getPort(); |
| | | SortedSet<InetAddress> addresses = desc.getAddresses(); |
| | | if (addresses.size() == 0) |
| | | { |
| | | if (port > 0) |
| | | { |
| | | if (server.isLocal()) |
| | | { |
| | | SortedSet<InetAddress> addresses = desc.getAddresses(); |
| | | if (addresses.isEmpty()) |
| | | { |
| | | url = sProtocol +"://localhost:"+port; |
| | | } |
| | | else |
| | | { |
| | | url = sProtocol + "://" + getHostNameForLdapUrl(server.getHostname()) + ":" + port; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (port > 0) |
| | | { |
| | | if (server.isLocal()) |
| | | { |
| | | InetAddress address = addresses.first(); |
| | | url = sProtocol + "://" + getHostNameForLdapUrl(address.getHostAddress()) + ":" + port; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | url = sProtocol + "://" + getHostNameForLdapUrl(server.getHostname()) + ":" + port; |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return url; |
| | | } |
| | | |
| | | private static String toString(ConnectionHandlerDescriptor.Protocol protocol) |
| | | { |
| | | switch (protocol) |
| | | { |
| | | case LDAP: |
| | | return "ldap"; |
| | | case LDAPS: |
| | | return "ldaps"; |
| | | case LDAP_STARTTLS: |
| | | return "ldap"; |
| | | case JMX: |
| | | return "jmx"; |
| | | case JMXS: |
| | | return "jmxs"; |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the Administration Connector URL. |
| | | * It returns <CODE>null</CODE> if URL for the |
| | |
| | | { |
| | | int port = desc.getPort(); |
| | | SortedSet<InetAddress> addresses = desc.getAddresses(); |
| | | if (addresses.size() == 0) { |
| | | if (port > 0) { |
| | | return getLDAPUrl("localhost", port, true); |
| | | if (!addresses.isEmpty()) |
| | | { |
| | | String hostAddr = addresses.first().getHostAddress(); |
| | | return getLDAPUrl(hostAddr, port, true); |
| | | } |
| | | } else { |
| | | if (port > 0) { |
| | | InetAddress address = addresses.first(); |
| | | String a = address.getHostAddress(); |
| | | return getLDAPUrl(a, port, true); |
| | | else |
| | | { |
| | | return getLDAPUrl("localhost", port, true); |
| | | } |
| | | } |
| | | } |
| | |
| | | // has not a lot of impact. |
| | | Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | |
| | | { |
| | | final Collection<ModificationItem> modifications = |
| | | getModifications(groupDn, dns); |
| | | if (modifications.size() > 0) |
| | | if (!modifications.isEmpty()) |
| | | { |
| | | ModificationItem[] mods = |
| | | new ModificationItem[modifications.size()]; |
| | |
| | | dnsToAdd.add(newDn.toString()); |
| | | } |
| | | } |
| | | if (dnsToAdd.size() > 0) |
| | | if (!dnsToAdd.isEmpty()) |
| | | { |
| | | Attribute attribute = |
| | | new BasicAttribute(memberAttr); |
| | | Attribute attribute = new BasicAttribute(memberAttr); |
| | | for (String dn : dnsToAdd) |
| | | { |
| | | attribute.add(dn); |
| | |
| | | // has not a lot of impact. |
| | | Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | |
| | | } |
| | | } |
| | | |
| | | if (backendsToDelete.size() > 0) |
| | | if (!backendsToDelete.isEmpty()) |
| | | { |
| | | if (sb.length() > 0) |
| | | { |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add( |
| | | getIncompatibilityMessage(this, taskToBeLaunched)); |
| | |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | node.getDN(), de); |
| | | } |
| | | } |
| | | if (toNotify.size() > 0) |
| | | if (!toNotify.isEmpty()) |
| | | { |
| | | final List<BrowserNodeInfo> fToNotify = |
| | | new ArrayList<BrowserNodeInfo>(toNotify); |
| | | final List<BrowserNodeInfo> fToNotify = new ArrayList<>(toNotify); |
| | | toNotify.clear(); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | |
| | | { |
| | | lastProgressTime = t; |
| | | final Collection<BrowserNodeInfo> fToNotify; |
| | | if (toNotify.size() > 0) |
| | | if (!toNotify.isEmpty()) |
| | | { |
| | | fToNotify = new ArrayList<BrowserNodeInfo>(toNotify); |
| | | fToNotify = new ArrayList<>(toNotify); |
| | | toNotify.clear(); |
| | | } |
| | | else |
| | |
| | | toNotify.add(controller.getNodeInfoFromPath(path)); |
| | | } |
| | | final Collection<BrowserNodeInfo> fToNotify; |
| | | if (toNotify.size() > 0) |
| | | if (!toNotify.isEmpty()) |
| | | { |
| | | fToNotify = new ArrayList<BrowserNodeInfo>(toNotify); |
| | | fToNotify = new ArrayList<>(toNotify); |
| | | toNotify.clear(); |
| | | } |
| | | else |
| | |
| | | // has not a lot of impact. |
| | | final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | |
| | | initializeBackendSet(); |
| | | } |
| | | |
| | | /** |
| | | * Initialize the list of backends that are affected by this task. |
| | | * |
| | | */ |
| | | /** Initialize the list of backends that are affected by this task. */ |
| | | private void initializeBackendSet() |
| | | { |
| | | backendSet = new TreeSet<String>(); |
| | | backendSet = new TreeSet<>(); |
| | | DN theDN = null; |
| | | for (String baseDN : baseDNs) |
| | | { |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | throw new IllegalArgumentException("Could not decode dn "+ |
| | | baseDN, t); |
| | | throw new IllegalArgumentException("Could not decode dn " + baseDN, t); |
| | | } |
| | | for (BackendDescriptor backend : |
| | | getInfo().getServerDescriptor().getBackends()) |
| | | BackendDescriptor backend = findBackendByID(theDN); |
| | | if (backend != null) { |
| | | backendSet.add(backend.getBackendID()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private BackendDescriptor findBackendByID(DN dn) |
| | | { |
| | | for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) |
| | | { |
| | | for (BaseDNDescriptor b : backend.getBaseDns()) |
| | | { |
| | | if (b.getDn().equals(theDN)) |
| | | if (b.getDn().equals(dn)) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | break; |
| | | } |
| | | } |
| | | if (backendSet.size() > 0) |
| | | { |
| | | break; |
| | | return backend; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | { |
| | | modifications.remove(passwordModification); |
| | | } |
| | | hasModifications = modifications.size() > 0 || |
| | | !oldDn.equals(newEntry.getName()) || |
| | | (passwordModification != null); |
| | | hasModifications = !modifications.isEmpty() |
| | | || !oldDn.equals(newEntry.getName()) |
| | | || passwordModification != null; |
| | | } |
| | | |
| | | /** |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | useAdminCtx = controller.isConfigurationNode(node); |
| | | if (!mustRename) |
| | | { |
| | | if (modifications.size() > 0) { |
| | | if (!modifications.isEmpty()) { |
| | | ModificationItem[] mods = |
| | | new ModificationItem[modifications.size()]; |
| | | modifications.toArray(mods); |
| | |
| | | ResetUserPasswordTask newTask = new ResetUserPasswordTask(getInfo(), |
| | | getProgressDialog(), (BasicNode)treePath.getLastPathComponent(), |
| | | controller, sPwd.toCharArray()); |
| | | if ((modifications.size() > 0) || mustRename) |
| | | if (!modifications.isEmpty() || mustRename) |
| | | { |
| | | getProgressDialog().appendProgressHtml("<br><br>"); |
| | | } |
| | |
| | | { |
| | | vs.remove(rdnValue); |
| | | } |
| | | if (vs.size() > 0) |
| | | if (!vs.isEmpty()) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | | DirContext.ADD_ATTRIBUTE, |
| | |
| | | } |
| | | else |
| | | { |
| | | if (toDelete.size() > 0) |
| | | if (!toDelete.isEmpty()) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | | DirContext.REMOVE_ATTRIBUTE, |
| | | createAttribute(attrName, toDelete))); |
| | | } |
| | | if (toAdd.size() > 0) |
| | | if (!toAdd.isEmpty()) |
| | | { |
| | | List<ByteString> vs = new ArrayList<ByteString>(toAdd); |
| | | if (rdnValue != null) |
| | | { |
| | | vs.remove(rdnValue); |
| | | } |
| | | if (vs.size() > 0) |
| | | if (!vs.isEmpty()) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | | DirContext.ADD_ATTRIBUTE, |
| | |
| | | } |
| | | } |
| | | } |
| | | if (!found && (oldValues.size() > 0)) |
| | | if (!found && !oldValues.isEmpty()) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | | DirContext.REMOVE_ATTRIBUTE, |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.tools.RebuildIndex; |
| | | |
| | | /** |
| | | * The class that is used when a set of indexes must be rebuilt. |
| | | * |
| | | */ |
| | | public class RebuildIndexTask extends IndexTask |
| | | { |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | for (final String baseDN : baseDNs) |
| | | { |
| | | ArrayList<String> arguments = getCommandLineArguments(baseDN); |
| | | |
| | | String[] args = new String[arguments.size()]; |
| | | |
| | | arguments.toArray(args); |
| | | String[] args = arguments.toArray(new String[arguments.size()]); |
| | | |
| | | final List<String> displayArgs = getObfuscatedCommandLineArguments( |
| | | getCommandLineArguments(baseDN)); |
| | |
| | | |
| | | private boolean rebuildAll() |
| | | { |
| | | boolean rebuildAll = true; |
| | | Set<BackendDescriptor> backends = new HashSet<BackendDescriptor>(); |
| | | for (AbstractIndexDescriptor index : indexes) |
| | | { |
| | |
| | | } |
| | | for (BackendDescriptor backend : backends) |
| | | { |
| | | Set<AbstractIndexDescriptor> allIndexes = |
| | | new HashSet<AbstractIndexDescriptor>(); |
| | | Set<AbstractIndexDescriptor> allIndexes = new HashSet<>(); |
| | | allIndexes.addAll(backend.getIndexes()); |
| | | allIndexes.addAll(backend.getVLVIndexes()); |
| | | for (AbstractIndexDescriptor index : allIndexes) |
| | | { |
| | | if (!ignoreIndex(index)) |
| | | if (!ignoreIndex(index) |
| | | && !indexExists(index)) |
| | | { |
| | | boolean found = false; |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private boolean indexExists(AbstractIndexDescriptor index) |
| | | { |
| | | for (AbstractIndexDescriptor indexToRebuild : indexes) |
| | | { |
| | | if (indexToRebuild.equals(index)) |
| | | { |
| | | found = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | if (!found) |
| | | { |
| | | rebuildAll = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return rebuildAll; |
| | | return false; |
| | | } |
| | | |
| | | private boolean ignoreIndex(AbstractIndexDescriptor index) |
| | | { |
| | | boolean ignoreIndex = false; |
| | | if (index instanceof IndexDescriptor) |
| | | { |
| | | for (String name : INDEXES_NOT_TO_SPECIFY) |
| | | { |
| | | if (name.equalsIgnoreCase(index.getName())) |
| | | { |
| | | ignoreIndex = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return ignoreIndex; |
| | | return false; |
| | | } |
| | | } |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | model.addElement(newElement); |
| | | } |
| | | // If there are not backends, we get no indexes to set. |
| | | if (newElements.size() > 0) |
| | | if (!newElements.isEmpty()) |
| | | { |
| | | model.addElement(COMBO_SEPARATOR); |
| | | } |
| | |
| | | private void handleErrorsAndLaunchTask(ArrayList<LocalizableMessage> errors) |
| | | { |
| | | Entry entry = null; |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | errors.add(ERR_CTRL_PANEL_ENTRY_ALREADY_EXISTS.get(dn)); |
| | | } |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | final ProgressDialog dlg = new ProgressDialog( |
| | | Utilities.createFrame(), Utilities.getParentDialog(this), |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_CREATING_NEW_ENTRY_SUMMARY.get(), |
| | |
| | | throw new RuntimeException("Unexpected error: "+t, t); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (customAttrNames.size() > 0) |
| | | if (!customAttrNames.isEmpty()) |
| | | { |
| | | newElements.add(new CategorizedComboBoxElement(CUSTOM_ATTRIBUTES, CategorizedComboBoxElement.Type.CATEGORY)); |
| | | for (String attrName : customAttrNames) |
| | |
| | | newElements.add(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR)); |
| | | } |
| | | } |
| | | if (standardAttrNames.size() > 0) |
| | | if (!standardAttrNames.isEmpty()) |
| | | { |
| | | newElements.add(new CategorizedComboBoxElement(STANDARD_ATTRIBUTES, CategorizedComboBoxElement.Type.CATEGORY)); |
| | | for (String attrName : standardAttrNames) |
| | |
| | | |
| | | private void handleErrorsAndLaunchTask(ArrayList<LocalizableMessage> errors) |
| | | { |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | ProgressDialog dlg = new ProgressDialog( |
| | | Utilities.createFrame(), |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_ADDING_TO_GROUP_SUMMARY.get(), |
| | |
| | | throw new RuntimeException("Unexpected error: "+t, t); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if ((backups.size() == 0) && (firstThrowable != null)) |
| | | if (backups.isEmpty() && firstThrowable != null) |
| | | { |
| | | throw firstThrowable; |
| | | } |
| | |
| | | renderer.setParentPath(new File(parentPath)); |
| | | if (t == null) |
| | | { |
| | | if (returnValue.size() > 0) |
| | | if (!returnValue.isEmpty()) |
| | | { |
| | | for (BackupInfo backup : returnValue) |
| | | { |
| | |
| | | Utilities.getParentDialog(BackupPanel.this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | public void okClicked() |
| | | { |
| | | setPrimaryValid(dnLabel); |
| | | LinkedHashSet<LocalizableMessage> errors = new LinkedHashSet<LocalizableMessage>(); |
| | | LinkedHashSet<LocalizableMessage> errors = new LinkedHashSet<>(); |
| | | |
| | | if ("".equals(dn.getText().trim())) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (errors.size() > 0) |
| | | { |
| | | setPrimaryInvalid(dnLabel); |
| | | } |
| | | if (errors.isEmpty()) |
| | | { |
| | | baseDn = dn.getText().trim(); |
| | |
| | | } |
| | | else |
| | | { |
| | | setPrimaryInvalid(dnLabel); |
| | | displayErrorDialog(errors); |
| | | dn.setSelectionStart(0); |
| | | dn.setSelectionEnd(dn.getText().length()); |
| | |
| | | setPrimaryInvalid(useBase64); |
| | | } |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | // Read the file or encode the base 64 content. |
| | | BackgroundTask<BinaryValue> worker = new BackgroundTask<BinaryValue>() |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | if (displayConfirmationDialog( |
| | | INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), |
| | |
| | | int positionUnderRoot = 0; |
| | | for (DefaultMutableTreeNode parent : categoryNodes) |
| | | { |
| | | if (nodes.get(i).size() == 0) |
| | | if (nodes.get(i).isEmpty()) |
| | | { |
| | | if (root.getIndex(parent) != -1) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get()); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | |
| | |
| | | checkCompatibleSuperiors(getObjectClassSuperiors(), getObjectClassType(), |
| | | errors); |
| | | |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | ProgressDialog dlg = new ProgressDialog( |
| | | Utilities.createFrame(), |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_MODIFYING_OBJECTCLASS_SUMMARY.get(ocName), |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (attributes.size() > 0) |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | setOperationsToDisplay(attributes); |
| | | updateTableSize(); |
| | |
| | | scroll.setVisible(backendsFound && !allAttributes.isEmpty()); |
| | | noDBsFound.setVisible(!backendsFound); |
| | | noMonitoringFound.setVisible(backendsFound && allAttributes.isEmpty()); |
| | | showOperations.setVisible(allAttributes.size() > 0); |
| | | showOperations.setVisible(!allAttributes.isEmpty()); |
| | | } |
| | | |
| | | |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | i ++; |
| | | } |
| | | if (selected.size() > 0) |
| | | if (!selected.isEmpty()) |
| | | { |
| | | int[] indArray = new int[indices.size()]; |
| | | i = 0; |
| | | for (Integer index : indices) |
| | | { |
| | | indArray[i] = index; |
| | | i++; |
| | | } |
| | | list.setSelectedIndices(indArray); |
| | | list.setSelectedIndices(toIntArray(indices)); |
| | | } |
| | | checkVisibility(); |
| | | } |
| | | |
| | | private int[] toIntArray(Set<Integer> indices) |
| | | { |
| | | int[] result = new int[indices.size()]; |
| | | int i = 0; |
| | | for (Integer index : indices) |
| | | { |
| | | result[i] = index; |
| | | i++; |
| | | } |
| | | return result; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | { |
| | | mb.append("<br> - ").append(baseDN.getDn()); |
| | | } |
| | | if (indirectBackendsToDelete.size() > 0) |
| | | if (!indirectBackendsToDelete.isEmpty()) |
| | | { |
| | | mb.append("<br><br>"); |
| | | mb.append( |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | { |
| | | task.canLaunch(newModifyTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | String attributeName = index.getName(); |
| | | String backendName = index.getBackend().getBackendID(); |
| | |
| | | } |
| | | } |
| | | |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (javaHomeErrors.size() == 0) |
| | | if (javaHomeErrors.isEmpty()) |
| | | { |
| | | final Set<String> providedArguments = new HashSet<String>(); |
| | | for (JavaArgumentsDescriptor cmd : getCurrentJavaArguments()) |
| | |
| | | } |
| | | } |
| | | } |
| | | if (notWorkingArgs.size() > 0) |
| | | if (!notWorkingArgs.isEmpty()) |
| | | { |
| | | File javaFile = getJavaFile(new File(jvm)); |
| | | LocalizableMessage confirmationMessage; |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_UPDATING_JAVA_SETTINGS_SUMMARY.get(), |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if ((errors.size() == 0) && newTask.hasModifications()) |
| | | |
| | | if (errors.isEmpty()) |
| | | { |
| | | if (newTask.hasModifications()) { |
| | | String dn = entry.getName().toString(); |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_MODIFYING_ENTRY_SUMMARY.get(dn), |
| | |
| | | saveChanges.setEnabled(false); |
| | | dlg.setVisible(true); |
| | | } |
| | | else if (errors.size() == 0) |
| | | else |
| | | { |
| | | // Mark the panel as it has no changes. This can happen because every |
| | | // time the user types something the saveChanges button is enabled |
| | |
| | | saveChanges.setEnabled(false); |
| | | } |
| | | } |
| | | } |
| | | catch (OpenDsException ode) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_INVALID_ENTRY.get(ode.getMessageObject())); |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | |
| | | private void deleteEntry() |
| | | { |
| | | final ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); |
| | | final ArrayList<LocalizableMessage> errors = new ArrayList<>(); |
| | | // Check that the entry is correct. |
| | | // Rely in numsubordinates and hassubordinates |
| | | boolean isLeaf = !BrowserController.getHasSubOrdinates(searchResult); |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | LocalizableMessage confirmationMessage = |
| | | isLeaf ? INFO_CTRL_PANEL_DELETE_ENTRY_CONFIRMATION_DETAILS.get( |
| | |
| | | } |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | } |
| | | boolean confirmed = true; |
| | | if (runningTasks.size() > 0) |
| | | if (!runningTasks.isEmpty()) |
| | | { |
| | | String allTasks = Utilities.getStringFromCollection(runningTasks, "<br>"); |
| | | LocalizableMessage title = INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(); |
| | |
| | | } |
| | | } |
| | | boolean confirmed = true; |
| | | if (runningTasks.size() > 0) |
| | | if (!runningTasks.isEmpty()) |
| | | { |
| | | String allTasks = Utilities.getStringFromCollection(runningTasks, "<br>"); |
| | | LocalizableMessage title = INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(); |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | boolean confirmed = displayConfirmationDialog( |
| | | INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), |
| | |
| | | Utilities.getParentDialog(this), |
| | | INFO_CTRL_PANEL_NEW_ATTRIBUTE_PANEL_TITLE.get(), getInfo()); |
| | | NewSchemaElementsTask newTask = null; |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | LinkedHashSet<AttributeType> attributes = |
| | | new LinkedHashSet<AttributeType>(); |
| | | LinkedHashSet<AttributeType> attributes = new LinkedHashSet<>(); |
| | | attributes.add(getAttribute()); |
| | | LinkedHashSet<ObjectClass> ocs = new LinkedHashSet<ObjectClass>(0); |
| | | LinkedHashSet<ObjectClass> ocs = new LinkedHashSet<>(0); |
| | | newTask = new NewSchemaElementsTask(getInfo(), dlg, ocs, attributes); |
| | | for (Task task : getInfo().getTasks()) |
| | | { |
| | |
| | | newTask.addConfigurationElementCreatedListener(listener); |
| | | } |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | String attrName = getAttributeName(); |
| | | launchOperation(newTask, |
| | |
| | | } |
| | | |
| | | ArrayList<Object> newElements = new ArrayList<Object>(sortedBackends); |
| | | if (sortedBackends.size() > 0) |
| | | if (!sortedBackends.isEmpty()) |
| | | { |
| | | newElements.add(COMBO_SEPARATOR); |
| | | } |
| | |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | |
| | | { |
| | | ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); |
| | | checkSyntax(errors); |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (customAttrNames.size() > 0) |
| | | if (!customAttrNames.isEmpty()) |
| | | { |
| | | newElements.add(new CategorizedComboBoxElement( |
| | | CUSTOM_ATTRIBUTES, |
| | |
| | | CategorizedComboBoxElement.Type.REGULAR)); |
| | | } |
| | | } |
| | | if (standardAttrNames.size() > 0) |
| | | if (!standardAttrNames.isEmpty()) |
| | | { |
| | | newElements.add(new CategorizedComboBoxElement( |
| | | STANDARD_ATTRIBUTES, |
| | |
| | | CategorizedComboBoxElement.Type.REGULAR)); |
| | | } |
| | | } |
| | | // Ignore configuration attr names |
| | | /* |
| | | if (configurationAttrNames.size() > 0) |
| | | { |
| | | newElements.add(new CategorizedComboBoxDescriptor( |
| | | "Configuration Attributes", |
| | | CategorizedComboBoxDescriptor.Type.CATEGORY)); |
| | | for (String attrName : configurationAttrNames) |
| | | { |
| | | newElements.add(new CategorizedComboBoxDescriptor( |
| | | attrName, |
| | | CategorizedComboBoxDescriptor.Type.REGULAR)); |
| | | } |
| | | } |
| | | */ |
| | | DefaultComboBoxModel model = |
| | | (DefaultComboBoxModel)attributes.getModel(); |
| | | updateComboBoxModel(newElements, model); |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUMMARY.get(attrName), |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | Utilities.getParentDialog(this), |
| | | INFO_CTRL_PANEL_NEW_OBJECTCLASS_PANEL_TITLE.get(), getInfo()); |
| | | NewSchemaElementsTask newTask = null; |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | LinkedHashSet<AttributeType> attributes = |
| | | new LinkedHashSet<AttributeType>(1); |
| | | LinkedHashSet<ObjectClass> ocs = new LinkedHashSet<ObjectClass>(); |
| | | LinkedHashSet<AttributeType> attributes = new LinkedHashSet<>(0); |
| | | LinkedHashSet<ObjectClass> ocs = new LinkedHashSet<>(1); |
| | | ocs.add(getObjectClass()); |
| | | newTask = new NewSchemaElementsTask(getInfo(), dlg, ocs, attributes); |
| | | for (Task task : getInfo().getTasks()) |
| | |
| | | newTask.addConfigurationElementCreatedListener(listener); |
| | | } |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | String ocName = getObjectClassName(); |
| | | launchOperation(newTask, |
| | |
| | | } |
| | | } |
| | | |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | errors.add(ERR_CTRL_PANEL_PASSWORD_DO_NOT_MATCH.get()); |
| | | } |
| | | |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | final Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | return false; |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | errors.add(INFO_CTRL_PANEL_INVALID_PERIOD_VALUE.get(MAX_VALUE)); |
| | | } |
| | | |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | setPrimaryInvalid(lPassword); |
| | | setPrimaryInvalid(lConfirmPassword); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | ProgressDialog dlg = new ProgressDialog( |
| | | Utilities.createFrame(), |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_RESETTING_USER_PASSWORD_SUMMARY.get(), |
| | |
| | | dlg.setVisible(true); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | throw new CheckEntrySyntaxException(errors); |
| | | } |
| | |
| | | |
| | | private boolean hasBinaryValue(List<Object> values) |
| | | { |
| | | boolean isBinary = false; |
| | | if (values.size() > 0) |
| | | if (!values.isEmpty()) |
| | | { |
| | | isBinary = values.iterator().next() instanceof byte[]; |
| | | return values.iterator().next() instanceof byte[]; |
| | | } |
| | | return isBinary; |
| | | return false; |
| | | } |
| | | |
| | | private boolean mustAddBrowseButton(String attrName) |
| | |
| | | /** {@inheritDoc} */ |
| | | protected List<Object> getValues(String attrName) |
| | | { |
| | | List<Object> values = new ArrayList<Object>(); |
| | | List<EditorComponent> comps = hmEditors.get(attrName); |
| | | if (comps.size() > 0) |
| | | { |
| | | for (EditorComponent comp : comps) |
| | | List<Object> values = new ArrayList<>(); |
| | | for (EditorComponent comp : hmEditors.get(attrName)) |
| | | { |
| | | if (hasValue(comp)) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return values; |
| | | } |
| | | |
| | | private void appendLDIFLines(StringBuilder sb, String attrName) |
| | | { |
| | | List<Object> values = getValues(attrName); |
| | | |
| | | if (values.size() > 0) |
| | | if (!values.isEmpty()) |
| | | { |
| | | appendLDIFLines(sb, attrName, values); |
| | | } |
| | |
| | | List<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(value.toString())) |
| | | { |
| | | if (values.size() > 0) |
| | | if (!values.isEmpty()) |
| | | { |
| | | String firstNonEmpty = null; |
| | | for (String v : values) |
| | | { |
| | | v = v.trim(); |
| | | if (v.length() > 0) |
| | | { |
| | | firstNonEmpty = v; |
| | | break; |
| | | } |
| | | } |
| | | String firstNonEmpty = getFirstNonEmpty(values); |
| | | if (firstNonEmpty != null) |
| | | { |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | |
| | | attributeValues.add(value); |
| | | } |
| | | } |
| | | if (attributeTypes.size() == 0) |
| | | if (attributeTypes.isEmpty()) |
| | | { |
| | | // Check the attributes in the order that we display them and use |
| | | // the first one. |
| | |
| | | continue; |
| | | } |
| | | List<EditorComponent> comps = hmEditors.get(attrName); |
| | | if (comps.size() > 0) |
| | | if (!comps.isEmpty()) |
| | | { |
| | | Object o = comps.iterator().next().getValue(); |
| | | if (o instanceof String) |
| | |
| | | } |
| | | } |
| | | DN parent = oldDN.parent(); |
| | | if (attributeTypes.size() > 0) |
| | | if (!attributeTypes.isEmpty()) |
| | | { |
| | | DN newDN; |
| | | RDN newRDN = new RDN(attributeTypes, attributeNames, attributeValues); |
| | | |
| | | DN newDN; |
| | | if (parent == null) |
| | | { |
| | | newDN = new DN(new RDN[]{newRDN}); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private String getFirstNonEmpty(List<String> values) |
| | | { |
| | | for (String v : values) |
| | | { |
| | | v = v.trim(); |
| | | if (v.length() > 0) |
| | | { |
| | | return v; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void addBrowseClicked(String attrName, JTextComponent textComponent) |
| | | { |
| | | LocalizableMessage previousTitle = null; |
| | |
| | | |
| | | private boolean hasValue(String attrName) |
| | | { |
| | | return getValues(attrName).size() > 0; |
| | | return !getValues(attrName).isEmpty(); |
| | | } |
| | | |
| | | private boolean hasValue(EditorComponent editor) |
| | |
| | | } |
| | | else if (value instanceof Collection<?>) |
| | | { |
| | | return ((Collection<?>)value).size() > 0; |
| | | return !((Collection<?>)value).isEmpty(); |
| | | } |
| | | else if (value != null) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | return value != null; |
| | | } |
| | | |
| | | /** Calls #addBrowseClicked(). */ |
| | |
| | | otherNames.add(name); |
| | | } |
| | | } |
| | | if (otherNames.size() > 0) |
| | | if (!otherNames.isEmpty()) |
| | | { |
| | | n = Utilities.getStringFromCollection(otherNames, ", "); |
| | | } |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | progressDialog.appendProgressHtml("<br><br>"); |
| | | launchOperation(newTask, INFO_CTRL_PANEL_REBUILDING_INDEXES_SUMMARY.get(backendName), |
| | |
| | | progressDialog.toFront(); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | @Override |
| | | public void run() |
| | | { |
| | | combo.setVisible(newElements.size() > 0); |
| | | lNoBackendsFound.setVisible(newElements.size() == 0); |
| | | boolean noElems = newElements.isEmpty(); |
| | | combo.setVisible(!noElems); |
| | | lNoBackendsFound.setVisible(noElems); |
| | | } |
| | | }); |
| | | } |
| | |
| | | { |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_STARTING_SERVER_SUMMARY.get(), |
| | |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | boolean confirmed = true; |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | confirmed = displayConfirmationDialog(INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), |
| | | INFO_CTRL_PANEL_CONFIRM_STOP_SERVER_DETAILS.get()); |
| | | } |
| | | if (errors.size() == 0 && confirmed) |
| | | if (errors.isEmpty() && confirmed) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_STOPPING_SERVER_SUMMARY.get(), |
| | |
| | | ERR_CTRL_PANEL_STOPPING_SERVER_ERROR_DETAILS, progressDialog); |
| | | progressDialog.setVisible(true); |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | task.canLaunch(newTask, errors); |
| | | } |
| | | boolean confirmed = true; |
| | | if (errors.size() == 0) |
| | | if (errors.isEmpty()) |
| | | { |
| | | confirmed = displayConfirmationDialog(INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), |
| | | INFO_CTRL_PANEL_CONFIRM_RESTART_SERVER_DETAILS.get()); |
| | | } |
| | | if (errors.size() == 0 && confirmed) |
| | | if (errors.isEmpty() && confirmed) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_STOPPING_SERVER_SUMMARY.get(), |
| | |
| | | ERR_CTRL_PANEL_RESTARTING_SERVER_ERROR_DETAILS, progressDialog); |
| | | progressDialog.setVisible(true); |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | } |
| | | |
| | | Collection<OpenDsException> exceptions = desc.getExceptions(); |
| | | if (exceptions.size() == 0) |
| | | if (exceptions.isEmpty()) |
| | | { |
| | | boolean errorPaneVisible = false; |
| | | if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED) |
| | |
| | | } |
| | | } |
| | | |
| | | if (rootUsers.size() > 0) |
| | | { |
| | | setText(administrativeUsers, |
| | | Utilities.getStringFromCollection(sortedRootUsers, "<br>")); |
| | | } |
| | | else |
| | | { |
| | | setText(administrativeUsers, |
| | | INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString()); |
| | | } |
| | | String htmlText = !rootUsers.isEmpty() |
| | | ? Utilities.getStringFromCollection(sortedRootUsers, "<br>") |
| | | : INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString(); |
| | | setText(administrativeUsers, htmlText); |
| | | |
| | | String install = desc.getInstallPath(); |
| | | if (install != null) |
| | | { |
| | | setText(installPath, install); |
| | | } |
| | | else |
| | | { |
| | | setText(installPath, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString()); |
| | | } |
| | | setText(install, installPath); |
| | | |
| | | String instance = desc.getInstancePath(); |
| | | |
| | | if (instance != null) |
| | | { |
| | | setText(instancePath, instance); |
| | | } |
| | | else |
| | | { |
| | | setText(instancePath, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString()); |
| | | } |
| | | setText(instance, instancePath); |
| | | |
| | | instancePath.setVisible(!desc.sameInstallAndInstance()); |
| | | lInstancePath.setVisible(!desc.sameInstallAndInstance()); |
| | |
| | | } |
| | | } |
| | | |
| | | boolean oneReplicated = false; |
| | | for (BaseDNDescriptor baseDN : baseDNs) |
| | | { |
| | | if (baseDN.getType() == BaseDNDescriptor.Type.REPLICATED) |
| | | { |
| | | oneReplicated = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | boolean hasBaseDNs = baseDNs.size() > 0; |
| | | boolean oneReplicated = oneReplicated(baseDNs); |
| | | boolean hasBaseDNs = !baseDNs.isEmpty(); |
| | | |
| | | replicationBaseDNsTable.setVisible(oneReplicated && hasBaseDNs); |
| | | replicationBaseDNsTable.getTableHeader().setVisible( |
| | |
| | | desc.getConnectionHandlers(); |
| | | connectionHandlerTableModel.setData(connectionHandlers); |
| | | |
| | | boolean hasConnectionHandlers = connectionHandlers.size() > 0; |
| | | boolean hasConnectionHandlers = !connectionHandlers.isEmpty(); |
| | | connectionHandlersTable.setVisible(hasConnectionHandlers); |
| | | connectionHandlersTable.getTableHeader().setVisible(hasConnectionHandlers); |
| | | connectionHandlerTableEmpty.setVisible(!hasConnectionHandlers); |
| | |
| | | Utilities.updateViewPositions(pos); |
| | | } |
| | | |
| | | private boolean oneReplicated(Set<BaseDNDescriptor> baseDNs) |
| | | { |
| | | for (BaseDNDescriptor baseDN : baseDNs) |
| | | { |
| | | if (baseDN.getType() == BaseDNDescriptor.Type.REPLICATED) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void setText(String text, JEditorPane editorPane) |
| | | { |
| | | if (text != null) |
| | | { |
| | | setText(editorPane, text); |
| | | } |
| | | else |
| | | { |
| | | setText(editorPane, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString()); |
| | | } |
| | | } |
| | | |
| | | private void setText(JEditorPane pane, String htmlText) |
| | | { |
| | | pane.setText(Utilities.applyFont(htmlText, |
| | |
| | | Set<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(value.toString())) |
| | | { |
| | | if (values.size() > 0) |
| | | if (!values.isEmpty()) |
| | | { |
| | | String firstNonEmpty = null; |
| | | for (String v : values) |
| | | { |
| | | v = v.trim(); |
| | | if (v.length() > 0) |
| | | { |
| | | firstNonEmpty = v; |
| | | break; |
| | | } |
| | | } |
| | | String firstNonEmpty = getFirstNonEmpty(values); |
| | | if (firstNonEmpty != null) |
| | | { |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | |
| | | attributeValues.add(value); |
| | | } |
| | | } |
| | | if (attributeTypes.size() == 0) |
| | | if (attributeTypes.isEmpty()) |
| | | { |
| | | // Check the attributes in the order that we display them and use |
| | | // the first one. |
| | |
| | | } |
| | | } |
| | | DN parent = oldDN.parent(); |
| | | if (attributeTypes.size() > 0) |
| | | if (!attributeTypes.isEmpty()) |
| | | { |
| | | DN newDN; |
| | | RDN newRDN = new RDN(attributeTypes, attributeNames, attributeValues); |
| | | |
| | | DN newDN; |
| | | if (parent == null) |
| | | { |
| | | newDN = new DN(new RDN[]{newRDN}); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private String getFirstNonEmpty(Set<String> values) |
| | | { |
| | | for (String v : values) |
| | | { |
| | | v = v.trim(); |
| | | if (v.length() > 0) |
| | | { |
| | | return v; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private Set<String> getDisplayedStringValues(String attrName) |
| | | { |
| | | Set<String> values = new LinkedHashSet<String>(); |
| | |
| | | |
| | | updateErrorMessages(errorMessages); |
| | | |
| | | if (errorMessages.size() > 0) |
| | | if (!errorMessages.isEmpty()) |
| | | { |
| | | displayErrorDialog(errorMessages); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | // All the operations are incompatible if they apply to this |
| | | // backend for safety. This is a short operation so the limitation |
| | | // has not a lot of impact. |
| | | final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | final Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | |
| | | Utilities.getParentDialog(this).setVisible(false); |
| | | } |
| | | } |
| | | if (errors.size() > 0) |
| | | if (!errors.isEmpty()) |
| | | { |
| | | displayErrorDialog(errors); |
| | | } |
| | |
| | | && type != Task.Type.EXPORT_LDIF |
| | | && type != Task.Type.ENABLE_WINDOWS_SERVICE |
| | | && type != Task.Type.DISABLE_WINDOWS_SERVICE |
| | | && backends.size() > 0) |
| | | && !backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | |
| | | { |
| | | sb.append(INFO_CTRL_OBJECTCLASS_DESCRIPTOR.get(ocDesc.getStructural())); |
| | | } |
| | | if (ocDesc.getAuxiliary().size() > 0) |
| | | if (!ocDesc.getAuxiliary().isEmpty()) |
| | | { |
| | | if (sb.length() > 0) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (valuesToSet.size() > 0) |
| | | if (!valuesToSet.isEmpty()) |
| | | { |
| | | sr.set(attrName, valuesToSet); |
| | | } |
| | |
| | | { |
| | | sb.append(value.getStructural()); |
| | | } |
| | | if (aux.size() > 0) |
| | | if (!aux.isEmpty()) |
| | | { |
| | | if (sb.length() > 0) |
| | | { |
| | |
| | | @Test(enabled = false) |
| | | public void testGetDirectoryManagerDns() throws IOException { |
| | | Set<String> dns = config.getDirectoryManagerDns(); |
| | | assertTrue(dns.size() > 0); |
| | | assertFalse(dns.isEmpty()); |
| | | } |
| | | |
| | | @Test(enabled = false) |
| | |
| | | |
| | | @Test(enabled = false) |
| | | public void testGetDatabasePaths() throws IOException { |
| | | assertTrue(config.getDatabasePaths().size() > 0); |
| | | assertTrue(!config.getDatabasePaths().isEmpty()); |
| | | } |
| | | |
| | | @Test(enabled = false) |
| | |
| | | |
| | | // Check that the task contains some log messages. |
| | | Set<String> logMessages = parseAttribute(resultEntry, ATTR_TASK_LOG_MESSAGES).asSetOfString(); |
| | | if (taskState != TaskState.COMPLETED_SUCCESSFULLY && logMessages.size() == 0) |
| | | if (taskState != TaskState.COMPLETED_SUCCESSFULLY && logMessages.isEmpty()) |
| | | { |
| | | fail("No log messages were written to the task entry on a failed task.\n" |
| | | + "taskState=" + taskState |