From d6a18c0ea456c2f132c2301b37c80fe7e3e3a276 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Thu, 12 Oct 2006 16:20:20 +0000
Subject: [PATCH] Fixes for the following issues, reviewed by neil_a_wilson.
---
opends/src/server/org/opends/server/core/SearchOperation.java | 168 ++++++++++++-------------------------------------------
1 files changed, 38 insertions(+), 130 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/SearchOperation.java b/opends/src/server/org/opends/server/core/SearchOperation.java
index 16620e2..d0feac0 100644
--- a/opends/src/server/org/opends/server/core/SearchOperation.java
+++ b/opends/src/server/org/opends/server/core/SearchOperation.java
@@ -932,14 +932,6 @@
List<Attribute> ocList = new ArrayList<Attribute>(1);
ocList.add(new Attribute(ocType));
entryToReturn.putAttribute(ocType, ocList);
-
- // Next, iterate through all the user attributes and include them.
- for (AttributeType t : entry.getUserAttributes().keySet())
- {
- List<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
}
else
{
@@ -954,13 +946,14 @@
// We cannot get this exception because the object classes have
// already been validated in the entry they came from.
}
+ }
-
- // Next iterate through all the user attributes and include them.
- for (AttributeType t : entry.getUserAttributes().keySet())
- {
- entryToReturn.putAttribute(t, entry.duplicateUserAttribute(t));
- }
+ // Next iterate through all the user attributes and include them.
+ for (AttributeType t : entry.getUserAttributes().keySet())
+ {
+ List<Attribute> attrList =
+ entry.duplicateUserAttribute(t, null, typesOnly);
+ entryToReturn.putAttribute(t, attrList);
}
continue;
@@ -971,17 +964,9 @@
// attributes should be returned.
for (AttributeType t : entry.getOperationalAttributes().keySet())
{
- if (typesOnly)
- {
- List<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
- else
- {
- entryToReturn.putAttribute(t,
- entry.duplicateOperationalAttribute(t));
- }
+ List<Attribute> attrList =
+ entry.duplicateOperationalAttribute(t, null, typesOnly);
+ entryToReturn.putAttribute(t, attrList);
}
continue;
@@ -1020,53 +1005,15 @@
{
if (t.hasNameOrOID(lowerName))
{
- if ((options == null) || options.isEmpty())
+ List<Attribute> attrList =
+ entry.duplicateUserAttribute(t, options, typesOnly);
+ if (attrList != null)
{
- if (typesOnly)
- {
- List<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
- else
- {
- entryToReturn.putAttribute(t,
- entry.duplicateUserAttribute(t));
- }
+ entryToReturn.putAttribute(t, attrList);
added = true;
break;
}
- else
- {
- List<Attribute> attrList = entry.duplicateUserAttribute(t);
- List<Attribute> includeAttrs =
- new ArrayList<Attribute>(attrList.size());
- for (Attribute a : attrList)
- {
- if (a.hasOptions(options))
- {
- includeAttrs.add(a);
- }
- }
-
- if (! includeAttrs.isEmpty())
- {
- if (typesOnly)
- {
- attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
- else
- {
- entryToReturn.putAttribute(t, includeAttrs);
- }
-
- added = true;
- break;
- }
- }
}
}
@@ -1079,87 +1026,48 @@
{
if (t.hasNameOrOID(lowerName))
{
- if ((options == null) || options.isEmpty())
+ List<Attribute> attrList =
+ entry.duplicateOperationalAttribute(t, options, typesOnly);
+ if (attrList != null)
{
- if (typesOnly)
- {
- List<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
- else
- {
- entryToReturn.putAttribute(t,
- entry.duplicateOperationalAttribute(t));
- }
+ entryToReturn.putAttribute(t, attrList);
- added = true;
break;
}
- else
- {
- List<Attribute> attrList =
- entry.duplicateOperationalAttribute(t);
- List<Attribute> includeAttrs =
- new ArrayList<Attribute>(attrList.size());
- for (Attribute a : attrList)
- {
- if (a.hasOptions(options))
- {
- includeAttrs.add(a);
- }
- }
-
- if (! includeAttrs.isEmpty())
- {
- if (typesOnly)
- {
- attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(t));
- entryToReturn.putAttribute(t, attrList);
- }
- else
- {
- entryToReturn.putAttribute(t, includeAttrs);
- }
-
- added = true;
- break;
- }
- }
}
}
}
else
{
- if (attrType.isObjectClassType() && !typesOnly)
- {
- Attribute ocAttr = entry.getObjectClassAttribute();
- try
+ if (attrType.isObjectClassType()) {
+ if (typesOnly)
{
- entryToReturn.setObjectClasses(ocAttr.getValues());
+ AttributeType ocType =
+ DirectoryServer.getObjectClassAttributeType();
+ List<Attribute> ocList = new ArrayList<Attribute>(1);
+ ocList.add(new Attribute(ocType));
+ entryToReturn.putAttribute(ocType, ocList);
}
- catch (DirectoryException e)
+ else
{
- // We cannot get this exception because the object classes have
- // already been validated in the entry they came from.
+ List<Attribute> attrList = new ArrayList<Attribute>(1);
+ attrList.add(entry.getObjectClassAttribute());
+ entryToReturn.putAttribute(attrType, attrList);
}
}
else
{
- List<Attribute> attrList = entry.getAttribute(attrType, options);
+ List<Attribute> attrList =
+ entry.duplicateOperationalAttribute(attrType, options,
+ typesOnly);
+ if (attrList == null)
+ {
+ attrList = entry.duplicateUserAttribute(attrType, options,
+ typesOnly);
+ }
if (attrList != null)
{
- if (typesOnly)
- {
- attrList = new ArrayList<Attribute>(1);
- attrList.add(new Attribute(attrType));
- entryToReturn.putAttribute(attrType, attrList);
- }
- else
- {
- entryToReturn.putAttribute(attrType, attrList);
- }
+ entryToReturn.putAttribute(attrType, attrList);
}
}
}
--
Gitblit v1.10.0