@@ -604,16 +604,16 @@ public boolean addUserToProject(Long projectId, String username, String email, L
604604
605605 boolean shouldIncrementResourceCount = projectRole != null && Role .Admin == projectRole ;
606606 try (CheckedReservation cr = new CheckedReservation (userAccount , ResourceType .project , shouldIncrementResourceCount ? 1L : 0L , reservationDao , _resourceLimitMgr )) {
607- if (assignUserToProject (project , user .getId (), user .getAccountId (), projectRole ,
608- Optional .ofNullable (role ).map (ProjectRole ::getId ).orElse (null )) != null ) {
609- if (shouldIncrementResourceCount ) {
610- _resourceLimitMgr .incrementResourceCount (userAccount .getId (), ResourceType .project );
607+ if (assignUserToProject (project , user .getId (), user .getAccountId (), projectRole ,
608+ Optional .ofNullable (role ).map (ProjectRole ::getId ).orElse (null )) != null ) {
609+ if (shouldIncrementResourceCount ) {
610+ _resourceLimitMgr .incrementResourceCount (userAccount .getId (), ResourceType .project );
611+ }
612+ return true ;
613+ } else {
614+ logger .warn ("Failed to add user to project: {}" , project );
615+ return false ;
611616 }
612- return true ;
613- } else {
614- logger .warn ("Failed to add user to project: {}" , project );
615- return false ;
616- }
617617 }
618618 }
619619 }
@@ -721,19 +721,16 @@ public void doInTransactionWithoutResult(TransactionStatus status) throws Resour
721721 }
722722
723723 try (CheckedReservation checkedReservation = new CheckedReservation (futureOwnerAccount , ResourceType .project , null , null , 1L , reservationDao , _resourceLimitMgr )) {
724-
725- _resourceLimitMgr .checkResourceLimit (_accountMgr .getAccount (futureOwnerAccount .getId ()), ResourceType .project );
726-
727- //unset the role for the old owner
728- ProjectAccountVO currentOwner = _projectAccountDao .findByProjectIdAccountId (projectId , currentOwnerAccount .getId ());
729- currentOwner .setAccountRole (Role .Regular );
730- _projectAccountDao .update (currentOwner .getId (), currentOwner );
731- _resourceLimitMgr .decrementResourceCount (currentOwnerAccount .getId (), ResourceType .project );
732-
733- //set new owner
734- futureOwner .setAccountRole (Role .Admin );
735- _projectAccountDao .update (futureOwner .getId (), futureOwner );
736- _resourceLimitMgr .incrementResourceCount (futureOwnerAccount .getId (), ResourceType .project );
724+ //unset the role for the old owner
725+ ProjectAccountVO currentOwner = _projectAccountDao .findByProjectIdAccountId (projectId , currentOwnerAccount .getId ());
726+ currentOwner .setAccountRole (Role .Regular );
727+ _projectAccountDao .update (currentOwner .getId (), currentOwner );
728+ _resourceLimitMgr .decrementResourceCount (currentOwnerAccount .getId (), ResourceType .project );
729+
730+ //set new owner
731+ futureOwner .setAccountRole (Role .Admin );
732+ _projectAccountDao .update (futureOwner .getId (), futureOwner );
733+ _resourceLimitMgr .incrementResourceCount (futureOwnerAccount .getId (), ResourceType .project );
737734 }
738735 } else {
739736 logger .trace ("Future owner {}is already the owner of the project {}" , newOwnerName , project );
0 commit comments