protected String getParentDn(String dn) { LdapName ldapName; String parentDn; if (dn != null) { try { ldapName = new LdapName(dn); ldapName.remove(ldapName.size() - 1); parentDn = ldapName.toString(); return parentDn; } catch (InvalidNameException ex) { return null; } } return null; }
public List<String> sup(String dn, int level) throws NamingException { int ncLevel = (new LdapName(contextDn.toString())).size(); LdapName lName = new LdapName(dn); List<String> cList = new ArrayList<String>(); if (level > 0) { if (lName.size() > level) { for (int i = 0; i < level; i++) { lName.remove(lName.size() - 1); } cList.add(lName.toString()); } } else if (level == 0) { cList.add(lName.toString()); int size = lName.size(); for (int i = 0; i < size - 1 && i < size - ncLevel; i++) { lName.remove(lName.size() - 1); cList.add(lName.toString()); } } else { return null; } return cList; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
if (suffixDn.size() > 0 && suffixDn.getRdn(0).size() == 0) suffixDn.remove(0);