opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -600,8 +600,8 @@ continue; } List<Object> oldValues = oldEntry.getAttributeValues(attrName); String attrNoOptions = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); AttributeDescription attrDesc = AttributeDescription.valueOf(attrName); String attrNoOptions = attrDesc.getNameOrOID().toLowerCase(); List<org.opends.server.types.Attribute> attrs = newEntry.getAttribute(attrNoOptions); if (!find(attrs, attrName) && !oldValues.isEmpty()) opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -71,6 +71,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.opendj.ldap.AVA; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.RDN; @@ -676,8 +677,8 @@ ArrayList<String> attrsWithNoOptions = new ArrayList<>(); for (String attr : entryAttrs) { attrsWithNoOptions.add( Utilities.getAttributeNameWithoutOptions(attr).toLowerCase()); AttributeDescription attrDesc = AttributeDescription.valueOf(attr); attrsWithNoOptions.add(attrDesc.getNameOrOID().toLowerCase()); } List<Object> values = @@ -1151,20 +1152,23 @@ private boolean isRequired(String attrName, CustomSearchResult sr) { attrName = Utilities.getAttributeNameWithoutOptions(attrName); Schema schema = getInfo().getServerDescriptor().getSchema(); if (schema != null && schema.hasAttributeType(attrName)) if (schema != null) { AttributeType attr = schema.getAttributeType(attrName); List<Object> ocs = sr.getAttributeValues(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); for (Object o : ocs) AttributeDescription attrDesc = AttributeDescription.valueOf(attrName, schema.getSchemaNG()); AttributeType attrType = attrDesc.getAttributeType(); if (!attrType.isPlaceHolder()) { String oc = (String) o; ObjectClass objectClass = schema.getObjectClass(oc.toLowerCase()); if (objectClass != null && objectClass.isRequired(attr)) List<Object> ocs = sr.getAttributeValues(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); for (Object o : ocs) { return true; String oc = (String) o; ObjectClass objectClass = schema.getObjectClass(oc.toLowerCase()); if (objectClass != null && objectClass.isRequired(attrType)) { return true; } } } } @@ -1279,9 +1283,8 @@ private List<String> getNewPasswords(String attrName) { String attr = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); return getDisplayedStringValues(attr); AttributeDescription attrDesc = AttributeDescription.valueOf(attrName); return getDisplayedStringValues(attrDesc.getNameOrOID()); } private List<String> getConfirmPasswords(String attrName) @@ -1291,8 +1294,8 @@ private String getConfirmPasswordKey(String attrName) { return CONFIRM_PASSWORD+ Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); AttributeDescription attrDesc = AttributeDescription.valueOf(attrName); return CONFIRM_PASSWORD + attrDesc.getNameOrOID().toLowerCase(); } private boolean isConfirmPassword(String key) @@ -1476,10 +1479,11 @@ Object o = comps.iterator().next().getValue(); if (o instanceof String) { String aName = Utilities.getAttributeNameWithoutOptions(attrName); if (schema.hasAttributeType(aName)) AttributeDescription attrDesc = AttributeDescription.valueOf(attrName, schema.getSchemaNG()); AttributeType attrType = attrDesc.getAttributeType(); if (!attrType.isPlaceHolder()) { avas.add(new AVA(schema.getAttributeType(aName), aName, o)); avas.add(new AVA(attrType, attrDesc.getNameOrOID(), o)); } break; } @@ -1654,8 +1658,7 @@ } for (String attrName : hmEditors.keySet()) { String attrNoOptions = Utilities.getAttributeNameWithoutOptions(attrName); String attrNoOptions = AttributeDescription.valueOf(attrName).getNameOrOID(); if (!attributes.contains(attrNoOptions)) { continue; opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -46,6 +46,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.AVA; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.RDN; @@ -308,10 +309,11 @@ Object o = table.getValueAt(i, 1); if (o instanceof String) { String aName = Utilities.getAttributeNameWithoutOptions(attrName); if (schema.hasAttributeType(aName)) AttributeDescription attrDesc = AttributeDescription.valueOf(attrName, schema.getSchemaNG()); AttributeType attrType = attrDesc.getAttributeType(); if (!attrType.isPlaceHolder()) { avas.add(new AVA(schema.getAttributeType(aName), attrName, o)); avas.add(new AVA(attrType, attrDesc.getNameOrOID(), o)); } break; } @@ -608,8 +610,8 @@ allSortedValues.add(new AttributeValuePair(attrName, v)); } } addedAttrs.add( Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase()); AttributeDescription attrDesc = AttributeDescription.valueOf(attrName); addedAttrs.add(attrDesc.getNameOrOID().toLowerCase()); } if (ocs != null && schema != null) { @@ -763,14 +765,10 @@ } for (AttributeValuePair currValue : allSortedValues) { String attrNoOptions = Utilities.getAttributeNameWithoutOptions( currValue.attrName).toLowerCase(); if (!attributes.contains(attrNoOptions)) { continue; } else if (!schemaReadOnlyAttributesLowerCase.contains( currValue.attrName.toLowerCase())) AttributeDescription attrDesc = AttributeDescription.valueOf(currValue.attrName); String attrNoOptions = attrDesc.getNameOrOID().toLowerCase(); if (attributes.contains(attrNoOptions) && !schemaReadOnlyAttributesLowerCase.contains(currValue.attrName.toLowerCase())) { setValues(newResult, currValue.attrName); } @@ -784,9 +782,8 @@ private boolean isRequired(AttributeValuePair value) { return requiredAttrs.contains( Utilities.getAttributeNameWithoutOptions( value.attrName.toLowerCase())); AttributeDescription attrDesc = AttributeDescription.valueOf(value.attrName.toLowerCase()); return requiredAttrs.contains(attrDesc.getNameOrOID()); } private boolean hasValue(AttributeValuePair value) opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -35,6 +35,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.AVA; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClassType; @@ -462,7 +463,7 @@ // Check all the attributes that we consider binaries. if (schema != null) { String attributeName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); String attributeName = AttributeDescription.valueOf(attrName).getNameOrOID().toLowerCase(); if (schema.hasAttributeType(attributeName)) { AttributeType attr = schema.getAttributeType(attributeName); @@ -541,7 +542,7 @@ */ public static boolean isEditable(String attrName, Schema schema) { attrName = Utilities.getAttributeNameWithoutOptions(attrName); attrName = AttributeDescription.valueOf(attrName).getNameOrOID(); if (schema != null && schema.hasAttributeType(attrName)) { AttributeType attrType = schema.getAttributeType(attrName); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java
@@ -28,6 +28,7 @@ import javax.swing.JLabel; import javax.swing.JTable; import org.forgerock.opendj.ldap.AttributeDescription; import org.opends.guitools.controlpanel.browser.IconPool; import org.opends.guitools.controlpanel.datamodel.BinaryValue; import org.opends.guitools.controlpanel.datamodel.ObjectClassValue; @@ -245,7 +246,7 @@ { Object o = table.getValueAt(row, 0); return requiredAttrs.contains( Utilities.getAttributeNameWithoutOptions((String)o).toLowerCase()); AttributeDescription.valueOf((String)o).getNameOrOID().toLowerCase()); } return false; } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -16,11 +16,12 @@ */ package org.opends.guitools.controlpanel.util; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.opends.admin.ads.util.ConnectionUtils.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.quicksetup.Installation.*; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import java.awt.Color; import java.awt.Component; @@ -120,9 +121,9 @@ import org.opends.server.types.OpenDsException; import org.opends.server.types.Schema; import org.opends.server.util.SchemaUtils; import org.opends.server.util.SchemaUtils.PasswordType; import org.opends.server.util.ServerConstants; import org.opends.server.util.StaticUtils; import org.opends.server.util.SchemaUtils.PasswordType; /** * A static class that provides miscellaneous functions. @@ -1467,16 +1468,6 @@ } /** * Returns the attribute name with no options (or subtypes). * @param attrName the complete attribute name. * @return the attribute name with no options (or subtypes). */ public static String getAttributeNameWithoutOptions(String attrName) { return AttributeDescription.valueOf(attrName).getNameOrOID(); } /** * Strings any potential "separator" from a given string. * @param s string to strip * @param separator the separator string to remove @@ -1484,11 +1475,7 @@ */ private static String stripStringToSingleLine(String s, String separator) { if (s != null) { return s.replaceAll(separator, ""); } return null; return (s == null) ? null : s.replaceAll(separator, ""); } /** The pattern for control characters. */ @@ -2088,17 +2075,19 @@ */ public static boolean hasImageSyntax(String attrName, Schema schema) { attrName = Utilities.getAttributeNameWithoutOptions(attrName); if ("photo".equals(attrName)) if ("photo".equals(AttributeDescription.valueOf(attrName).getNameOrOID())) { return true; } // Check all the attributes that we consider binaries. if (schema != null && schema.hasAttributeType(attrName)) if (schema != null) { AttributeType attr = schema.getAttributeType(attrName); String syntaxOID = attr.getSyntax().getOID(); return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); if (!attrType.isPlaceHolder()) { String syntaxOID = attrType.getSyntax().getOID(); return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); } } return false; } @@ -2129,11 +2118,10 @@ { if (schema != null) { attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); if (schema.hasAttributeType(attrName)) AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); if (!attrType.isPlaceHolder()) { AttributeType attr = schema.getAttributeType(attrName); PasswordType passwordType = SchemaUtils.checkPasswordType(attr); PasswordType passwordType = SchemaUtils.checkPasswordType(attrType); return passwordType.equals(PasswordType.USER_PASSWORD); } } @@ -2144,11 +2132,10 @@ { if (schema != null) { attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); if (schema.hasAttributeType(attrName)) AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); if (!attrType.isPlaceHolder()) { AttributeType attr = schema.getAttributeType(attrName); return contains(oids, attr.getSyntax().getOID()); return contains(oids, attrType.getSyntax().getOID()); } } return false;