Beispiel #1
0
    def on_before_append_item(self, item):
        # type: (FileTransferChannel) -> FileTransferChannel

        if item.service_list:
            item.service_list = item.service_list if isinstance(
                item.service_list, list) else [item.service_list]
            item.service_list = sorted(item.service_list)
            item.service_list_json = dumps(item.service_list)

        if item.topic_list:
            item.topic_list = item.topic_list if isinstance(
                item.topic_list, list) else [item.topic_list]
            item.topic_list = sorted(item.topic_list)
            item.topic_list_json = dumps(item.topic_list)

        if item.outconn_rest_list:

            # All REST outgoing connections for the cluster
            all_outconn_rest_list = get_outconn_rest_list(self.req)

            item.outconn_rest_list = item.outconn_rest_list if isinstance(item.outconn_rest_list, list) else \
                [item.outconn_rest_list]
            item.outconn_rest_list_by_name = sorted(
                all_outconn_rest_list[int(elem)]
                for elem in item.outconn_rest_list if elem)
            item.outconn_rest_list_json = dumps(item.outconn_rest_list)

        return item
Beispiel #2
0
    def post_process_return_data(self, return_data):

        service_list_html = ''
        topic_list_html   = ''
        outconn_rest_list_html   = ''

        cluster_id = self.input_dict['cluster_id']
        service_list = sorted(set(self.input_dict['service_list'] or []))
        topic_list = sorted(set(self.input_dict['topic_list'] or []))
        outconn_rest_list = self.input_dict['outconn_rest_list'] or []

        if outconn_rest_list:

            # All REST outgoing connections for the cluster
            all_outconn_rest_list = get_outconn_rest_list(self.req)

            outconn_rest_list = outconn_rest_list if isinstance(outconn_rest_list, list) else [outconn_rest_list]
            outconn_rest_list = sorted(set(all_outconn_rest_list[int(elem)] for elem in outconn_rest_list if elem))

        #
        # Services
        #

        for service_name in service_list:

            if not service_name:
                continue

            # The list of services as HTML
            service_list_html += """
            <span class="form_hint">S</span>→
                <a href="/zato/service/overview/{service_name}/?cluster={cluster_id}">{service_name}</a>
            <br/>
            """.format(**{
                'service_name': service_name,
                'cluster_id': cluster_id
            })

        #
        # Topics
        #

        for topic_name in topic_list:

            if not topic_name:
                continue

            # The list of topics as HTML
            topic_list_html += """
            <span class="form_hint">T</span>→
                <a href="/zato/pubsub/topic/?cluster={cluster_id}&amp;query={topic_name}">{topic_name}</a>
            <br/>
            """.format(**{
                'topic_name': topic_name,
                'cluster_id': cluster_id
            })

        #
        # REST
        #

        for outconn_name in outconn_rest_list:

            if not outconn_name:
                continue

            # The list of REST outconns as HTML
            outconn_rest_list_html += """
            <span class="form_hint">R</span>→
                <a href="/zato/http-soap/?cluster={cluster_id}&amp;connection=outgoing&amp;transport=plain_http&amp;query={outconn_name}">{outconn_name}</a>
            <br/>
            """.format(**{
                'outconn_name': outconn_name,
                'cluster_id': cluster_id
            })

        # Get human-readable names of the source for this channel
        if self.input.source_type == source_type_local:
            # Nothing to do in this case
            pass

        elif self.input.source_type == source_type_ftp:

            if self.input.ftp_source_id:
                response = self.req.zato.client.invoke('zato.outgoing.ftp.get-by-id', {
                    'cluster_id': cluster_id,
                    'id': self.input.ftp_source_id,
                })

                return_data['ftp_source_name'] = response.data['name']

        elif self.input.source_type == source_type_sftp:
            raise NotImplementedError()

        else:
            raise ValueError('Unknown self.input.source_type')

        #
        # Return data
        #

        return_data['recipients_html'] = service_list_html + topic_list_html + outconn_rest_list_html
        return_data['service_list'] = service_list
        return_data['topic_list'] = topic_list
        return_data['outconn_rest_list'] = outconn_rest_list