'Respond to an incoming push from the peer repository
@param source: the input stream (list of file-like objects)
@param resource: the target resource
@param strategy: the import strategy
@param update_policy: the update policy
@param conflict_policy: the conflict resolution policy
@param onconflict: callback for conflict resolution
@param last_sync: the last synchronization date/time for the peer
@param mixed: negotiate resource with peer (disregard resource)'

def receive(self, source, resource, strategy=None, update_policy=None, conflict_policy=None, onconflict=None, last_sync=None, mixed=False):

    s3db = current.s3db
    xml = current.xml
    log = self.log
    remote = False
    source = source[0]
    tree = xml.parse(source)
    if (not tree):
        msg = (xml.error if xml.error else 'Invalid    source')
        return {'status': log.FATAL, 'message': msg, 'remote': remote, 'response': xml.json_message(False, 400, msg)}
    category = tree.findall('//channel/category')
    if (not category):
        msg = 'Feed    category    missing'
        return {'status': log.ERROR, 'message': msg, 'remote': remote, 'response': xml.json_message(False, 400, msg)}
    category = category[0].text
    if (category == 'AVL'):
        resource = s3db.resource('pr_group')
    elif (category == 'Incidents'):
        resource = s3db.resource('event_incident')
        resource.configure(oncommit_import_item=self.update_assignments)
    else:
        msg = 'Unknown    feed    category'
        return {'status': log.WARNING, 'message': msg, 'remote': remote, 'response': xml.json_message(False, 400, msg)}
    repository = self.repository
    if repository.keep_source:
        self.keep_source(tree, category)
    stylesheet = os.path.join(current.request.folder, 'static', 'formats', 'georss', 'import.xsl')
    if onconflict:
        onconflict_callback = (lambda item: onconflict(item, repository, resource))
    else:
        onconflict_callback = None
    ignore_errors = True
    s3 = current.response.s3
    s3.repository_id = self.repository.id
    output = resource.import_xml(tree, format='xml', stylesheet=stylesheet, ignore_errors=ignore_errors, strategy=strategy, update_policy=update_policy, conflict_policy=conflict_policy, last_sync=last_sync, onconflict=onconflict_callback, source_type='adashi')
    s3.repository_id = None
    if (resource.error_tree is not None):
        result = (log.WARNING if ignore_errors else log.FATAL)
        message = ('%s' % resource.error)
        for element in resource.error_tree.findall('resource'):
            error_msg = element.get('error', 'unknown    error')
            error_fields = element.findall('data[@error]')
            if error_fields:
                for field in error_fields:
                    error_msg = field.get('error', 'unknown    error')
                    if error_msg:
                        msg = ('(UID:    %s)    %s.%s=%s:    %s' % (element.get('uuid', None), element.get('name', None), field.get('field', None), field.get('value', field.text), error_msg))
                        message = ('%s,    %s' % (message, msg))
            else:
                msg = ('(UID:    %s)    %s:    %s' % (element.get('uuid', None), element.get('name', None), error_msg))
                message = ('%s,    %s' % (message, msg))
    else:
        result = log.SUCCESS
        message = 'Data    received    from    peer'
    return {'status': result, 'remote': remote, 'message': message, 'response': output}
