Changeset 4828


Ignore:
Timestamp:
19/01/09 09:50:19 (11 years ago)
Author:
cbyrom
Message:

Improve exist client checking of results + extend logging + add support
for producing DIF feeds + improve error handling.

Location:
ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/existdbclient.py

    r4810 r4828  
    183183            validationQuery = 'validation:validate-report("' + atomPath + \ 
    184184                '", xs:anyURI("' + self.AtomSchema + '"))' 
     185            logging.debug("Running validation, '%s'" %validationQuery) 
     186 
    185187            id, result = self.xmldb.executeQuery(validationQuery) 
    186188            errorMessage = None 
     
    189191            elif result['hits'] > 1: 
    190192                errorMessage = "More than one atom was validated - expecting only a single atom validation - please retry" 
     193                 
    191194        except Exception, e: 
    192195            errorMessage = "Error encountered whilst validating atom: '%s'" %e.message 
     
    270273            logging.info("File does not exist in eXist DB") 
    271274            return None 
     275         
     276        # check status of result 
     277        doc = self.xmldb.retrieve(id, 0) 
     278        et = ET.fromstring(doc) 
     279        status = et.findtext('status') 
     280        if status == 'invalid': 
     281            raise SystemError("Problem occured whilst looking up file, '%s'" %docPath) 
     282         
    272283        logging.info("Found file - returning result ID") 
    273284        return id 
     
    759770        logging.info("Creating and storing DIF document") 
    760771        doc = self.transformAtomIntoDIF(atom) 
    761         fileName = atom.atomName.replace('.atom', '.dif') 
     772        fileName = atom.atomName.replace('.atom', '.xml') 
    762773         
    763774        # now add to eXist 
    764775        providerID = atom.ME.providerID 
    765776        collectionPath = ec.DIF_COLLECTION_PATH + providerID 
    766         # NB, check if provider collection exists; if not, add this with a feed 
     777         
     778        # NB, check if a top level provider collection exists; if not, add  
     779        # this with a feed 
    767780        # NB, the collection will be created along with the DIF file - so set the 
    768781        # feed up after the file has been created 
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/existdbfeedclient.py

    r4810 r4828  
    128128        # add to DIF feeds - if appropriate 
    129129        if atom.isDE(): 
    130             self.createAtomFeedEntry(ec.DIF_COLLECTION_PATH, atom) 
     130            self.createAtomFeedEntry(ec.DIF_COLLECTION_PATH, atom, isDIFRecord=True) 
    131131            self.createAtomFeedEntry(ec.DIF_COLLECTION_PATH + atom.ME.providerID + '/',  
    132                                      atom) 
     132                                     atom, isDIFRecord=True) 
    133133         
    134134 
     
    206206        if not suppressPrefix: 
    207207            url = self.REST_BASE_URL + docPath 
    208         try: 
    209             connection.request("GET", '%s' %(url)) 
    210             response = connection.getresponse() 
    211              
    212             if response.status == 200: 
    213                 logging.info("Document successfully retrieved - returning this now") 
    214                 return response.read() 
    215         except Exception, e: 
    216             import pdb 
    217             pdb.set_trace() 
     208 
     209        connection.request("GET", '%s' %(url)) 
     210        response = connection.getresponse() 
     211         
     212        if response.status == 200: 
     213            logging.info("Document successfully retrieved - returning this now") 
     214            return response.read() 
    218215         
    219216        logging.info("- no document found at path, '%s'" %docPath) 
Note: See TracChangeset for help on using the changeset viewer.