private void moveRoles ( AuthzTrans trans , NsDAO . Data parent , StringBuilder sb , Result < List < RoleDAO . Data > > rrdc ) { Result < Void > rv ; Result < RoleDAO . Data > rd ; if ( rrdc . isOKhasData ( ) ) { for ( RoleDAO . Data rdd : rrdc . value ) { String delP2 = rdd . name ; if ( "admin" . equals ( delP2 ) || "owner" . equals ( delP2 ) ) { continue ; } // Remove old Role from Perms, save them off List < PermDAO . Data > lpdd = new ArrayList < PermDAO . Data > ( ) ; for ( String p : rdd . perms ( false ) ) { Result < PermDAO . Data > rpdd = PermDAO . Data . decode ( trans , q , p ) ; if ( rpdd . isOKhasData ( ) ) { PermDAO . Data pdd = rpdd . value ; lpdd . add ( pdd ) ; q . permDAO . delRole ( trans , pdd , rdd ) ; } else { trans . error ( ) . log ( rpdd . errorString ( ) ) ; } } // Save off Old keys String delP1 = rdd . ns ; NsSplit nss = new NsSplit ( parent , rdd . fullName ( ) ) ; rdd . ns = nss . ns ; rdd . name = nss . name ; // Use direct Create/Delete, because switching namespaces if ( ( rd = q . roleDAO . create ( trans , rdd ) ) . isOK ( ) ) { // Put Role back into Perm, with correct info for ( PermDAO . Data pdd : lpdd ) { q . permDAO . addRole ( trans , pdd , rdd ) ; } rdd . ns = delP1 ; rdd . name = delP2 ; if ( ( rv = q . roleDAO . delete ( trans , rdd , true ) ) . notOK ( ) ) { sb . append ( rv . details ) ; sb . append ( ' ' ) ; // } else { // Need to invalidate directly, because we're switching // places in NS, not normal cache behavior // q.roleDAO.invalidate(trans,rdd); } } else { sb . append ( rd . details ) ; sb . append ( ' ' ) ; } } } }
Helper function that moves roles from a namespace being deleted to its parent namespace