diff --git a/ckanext/harvest/controllers/view.py b/ckanext/harvest/controllers/view.py index f537cab..b950231 100644 --- a/ckanext/harvest/controllers/view.py +++ b/ckanext/harvest/controllers/view.py @@ -252,7 +252,15 @@ class ViewController(BaseController): # Check content type. It will probably be either XML or JSON try: - content = re.sub('<\?xml(.*)\?>','', obj['content']) + + if obj['content']: + content = obj['content'] + elif 'original_document' in obj['extras']: + content = obj['extras']['original_document'] + else: + abort(404,_('No content found')) + + content = re.sub('<\?xml(.*)\?>','',content) etree.fromstring(content) response.content_type = 'application/xml' except XMLSyntaxError: @@ -262,8 +270,8 @@ class ViewController(BaseController): except ValueError: pass - response.headers['Content-Length'] = len(obj['content']) - return obj['content'] + response.headers['Content-Length'] = len(content) + return content except NotFound: abort(404,_('Harvest object not found')) except NotAuthorized,e: diff --git a/ckanext/harvest/logic/dictization.py b/ckanext/harvest/logic/dictization.py index e351efd..8eb9238 100644 --- a/ckanext/harvest/logic/dictization.py +++ b/ckanext/harvest/logic/dictization.py @@ -44,10 +44,13 @@ def harvest_object_dictize(obj, context): out['package'] = obj.package.id out['errors'] = [] - for error in obj.errors: out['errors'].append(error.as_dict()) + out['extras'] = {} + for extra in obj.extras: + out['extras'][extra.key] = extra.value + return out def _get_source_status(source, context):