CLOUDSTACK-9985: Allow creation of roles with names of deleted roles

This allows admins to create roles with names of previously deleted
roles.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2017-07-06 13:20:35 +05:30 committed by Rohit Yadav
parent 90e7cabf4e
commit de0d1c7893
1 changed files with 7 additions and 1 deletions

View File

@ -50,6 +50,7 @@ import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Local(value = {RoleService.class})
@ -172,7 +173,12 @@ public class RoleManagerImpl extends ManagerBase implements RoleService, Configu
rolePermissionsDao.remove(rolePermission.getId());
}
}
return roleDao.remove(role.getId());
if (roleDao.remove(role.getId())) {
RoleVO roleVO = roleDao.findByIdIncludingRemoved(role.getId());
roleVO.setName(role.getName() + "-deleted-" + new Date());
return roleDao.update(role.getId(), roleVO);
}
return false;
}
});
}