if ( rdn.size() == 0 ) newDn = newDn.add( new Rdn() ); continue; else if ( rdn.size() == 1 ) String name = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName(); String value = rdn.getValue(); newDn = newDn.add( new Rdn( name, value ) ); continue; for ( Iterator<Ava> atavs = rdn.iterator(); atavs.hasNext(); /**/) String type = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName(); buf.append( type ).append( '=' ).append( atav.getValue().getValue() ); newDn = newDn.add( new Rdn( buf.toString() ) );
/** * Method will retrieve the relative distinguished name from a distinguished name variable. * * @param dn contains ldap distinguished name. * @return rDn as string. */ protected String getRdn( String dn ) { try { return new Dn( dn ).getRdn().getName(); } catch ( LdapInvalidDnException lide ) { return null; } }
if ( rdn.equals( currentNode.nodeRdn ) ) currentNode = currentNode.children.get( rdn.getNormName() );
/** * Validate a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param dn The string to parse * @return <code>true</code> if the Rdn is valid */ public static boolean isValid( String dn ) { Rdn rdn = new Rdn(); try { parse( null, dn, rdn ); return true; } catch ( LdapInvalidDnException e ) { return false; } }
/** * {@inheritDoc} */ @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the UPName upName = in.readUTF(); // Read the RDNs. Is it's null, the number will be -1. int nbRdns = in.readInt(); rdns = new ArrayList<>( nbRdns ); for ( int i = 0; i < nbRdns; i++ ) { Rdn rdn = new Rdn( schemaManager ); rdn.readExternal( in ); rdns.add( rdn ); } toUpName(); }
/** * Adds a single Rdn to the (leaf) end of this name. * * @param newRdn the Rdn to add * @return the updated cloned Dn * @throws LdapInvalidDnException If the Dn is invalid */ public Dn add( Rdn newRdn ) throws LdapInvalidDnException { if ( ( newRdn == null ) || ( newRdn.size() == 0 ) ) { return this; } Dn clonedDn = copy(); clonedDn.rdns.add( 0, new Rdn( schemaManager, newRdn ) ); clonedDn.toUpName(); return clonedDn; }
/** * Checks that the parent Dn is a valid Dn * * @param newParent The parent DN to check * @param schemaManager The SchemaManager instance * @param objectType The ObjectType to check * @throws LdapException If the deletion failed */ protected void checkParent( Dn newParent, SchemaManager schemaManager, String objectType ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_337 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ) .equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_338, objectType ) ); } if ( !rdn.getValue().equalsIgnoreCase( OBJECT_TYPE_TO_PATH.get( objectType ) ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_339, objectType, OBJECT_TYPE_TO_PATH.get( objectType ) ) ); } }
reverted.setNewRdn( oldRdn.getName() ); boolean keepOldRdn = entry.contains( newRdn.getNormType(), newRdn.getValue() );
/** * Read the configuration from the DIT, returning a bean containing all of it. * <p> * This method implicitly uses <em>"ou=config"</em> as base Dn * * @return The Config bean, containing the whole configuration * @throws ConfigurationException If we had some issue reading the configuration */ public ConfigBean readConfig() throws LdapException { // The starting point is the DirectoryService element return readConfig( new Dn( new Rdn( SchemaConstants.OU_AT, "config" ) ) ); }
currentAva = rdn.getAva( avaPos ); currentAva = rdn.getAva( avaPos ); attributeType = currentAva.getAttributeType(); rdn.hashCode(); rdn.setUpName( rdnStr.toString() ); rdn.setNormName( rdnNormStr.toString() );
Rdn ldapRdn = rdns.get( rdns.size() - i - 1 ); if ( !nameRdn.equals( ldapRdn ) )
private void injectRdnAttributeValues( Dn target, Entry serverEntry ) throws NamingException { // Add all the Rdn attributes and their values to this entry Rdn rdn = target.getRdn(); if ( rdn.size() == 1 ) { serverEntry.put( rdn.getType(), rdn.getValue() ); } else { for ( Ava atav : rdn ) { serverEntry.put( atav.getType(), atav.getValue() ); } } }
/** * Returns the first name from a DN (Distinguished Name). Ex: for * <i>DN=cn=administrators,ou=groups,dc=roda,dc=org</i> returns * <i>administrators</i>. * * @param dn * the Distinguished Name. * @return a {@link String} with the first name. */ private String getFirstNameFromDN(final Dn dn) { return dn.getRdn().getValue(); }
Rdn rdn = new Rdn( schemaManager ); parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); rdns.add( rdn );
sb.append( Rdn.escapeValue( rdnValues[i] ) ); Rdn rdn = new Rdn( sb.toString() ); return rdn;
sbUpName.append( rdn.getName() ); sbNormName.append( rdn.getNormName() );
/** * Tells if the current DnBranchNode contains another node associated * with an rdn. * * @param rdn The name we are looking for * @return <code>true</code> if the tree instance contains this name */ public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); }