From e31e221ede36f7e31aa222c21da972ea6fd1b12a Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 14 Oct 2009 11:24:26 +0000
Subject: [PATCH] Fix for issue 4283 (No way to add operational attribute to an entry)
---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java | 3
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java | 12 ++--
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java | 61 ++++++--------------
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java | 5 +
opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java | 45 ++-------------
opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java | 4
12 files changed, 44 insertions(+), 102 deletions(-)
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index fd33fe3..c02efca 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -1341,7 +1341,7 @@
{
SearchControls sc = new SearchControls();
sc.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- String[] attList = {"dn"};
+ String[] attList = {"1.1"};
sc.setReturningAttributes(attList);
NamingEnumeration<SearchResult> ne = ctx.search(TRUSTSTORE_DN,
"(objectclass=ds-cfg-instance-key)", sc);
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
index fa62ace..013f6e3 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -627,7 +627,7 @@
searchControls.setSearchScope(
SearchControls. OBJECT_SCOPE);
searchControls.setReturningAttributes(
- new String[] {"dn"});
+ new String[] {"1.1"});
ctx.search("cn=config", "objectclass=*", searchControls);
connectedAsAdministrativeUser = true;
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java
index 238e6c8..219edd4 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java
@@ -340,7 +340,7 @@
{
SearchControls ctls = controller.getBasicSearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- ctls.setReturningAttributes(new String[]{"dn"});
+ ctls.setReturningAttributes(new String[]{"1.1"});
ctls.setCountLimit(1);
NamingEnumeration<SearchResult> s = ctx.search(new LdapName(node.getDN()),
controller.getFilter(),
@@ -586,7 +586,7 @@
// It's enough to know if the entry has children or not.
SearchControls ctls = controller.getBasicSearchControls();
ctls.setCountLimit(1);
- String[] attrs = {"dn"};
+ String[] attrs = {"1.1"};
ctls.setReturningAttributes(attrs);
if (useCustomFilter())
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
index 6327eea..8113ba8 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -363,7 +363,7 @@
ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
String filter =
"(|(objectClass=*)(objectclass=ldapsubentry))";
- ctls.setReturningAttributes(new String[] {"dn"});
+ ctls.setReturningAttributes(new String[] {"1.1"});
NamingEnumeration<SearchResult> entryDNs =
ctx.search(Utilities.getJNDIName(dnToRemove.toString()), filter, ctls);
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
index ef595d3..440c851 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -511,8 +511,7 @@
{
InitialLdapContext ctx =
controller.findConnectionForDisplayedEntry(node);
- Schema schema = getInfo().getServerDescriptor().getSchema();
- LDAPEntryReader reader = new LDAPEntryReader(dn, ctx, schema);
+ LDAPEntryReader reader = new LDAPEntryReader(dn, ctx);
reader.addEntryReadListener(entryPane);
cleanupReaderQueue();
// Required to update the browser controller properly if the entry is
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index fb08b13..47b6c2d 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -1401,9 +1401,9 @@
}
values.addAll(ocValue.getAuxiliary());
}
- else if (value instanceof Collection)
+ else if (value instanceof Collection<?>)
{
- for (Object o : (Collection)value)
+ for (Object o : (Collection<?>)value)
{
values.add((String)o);
}
@@ -1559,9 +1559,9 @@
if (hasValue(comp))
{
Object value = comp.getValue();
- if (value instanceof Collection)
+ if (value instanceof Collection<?>)
{
- for (Object o : (Collection)value)
+ for (Object o : (Collection<?>)value)
{
values.add(o);
}
@@ -1930,9 +1930,9 @@
{
hasValue = ((String)value).trim().length() > 0;
}
- else if (value instanceof Collection)
+ else if (value instanceof Collection<?>)
{
- hasValue = ((Collection)value).size() > 0;
+ hasValue = ((Collection<?>)value).size() > 0;
}
else
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
index f7c217a..12bf0d2 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -2063,7 +2063,7 @@
ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
ctls.setReturningAttributes(
new String[] {
- "dn"
+ "1.1"
});
String filter = BrowserController.ALL_OBJECTS_FILTER;
NamingEnumeration<SearchResult> result =
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
index 7862861..50447e3 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -53,7 +53,6 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.server.api.AttributeSyntax;
-import org.opends.server.config.ConfigConstants;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
@@ -74,6 +73,7 @@
*/
public abstract class ViewEntryPanel extends StatusGenericPanel
{
+ private static final long serialVersionUID = -1908757626234678L;
/**
* The read-only attributes as they appear on the schema.
*/
@@ -83,6 +83,11 @@
*/
protected SortedSet<String> schemaReadOnlyAttributesLowerCase =
new TreeSet<String>();
+ /**
+ * The editable operational attributes.
+ */
+ protected SortedSet<String> editableOperationalAttrNames =
+ new TreeSet<String>();
private JLabel title= Utilities.createDefaultLabel();
private Set<LDAPEntryChangedListener> listeners =
@@ -390,20 +395,21 @@
public void configurationChanged(ConfigurationChangeEvent ev)
{
Schema schema = ev.getNewDescriptor().getSchema();
- if (schema != null)
+ if (schema != null && schemaReadOnlyAttributes.isEmpty())
{
schemaReadOnlyAttributes.clear();
schemaReadOnlyAttributesLowerCase.clear();
for (AttributeType attr : schema.getAttributeTypes().values())
{
- if (attr.isOperational())
+ if (attr.isNoUserModification())
{
String attrName = attr.getNameOrOID();
- if (!isEditable(attrName, schema))
- {
- schemaReadOnlyAttributes.add(attrName);
- schemaReadOnlyAttributesLowerCase.add(attrName.toLowerCase());
- }
+ schemaReadOnlyAttributes.add(attrName);
+ schemaReadOnlyAttributesLowerCase.add(attrName.toLowerCase());
+ }
+ else if (attr.isOperational())
+ {
+ editableOperationalAttrNames.add(attr.getNameOrOID());
}
}
}
@@ -535,7 +541,7 @@
Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase());
if (attr != null)
{
- AttributeSyntax syntax = attr.getSyntax();
+ AttributeSyntax<?> syntax = attr.getSyntax();
if (syntax != null)
{
isCertificate = syntax.getOID().equals(
@@ -546,37 +552,6 @@
return isCertificate;
}
- static String[] editableOperationalAttrNames = {
- ConfigConstants.ATTR_OBJECTCLASSES,
- ConfigConstants.ATTR_ATTRIBUTE_TYPES,
- ConfigConstants.ATTR_MATCHING_RULES,
- ConfigConstants.ATTR_NAME_FORMS,
- ConfigConstants.ATTR_LDAP_SYNTAXES,
- ConfigConstants.ATTR_DIT_STRUCTURE_RULES,
- "aci"
- };
-
- /**
- * Returns <CODE>true</CODE> if the provided attribute name is an editable
- * operational attribute and <CODE>false</CODE> otherwise.
- * @param attrName the attribute name.
- * @return <CODE>true</CODE> if the provided attribute name is an editable
- * operational attribute and <CODE>false</CODE> otherwise.
- */
- private static boolean isEditableOperationalAttribute(String attrName)
- {
- boolean isEditableOperationalAttribute = false;
- for (String attr : editableOperationalAttrNames)
- {
- if (attr.equalsIgnoreCase(attrName))
- {
- isEditableOperationalAttribute = true;
- break;
- }
- }
- return isEditableOperationalAttribute;
- }
-
/**
* Gets the values associated with a given attribute. The values are the
* ones displayed in the panel.
@@ -645,16 +620,16 @@
*/
public static boolean isEditable(String attrName, Schema schema)
{
- boolean isOperational = false;
+ boolean isEditable = false;
attrName = Utilities.getAttributeNameWithoutOptions(attrName);
if (schema != null)
{
AttributeType attrType = schema.getAttributeType(attrName.toLowerCase());
if (attrType != null)
{
- isOperational = attrType.isOperational();
+ isEditable = !attrType.isNoUserModification();
}
}
- return !isOperational || isEditableOperationalAttribute(attrName);
+ return isEditable;
}
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
index 18df400..6e8ffc8 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -22,13 +22,12 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.guitools.controlpanel.util;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import javax.naming.NamingEnumeration;
@@ -40,8 +39,6 @@
import org.opends.guitools.controlpanel.event.EntryReadErrorEvent;
import org.opends.guitools.controlpanel.event.EntryReadEvent;
import org.opends.guitools.controlpanel.event.EntryReadListener;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.Schema;
/**
* A class that reads an entry on the background. This is used in the LDAP
@@ -53,7 +50,6 @@
{
private String dn;
private InitialLdapContext ctx;
- private Schema schema;
private Set<EntryReadListener> listeners = new HashSet<EntryReadListener>();
private boolean isOver;
@@ -61,13 +57,11 @@
* Constructor of the entry reader.
* @param dn the DN of the entry.
* @param ctx the connection to the server.
- * @param schema the schema of the server.
*/
- public LDAPEntryReader(String dn, InitialLdapContext ctx, Schema schema)
+ public LDAPEntryReader(String dn, InitialLdapContext ctx)
{
this.dn = dn;
this.ctx = ctx;
- this.schema = schema;
}
/**
@@ -80,25 +74,16 @@
{
SearchControls controls = new SearchControls();
controls.setCountLimit(1);
- Set<String> operational = getAllOperationalAttributes();
- String[] attrs = new String[operational.size()+1];
- Iterator<String> it = operational.iterator();
- int i = 0;
- while (it.hasNext())
- {
- attrs[i] = it.next();
- i++;
- }
- attrs[attrs.length - 1] = "*";
+ String[] attrs = {"*", "+"};
controls.setReturningAttributes(attrs);
controls.setSearchScope(SearchControls.OBJECT_SCOPE);
final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))";
- NamingEnumeration en = ctx.search(Utilities.getJNDIName(dn), filter,
- controls);
+ NamingEnumeration<SearchResult> en =
+ ctx.search(Utilities.getJNDIName(dn), filter, controls);
- SearchResult sr = (SearchResult)en.next();
+ SearchResult sr = en.next();
return new CustomSearchResult(sr, dn);
}
@@ -185,22 +170,4 @@
{
listeners.remove(listener);
}
-
- private Set<String> getAllOperationalAttributes()
- {
- HashSet<String> attrs = new HashSet<String>();
- // Do a best effort if schema could not be retrieved when creating
- // this object.
- if (schema != null)
- {
- for (AttributeType attr : schema.getAttributeTypes().values())
- {
- if (attr.isOperational())
- {
- attrs.add(attr.getNameOrOID());
- }
- }
- }
- return attrs;
- }
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
index 2e7fa53..ce49ef8 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -1905,7 +1905,7 @@
* @param syntax the attribute syntax.
* @return the string representation of an attribute syntax.
*/
- public static String getSyntaxText(AttributeSyntax syntax)
+ public static String getSyntaxText(AttributeSyntax<?> syntax)
{
String returnValue;
String syntaxName = syntax.getSyntaxName();
@@ -2163,7 +2163,7 @@
searchControls.setSearchScope(
SearchControls. OBJECT_SCOPE);
searchControls.setReturningAttributes(
- new String[] {"dn"});
+ new String[] {"1.1"});
ctx.search("cn=config", "objectclass=*", searchControls);
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
index d948c54..1ee1f83 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.ui;
@@ -351,7 +351,7 @@
searchControls.setSearchScope(
SearchControls. OBJECT_SCOPE);
searchControls.setReturningAttributes(
- new String[] {"dn"});
+ new String[] {"1.1"});
ctx.search("cn=config", "objectclass=*", searchControls);
} catch (NamingException ne)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
index 9d8520e..ff7b77f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.ui;
@@ -84,7 +84,8 @@
*
* @param frame for which the icon will be set
*/
- static public void setFrameIcon(JFrame frame) {
+ static public void setFrameIcon(JFrame frame)
+ {
UIFactory.IconType ic;
if (Utils.isMacOS()) {
ic = UIFactory.IconType.MINIMIZED_MAC;
--
Gitblit v1.10.0