maarch: log storeResource SOAP calls (#8899)

This commit is contained in:
Serghei Mihai 2015-11-06 15:42:16 +01:00 committed by Thomas NOEL
parent 923937cdf8
commit 79ef3d79dc
1 changed files with 21 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import json
import urlparse
import requests
from datetime import datetime
import logging
from django.core.urlresolvers import reverse
from django.views.generic import DetailView as GenericDetailView
@ -31,6 +32,8 @@ from .soap import get_client, client_to_jsondict, recursive_asdict
from .models import Management
from .forms import ManagementForm, ManagementUpdateForm
logger = logging.getLogger('passerelle.contrib.maarch')
class MaarchException(Exception):
pass
@ -226,9 +229,15 @@ class ResourceView(DetailView):
#
# call Maarch web services
#
logger.debug('storeResource+Ext+Attachment: start')
# store the resource (storeResource)
logger.debug('storeResource: encodedFile(size):%r fileFormat:%r '
'collId:%r table:%r status:%r', len(encodedFile),
fileFormat, collId, table, status)
logger.debug('storeResource: metadata: %r', metadata)
if maarch_id:
logger.debug('storeResource: INES maarch_id: %r', maarch_id)
results = client.service.storeResource(
maarch_id,
encodedFile, metadata, collId,
@ -238,13 +247,19 @@ class ResourceView(DetailView):
encodedFile, metadata, collId,
table, fileFormat, status)
data = recursive_asdict(results)
logger.debug('storeResource result: %r', data)
resId = data.get('resId')
if not resId:
raise MaarchException('no resId after storeResource')
logger.debug('storeResource result: resId:%r', resId)
logger.debug('storeExtResource: resId:%r ext_table:%r', resId,
ext_table)
logger.debug('storeExtResource: ext_metadata: %r', ext_metadata)
# store external metadata (storeExtResource)
if maarch_id:
logger.debug('storeExtResource: INES maarch_id: %r', maarch_id)
results = client.service.storeExtResource(
maarch_id,
resId, ext_metadata, ext_table)
@ -254,7 +269,12 @@ class ResourceView(DetailView):
# store attachments
for attachment in attachments:
logger.debug('storeAttachmentResource: resId:%r collId:%r '
'content(size):%r fileFormat:%r filename:%r', resId,
collId, len(attachment['content']),
attachment['fileFormat'], attachment['filename'])
if maarch_id:
logger.debug('storeAttachmentResource: INES maarch_id: %r', maarch_id)
client.service.storeAttachmentResource(
maarch_id,
resId, collId, attachment['content'],
@ -267,4 +287,5 @@ class ResourceView(DetailView):
if debug:
data['debug'] = debug_output
logger.debug('storeResource+Ext+Attachment: resId:%r -- end', resId)
return utils.response_for_json(request, data)