| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.browser; |
| | | |
| | |
| | | { |
| | | DN dn1 = DN.valueOf(getNode().getDN()); |
| | | DN dn2 = url.getBaseDN(); |
| | | if (dn2.isAncestorOf(dn1)) |
| | | if (dn2.isSuperiorOrEqualTo(dn1)) |
| | | { |
| | | String host = url.getHost(); |
| | | int port = url.getPort(); |
| | |
| | | { |
| | | isBaseDN = true; |
| | | } |
| | | else if (baseDN.getDn().isAncestorOf(theDN)) |
| | | else if (baseDN.getDn().isSuperiorOrEqualTo(theDN)) |
| | | { |
| | | isSubordinate = true; |
| | | } |
| | |
| | | { |
| | | for (DN suffix : allSuffixes) |
| | | { |
| | | if (suffix.isAncestorOf(dn) && !suffix.equals(dn)) |
| | | if (suffix.isSuperiorOrEqualTo(dn) && !suffix.equals(dn)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | { |
| | | return invalidBaseDNValue(dn, ERR_BASE_DN_ALREADY_EXISTS.get(dn), errors); |
| | | } |
| | | else if (baseDN.getDn().isAncestorOf(theDN) && backendName.equalsIgnoreCase(backend.getBackendID())) |
| | | else if (baseDN.getDn().isSuperiorOrEqualTo(theDN) && backendName.equalsIgnoreCase(backend.getBackendID())) |
| | | { |
| | | return invalidBaseDNValue(dn, ERR_BASE_DN_ANCESTOR_EXISTS.get(baseDN.getDn()), errors); |
| | | } |
| | | else if (theDN.isAncestorOf(baseDN.getDn()) && backendName.equalsIgnoreCase(backend.getBackendID())) |
| | | else if (theDN.isSuperiorOrEqualTo(baseDN.getDn()) && backendName.equalsIgnoreCase(backend.getBackendID())) |
| | | { |
| | | return invalidBaseDNValue(dn, ERR_BASE_DN_DN_IS_ANCESTOR_OF.get(baseDN.getDn()), errors); |
| | | } |
| | |
| | | boolean isBelowBaseDN = false; |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | if (baseDN.isAncestorOf(entryDN)) |
| | | if (baseDN.isSuperiorOrEqualTo(entryDN)) |
| | | { |
| | | isBelowBaseDN = true; |
| | | break; |
| | |
| | | boolean matchFound = false; |
| | | for (DN dn : baseDNs) |
| | | { |
| | | if (dn.isAncestorOf(e.getName())) |
| | | if (dn.isSuperiorOrEqualTo(e.getName())) |
| | | { |
| | | matchFound = true; |
| | | break; |
| | |
| | | found = true; |
| | | break; |
| | | } |
| | | else if (dn.isAncestorOf(baseDN)) |
| | | else if (dn.isSuperiorOrEqualTo(baseDN)) |
| | | { |
| | | matchedDN = dn; |
| | | break; |
| | |
| | | for (DN includeBranch : includeBranches) |
| | | { |
| | | if (includeBranch.isSubordinateOrEqualTo(baseDN) || |
| | | includeBranch.isAncestorOf(baseDN)) |
| | | includeBranch.isSuperiorOrEqualTo(baseDN)) |
| | | { |
| | | exportContainers.add(entryContainer); |
| | | break; |
| | |
| | | { |
| | | otherBaseDNs.add(dn); |
| | | |
| | | if (baseDN.isAncestorOf(dn) || baseDN.isSubordinateOrEqualTo(dn)) |
| | | if (baseDN.isSuperiorOrEqualTo(dn) || baseDN.isSubordinateOrEqualTo(dn)) |
| | | { |
| | | LocalizableMessage message = ERR_REGISTER_BASEDN_HIERARCHY_CONFLICT. |
| | | get(baseDN, backend.getBackendID(), dn); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | case SINGLE_LEVEL: |
| | | return baseDN.equals(dn.getParentDNInSuffix()); |
| | | case WHOLE_SUBTREE: |
| | | return baseDN.isAncestorOf(dn); |
| | | return baseDN.isSuperiorOrEqualTo(dn); |
| | | case SUBORDINATES: |
| | | return !baseDN.equals(dn) && baseDN.isAncestorOf(dn); |
| | | return !baseDN.equals(dn) && baseDN.isSuperiorOrEqualTo(dn); |
| | | default: |
| | | return false; |
| | | } |
| | |
| | | case SINGLE_LEVEL: |
| | | return baseDN.equals(dn.parent()); |
| | | case WHOLE_SUBTREE: |
| | | return baseDN.isAncestorOf(dn); |
| | | return baseDN.isSuperiorOrEqualTo(dn); |
| | | case SUBORDINATES: |
| | | return !baseDN.equals(dn) && baseDN.isAncestorOf(dn); |
| | | return !baseDN.equals(dn) && baseDN.isSuperiorOrEqualTo(dn); |
| | | default: |
| | | return false; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | break; |
| | | |
| | | case SUBORDINATES: |
| | | if (baseDN.equals(nextDN) || !baseDN.isAncestorOf(nextDN)) |
| | | if (baseDN.equals(nextDN) || !baseDN.isSuperiorOrEqualTo(nextDN)) |
| | | { |
| | | continue; |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | if (!baseDN.isAncestorOf(nextDN)) |
| | | if (!baseDN.isSuperiorOrEqualTo(nextDN)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | * Check if the operation to be run is an addOperation on a |
| | | * parent of the current AddOperation. |
| | | */ |
| | | if (pendingMsg.getDN().isAncestorOf(targetDN)) |
| | | if (pendingMsg.getDN().isSuperiorOrEqualTo(targetDN)) |
| | | { |
| | | hasDependencies = true; |
| | | addDependency(change, pendingChange); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | try |
| | | { |
| | | DN newDN = computeNewDN(); |
| | | return newDN.isAncestorOf(targetDn); |
| | | return newDN.isSuperiorOrEqualTo(targetDn); |
| | | } catch (DirectoryException e) |
| | | { |
| | | // The DN was not a correct DN, and therefore does not a parent of the |
| | |
| | | { |
| | | for (DN includeDN : includeBranches) |
| | | { |
| | | if (baseDN.isAncestorOf(includeDN)) |
| | | if (baseDN.isSuperiorOrEqualTo(includeDN)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if this DN is an ancestor of the |
| | | * provided DN, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean isAncestorOf(DN dn) |
| | | public boolean isSuperiorOrEqualTo(DN dn) |
| | | { |
| | | int offset = dn.numComponents - numComponents; |
| | | if (offset < 0) |
| | |
| | | { |
| | | for (DN excludeBranch : excludeBranches) |
| | | { |
| | | if (excludeBranch.isAncestorOf(dn)) |
| | | if (excludeBranch.isSuperiorOrEqualTo(dn)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | for (DN includeBranch : includeBranches) |
| | | { |
| | | if (includeBranch.isAncestorOf(dn)) |
| | | if (includeBranch.isSuperiorOrEqualTo(dn)) |
| | | { |
| | | break checkIncludeBranches; |
| | | } |
| | |
| | | { |
| | | for (DN excludeBranch : excludeBranches) |
| | | { |
| | | if (excludeBranch.isAncestorOf(dn)) |
| | | if (excludeBranch.isSuperiorOrEqualTo(dn)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | for (DN includeBranch : includeBranches) |
| | | { |
| | | if (includeBranch.isAncestorOf(dn)) |
| | | if (includeBranch.isSuperiorOrEqualTo(dn)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | |
| | | // If the request base DN is not a subordinate of the subordinate |
| | | // workflow base DN then do not search in the subordinate workflow. |
| | | if (!originalBaseDN.isAncestorOf(subordinateDN)) |
| | | if (!originalBaseDN.isSuperiorOrEqualTo(subordinateDN)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | assertTrue(p.compareTo(c) < 0); |
| | | assertTrue(c.compareTo(p) > 0); |
| | | |
| | | assertTrue(p.isAncestorOf(c)); |
| | | assertFalse(c.isAncestorOf(p)); |
| | | assertTrue(p.isSuperiorOrEqualTo(c)); |
| | | assertFalse(c.isSuperiorOrEqualTo(p)); |
| | | |
| | | assertTrue(c.isSubordinateOrEqualTo(p)); |
| | | assertFalse(p.isSubordinateOrEqualTo(c)); |
| | |
| | | assertTrue(c.compareTo(p) > 0); |
| | | assertTrue(p.compareTo(c) < 0); |
| | | |
| | | assertTrue(p.isAncestorOf(c)); |
| | | assertFalse(c.isAncestorOf(p)); |
| | | assertTrue(p.isSuperiorOrEqualTo(c)); |
| | | assertFalse(c.isSuperiorOrEqualTo(p)); |
| | | |
| | | assertTrue(c.isSubordinateOrEqualTo(p)); |
| | | assertFalse(p.isSubordinateOrEqualTo(c)); |
| | |
| | | DN dn = DN.valueOf(s); |
| | | DN other = DN.valueOf(d); |
| | | |
| | | assertEquals(dn.isAncestorOf(other), e, s + " isAncestoryOf " + d); |
| | | assertEquals(dn.isSuperiorOrEqualTo(other), e, s + " isAncestoryOf " + d); |
| | | } |
| | | |
| | | |
| | |
| | | AssertionError.class }) |
| | | public void testIsAncestorOfException() throws Exception { |
| | | DN dn = DN.valueOf("dc=com"); |
| | | dn.isAncestorOf(null); |
| | | dn.isSuperiorOrEqualTo(null); |
| | | } |
| | | |
| | | |