예제 #1
0
    def post(self, *uriargs):
        """
        Request: wbSubmissionDesc
        Response: wbSubmissionDesc
        Errors: ContextGusNotFound, InvalidInputFormat, SubmissionFailFields

        This creates an empty submission for the requested context,
        and returns submissionStatus with empty fields and a Submission Unique String,
        This is the unique token used during the submission procedure.
        sessionGUS is used as authentication secret for the next interaction.
        expire after the time set by Admin (Context dependent setting)
        """

        context_iface = Context()
        try:
            request = validateMessage(self.request.body, requests.wbSubmissionDesc)

            # XXX DUMMY PATCH CLIENT USAGE -- open tiket in GLClient
            print "Before", request
            if not request.has_key('wb_fields'):
                request.update({'wb_fields' : ''})
            if not request.has_key('receivers'):
                request.update({'receivers' : []})
            if not request.has_key('files'):
                request.update({'files' : []})
            if not request.has_key('finalize'):
                request.update({'finalize' : False })
            print "After ", request
            # XXX DUMMY PATCH CLIENT USAGE -- open tiket in GLClient

            context_desc = yield context_iface.get_single(request['context_gus'])

            submission_iface = Submission()
            submission_desc = yield submission_iface.new(request)

            if not context_desc['selectable_receiver']:
                submission_iface.receivers = context_iface.receivers

            if submission_desc['finalize']:

                internaltip_iface = InternalTip()
                wb_iface = WhistleblowerTip()

                internaltip_desc = yield internaltip_iface.new(submission_desc)
                wbtip_desc = yield wb_iface.new(internaltip_desc)

                submission_desc.update({'receipt' : wbtip_desc['receipt']})
            else:
                submission_desc.update({'receipt' : ''})

            self.set_status(201) # Created
            # TODO - output processing
            self.write(submission_desc)

        except ContextGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})
예제 #2
0
    def put(self, submission_gus, *uriargs):
        """
        Parameter: submission_gus
        Request: wbSubmissionDesc
        Response: wbSubmissionDesc
        Errors: ContextGusNotFound, InvalidInputFormat, SubmissionFailFields, SubmissionGusNotFound, SubmissionConcluded

        PUT update the submission and finalize if requested.
        """

        context_iface = Context()
        try:
            request = validateMessage(self.request.body, requests.wbSubmissionDesc)

            context_desc = yield context_iface.get_single(request['context_gus'])

            submission_iface = Submission()
            submission_desc = yield submission_iface.update(submission_gus, request)

            if not context_desc['selectable_receiver']:
                submission_iface.receivers = context_iface.receivers

            if submission_desc['finalize']:

                internaltip_iface = InternalTip()
                wb_iface = WhistleblowerTip()

                internaltip_desc = yield internaltip_iface.new(submission_desc)
                wbtip_desc = yield wb_iface.new(internaltip_desc)

                submission_desc.update({'receipt' : wbtip_desc['receipt']})
            else:
                submission_desc.update({'receipt' : ''})

            self.set_status(202) # Updated
            # TODO - output processing
            self.write(submission_desc)

        except ContextGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})