Пример #1
0
    def post(self, member_info):
        """Shares the resource to a new member."""
        acl.enforce('members:create', context.ctx())

        LOG.info(
            "Share resource to a member. [resource_id=%s, "
            "resource_type=%s, member_info=%s].",
            self.resource_id,
            self.type,
            member_info
        )

        if not member_info.member_id:
            msg = "Member id must be provided."
            raise exc.WorkflowException(msg)

        wf_db = db_api.get_workflow_definition(self.resource_id)

        if wf_db.scope != 'private':
            msg = "Only private resource could be shared."
            raise exc.WorkflowException(msg)

        resource_member = {
            'resource_id': self.resource_id,
            'resource_type': self.type,
            'member_id': member_info.member_id,
            'status': 'pending'
        }

        db_member = db_api.create_resource_member(resource_member)

        return resources.Member.from_dict(db_member.to_dict())
Пример #2
0
    def post(self, member_info):
        """Shares the resource to a new member."""
        acl.enforce('members:create', context.ctx())

        LOG.info(
            "Share resource to a member. [resource_id=%s, "
            "resource_type=%s, member_info=%s].", self.resource_id, self.type,
            member_info)

        if not member_info.member_id:
            raise exc.WorkflowException("Member id must be provided.")

        with db_api.transaction():
            wf_db = db_api.get_workflow_definition(self.resource_id)

            if wf_db.scope != 'private':
                raise exc.WorkflowException(
                    "Only private resource could be shared.")

            resource_member = {
                'resource_id': self.resource_id,
                'resource_type': self.type,
                'member_id': member_info.member_id,
                'status': 'pending'
            }

            db_member = db_api.create_resource_member(resource_member)

        return resources.Member.from_db_model(db_member)
Пример #3
0
    def post(self, member_info):
        """Shares the resource to a new member."""
        LOG.info(
            "Share resource to a member. [resource_id=%s, "
            "resource_type=%s, member_info=%s].",
            self.resource_id,
            self.type,
            member_info
        )

        if not member_info.member_id:
            msg = "Member id must be provided."
            raise exc.WorkflowException(msg)

        wf_db = db_api.get_workflow_definition(self.resource_id)

        if wf_db.scope != 'private':
            msg = "Only private resource could be shared."
            raise exc.WorkflowException(msg)

        resource_member = {
            'resource_id': self.resource_id,
            'resource_type': self.type,
            'member_id': member_info.member_id,
            'status': 'pending'
        }

        db_member = db_api.create_resource_member(resource_member)

        return Member.from_dict(db_member.to_dict())
Пример #4
0
        def _create_resource_member():
            with db_api.transaction():
                wf_db = db_api.get_workflow_definition(self.resource_id)

                if wf_db.scope != 'private':
                    raise exc.WorkflowException(
                        "Only private resource could be shared.")

                resource_member = {
                    'resource_id': self.resource_id,
                    'resource_type': self.type,
                    'member_id': member_info.member_id,
                    'status': 'pending'
                }

                return db_api.create_resource_member(resource_member)
Пример #5
0
        def _create_resource_member():
            with db_api.transaction():
                wf_db = db_api.get_workflow_definition(self.resource_id)

                if wf_db.scope != 'private':
                    raise exc.WorkflowException(
                        "Only private resource could be shared."
                    )

                resource_member = {
                    'resource_id': self.resource_id,
                    'resource_type': self.type,
                    'member_id': member_info.member_id,
                    'status': 'pending'
                }

                return db_api.create_resource_member(resource_member)