source: TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcsx.py @ 2966

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcsx.py@2966
Revision 2966, 2.9 KB checked in by domlowe, 13 years ago (diff)

returning correct content type for invalid request #2

Line 
1# Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council).
2# This software may be distributed under the terms of the
3# Q Public License, version 1.0 or later.
4# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
5"""
6Controller that redirects WCS requests to the controller for the correct version of WCS
7@author: Dominic Lowe
8"""
9
10from ows_server.lib.base import *
11from ows_server.lib.decorators import *
12from ows_server.controllers import csml_wcs1_1_0, csml_wcs1_0_0
13import sys
14
15class CsmlWcsxController(OwsController):
16    ''' Overarching version independent wcs controller that passes request to correct version of WCS controller (eg 1.0.0 or 1.1.1 etc) '''     
17       
18    def _getWCSController(self):
19        ''' return the wcs controller that corresponds to the version requested
20        called from within the other methods, which have already performed validation on the version parameter '''
21        if self.version not in ['1.0.0', '1.1.0']: 
22            self.version='1.0.0' #default is 1.0.0
23       
24        if self.version == '1.0.0':
25            ctrl=csml_wcs1_0_0.CsmlWcs100Controller()
26            return ctrl(request.environ, self.start_response)
27        elif self.version == '1.1.0':
28            ctrl=csml_wcs1_1_0.CsmlWcs110Controller()
29            return ctrl(request.environ, self.start_response)
30       
31       
32    @operation
33    @parameter('Version', possibleValues=['','1.0.0','1.1.0'])
34    def GetCapabilities(self, version=None):
35        """
36        Use the right controller (correct version) to perform the getCapabilities operation
37        """
38        self.version=version
39        return self._getWCSController()
40           
41    @operation   
42    @parameter('Version', possibleValues=['1.0.0','1.1.0'])
43    def DescribeCoverage(self, version=None):
44        """
45        Use the right controller (correct version) to perform the DescribeCoverage operation
46        """
47        if version not in ['1.0.0','1.1.0']:
48            e=OWS_E.OwsError('Missing parameter',text='Version parameter missing', version = '1.0.0')           
49            c.ex=e.report               
50            r=render_response('ogc_se', format='xml')
51            r.headers['content-type'] = 'application/vnd.ogc.se_xml'
52            return r
53        self.version=version
54        return self._getWCSController()
55       
56       
57    @operation
58    @parameter('Version', possibleValues=['1.0.0','1.1.0'])
59    def GetCoverage(self, version=None):
60        """
61        Use the right controller (correct version) to perform the GetCoverage operation
62        """       
63        if version not in ['1.0.0','1.1.0']:
64            e=OWS_E.OwsError('Missing parameter',text='Version parameter missing', version = '1.0.0')           
65            c.ex=e.report               
66            r=render_response('ogc_se', format='xml')
67            r.headers['content-type'] = 'application/vnd.ogc.se_xml'
68            return r
69        self.version=version
70        return self._getWCSController()
Note: See TracBrowser for help on using the repository browser.