private void getAncestors ( Entity entity , LdapEntry ldapEntry , AncestorControl ancesCtrl ) throws WIMException { if ( ancesCtrl == null ) { return ; } List < String > propNames = ancesCtrl . getProperties ( ) ; int level = ancesCtrl . getLevel ( ) ; List < String > ancesTypes = getEntityTypes ( ancesCtrl ) ; String [ ] bases = getBases ( ancesCtrl , ancesTypes ) ; String dn = ldapEntry . getDN ( ) ; List < String > ancestorDns = iLdapConn . getAncestorDNs ( dn , level ) ; Entity parentEntity = entity ; for ( int i = 0 ; i < ancestorDns . size ( ) ; i ++ ) { String ancesDn = ancestorDns . get ( i ) ; if ( ancesDn . length ( ) == 0 ) { continue ; } if ( LdapHelper . isUnderBases ( ancesDn , bases ) ) { LdapEntry ancesEntry = iLdapConn . getEntityByIdentifier ( ancesDn , null , null , ancesTypes , propNames , false , false ) ; String ancesType = ancesEntry . getType ( ) ; Entity ancestor = null ; if ( ancesTypes . contains ( ancesType ) ) { ancestor = createEntityFromLdapEntry ( parentEntity , SchemaConstants . DO_PARENT , ancesEntry , propNames ) ; } else { ancestor = createEntityFromLdapEntry ( parentEntity , SchemaConstants . DO_PARENT , ancesEntry , null ) ; } parentEntity = ancestor ; } } }
Method to get the ancestors of the given entity .