@ Override public void monitor ( Consumer < CompletedRepositoryPromotion > onComplete , Consumer < Exception > onError ) { try { StoreKey fromKey = new StoreKey ( pakageType , fromType , fromId ) ; if ( ! indy . stores ( ) . exists ( fromKey ) ) { throw new RepositoryManagerException ( "No such %s repository: %s" , fromType . singularEndpointName ( ) , fromId ) ; } StoreKey toKey = new StoreKey ( pakageType , StoreType . group , toId ) ; Group recordSetGroup = indy . stores ( ) . load ( toKey , Group . class ) ; if ( recordSetGroup == null ) { throw new RepositoryManagerException ( "No such group: %s" , toId ) ; } recordSetGroup . addConstituent ( fromKey ) ; boolean result = indy . stores ( ) . update ( recordSetGroup , "Promoting " + fromType . singularEndpointName ( ) + " repository : " + fromId + " to group: " + toId ) ; onComplete . accept ( new IndyCompletedPromotion ( result ) ) ; } catch ( IndyClientException | RepositoryManagerException e ) { onError . accept ( e ) ; } }
Trigger the repository promotion configured for this instance and send the result to the appropriate consumer .