Ignore:
Timestamp:
10/02/09 17:33:35 (11 years ago)
Author:
cbyrom
Message:

Update ndgRetrieve to use new clients suite + tidy up logic slightly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/dal/ndgRetrieve.py

    r4834 r4932  
    66import cgi,time, logging 
    77import DocumentRetrieve 
    8 from ndg.common.src.clients.ws.ndgSearch import ndgSearch 
     8from ndg.common.src.clients.xmldb.eXist.searchclient import SearchClient 
     9import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 
     10from ndg.common.src.clients.ws.discoveryserviceclient import DiscoveryServiceClient 
    911from ndg.common.src.models.ndgObject import ndgObject as no 
    1012 
    11 MOLES_COLLECTION = '/db/ndg_B_metadata' 
    12 ATOM_COLLECTION = '/db/atoms' 
    13 ATOM_BACKUP_COLLECTION = '/db/atoms_backup' 
    14 NUMSIM_COLLECTION = '/db/NumSim' 
    15 NDGA0_COLLECTION = '/db/ndg_A_metadata' 
    16 DIF_COLLECTION = '/db/DIF' 
    1713 
    1814class NDGRetrieveError(Exception): 
     
    3127            If discovery is non-zero AND the schema is in  
    3228                [DIF,MDIP,or ISO] 
    33         then use the ndgSearch interface to obtain the document rather 
     29        then use the discoveryserviceclient class to obtain the document rather 
    3430        than direct from an eXist database.''' 
    3531     
     
    4844            logging.debug("Using Discovery service") 
    4945            if uri.schema in no.DISCOVERY_SCHEMES: 
    50                 ws=ndgSearch() 
     46                ws = DiscoveryServiceClient() 
    5147            else: 
    5248                raise NDGRetrieveError('Invalid schema (%s) with discovery \ 
     
    8379 
    8480                logging.debug("Retrieving data from repository, '%s'" %er) 
    85                 ws=DocumentRetrieve.DocumentRetrieve(er,pwfile=pwf) 
     81                ws = SearchClient(dbHostName = er, 
     82                                  configFileName = pwf) 
    8683        return 1,ws 
     84 
    8785     
    8886    status,ws=getws(config,uri,remote) 
     
    9189            
    9290    if uri.schema==no.NDGA0_DOC_TYPE: 
    93         target = NDGA0_COLLECTION 
     91        target = dc.NDG_A_COLLECTION_PATH 
    9492    elif uri.schema == no.NUMSIM_DOC_TYPE: 
    95         target = NUMSIM_COLLECTION 
     93        target = dc.NUMSIM_COLLECTION_PATH 
    9694    elif uri.schema == no.ATOM_DOC_TYPE: 
    97         target = ATOM_COLLECTION  
     95        target = dc.ATOM_COLLECTION_PATH 
    9896    elif uri.schema == no.ATOM_BACKUP_DOC_TYPE: 
    99         target = ATOM_BACKUP_COLLECTION 
     97        target = dc.BACKUP_COLLECTION_PATH 
    10098    elif uri.schema == no.BROWSE_DIF_DOC_TYPE: 
    101         target = DIF_COLLECTION  
     99        target = dc.DIF_COLLECTION_PATH  
    102100    else: 
    103         target = MOLES_COLLECTION 
     101        target = dc.MOLES_COLLECTION_PATH 
    104102    
     103    # strip trainling slashes, if required 
     104    if target.endswith('/'): 
     105        target = target[0:-1] 
     106         
    105107    #do the actual retrieve: 
    106108    e=None 
    107109    try: 
    108110        time1=time.time() 
    109         r=ws.get(uri.repository,uri.schema,uri.localID,targetCollection=target) 
     111         
     112        r=ws.getNDGDoc(uri.repository,uri.schema,uri.localID,targetCollection=target) 
    110113        time2=time.time()-time1 
    111114        logging.info('Document retrieve [%s] took [%s]'%(uri,time2)) 
Note: See TracChangeset for help on using the changeset viewer.