From 91d372cca007303222f2ec621da6b2e62480fbc3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 25 Aug 2015 16:02:28 +0000
Subject: [PATCH] Use Collection.contains() Used early exits Removed duplicated code
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java | 22 --
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java | 10
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java | 63 ++----
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java | 99 +++-------
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/NumSubordinateHacker.java | 60 +-----
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java | 30 +--
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 141 ++-------------
opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java | 52 +---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java | 24 --
9 files changed, 133 insertions(+), 368 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java
index 1da403f..5181e0b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java
@@ -287,13 +287,7 @@
*/
public String getLDAPURL()
{
- int port = getPort(ServerProperty.LDAP_ENABLED, ServerProperty.LDAP_PORT);
- if (port != -1)
- {
- String host = getHostName();
- return getLDAPUrl(host, port, false);
- }
- return null;
+ return getLDAPUrl0(ServerProperty.LDAP_ENABLED, ServerProperty.LDAP_PORT, false);
}
/**
@@ -304,31 +298,25 @@
*/
public String getLDAPsURL()
{
- int port = getPort(ServerProperty.LDAPS_ENABLED, ServerProperty.LDAPS_PORT);
+ return getLDAPUrl0(ServerProperty.LDAPS_ENABLED, ServerProperty.LDAPS_PORT, true);
+ }
+
+ private String getLDAPUrl0(ServerProperty enabledProp, ServerProperty portProp, boolean useSSL)
+ {
+ int port = getPort(enabledProp, portProp);
if (port != -1)
{
String host = getHostName();
- return getLDAPUrl(host, port, true);
+ return getLDAPUrl(host, port, useSSL);
}
return null;
}
- private int getPort(ServerProperty enabled, ServerProperty port)
+ private int getPort(ServerProperty enabledProp, ServerProperty portProp)
{
if (!serverProperties.isEmpty())
{
- List<?> s = (List<?>) serverProperties.get(enabled);
- List<?> p = (List<?>) serverProperties.get(port);
- if (s != null)
- {
- for (int i=0; i<s.size(); i++)
- {
- if (Boolean.TRUE.equals(s.get(i)))
- {
- return (Integer) p.get(i);
- }
- }
- }
+ return getPort(enabledProp, portProp, -1);
}
return -1;
}
@@ -341,13 +329,7 @@
*/
public String getAdminConnectorURL()
{
- String host = getHostName();
- int port = getPort(ServerProperty.ADMIN_ENABLED, ServerProperty.ADMIN_PORT);
- if (port != -1)
- {
- return getLDAPUrl(host, port, true);
- }
- return null;
+ return getLDAPUrl0(ServerProperty.ADMIN_ENABLED, ServerProperty.ADMIN_PORT, true);
}
/**
@@ -386,10 +368,10 @@
if (!serverProperties.isEmpty())
{
- port = getPort(port, ServerProperty.LDAP_ENABLED, ServerProperty.LDAP_PORT);
+ port = getPort(ServerProperty.LDAP_ENABLED, ServerProperty.LDAP_PORT, port);
if (securePreferred)
{
- port = getPort(port, ServerProperty.ADMIN_ENABLED, ServerProperty.ADMIN_PORT);
+ port = getPort(ServerProperty.ADMIN_ENABLED, ServerProperty.ADMIN_PORT, port);
}
}
else
@@ -462,12 +444,12 @@
}
}
- private int getPort(int port, ServerProperty adminEnabled, ServerProperty adminPort)
+ private int getPort(ServerProperty enabledProp, ServerProperty portProp, int defaultValue)
{
- List<?> s = (List<?>) serverProperties.get(adminEnabled);
- List<?> p = (List<?>) serverProperties.get(adminPort);
+ List<?> s = (List<?>) serverProperties.get(enabledProp);
if (s != null)
{
+ List<?> p = (List<?>) serverProperties.get(portProp);
for (int i=0; i<s.size(); i++)
{
if (Boolean.TRUE.equals(s.get(i)))
@@ -476,7 +458,7 @@
}
}
}
- return port;
+ return defaultValue;
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
index ddca70c..9c8cae7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -24,7 +24,6 @@
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.task;
import static org.opends.messages.AdminToolMessages.*;
@@ -65,9 +64,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
-/**
- * The task that is called when we must modify an entry.
- */
+/** The task that is called when we must modify an entry. */
public class ModifyEntryTask extends Task
{
private Set<String> backendSet;
@@ -170,7 +167,6 @@
return INFO_CTRL_PANEL_MODIFY_ENTRY_TASK_DESCRIPTION.get(oldEntry.getDN());
}
-
/** {@inheritDoc} */
protected String getCommandLinePath()
{
@@ -466,7 +462,7 @@
for (int i = 0; i < rdn.getNumValues(); i++)
{
List<Object> values = entry.getAttributeValues(rdn.getAttributeName(i));
- if (!!values.isEmpty())
+ if (values.isEmpty())
{
return false;
}
@@ -547,7 +543,7 @@
if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName))
{
ByteString value = oldRDN.getAttributeValue(i);
- if (containsValue(attr, value))
+ if (attr.contains(value))
{
if (rdnValue == null || !rdnValue.equals(value))
{
@@ -655,18 +651,6 @@
return false;
}
- private static boolean containsValue(org.opends.server.types.Attribute attr, Object value)
- {
- for (Iterator<ByteString> it = attr.iterator(); it.hasNext();)
- {
- if (value.equals(it.next()))
- {
- return true;
- }
- }
- return false;
- }
-
/**
* Creates a JNDI attribute using an attribute name and a set of values.
* @param attrName the attribute name.
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
index d640126..d64a346 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
@@ -24,7 +24,6 @@
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.task;
import static org.opends.messages.AdminToolMessages.*;
@@ -43,6 +42,8 @@
import javax.swing.SwingUtilities;
import javax.swing.tree.TreePath;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
@@ -52,16 +53,11 @@
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.ui.nodes.BrowserNodeInfo;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.config.ConfigConstants;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
-/**
- * The task launched when we must create an entry.
- *
- */
+/** The task launched when we must create an entry. */
public class NewEntryTask extends Task
{
private Entry newEntry;
@@ -377,24 +373,16 @@
private boolean isBaseDN(DN dn)
{
- boolean isBaseDN = false;
- for (BackendDescriptor backend :
- getInfo().getServerDescriptor().getBackends())
+ for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends())
{
for (BaseDNDescriptor baseDN : backend.getBaseDns())
{
if (baseDN.getDn().equals(dn))
{
- isBaseDN = true;
- break;
+ return true;
}
}
- if (isBaseDN)
- {
- break;
- }
}
- return isBaseDN;
+ return false;
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
index 53e9ae9..c4f2012 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -136,7 +136,6 @@
private CommonSchemaElements lastCreatedElement;
-
private final CategoryTreeNode attributes = new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get());
private final CategoryTreeNode objectClasses =
new CategoryTreeNode(INFO_CTRL_PANEL_OBJECTCLASSES_CATEGORY_NODE.get());
@@ -1172,18 +1171,15 @@
return mustAdd(ocName, oc.getOID(), oc.getPrimaryName(), oc.getNormalizedNames());
}
- private boolean mustAdd(String name, String oid, String primaryName, Iterable<String> names)
+ private boolean mustAdd(String name, String oid, String primaryName, Set<String> names)
{
- List<String> values = new ArrayList<>();
+ List<String> values = new ArrayList<>(names.size() + 2);
values.add(oid);
if (primaryName != null)
{
values.add(primaryName);
}
- for (String v : names)
- {
- values.add(v);
- }
+ values.addAll(names);
return matchFilter(values, name, false);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
index 396dee8..22bb5b5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
@@ -24,7 +24,6 @@
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -55,6 +54,8 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
@@ -63,38 +64,24 @@
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.types.DN;
/**
* The panel displayed when the user clicks on 'Delete Base DN...' in the
* browse entries dialog.
- *
*/
public class DeleteBaseDNPanel extends StatusGenericPanel
{
private static final long serialVersionUID = 2182662824496761087L;
- /**
- * The list containing the base DNs.
- */
+ /** The list containing the base DNs. */
protected JList list;
-
- /**
- * Label indicating that no element was found.
- */
+ /** Label indicating that no element was found. */
protected JLabel lNoElementsFound;
-
- /**
- * The main panel.
- */
+ /** The main panel. */
protected JPanel mainPanel;
- /**
- * Default constructor.
- *
- */
+ /** Default constructor. */
public DeleteBaseDNPanel()
{
super();
@@ -213,9 +200,7 @@
lNoElementsFound.setVisible(list.getModel().getSize() == 0);
}
- /**
- * Creates the layout of the panel (but the contents are not populated here).
- */
+ /** Creates the layout of the panel (but the contents are not populated here). */
private void createLayout()
{
GridBagConstraints gbc = new GridBagConstraints();
@@ -364,23 +349,10 @@
for (Object o : dns)
{
DN dn = (DN)o;
- boolean found = false;
- for (BackendDescriptor backend :
- getInfo().getServerDescriptor().getBackends())
+ BaseDNDescriptor baseDN = findBaseDN(dn);
+ if (baseDN != null)
{
- for (BaseDNDescriptor baseDN : backend.getBaseDns())
- {
- if (baseDN.getDn().equals(dn))
- {
- baseDNsToDelete.add(baseDN);
- found = true;
- break;
- }
- }
- if (found)
- {
- break;
- }
+ baseDNsToDelete.add(baseDN);
}
}
DeleteBaseDNAndBackendTask newTask = new DeleteBaseDNAndBackendTask(
@@ -415,6 +387,21 @@
}
}
+ private BaseDNDescriptor findBaseDN(DN dn)
+ {
+ for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends())
+ {
+ for (BaseDNDescriptor baseDN : backend.getBaseDns())
+ {
+ if (baseDN.getDn().equals(dn))
+ {
+ return baseDN;
+ }
+ }
+ }
+ return null;
+ }
+
private LocalizableMessage getConfirmationMessage(
Collection<BaseDNDescriptor> baseDNsToDelete)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
index 0213fdd..5df0171 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
@@ -35,6 +35,8 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import javax.swing.JButton;
import javax.swing.JPanel;
@@ -43,6 +45,7 @@
import javax.swing.border.EmptyBorder;
import javax.swing.tree.TreePath;
+import org.forgerock.i18n.LocalizableMessage;
import org.opends.guitools.controlpanel.browser.BasicNodeError;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
@@ -58,17 +61,13 @@
import org.opends.guitools.controlpanel.task.ModifyEntryTask;
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.ServerConstants;
-/**
- * This is the panel that contains all the different views to display an entry.
- *
- */
+/** This is the panel that contains all the different views to display an entry. */
public class LDAPEntryPanel extends StatusGenericPanel
implements EntryReadListener
{
@@ -100,40 +99,25 @@
private View view = View.SIMPLIFIED_VIEW;
- /**
- * The different views that we have to display an LDAP entry.
- *
- */
+ /** The different views that we have to display an LDAP entry. */
public enum View
{
- /**
- * Simplified view.
- */
+ /** Simplified view. */
SIMPLIFIED_VIEW,
- /**
- * Attribute view (contained in a table).
- */
+ /** Attribute view (contained in a table). */
ATTRIBUTE_VIEW,
- /**
- * LDIF view (text based).
- */
+ /** LDIF view (text based). */
LDIF_VIEW
}
- /**
- * Default constructor.
- *
- */
+ /** Default constructor. */
public LDAPEntryPanel()
{
super();
createLayout();
}
- /**
- * Creates the layout of the panel (but the contents are not populated here).
- *
- */
+ /** Creates the layout of the panel (but the contents are not populated here). */
private void createLayout()
{
GridBagConstraints gbc = new GridBagConstraints();
@@ -358,10 +342,7 @@
displayedEntryPanel = null;
}
- /**
- * Displays a panel informing that nothing is selected.
- *
- */
+ /** Displays a panel informing that nothing is selected. */
public void noEntrySelected()
{
searchResult = null;
@@ -374,10 +355,7 @@
displayedEntryPanel = null;
}
- /**
- * Displays a panel informing that multiple entries are selected.
- *
- */
+ /** Displays a panel informing that multiple entries are selected. */
public void multipleEntriesSelected()
{
searchResult = null;
@@ -431,7 +409,6 @@
});
}
-
/** {@inheritDoc} */
public void setInfo(ControlPanelInfo info)
{
@@ -442,22 +419,22 @@
errorSearchingPanel.setInfo(info);
}
- private DN[] parentReadOnly;
- private DN[] nonDeletable;
+ private List<DN> parentReadOnly;
+ private List<DN> nonDeletable;
{
try
{
- parentReadOnly = new DN[] {
+ parentReadOnly = Arrays.asList(
DN.valueOf(ConfigConstants.DN_TASK_ROOT),
DN.valueOf(ConfigConstants.DN_MONITOR_ROOT),
DN.valueOf(ConfigConstants.DN_BACKUP_ROOT),
DN.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT)
- };
- nonDeletable = new DN[] {
+ );
+ nonDeletable = Arrays.asList(
DN.valueOf(ConfigConstants.DN_CONFIG_ROOT),
DN.valueOf(ConfigConstants.DN_DEFAULT_SCHEMA_ROOT),
DN.valueOf(ConfigConstants.DN_TRUST_STORE_ROOT)
- };
+ );
}
catch (Throwable t)
{
@@ -507,39 +484,29 @@
*/
public boolean canDelete(String sDn)
{
- boolean canDelete = true;
try
{
DN dn = DN.valueOf(sDn);
- for (DN parentDN : parentReadOnly)
- {
- if (dn.isDescendantOf(parentDN))
- {
- canDelete = false;
- break;
- }
- }
- if (canDelete)
- {
- for (DN cannotDelete : nonDeletable)
- {
- if (cannotDelete.equals(dn))
- {
- canDelete = false;
- break;
- }
- }
- }
- if (canDelete)
- {
- canDelete = !dn.equals(DN.NULL_DN);
- }
+ return !dn.equals(DN.NULL_DN)
+ && !nonDeletable.contains(dn)
+ && isDescendantOfAny(dn, parentReadOnly);
}
catch (Throwable t)
{
throw new RuntimeException("Error decoding DNs: "+t, t);
}
- return canDelete;
+ }
+
+ private boolean isDescendantOfAny(DN dn, List<DN> parentDNs)
+ {
+ for (DN parentDN : parentDNs)
+ {
+ if (dn.isDescendantOf(parentDN))
+ {
+ return false;
+ }
+ }
+ return true;
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/NumSubordinateHacker.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/NumSubordinateHacker.java
index 67bc36b..7f17900 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/NumSubordinateHacker.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/NumSubordinateHacker.java
@@ -24,7 +24,6 @@
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.util;
import java.util.ArrayList;
@@ -36,10 +35,10 @@
/** Class used to handle the case where numsubordinates does not work between databases. */
public class NumSubordinateHacker {
- String serverHost = "not-initialized";
- int serverPort = -1;
- final ArrayList<DN> unreliableEntryList = new ArrayList<>();
- boolean isUnreliableEntryListEmpty;
+ private String serverHost = "not-initialized";
+ private int serverPort = -1;
+ private final ArrayList<DN> unreliableEntryList = new ArrayList<>();
+ private boolean isUnreliableEntryListEmpty;
/**
* Tells whether the list of unreliable contains children of
@@ -48,33 +47,13 @@
* @return <CODE>true</CODE> if the list of unreliable entries contains a
* children of the parentUrl. Returns <CODE>false</CODE> otherwise.
*/
- public boolean containsChildrenOf(LDAPURL parentUrl) {
- if (!isUnreliableEntryListEmpty) {
- boolean isInServer = serverHost.equalsIgnoreCase(String.valueOf(parentUrl.getHost()))
- && serverPort == parentUrl.getPort();
- if (isInServer) {
- try
- {
- for (DN dn : unreliableEntryList)
- {
- if (dn.equals(DN.valueOf(parentUrl.getRawBaseDN())))
- {
- return true;
- }
- }
- }
- catch (OpenDsException oe)
- {
- throw new RuntimeException("Error decoding DN of url: "+ parentUrl);
- }
- }
- }
- return false;
+ public boolean containsChildrenOf(LDAPURL parentUrl)
+ {
+ return contains(parentUrl);
}
/**
- * Tells whether the list of unreliable contains the entry with LDAPURL
- * url.
+ * Tells whether the list of unreliable contains the entry with LDAPURL url.
* It assumes that we previously called containsChildrenOf (there's no check
* of the host/port).
* @param url the LDAPURL of the parent.
@@ -83,24 +62,15 @@
*/
public boolean contains(LDAPURL url) {
if (!isUnreliableEntryListEmpty) {
- boolean isInServer =
- serverHost.equalsIgnoreCase(String.valueOf(url.getHost())) &&
- serverPort == url.getPort();
+ boolean isInServer = serverHost.equalsIgnoreCase(url.getHost()) && serverPort == url.getPort();
if (isInServer) {
- for (DN dn : unreliableEntryList)
+ try
{
- try
- {
- if (dn.equals(DN.valueOf(url.getRawBaseDN())))
- {
- return true;
- }
- }
- catch (OpenDsException oe)
- {
- throw new RuntimeException("Error decoding DN of url: "+
- url);
- }
+ return unreliableEntryList.contains(DN.valueOf(url.getRawBaseDN()));
+ }
+ catch (OpenDsException oe)
+ {
+ throw new RuntimeException("Error decoding DN of url: " + url);
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 12c8e45..cb4a77f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -113,103 +113,50 @@
public class SchemaBackend extends Backend<SchemaBackendCfg>
implements ConfigurationChangeListener<SchemaBackendCfg>, AlertGenerator, Backupable
{
-
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
- /**
- * The fully-qualified name of this class.
- */
+ /** The fully-qualified name of this class. */
private static final String CLASS_NAME =
"org.opends.server.backends.SchemaBackend";
-
private static final String CONFIG_SCHEMA_ELEMENTS_FILE = "02-config.ldif";
private static final String CORE_SCHEMA_ELEMENTS_FILE = "00-core.ldif";
-
-
- /**
- * The set of user-defined attributes that will be included in the schema
- * entry.
- */
+ /** The set of user-defined attributes that will be included in the schema entry. */
private ArrayList<Attribute> userDefinedAttributes;
- /**
- * The attribute type that will be used to include the defined attribute
- * types.
- */
+ /** The attribute type that will be used to include the defined attribute types. */
private AttributeType attributeTypesType;
-
- /**
- * The attribute type that will be used to hold the schema creation timestamp.
- */
+ /** The attribute type that will be used to hold the schema creation timestamp. */
private AttributeType createTimestampType;
-
/** The attribute type that will be used to hold the schema creator's name. */
private AttributeType creatorsNameType;
-
- /**
- * The attribute type that will be used to include the defined DIT content
- * rules.
- */
+ /** The attribute type that will be used to include the defined DIT content rules. */
private AttributeType ditContentRulesType;
-
- /**
- * The attribute type that will be used to include the defined DIT structure
- * rules.
- */
+ /** The attribute type that will be used to include the defined DIT structure rules. */
private AttributeType ditStructureRulesType;
-
- /**
- * The attribute type that will be used to include the defined attribute
- * syntaxes.
- */
+ /** The attribute type that will be used to include the defined attribute syntaxes. */
private AttributeType ldapSyntaxesType;
-
- /**
- * The attribute type that will be used to include the defined matching rules.
- */
+ /** The attribute type that will be used to include the defined matching rules. */
private AttributeType matchingRulesType;
-
- /**
- * The attribute type that will be used to include the defined matching rule
- * uses.
- */
+ /** The attribute type that will be used to include the defined matching rule uses. */
private AttributeType matchingRuleUsesType;
-
/** The attribute that will be used to hold the schema modifier's name. */
private AttributeType modifiersNameType;
-
- /**
- * The attribute type that will be used to hold the schema modification
- * timestamp.
- */
+ /** The attribute type that will be used to hold the schema modification timestamp. */
private AttributeType modifyTimestampType;
-
- /**
- * The attribute type that will be used to include the defined object classes.
- */
+ /** The attribute type that will be used to include the defined object classes. */
private AttributeType objectClassesType;
-
/** The attribute type that will be used to include the defined name forms. */
private AttributeType nameFormsType;
- /**
- * The value containing DN of the user we'll say created the configuration.
- */
+ /** The value containing DN of the user we'll say created the configuration. */
private ByteString creatorsName;
-
- /**
- * The value containing the DN of the last user to modify the configuration.
- */
+ /** The value containing the DN of the last user to modify the configuration. */
private ByteString modifiersName;
-
/** The timestamp that will be used for the schema creation time. */
private ByteString createTimestamp;
-
- /**
- * The timestamp that will be used for the latest schema modification time.
- */
+ /** The timestamp that will be used for the latest schema modification time. */
private ByteString modifyTimestamp;
/**
@@ -253,7 +200,6 @@
// Perform all initialization in initializeBackend.
}
- /** {@inheritDoc} */
@Override
public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException
{
@@ -343,7 +289,6 @@
}
}
- /** {@inheritDoc} */
@Override
public void openBackend() throws ConfigException, InitializationException
{
@@ -467,7 +412,6 @@
currentConfig.addSchemaChangeListener(this);
}
- /** {@inheritDoc} */
@Override
public void closeBackend()
{
@@ -515,14 +459,12 @@
}
- /** {@inheritDoc} */
@Override
public DN[] getBaseDNs()
{
return baseDNs;
}
- /** {@inheritDoc} */
@Override
public long getEntryCount()
{
@@ -530,7 +472,6 @@
return 1;
}
- /** {@inheritDoc} */
@Override
public boolean isIndexed(AttributeType attributeType, IndexType indexType)
{
@@ -538,7 +479,6 @@
return true;
}
- /** {@inheritDoc} */
@Override
public ConditionResult hasSubordinates(DN entryDN)
throws DirectoryException
@@ -546,7 +486,6 @@
return ConditionResult.FALSE;
}
- /** {@inheritDoc} */
@Override
public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
{
@@ -554,7 +493,6 @@
return 1L;
}
- /** {@inheritDoc} */
@Override
public long getNumberOfChildren(DN parentDN) throws DirectoryException
{
@@ -562,23 +500,15 @@
return 0L;
}
- /** {@inheritDoc} */
@Override
- public Entry getEntry(DN entryDN)
- throws DirectoryException
+ public Entry getEntry(DN entryDN) throws DirectoryException
{
- // If the requested entry was one of the schema entries, then create and
- // return it.
- DN[] dnArray = baseDNs;
- for (DN baseDN : dnArray)
+ // If the requested entry was one of the schema entries, then create and return it.
+ if (entryExists(entryDN))
{
- if (entryDN.equals(baseDN))
- {
- return getSchemaEntry(entryDN, false, true);
- }
+ return getSchemaEntry(entryDN, false, true);
}
-
// There is never anything below the schema entries, so we will return null.
return null;
}
@@ -772,10 +702,8 @@
}
}
- /** {@inheritDoc} */
@Override
- public boolean entryExists(DN entryDN)
- throws DirectoryException
+ public boolean entryExists(DN entryDN) throws DirectoryException
{
// The specified DN must be one of the specified schema DNs.
DN[] baseArray = baseDNs;
@@ -789,7 +717,6 @@
return false;
}
- /** {@inheritDoc} */
@Override
public void addEntry(Entry entry, AddOperation addOperation)
throws DirectoryException
@@ -798,7 +725,6 @@
ERR_BACKEND_ADD_NOT_SUPPORTED.get(entry.getName(), getBackendID()));
}
- /** {@inheritDoc} */
@Override
public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
throws DirectoryException
@@ -807,7 +733,6 @@
ERR_BACKEND_DELETE_NOT_SUPPORTED.get(entryDN, getBackendID()));
}
- /** {@inheritDoc} */
@Override
public void replaceEntry(Entry oldEntry, Entry newEntry,
ModifyOperation modifyOperation) throws DirectoryException
@@ -3445,8 +3370,7 @@
*
* @throws IOException If a problem occurs.
*/
- private void copyFile(File from, File to)
- throws IOException
+ private void copyFile(File from, File to) throws IOException
{
byte[] buffer = new byte[4096];
FileInputStream inputStream = null;
@@ -3483,7 +3407,6 @@
deleteFiles(tempSchemaFiles.values());
}
- /** {@inheritDoc} */
@Override
public void renameEntry(DN currentDN, Entry entry,
ModifyDNOperation modifyDNOperation)
@@ -3493,7 +3416,6 @@
ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID()));
}
- /** {@inheritDoc} */
@Override
public void search(SearchOperation searchOperation)
throws DirectoryException
@@ -3545,21 +3467,18 @@
}
}
- /** {@inheritDoc} */
@Override
public Set<String> getSupportedControls()
{
return Collections.emptySet();
}
- /** {@inheritDoc} */
@Override
public Set<String> getSupportedFeatures()
{
return Collections.emptySet();
}
- /** {@inheritDoc} */
@Override
public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
@@ -3602,7 +3521,6 @@
}
}
- /** {@inheritDoc} */
@Override
public boolean supports(BackendOperation backendOperation)
{
@@ -3621,7 +3539,6 @@
}
}
- /** {@inheritDoc} */
@Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
throws DirectoryException
@@ -3900,28 +3817,24 @@
}
}
- /** {@inheritDoc} */
@Override
public void createBackup(BackupConfig backupConfig) throws DirectoryException
{
new BackupManager(getBackendID()).createBackup(this, backupConfig);
}
- /** {@inheritDoc} */
@Override
public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException
{
new BackupManager(getBackendID()).removeBackup(backupDirectory, backupID);
}
- /** {@inheritDoc} */
@Override
public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
{
new BackupManager(getBackendID()).restoreBackup(this, restoreConfig);
}
- /** {@inheritDoc} */
@Override
public boolean isConfigurationChangeAcceptable(
SchemaBackendCfg configEntry,
@@ -3930,10 +3843,8 @@
return true;
}
- /** {@inheritDoc} */
@Override
- public ConfigChangeResult applyConfigurationChange(
- SchemaBackendCfg backendCfg)
+ public ConfigChangeResult applyConfigurationChange(SchemaBackendCfg backendCfg)
{
final ConfigChangeResult ccr = new ConfigChangeResult();
@@ -4098,21 +4009,18 @@
this.showAllAttributes = showAllAttributes;
}
- /** {@inheritDoc} */
@Override
public DN getComponentEntryDN()
{
return configEntryDN;
}
- /** {@inheritDoc} */
@Override
public String getClassName()
{
return CLASS_NAME;
}
- /** {@inheritDoc} */
@Override
public Map<String, String> getAlerts()
{
@@ -4126,7 +4034,6 @@
return alerts;
}
- /** {@inheritDoc} */
@Override
public File getDirectory()
{
@@ -4142,21 +4049,18 @@
}
};
- /** {@inheritDoc} */
@Override
public ListIterator<Path> getFilesToBackup() throws DirectoryException
{
return BackupManager.getFiles(getDirectory(), BACKUP_FILES_FILTER, getBackendID()).listIterator();
}
- /** {@inheritDoc} */
@Override
public boolean isDirectRestore()
{
return true;
}
- /** {@inheritDoc} */
@Override
public Path beforeRestore() throws DirectoryException
{
@@ -4164,13 +4068,10 @@
return BackupManager.saveCurrentFilesToDirectory(this, getBackendID());
}
- /** {@inheritDoc} */
@Override
public void afterRestore(Path restoreDirectory, Path saveDirectory) throws DirectoryException
{
// restore was successful, delete save directory
StaticUtils.recursiveDelete(saveDirectory.toFile());
}
-
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
index 38fb253..8153858 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -733,46 +733,39 @@
*/
private boolean isReplaceEntryAcceptable(ModifyOperation modifyOperation)
{
- boolean acceptable = true;
-
for (Modification m : modifyOperation.getModifications()) {
if (m.isInternal()) {
continue;
}
if (m.getModificationType() != ModificationType.REPLACE) {
- acceptable = false;
- break;
+ return false;
}
Attribute a = m.getAttribute();
AttributeType at = a.getAttributeType();
if (!at.hasName(ATTR_TASK_STATE)) {
- acceptable = false;
- break;
+ return false;
}
Iterator<ByteString> iterator = a.iterator();
if (!iterator.hasNext()) {
- acceptable = false;
- break;
+ return false;
}
ByteString v = iterator.next();
+ if (iterator.hasNext()) {
+ return false;
+ }
+
String valueString = toLowerCase(v.toString());
if (!valueString.startsWith("cancel")
&& !valueString.startsWith("stop")) {
- acceptable = false;
- break;
- }
-
- if (iterator.hasNext()) {
- acceptable = false;
- break;
+ return false;
}
}
- return acceptable;
+ return true;
}
@@ -1069,10 +1062,7 @@
LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(e);
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, le);
}
- else
- {
- continue;
- }
+ continue;
}
ldifWriter.writeEntry(e);
}
--
Gitblit v1.10.0