Commit 46b6288a authored by Ivan Tyagov's avatar Ivan Tyagov

Support new OOOd return format (fail/retry approach soon to be added)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14405 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24cc9adc
...@@ -381,18 +381,19 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -381,18 +381,19 @@ class OOoDocument(File, ConversionCacheMixin):
on the object. Update metadata information. on the object. Update metadata information.
""" """
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try: response_code, response_dict, response_message = server_proxy.run_convert(self.getSourceReference() or self.getId(),
kw = server_proxy.run_convert(self.getSourceReference() or self.getId(),
enc(_unpackData(self.getData()))) enc(_unpackData(self.getData())))
except Exception, inst: if response_code == 200:
# Catch, log and raise errors with converting server.Explicitly raise the exception! # sucessfully converted document
self._setBaseData(dec(response_dict['data']))
metadata = response_dict['meta']
self._base_metadata = metadata
if metadata.get('MIMEType', None) is not None:
self._setBaseContentType(metadata['MIMEType'])
else:
# log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error converting document to base format %s' %inst) LOG('[DMS]', ERROR, 'Error converting document to base format %s' %inst)
raise Exception raise ConversionError(response_code), response_message
self._setBaseData(dec(kw['data']))
metadata = kw['meta']
self._base_metadata = metadata
if metadata.get('MIMEType', None):
self._setBaseContentType(metadata['MIMEType'])
security.declareProtected(Permissions.AccessContentsInformation, 'getContentInformation') security.declareProtected(Permissions.AccessContentsInformation, 'getContentInformation')
def getContentInformation(self): def getContentInformation(self):
...@@ -400,7 +401,6 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -400,7 +401,6 @@ class OOoDocument(File, ConversionCacheMixin):
Returns the metadata extracted by the conversion Returns the metadata extracted by the conversion
server. server.
""" """
# LOG('in getContentInformation', 0, self.getRelativeUrl())
return self._base_metadata return self._base_metadata
security.declareProtected(Permissions.ModifyPortalContent, 'updateBaseMetadata') security.declareProtected(Permissions.ModifyPortalContent, 'updateBaseMetadata')
...@@ -411,12 +411,13 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -411,12 +411,13 @@ class OOoDocument(File, ConversionCacheMixin):
through the invocation of the conversion server. through the invocation of the conversion server.
""" """
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try: response_code, response_dict, response_message = server_proxy.run_setmetadata(self.getId(),
kw = server_proxy.run_setmetadata(self.getId(), enc(_unpackData(self.getBaseData())),
enc(_unpackData(self.getBaseData())), kw)
kw) if response_code == 200:
except Exception, inst: # successful meta data extraction
# Catch, log and raise errors with converting server.Explicitly raise the exception! self._setBaseData(dec(response_dict['data']))
else:
# log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error getting document\'s metadata %s' %inst) LOG('[DMS]', ERROR, 'Error getting document\'s metadata %s' %inst)
raise Exception raise ConversionError(response_code), response_message
self._setBaseData(dec(kw['data']))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment