Changeset 4720


Ignore:
Timestamp:
05/01/09 09:35:49 (11 years ago)
Author:
cbyrom
Message:

Improve handling of errors when doing validation + granulite ingests.

Location:
exist/trunk/python/ndgUtils/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/lib/existdbclient.py

    r4696 r4720  
    147147        ''' 
    148148        logging.info("Validating atom, '%s' against schemae in eXist" %atomPath) 
    149          
    150         if atom: 
    151             logging.info("Creating temporary file in eXist to do validation against") 
    152             fileName = atom.datasetID + str(datetime.datetime.today().microsecond) 
    153             self.createEXistFile(atom.toPrettyXML(), \ 
    154                                  atom.getDefaultCollectionPath(), fileName) 
    155             atomPath = atom.getDefaultCollectionPath() + fileName 
    156              
    157         validationQuery = 'validation:validate-report("' + atomPath + \ 
    158             '", xs:anyURI("' + self.AtomSchema + '"))' 
    159         id, result = self.xmldb.executeQuery(validationQuery) 
    160         errorMessage = None 
    161         if result['hits'] == 0:  
    162             errorMessage = "Validation did not complete successfully - please retry" 
    163         elif result['hits'] > 1: 
    164             errorMessage = "More than one atom was validated - expecting only a single atom validation - please retry" 
     149        try: 
     150            if atom: 
     151                logging.info("Creating temporary file in eXist to do validation against") 
     152                fileName = atom.datasetID + str(datetime.datetime.today().microsecond) 
     153                self.createEXistFile(atom.toPrettyXML(), \ 
     154                                     atom.getDefaultCollectionPath(), fileName) 
     155                atomPath = atom.getDefaultCollectionPath() + fileName 
     156                 
     157            validationQuery = 'validation:validate-report("' + atomPath + \ 
     158                '", xs:anyURI("' + self.AtomSchema + '"))' 
     159            id, result = self.xmldb.executeQuery(validationQuery) 
     160            errorMessage = None 
     161            if result['hits'] == 0:  
     162                errorMessage = "Validation did not complete successfully - please retry" 
     163            elif result['hits'] > 1: 
     164                errorMessage = "More than one atom was validated - expecting only a single atom validation - please retry" 
     165        except Exception, e: 
     166            errorMessage = "Error encountered whilst validating atom: '%s'" %e.message 
    165167 
    166168        if atom: 
  • exist/trunk/python/ndgUtils/lib/granulite.py

    r4697 r4720  
    604604                self.__addGranuleToDataEntityRecords() 
    605605            except: 
    606                 logging.error("Exception thrown whilst updating data entities - detail: ") 
    607                 logging.error(sys.exc_info()) 
    608                 logging.error("Will now roll back changes to granule atom to leave system in original state") 
     606                errorMessage = "Exception thrown whilst updating data entities - detail: " + \ 
     607                    str(sys.exc_info()) + \ 
     608                    "Will now roll back changes to granule atom to leave system in original state" 
     609                logging.error(errorMessage) 
    609610                self.deleteGranuleAndDEReferences() 
    610611 
     
    613614                    self._eXist.restoreBackup(self._eXist.backupName) 
    614615                    self.__restoreGranuleToDataEntityRecords() 
     616                raise SystemError(errorMessage) 
    615617                 
    616618        logging.info("granulite processing complete") 
Note: See TracChangeset for help on using the changeset viewer.