public function initializePermissions(Activity $activity)
    {
        $primary = $activity->getPrimaryResource();
        $secondaries = [];
        $nodes = [];
        $token = $this->tokenStorage->getToken();
        $user = $token === null ? $activity->getResourceNode()->getCreator(): $token->getUser();

        if ($primary) {
            $nodes[] = $primary;
        }

        foreach ($activity->getParameters()->getSecondaryResources() as $res) {
            $secondaries[] = $res;
        }

        $nodes = array_merge($nodes, $secondaries);
        $nodesInitialized = [];

        foreach ($nodes as $node) {
            $isNodeCreator = $node->getCreator() === $user;
            $ws = $node->getWorkspace();
            $roleWsManager = $this->roleRepo->findManagerRole($ws);
            $isWsManager = $user->hasRole($roleWsManager);

            if ($isNodeCreator || $isWsManager) {
                $nodesInitialized[] = $node;
            }
        }

        $rolesInitialized = [];
        $rights = $activity->getResourceNode()->getRights();

        foreach ($rights as $right) {
            $role = $right->getRole();

            if (!strpos('_' . $role->getName(), 'ROLE_WS_MANAGER')
                //the open value is always 1
                && $right->getMask() & 1
            ) {
                $rolesInitialized[] = $role;
            }
        }

        $this->rightsManager->initializePermissions($nodesInitialized, $rolesInitialized);
    }