opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -46,7 +46,7 @@ */ public class CustomSearchResult implements Comparable<CustomSearchResult> { private final String dn; private final DN dn; private Map<String, List<Object>> attributes; private SortedSet<String> attrNames; private String toString; @@ -58,7 +58,7 @@ * editors use some methods that require CustomSearchResult. * @param dn the dn of the entry. */ public CustomSearchResult(String dn) public CustomSearchResult(DN dn) { this.dn = dn; attributes = new HashMap<>(); @@ -74,7 +74,7 @@ */ public CustomSearchResult(SearchResultEntry sr) throws NamingException { dn = sr.getName().toString(); dn = sr.getName(); attributes = new HashMap<>(); attrNames = new TreeSet<>(); @@ -100,7 +100,8 @@ * Returns the DN of the entry. * @return the DN of the entry. */ public String getDN() { public DN getDN() { return dn; } @@ -113,11 +114,7 @@ */ public List<Object> getAttributeValues(String name) { List<Object> values = attributes.get(name.toLowerCase()); if (values == null) { values = Collections.emptyList(); } return values; return values != null ? values : Collections.emptyList(); } /** @@ -209,7 +206,6 @@ */ public Entry getEntry() throws OpenDsException { DN dn = DN.valueOf(getDN()); Map<ObjectClass,String> objectClasses = new HashMap<>(); Map<AttributeType,List<org.opends.server.types.Attribute>> userAttributes = new HashMap<>(); Map<AttributeType,List<org.opends.server.types.Attribute>> operationalAttributes = new HashMap<>(); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -320,7 +320,6 @@ String filter = "(|(objectClass=*)(objectclass=ldapsubentry))"; SearchRequest request = newSearchRequest(dnToRemove, SINGLE_LEVEL, Filter.valueOf(filter), NO_ATTRIBUTES); DN entryDNFound = dnToRemove; try (ConnectionEntryReader entryDNs = conn.getConnection().search(request)) { while (entryDNs.hasNext()) @@ -329,8 +328,7 @@ if (!sr.getName().equals("")) { CustomSearchResult res = new CustomSearchResult(sr); entryDNFound = DN.valueOf(res.getDN()); deleteSubtreeRecursively(conn, entryDNFound, null, toNotify); deleteSubtreeRecursively(conn, res.getDN(), null, toNotify); } } } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -96,7 +96,7 @@ this.treePath = path; DN newDn = newEntry.getName(); oldDn = DN.valueOf(oldEntry.getDN()); oldDn = oldEntry.getDN(); for (BackendDescriptor backend : info.getServerDescriptor().getBackends()) { for (BaseDNDescriptor baseDN : backend.getBaseDns()) @@ -228,7 +228,7 @@ } }); conn.getLdapContext().modifyAttributes(Utilities.getJNDIName(oldEntry.getDN()), mods); conn.getLdapContext().modifyAttributes(Utilities.getJNDIName(oldEntry.getDN().toString()), mods); SwingUtilities.invokeLater(new Runnable() { @@ -515,7 +515,7 @@ * modifications. */ ByteString oldRdnValueDeleted = null; RDN oldRDN = DN.valueOf(oldEntry.getDN()).rdn(); RDN oldRDN = oldEntry.getDN().rdn(); for (AVA ava : oldRDN) { if (ava.getAttributeType().equals(attrDesc.getAttributeType())) opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -336,7 +336,7 @@ for (TreePath p : paths) { BasicNode n = (BasicNode)p.getLastPathComponent(); if (!entryPane.canDelete(n.getDN())) if (!entryPane.canDelete(DN.valueOf(n.getDN()))) { return false; } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
@@ -377,7 +377,7 @@ } else { String newValue = getFirstValue(dn); String newValue = getFirstValue(DN.valueOf(dn)); if (values.size() == 1) { sb.append("\n"); @@ -404,9 +404,9 @@ return sb.toString(); } private String getFirstValue(String dn) private String getFirstValue(DN dn) { return DN.valueOf(dn).rdn().getFirstAVA().getAttributeValue().toString(); return dn.rdn().getFirstAVA().getAttributeValue().toString(); } private void browseClicked() @@ -467,8 +467,7 @@ entryToDuplicate = sr; try { DN dn = DN.valueOf(sr.getDN()); rdnAttribute = dn.rdn().getFirstAVA().getAttributeType().getNameOrOID(); rdnAttribute = sr.getDN().rdn().getFirstAVA().getAttributeType().getNameOrOID(); updateDNValue(); Boolean hasPassword = !sr.getAttributeValues( opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
@@ -36,6 +36,7 @@ import javax.swing.tree.TreePath; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.DN; import org.opends.guitools.controlpanel.browser.BasicNodeError; import org.opends.guitools.controlpanel.browser.BrowserController; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; @@ -52,7 +53,6 @@ import org.opends.guitools.controlpanel.task.Task; import org.opends.guitools.controlpanel.util.Utilities; import org.opends.server.config.ConfigConstants; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.Entry; import org.opends.server.types.OpenDsException; import org.opends.server.util.ServerConstants; @@ -192,11 +192,8 @@ } else { boolean modified = !Utilities.areDnsEqual(ev.getEntry().getName().toString(), searchResult.getDN()) || !ModifyEntryTask.getModifications(ev.getEntry(), searchResult, getInfo()).isEmpty(); boolean modified = !ev.getEntry().getName().equals(searchResult.getDN()) || !ModifyEntryTask.getModifications(ev .getEntry(), searchResult, getInfo()).isEmpty(); enable = modified; } } @@ -441,44 +438,29 @@ * @return <CODE>true</CODE> if the provided DN corresponds to a read-only * entry and <CODE>false</CODE> otherwise. */ private boolean isReadOnly(String sDn) private boolean isReadOnly(DN dn) { boolean isReadOnly = false; try { DN dn = DN.valueOf(sDn); for (DN parentDN : parentReadOnly) { if (dn.isSubordinateOrEqualTo(parentDN)) { isReadOnly = true; break; return true; } } if (!isReadOnly) { isReadOnly = dn.equals(DN.rootDN()); } } catch (Throwable t) { throw new RuntimeException("Error decoding DNs: "+t, t); } return isReadOnly; return dn.equals(DN.rootDN()); } /** * Returns <CODE>true</CODE> if the provided DN corresponds to an entry that * can be deleted and <CODE>false</CODE> otherwise. * @param sDn the DN of the entry. * @param dn the DN of the entry. * @return <CODE>true</CODE> if the provided DN corresponds to an entry that * can be deleted and <CODE>false</CODE> otherwise. */ public boolean canDelete(String sDn) public boolean canDelete(DN dn) { try { DN dn = DN.valueOf(sDn); return !dn.equals(DN.rootDN()) && !nonDeletable.contains(dn) && isDescendantOfAny(dn, parentReadOnly); @@ -591,7 +573,7 @@ INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), confirmationMessage)) { String dn = searchResult.getDN(); DN dn = searchResult.getDN(); if (isLeaf) { launchOperation(newTask, opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -57,6 +57,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; @@ -72,7 +73,6 @@ import org.opends.server.types.Attribute; import org.opends.server.types.AttributeBuilder; import org.opends.server.types.Entry; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.opends.server.types.OpenDsException; /** The panel displaying the list of scheduled tasks. */ @@ -468,8 +468,7 @@ int numberTasks = r.nextInt(10); for (int i= 0; i<numberTasks; i++) { CustomSearchResult csr = new CustomSearchResult("cn=mytask"+i+",cn=tasks"); CustomSearchResult csr = new CustomSearchResult(DN.valueOf("cn=mytask" + i + ",cn=tasks")); String p = "ds-task-"; String[] attrNames = { @@ -534,8 +533,7 @@ Set<TaskEntry> list = new HashSet<>(); for (int i= 0; i<10; i++) { CustomSearchResult csr = new CustomSearchResult("cn=mytask"+i+",cn=tasks"); CustomSearchResult csr = new CustomSearchResult(DN.valueOf("cn=mytask" + i + ",cn=tasks")); String p = "ds-task-"; String[] attrNames = { @@ -634,7 +632,7 @@ */ private static Entry getEntry(CustomSearchResult csr) throws OpenDsException { DN dn = DN.valueOf(csr.getDN()); DN dn = csr.getDN(); Map<ObjectClass,String> objectClasses = new HashMap<>(); Map<AttributeType,List<Attribute>> userAttributes = new HashMap<>(); Map<AttributeType,List<Attribute>> operationalAttributes = new HashMap<>(); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -1422,7 +1422,7 @@ StringBuilder sb = new StringBuilder(); try { DN oldDN = DN.valueOf(searchResult.getDN()); DN oldDN = searchResult.getDN(); if (oldDN.size() > 0) { List<AVA> avas = toAvas(oldDN.rdn()); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -262,7 +262,7 @@ StringBuilder sb = new StringBuilder(); try { DN oldDN = DN.valueOf(searchResult.getDN()); DN oldDN = searchResult.getDN(); if (oldDN.size() > 0) { RDN rdn = oldDN.rdn(); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -37,6 +37,7 @@ 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.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.ObjectClassType; @@ -181,10 +182,10 @@ */ protected void updateTitle(CustomSearchResult sr, TreePath path) { String dn = sr.getDN(); if (dn != null && dn.length() > 0) final DN dn = sr.getDN(); if (dn != null && dn.size() > 0) { title.setText(sr.getDN()); title.setText(dn.toString()); } else if (path != null) {