From ed519feefd5b2b89097a9b2abcc34c56aea0f1be Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Feb 2016 08:44:53 +0000
Subject: [PATCH] *.java: Removed DirectoryServer.getAttributeTypeOrNull(), replaced with DirectoryServer.getAttributeType()
---
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java | 5
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java | 2
opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java | 4
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java | 26 +---
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java | 34 +++--
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 2
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java | 6
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java | 4
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java | 2
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 214 +++++++++++++++++------------------
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java | 9
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java | 34 +----
12 files changed, 157 insertions(+), 185 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
index f0ca369..258503e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
@@ -41,6 +41,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.core.AuthenticatedUsers;
import org.opends.server.core.DirectoryServer;
@@ -48,7 +49,6 @@
import org.opends.server.core.PluginConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
-import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
@@ -1066,7 +1066,7 @@
newPrivileges.addAll(DirectoryServer.getRootPrivileges());
}
- AttributeType privType = DirectoryServer.getAttributeTypeOrNull(OP_ATTR_PRIVILEGE_NAME);
+ AttributeType privType = DirectoryServer.getAttributeType(OP_ATTR_PRIVILEGE_NAME);
for (Attribute a : entry.getAttribute(privType))
{
for (ByteString v : a)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
index 7d6ffff..fd46f2d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -232,15 +232,15 @@
{
if (aclRights == null)
{
- aclRights = DirectoryServer.getAttributeTypeOrNull(aclRightsAttrStr);
+ aclRights = DirectoryServer.getAttributeType(aclRightsAttrStr);
}
if (aclRightsInfo == null)
{
- aclRightsInfo = DirectoryServer.getAttributeTypeOrNull(aclRightsInfoAttrStr);
+ aclRightsInfo = DirectoryServer.getAttributeType(aclRightsInfoAttrStr);
}
if (dnAttributeType == null)
{
- dnAttributeType = DirectoryServer.getAttributeTypeOrNull(dnAttrStr);
+ dnAttributeType = DirectoryServer.getAttributeType(dnAttrStr);
}
// Check if the attributes aclRights and aclRightsInfo were requested and
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
index 84f6859..dbe698a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -226,7 +226,7 @@
return false;
}
- AttributeType rdnAttrType = DirectoryServer.getAttributeTypeOrNull(rdnKey);
+ AttributeType rdnAttrType = DirectoryServer.getAttributeType(rdnKey);
if (!matchValuePattern(patternMap.get(rdnKey), rdnAttrType, rdnMap.get(rdnKey)))
{
return false;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
index 85ee0b6..d4fe4e6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -45,6 +45,7 @@
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.backends.pluggable.spi.Cursor;
import org.opends.server.backends.pluggable.spi.ReadableTransaction;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
@@ -54,7 +55,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
-import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -85,7 +85,7 @@
* The standard attribute type that is used to specify the set of referral
* URLs in a referral entry.
*/
- private final AttributeType referralType = DirectoryServer.getAttributeTypeOrNull(ATTR_REFERRAL_URL);
+ private final AttributeType referralType = DirectoryServer.getAttributeType(ATTR_REFERRAL_URL);
/**
* A flag that indicates whether there are any referrals contained in this
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 193cad4..b126ec0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -2511,27 +2511,13 @@
}
/**
- * Retrieves the attribute type for the provided lowercase name or OID.
+ * Retrieves the attribute type for the provided name or OID. It can optionally return a generated
+ * placeholder version if the requested attribute type is not defined in the schema.
*
- * @param attrName The attribute name or OID for the attribute type to retrieve.
- * @return The requested attribute type, or <CODE>null</CODE> if there is no
- * attribute with the specified type defined in the server schema.
- */
- public static AttributeType getAttributeTypeOrNull(String attrName)
- {
- AttributeType attrType = getAttributeType(attrName);
- return attrType.isPlaceHolder() ? null : attrType;
- }
-
- /**
- * Retrieves the attribute type for the provided name or OID. It
- * can optionally return a generated "default" version if the requested
- * attribute type is not defined in the schema.
- *
- * @param nameOrOid The name or OID for the attribute type to retrieve.
- * @return The requested attribute type, or <CODE>null</CODE> if there is no
- * attribute with the specified type defined in the server schema and
- * a default type should not be returned.
+ * @param nameOrOid
+ * The name or OID for the attribute type to retrieve.
+ * @return The requested attribute type, or a generated placeholder version if there is no
+ * attribute with the specified nameOrOid defined in the server schema
*/
public static AttributeType getAttributeType(String nameOrOid)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index 6c1de45..a90f64a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -177,8 +177,6 @@
*/
private LinkedHashMap<AttributeType, SearchFilter> attrFiltMap = new LinkedHashMap<>();
-
- /** {@inheritDoc} */
@Override
public final void initializePlugin(Set<PluginType> pluginTypes,
ReferentialIntegrityPluginCfg pluginCfg)
@@ -194,8 +192,7 @@
applyConfigurationChange(pluginCfg);
- // Set up log file. Note: it is not allowed to change once the plugin is
- // active.
+ // Set up log file. Note: it is not allowed to change once the plugin is active.
setUpLogFile(pluginCfg.getLogFile());
interval=pluginCfg.getUpdateInterval();
@@ -208,7 +205,6 @@
- /** {@inheritDoc} */
@Override
public ConfigChangeResult applyConfigurationChange(
ReferentialIntegrityPluginCfg newConfiguration)
@@ -222,7 +218,6 @@
new LinkedHashSet<>(newConfiguration.getAttributeType());
// Load the attribute-filter mapping
-
LinkedHashMap<AttributeType, SearchFilter> newAttrFiltMap = new LinkedHashMap<>();
for (String attrFilt : newConfiguration.getCheckReferencesFilterCriteria())
@@ -231,18 +226,15 @@
String attr = attrFilt.substring(0, sepInd);
String filtStr = attrFilt.substring(sepInd + 1);
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attr);
+ AttributeType attrType = DirectoryServer.getAttributeType(attr);
try
{
- SearchFilter filter = SearchFilter.createFilterFromString(filtStr);
- newAttrFiltMap.put(attrType, filter);
+ newAttrFiltMap.put(attrType, SearchFilter.createFilterFromString(filtStr));
}
- catch (DirectoryException de)
+ catch (DirectoryException unexpected)
{
- /* This should never happen because the filter has already
- * been verified.
- */
- logger.error(de.getMessageObject());
+ // This should never happen because the filter has already been verified.
+ logger.error(unexpected.getMessageObject());
}
}
@@ -275,8 +267,6 @@
return ccr;
}
-
- /** {@inheritDoc} */
@Override
public boolean isConfigurationAcceptable(PluginCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -378,8 +368,6 @@
return isAcceptable;
}
-
- /** {@inheritDoc} */
@Override
public boolean isConfigurationChangeAcceptable(
ReferentialIntegrityPluginCfg configuration,
@@ -388,8 +376,6 @@
return isConfigurationAcceptable(configuration, unacceptableReasons);
}
-
- /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public PluginResult.PostOperation
@@ -419,9 +405,6 @@
return PluginResult.PostOperation.continueOperationProcessing();
}
-
-
- /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public PluginResult.PostOperation doPostOperation(
@@ -447,7 +430,6 @@
return PluginResult.PostOperation.continueOperationProcessing();
}
- /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public PluginResult.SubordinateModifyDN processSubordinateModifyDN(
@@ -468,7 +450,6 @@
return PluginResult.SubordinateModifyDN.continueOperationProcessing();
}
- /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public PluginResult.SubordinateDelete processSubordinateDelete(
@@ -948,8 +929,6 @@
return name;
}
-
- /** {@inheritDoc} */
@Override
public final void finalizePlugin() {
currentConfiguration.removeReferentialIntegrityChangeListener(this);
@@ -1055,7 +1034,6 @@
}
}
- /** {@inheritDoc} */
@Override
public PluginResult.PreOperation doPreOperation(
PreOperationModifyOperation modifyOperation)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
index f33272d..7e7a894 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -269,7 +269,7 @@
*/
public static void setHistoricalAttrToOperation(PreOperationAddOperation addOperation)
{
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(HISTORICAL_ATTRIBUTE_NAME);
+ AttributeType attrType = DirectoryServer.getAttributeType(HISTORICAL_ATTRIBUTE_NAME);
String attrValue = encodeHistorical(OperationContext.getCSN(addOperation), "add");
List<Attribute> attrs = Attributes.createAsList(attrType, attrValue);
addOperation.setAttribute(attrType, attrs);
@@ -357,8 +357,7 @@
purgeDate = TimeThread.getTime() - purgeDelayInMillisec;
}
- AttributeType historicalAttrType = DirectoryServer.getAttributeTypeOrNull(HISTORICAL_ATTRIBUTE_NAME);
- AttributeBuilder builder = new AttributeBuilder(historicalAttrType);
+ AttributeBuilder builder = new AttributeBuilder(HISTORICAL_ATTRIBUTE_NAME);
for (Map.Entry<AttributeDescription, AttrHistorical> mapEntry : attributesHistorical.entrySet())
{
@@ -685,7 +684,7 @@
*/
public static String getEntryUUID(Entry entry)
{
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(ENTRYUUID_ATTRIBUTE_NAME);
+ AttributeType attrType = DirectoryServer.getAttributeType(ENTRYUUID_ATTRIBUTE_NAME);
List<Attribute> uuidAttrs = entry.getOperationalAttribute(attrType);
return extractEntryUUID(uuidAttrs, entry.getName());
}
@@ -700,7 +699,7 @@
*/
public static String getEntryUUID(PreOperationAddOperation op)
{
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(ENTRYUUID_ATTRIBUTE_NAME);
+ AttributeType attrType = DirectoryServer.getAttributeType(ENTRYUUID_ATTRIBUTE_NAME);
List<Attribute> uuidAttrs = op.getOperationalAttributes().get(attrType);
return extractEntryUUID(uuidAttrs, op.getEntryDN());
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
index ab167bf..a93be31 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -26,24 +26,35 @@
*/
package org.opends.server.replication.plugin;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Utils;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
-import org.opends.server.admin.std.server.*;
+import org.opends.server.admin.std.server.FractionalLDIFImportPluginCfg;
+import org.opends.server.admin.std.server.PluginCfg;
+import org.opends.server.admin.std.server.ReplicationDomainCfg;
+import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg;
+import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.replication.plugin.LDAPReplicationDomain.AttributeValueStringIterator;
import org.opends.server.replication.plugin.LDAPReplicationDomain.FractionalConfig;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.LDIFImportConfig;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
@@ -323,17 +334,17 @@
{
// This is the root entry, try to read a fractional configuration from it
Attribute exclAttr = getAttribute(REPLICATION_FRACTIONAL_EXCLUDE, entry);
- Iterator<String> exclIt = null;
+ Iterator<ByteString> exclIt = null;
if (exclAttr != null)
{
- exclIt = new AttributeValueStringIterator(exclAttr.iterator());
+ exclIt = exclAttr.iterator();
}
Attribute inclAttr = getAttribute(REPLICATION_FRACTIONAL_INCLUDE, entry);
- Iterator<String> inclIt = null;
+ Iterator<ByteString> inclIt = null;
if (inclAttr != null)
{
- inclIt = new AttributeValueStringIterator(inclAttr.iterator());
+ inclIt = inclAttr.iterator();
}
// Compare backend and local fractional configuration
@@ -405,9 +416,8 @@
private Attribute getAttribute(String attributeName, Entry entry)
{
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attributeName);
- List<Attribute> inclAttrs = entry.getAttribute(attrType);
- return !inclAttrs.isEmpty() ? inclAttrs.get(0) : null;
+ List<Attribute> attrs = entry.getAttribute(DirectoryServer.getAttributeType(attributeName));
+ return !attrs.isEmpty() ? attrs.get(0) : null;
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 54b9ff1..022888e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -42,7 +42,23 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -60,6 +76,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.IsolationPolicy;
import org.opends.server.admin.std.server.ExternalChangelogDomainCfg;
@@ -72,7 +89,14 @@
import org.opends.server.api.ServerShutdownListener;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.task.Task;
-import org.opends.server.core.*;
+import org.opends.server.core.AddOperation;
+import org.opends.server.core.DeleteOperation;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.LockFileManager;
+import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyDNOperationBasis;
+import org.opends.server.core.ModifyOperation;
+import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchListener;
import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -86,15 +110,56 @@
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.replication.common.StatusMachineEvent;
-import org.opends.server.replication.protocol.*;
+import org.opends.server.replication.protocol.AddContext;
+import org.opends.server.replication.protocol.AddMsg;
+import org.opends.server.replication.protocol.DeleteContext;
+import org.opends.server.replication.protocol.DeleteMsg;
+import org.opends.server.replication.protocol.LDAPUpdateMsg;
+import org.opends.server.replication.protocol.ModifyContext;
+import org.opends.server.replication.protocol.ModifyDNMsg;
+import org.opends.server.replication.protocol.ModifyDnContext;
+import org.opends.server.replication.protocol.ModifyMsg;
+import org.opends.server.replication.protocol.OperationContext;
+import org.opends.server.replication.protocol.RoutableMsg;
+import org.opends.server.replication.protocol.UpdateMsg;
import org.opends.server.replication.service.DSRSShutdownSync;
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.tasks.PurgeConflictsHistoricalTask;
import org.opends.server.tasks.TaskUtils;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.types.*;
-import org.opends.server.types.operation.*;
+import org.opends.server.types.AdditionalLogItem;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.Attributes;
+import org.opends.server.types.Control;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.Entry;
+import org.opends.server.types.ExistingFileBehavior;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.LDIFExportConfig;
+import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.types.Modification;
+import org.opends.server.types.ObjectClass;
+import org.opends.server.types.Operation;
+import org.opends.server.types.OperationType;
+import org.opends.server.types.RDN;
+import org.opends.server.types.RawModification;
+import org.opends.server.types.Schema;
+import org.opends.server.types.SearchFilter;
+import org.opends.server.types.SearchResultEntry;
+import org.opends.server.types.SearchResultReference;
+import org.opends.server.types.SynchronizationProviderResult;
+import org.opends.server.types.operation.PluginOperation;
+import org.opends.server.types.operation.PostOperationAddOperation;
+import org.opends.server.types.operation.PostOperationDeleteOperation;
+import org.opends.server.types.operation.PostOperationModifyDNOperation;
+import org.opends.server.types.operation.PostOperationModifyOperation;
+import org.opends.server.types.operation.PostOperationOperation;
+import org.opends.server.types.operation.PreOperationAddOperation;
+import org.opends.server.types.operation.PreOperationDeleteOperation;
+import org.opends.server.types.operation.PreOperationModifyDNOperation;
+import org.opends.server.types.operation.PreOperationModifyOperation;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.TimeThread;
import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation;
@@ -690,10 +755,8 @@
}
// Now extract fractional configuration if any
- Iterator<String> exclIt =
- getAttributeValueIterator(resultEntry, REPLICATION_FRACTIONAL_EXCLUDE);
- Iterator<String> inclIt =
- getAttributeValueIterator(resultEntry, REPLICATION_FRACTIONAL_INCLUDE);
+ Iterator<ByteString> exclIt = getAttributeValueIterator(resultEntry, REPLICATION_FRACTIONAL_EXCLUDE);
+ Iterator<ByteString> inclIt = getAttributeValueIterator(resultEntry, REPLICATION_FRACTIONAL_INCLUDE);
// Compare backend and local fractional configuration
return isFractionalConfigConsistent(fractionalConfig, exclIt, inclIt);
@@ -705,7 +768,7 @@
final SearchResultEntry resultEntry = getFirstResult(searchOperation);
if (resultEntry != null)
{
- AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID);
+ AttributeType synchronizationGenIDType = DirectoryServer.getAttributeType(REPLICATION_GENERATION_ID);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType);
if (!attrs.isEmpty())
{
@@ -724,16 +787,16 @@
return null;
}
- private Iterator<String> getAttributeValueIterator(SearchResultEntry resultEntry, String attrName)
+ private Iterator<ByteString> getAttributeValueIterator(SearchResultEntry resultEntry, String attrName)
{
- AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
+ AttributeType attrType = DirectoryServer.getAttributeType(attrName);
List<Attribute> exclAttrs = resultEntry.getAttribute(attrType);
if (!exclAttrs.isEmpty())
{
Attribute exclAttr = exclAttrs.get(0);
if (exclAttr != null)
{
- return new AttributeValueStringIterator(exclAttr.iterator());
+ return exclAttr.iterator();
}
}
return null;
@@ -753,14 +816,9 @@
* configuration stored in the local variables.
*/
static boolean isFractionalConfigConsistent(
- FractionalConfig fractionalConfig, Iterator<String> exclIt,
- Iterator<String> inclIt)
+ FractionalConfig fractionalConfig, Iterator<ByteString> exclIt, Iterator<ByteString> inclIt)
{
- /*
- * Parse fractional configuration stored in passed fractional configuration
- * attributes values
- */
-
+ // Parse fractional configuration stored in passed fractional configuration attributes values
Map<String, Set<String>> storedFractionalSpecificClassesAttributes = new HashMap<>();
Set<String> storedFractionalAllClassesAttributes = new HashSet<>();
@@ -812,44 +870,6 @@
}
/**
- * Utility class to have get a string iterator from an AtributeValue iterator.
- * Assuming the attribute values are strings.
- */
- static class AttributeValueStringIterator implements Iterator<String>
- {
- private final Iterator<ByteString> attrValIt;
-
- /**
- * Creates a new AttributeValueStringIterator object.
- * @param attrValIt The underlying attribute iterator to use, assuming
- * internal values are strings.
- */
- AttributeValueStringIterator(Iterator<ByteString> attrValIt)
- {
- this.attrValIt = attrValIt;
- }
-
- @Override
- public boolean hasNext()
- {
- return attrValIt.hasNext();
- }
-
- @Override
- public String next()
- {
- return attrValIt.next().toString();
- }
-
- // Should not be needed anyway
- @Override
- public void remove()
- {
- attrValIt.remove();
- }
- }
-
- /**
* Compare 2 attribute collections and returns true if they are equivalent.
*
* @param attributes1
@@ -1084,7 +1104,7 @@
// Create a list of filtered attributes for this entry
Entry concernedEntry = modifyDNOperation.getOriginalEntry();
- Set<String> fractionalConcernedAttributes =
+ Set<AttributeType> fractionalConcernedAttributes =
createFractionalConcernedAttrList(fractionalConfig,
concernedEntry.getObjectClasses().keySet());
@@ -1115,7 +1135,7 @@
AttributeType attributeType = rdn.getAttributeType(i);
// Is it present in the fractional attributes established list ?
boolean foundAttribute =
- exists(fractionalConcernedAttributes, attributeType);
+ fractionalConcernedAttributes.contains(attributeType);
if (canRemoveAttribute(fractionalExclusive, foundAttribute)
&& !newRdn.hasAttributeType(attributeType)
&& !modifyDNOperation.deleteOldRDN())
@@ -1136,18 +1156,6 @@
return inconsistentOperation;
}
- private boolean exists(Set<String> attrNames, AttributeType attrTypeToFind)
- {
- for (String attrName : attrNames)
- {
- if (DirectoryServer.getAttributeTypeOrNull(attrName).equals(attrTypeToFind))
- {
- return true;
- }
- }
- return false;
- }
-
/**
* Remove attributes from an entry, according to the passed fractional
* configuration. The entry is represented by the 2 passed parameters.
@@ -1175,7 +1183,7 @@
* fractional replication configuration
*/
- Set<String> fractionalConcernedAttributes =
+ Set<AttributeType> fractionalConcernedAttributes =
createFractionalConcernedAttrList(fractionalConfig, classes.keySet());
boolean fractionalExclusive = fractionalConfig.isFractionalExclusive();
if (fractionalExclusive && fractionalConcernedAttributes.isEmpty())
@@ -1204,8 +1212,7 @@
if (isMandatoryAttribute(entryClasses, attributeType)
// Do not remove an attribute if it is a prohibited one
|| isFractionalProhibited(attributeType)
- || !canRemoveAttribute(attributeType, fractionalExclusive,
- fractionalConcernedAttributes))
+ || !canRemoveAttribute(attributeType, fractionalExclusive, fractionalConcernedAttributes))
{
continue;
}
@@ -1303,31 +1310,21 @@
}
private static boolean canRemoveAttribute(AttributeType attributeType,
- boolean fractionalExclusive, Set<String> fractionalConcernedAttributes)
+ boolean fractionalExclusive, Set<AttributeType> fractionalConcernedAttributes)
{
- String attributeName = attributeType.getNameOrOID();
- String attributeOid = attributeType.getOID();
-
- // Is the current attribute part of the established list ?
- boolean foundAttribute = contains(fractionalConcernedAttributes, attributeName, attributeOid);
// Now remove the attribute or modification if:
// - exclusive mode and attribute is in configuration
// - inclusive mode and attribute is not in configuration
- return canRemoveAttribute(fractionalExclusive, foundAttribute);
+ return canRemoveAttribute(fractionalExclusive,
+ fractionalConcernedAttributes.contains(attributeType));
}
- private static boolean canRemoveAttribute(boolean fractionalExclusive,
- boolean foundAttribute)
+ private static boolean canRemoveAttribute(boolean fractionalExclusive, boolean foundAttribute)
{
return (foundAttribute && fractionalExclusive)
|| (!foundAttribute && !fractionalExclusive);
}
- private static boolean contains(Set<String> attrNames, String attrName, String attrOID)
- {
- return attrNames.contains(attrOID) || attrNames.contains(attrName.toLowerCase());
- }
-
/**
* Prepares a list of attributes of interest for the fractional feature.
* @param fractionalConfig The fractional configuration to use
@@ -1336,16 +1333,14 @@
* @return The list of attributes of the entry to be excluded/included
* when the operation will be performed.
*/
- private static Set<String> createFractionalConcernedAttrList(
+ private static Set<AttributeType> createFractionalConcernedAttrList(
FractionalConfig fractionalConfig, Set<ObjectClass> entryObjectClasses)
{
/*
- * Is the concerned entry of a type concerned by fractional replication
- * configuration ? If yes, add the matching attribute names to a set of
- * attributes to take into account for filtering
- * (inclusive or exclusive mode).
- * Using a Set to avoid duplicate attributes (from 2 inheriting classes for
- * instance)
+ * Is the concerned entry of a type concerned by fractional replication configuration ?
+ * If yes, add the matching attribute names to a set of attributes
+ * to take into account for filtering (inclusive or exclusive mode).
+ * Using a Set to avoid duplicate attributes (from 2 inheriting classes for instance)
*/
Set<String> fractionalConcernedAttributes = new HashSet<>();
@@ -1372,7 +1367,12 @@
// Add to the set any attribute which is class independent
fractionalConcernedAttributes.addAll(fractionalAllClassesAttributes);
- return fractionalConcernedAttributes;
+ Set<AttributeType> results = new HashSet<>();
+ for (String attrName : fractionalConcernedAttributes)
+ {
+ results.add(DirectoryServer.getAttributeType(attrName));
+ }
+ return results;
}
/**
@@ -1397,9 +1397,8 @@
*/
Entry modifiedEntry = modifyOperation.getCurrentEntry();
- Set<String> fractionalConcernedAttributes =
- createFractionalConcernedAttrList(fractionalConfig,
- modifiedEntry.getObjectClasses().keySet());
+ Set<AttributeType> fractionalConcernedAttributes =
+ createFractionalConcernedAttrList(fractionalConfig, modifiedEntry.getObjectClasses().keySet());
boolean fractionalExclusive = fractionalConfig.isFractionalExclusive();
if (fractionalExclusive && fractionalConcernedAttributes.isEmpty())
{
@@ -3274,7 +3273,7 @@
SearchResultEntry resultEntry = result.get(0);
if (resultEntry != null)
{
- AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID);
+ AttributeType synchronizationGenIDType = DirectoryServer.getAttributeType(REPLICATION_GENERATION_ID);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType);
if (!attrs.isEmpty())
{
@@ -4690,15 +4689,15 @@
* not fractional, exclusive fractional or inclusive fractional
* modes
*/
- private static int parseFractionalConfig (
- Iterator<String> exclIt, Iterator<String> inclIt,
+ private static int parseFractionalConfig(
+ Iterator<?> exclIt, Iterator<?> inclIt,
Map<String, Set<String>> fractionalSpecificClassesAttributes,
Set<String> fractionalAllClassesAttributes) throws ConfigException
{
// Determine if fractional-exclude or fractional-include property is used:
// only one of them is allowed
int fractionalMode;
- Iterator<String> iterator;
+ Iterator<?> iterator;
if (exclIt != null && exclIt.hasNext())
{
if (inclIt != null && inclIt.hasNext())
@@ -4727,13 +4726,12 @@
{
// Parse a value with the form class:attr1,attr2...
// or *:attr1,attr2...
- String fractCfgStr = iterator.next();
+ String fractCfgStr = iterator.next().toString();
StringTokenizer st = new StringTokenizer(fractCfgStr, ":");
int nTokens = st.countTokens();
if (nTokens < 2)
{
- throw new ConfigException(NOTE_ERR_FRACTIONAL_CONFIG_WRONG_FORMAT.
- get(fractCfgStr));
+ throw new ConfigException(NOTE_ERR_FRACTIONAL_CONFIG_WRONG_FORMAT.get(fractCfgStr));
}
// Get the class name
String classNameLower = st.nextToken().toLowerCase();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
index bb15324..25a11c8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
@@ -53,6 +53,7 @@
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.replication.plugin.EntryHistorical.*;
/**
* This class implements a ServerState that is stored in the backend
@@ -220,7 +221,7 @@
*/
private void updateStateFromEntry(SearchResultEntry resultEntry)
{
- AttributeType synchronizationStateType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_STATE);
+ AttributeType synchronizationStateType = DirectoryServer.getAttributeType(REPLICATION_STATE);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationStateType);
if (!attrs.isEmpty())
{
@@ -317,7 +318,7 @@
*/
private final void checkAndUpdateServerState()
{
- final AttributeType histType = DirectoryServer.getAttributeTypeOrNull(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
+ final AttributeType histType = DirectoryServer.getAttributeType(HISTORICAL_ATTRIBUTE_NAME);
// Retrieves the entries that have changed since the
// maxCsn stored in the serverState
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
index 7b96df7..19e75af 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -549,7 +549,7 @@
// create a rule and register it into the DirectoryServer
provider.initializeVirtualAttributeProvider(null);
- AttributeType attributeType = DirectoryServer.getAttributeTypeOrNull(attrName);
+ AttributeType attributeType = DirectoryServer.getAttributeType(attrName);
return new VirtualAttributeRule(attributeType, provider,
baseDNs, SearchScope.BASE_OBJECT,
groupDNs, filters, conflictBehavior);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
index 1be2b35..d375368 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -2832,7 +2832,7 @@
}
// Get collective attribute exclusions.
- AttributeType exclusionsType = DirectoryServer.getAttributeTypeOrNull(ATTR_COLLECTIVE_EXCLUSIONS_LC);
+ AttributeType exclusionsType = DirectoryServer.getAttributeType(ATTR_COLLECTIVE_EXCLUSIONS_LC);
List<Attribute> exclusionsAttrList = operationalAttributes.get(exclusionsType);
Set<String> exclusionsNameSet = new HashSet<>();
if (exclusionsAttrList != null && !exclusionsAttrList.isEmpty())
--
Gitblit v1.10.0