Changeset 2860
- Timestamp:
- 30/08/07 11:42:47 (14 years ago)
- Location:
- TI05-delivery/ows_framework/trunk/ows_server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/trunk/ows_server/development.ini
r2769 r2860 33 33 configfile = %(here)s/ndgDiscovery.config 34 34 #the password file needs to be outside the egg: 35 passwordFile = %(here)s/passwords.txt36 35 #passwordFile = %(here)s/passwords.txt 36 #but it's gone back to ndgDiscoveryq 37 37 38 38 # If you'd like to fine-tune the individual locations of the cache data dirs -
TI05-delivery/ows_framework/trunk/ows_server/ndgDiscovery.config
r2800 r2860 13 13 # 14 14 # the following is the server on which the NDG discovery service is running! (Not to be confused with 15 # the server on which the NDG discover web service is running) 15 # the server on which the NDG discovery web service is running). This can and probably should be the local 16 # server (i.e. dont change it!) 16 17 # 17 18 ndgServer: %(server)s … … 28 29 metadataMaintainer: b.n.lawrence@rl.ac.uk 29 30 repository: http://localhost:8080 31 tbrecipient: b.n.lawrence@rl.ac.uk 30 32 33 # The following should only be needed for debugging some parts of the code when running on sandboxes behind a firewall 34 proxyServer: http://wwwcache3.rl.ac.uk:8080/ 31 35 32 36 [SEARCH] … … 81 85 neodc.nerc.ac.uk: %(server)s 82 86 badc.nerc.ac.uk: %(server)s 83 npm.ac.uk: wwwdev.npm.ac.uk/rsdas/projects/ndg 84 #grid.bodc.nerc.ac.uk: glue.badc.rl.ac.uk 85 grid.bodc.nerc.ac.uk: localhost:8001 86 ndg.noc.soton.ac.uk: ndg.noc.soton.ac.uk:8001 87 www.npm.ac.uk: http://wwwdev.neodaas.ac.uk/projects/ndg 88 grid.bodc.nerc.ac.uk: http://grid.bodc.nerc.ac.uk 89 ndg.noc.soton.ac.uk: http://ndg.noc.soton.ac.uk:8001 87 90 icon: %(layout)s/B.gif 88 91 icon_alt: B Service … … 104 107 grid.bodc.nerc.ac.uk: grid.bodc.nerc.ac.uk 105 108 ndg.noc.soton.ac.uk: ndg.noc.soton.ac.uk 106 npm.ac.uk: pgsql.npm.ac.uk 109 www.npm.ac.uk: pgsql.npm.ac.uk 110 passwordFile: /home/bnl/sandboxes/ndg/TI05-delivery/ows_framework/trunk/ows_server/passwords.txt 107 111 108 112 [NDG_SECURITY] -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DocumentRetrieve.py
r2672 r2860 2 2 from ndg_xqueries import * 3 3 from xml.dom import minidom 4 import urllib2 4 5 #from stripped_xqueries import strip_de_xquery 5 6 … … 114 115 self.sessionRelease(id) 115 116 return r 117 118 119 class RestfulGet: 120 ''' Provides a get method to obtain an xml document from a remote NDG repository ''' 121 def __init__(self,remoteHost,proxyServer=None): 122 self.remoteHost=remoteHost 123 if proxyServer is None: 124 proxyHandler=urllib2.ProxyHandler({}) 125 else: 126 proxy=proxyServer 127 if proxy[0:4]!='http':proxy='http://'+proxy 128 proxyHandler=urllib2.ProxyHandler({'http':proxy}) 129 self.opener=urllib2.build_opener(proxyHandler) 130 131 def get(self,repository,schema,localID,format='NDG-B0',targetCollection=None): 132 #TODO what about security? Probably means we need to get the headers of our responses sorted ... 133 url='%s/view/%s__%s__%s?format=raw&outputSchema=%s'%(self.remoteHost,repository,schema,localID,format) 134 #http://docs.python.org/lib/urllib2-examples.html 135 request=urllib2.Request(url) 136 response='Error obtaining remote file: ' 137 try: 138 f = self.opener.open(request) 139 response='' 140 except urllib2.URLError,e: 141 if hasattr(e,'reason'): 142 response+='No access to server [%s]'%e.reason 143 elif hasattr(e,'code'): 144 response+='Response code [%s]'%e.code 145 except socket.error: 146 response+='Network Socket problem' 147 except Exception,e: 148 response+='[%s]'%str(e) 149 if response=='': 150 return f.read() 151 else: 152 raise IOError(response) 153 -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndgRetrieve.py
r2852 r2860 5 5 6 6 7 def ndgRetrieve(uri,config,logger=0,output='' ):7 def ndgRetrieve(uri,config,logger=0,output='',remote=0): 8 8 9 ''' Given an ndgObject, uri, retrieve it, with security in place ''' 9 ''' Given an ndgObject, uri, retrieve it, with security in place. 10 If logger is non-zero it should be a python log class 11 If output is not '' it should be desired output schema (normally 12 to be used for discovery documents in a variety of outputs or 13 to indicate that an original document is required. 14 If remote is non zero, then attempt to get the document 15 from a remote site via a (secured) restful http call''' 10 16 11 12 def getws(config,uri,): 17 def getws(config,uri,remote): 13 18 ''' Get a ws connection to the local exist database ''' 14 19 # The logic here is that … … 20 25 r=config.get('NDG_B_SERVICE',uri.repository) 21 26 sr=config.get('DEFAULT','repository') 27 er=config.get('NDG_EXIST',uri.repository) 22 28 if r<> sr: 23 return 0,'The uri [%s] is not available on [%s]'%(uri,server)24 er=config.get('NDG_EXIST',uri.repository)25 26 #Changes by Dom:27 #pwf=config.get('DEFAULT','passwordFile')28 #passwordFile is now in development.ini, moved from ndgDiscovery.config29 pwf=cf= CONFIG['app_conf']['passwordFile']30 ws=DocumentRetrieve.DocumentRetrieve(er,pwfile=pwf)29 if not remote: 30 return 0,'The uri [%s] is not available on [%s]'%(uri,server) 31 else: 32 ps=config.get('DEFAULT','proxyServer') 33 ws=DocumentRetrieve.RestfulGet(r,proxyServer=ps) 34 else: 35 pwf=config.get('NDG_EXIST','passwordFile') 36 ws=DocumentRetrieve.DocumentRetrieve(er,pwfile=pwf) 31 37 return 1,ws 32 38 … … 34 40 if uri.schema in ['DIF','MDIP']: 35 41 r=server 36 ws=ndgSearch.ndgSearch()42 status,ws=1,ndgSearch.ndgSearch() 37 43 elif uri.schema[0:5]=='NDG-B' or uri.schema=='NumSim': 38 status,ws=getws(config,uri) 39 if not status: return status,ws 44 status,ws=getws(config,uri,remote) 40 45 elif uri.schema=='NDG-A0': 41 status,ws=getws(config,uri) 42 if not status: return status,ws 46 status,ws=getws(config,uri,remote) 47 48 if not status: return status,ws 49 43 50 #try: 44 51 if uri.schema=='NDG-A0': … … 48 55 else: 49 56 target='/db/ndg_B_metadata' 50 51 print uri.uri, 'Output format [%s]'%output52 57 53 58 if output=='': output=uri.schema 54 59 55 56 57 60 #do the actual retrieve: 58 61 e=None … … 90 93 91 94 def setup(self): 92 self.c=myConfig('../ config/ndgDiscovery.config')95 self.c=myConfig('../../ndgDiscovery.config') 93 96 94 97 def testSOAP(self): … … 150 153 if status: s=str(xml) 151 154 155 def testRemoteGet(self): 156 ''' Attempt a remote get ''' 157 self.setup() 158 doc='www.npm.ac.uk__NDG-B1__data_entity.692' 159 uri=ndgObject.ndgObject(doc) 160 status,xml=ndgRetrieve(uri,self.c,remote=1) 161 if not status: print xml 162 self.assertEqual(status,1) 152 163 153 164
Note: See TracChangeset
for help on using the changeset viewer.