def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.title = name headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url=store.resource_url if jdbc_virtual_table is not None: feature_type.metadata=({'JDBC_VIRTUAL_TABLE':jdbc_virtual_table}) params = dict() resource_url=url(self.service_url, ["workspaces", store.workspace.name, "datastores", store.name, "featuretypes.json"], params) headers, response = self.http.request(resource_url, "POST", feature_type.message(), headers) feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.title = name headers = { "Content-type": "application/xml", "Accept": "application/xml" } headers, response = self.http.request(store.resource_url, "POST", feature_type.message(), headers) feature_type.fetch() return feature_type
def publish_postgis_table(self, data, reload_gs_slaves=True, native_crs=None, srs=None, overwrite=False): try: '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer name = data["layerName"] title = data["title"] if "title" in data else name store = self.gs_master.get_store(data["store"]) # #if native_crs is None: raise ValueError("must specify native_crs") #srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name # feature_type.dirty['srs'] = srs # feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.title = title headers = { "Content-type": "application/xml", "Accept": "application/xml" } headers, response = self.gs_master.http.request(store.resource_url, "POST", feature_type.message(), headers) if headers.status != 201: raise Exception(response, headers.status) # defaultStyle if "defaultStyle" in data: # TODO: test it self.set_style(name, store.workspace.name, data["defaultStyle"], False) # reload geoservers if reload_gs_slaves: self.reload_gs_slaves() return feature_type except Exception, (response, status): raise Exception(response, status)
def publish_featuretype(self, name, store, native_crs, srs=None): """Publish a featuretype from data in an existing store""" # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty["name"] = name feature_type.dirty["srs"] = srs feature_type.dirty["nativeCRS"] = native_crs feature_type.enabled = True feature_type.title = name headers = {"Content-type": "application/xml", "Accept": "application/xml"} headers, response = self.http.request(store.resource_url, "POST", feature_type.message(), headers) feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None, native_name=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.advertised = True feature_type.title = name if native_name is not None: feature_type.native_name = native_name headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url = store.resource_url if jdbc_virtual_table is not None: feature_type.metadata = ({ 'JDBC_VIRTUAL_TABLE': jdbc_virtual_table }) params = dict() resource_url = build_url(self.service_url, [ "workspaces", store.workspace.name, "datastores", store.name, "featuretypes.xml" ], params) resp = self.http_request(resource_url, method='post', data=feature_type.message(), headers=headers) if resp.status_code not in (200, 201, 202): raise FailedRequestError( 'Failed to publish feature type {} : {}, {}'.format( name, resp.status_code, resp.text)) self._cache.clear() feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None,keywords=None,title=None,abstract=None,nativeName=None,jdbc_virtual_table=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") if native_crs == "EPSG:0": raise ValueError("CRS was set as EPSG:0! Check that the Input object is specified with a valid CRS") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs if nativeName: feature_type.dirty["nativeName"] = nativeName else: feature_type.dirty["nativeName"] = name if title: feature_type.dirty['title'] = title else: feature_type.title = name if abstract: feature_type.dirty['abstract'] = abstract if keywords: feature_type.dirty['keywords'] = keywords feature_type.enabled = True headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url=store.resource_url if jdbc_virtual_table is not None: feature_type.metadata=({'JDBC_VIRTUAL_TABLE':jdbc_virtual_table}) params = dict() resource_url=url(self.service_url, ["workspaces", store.workspace.name, "datastores", store.name, "featuretypes.json"], params) headers, response = self.http.request(resource_url, "POST", feature_type.message(), headers) if int(headers['status']) >= 400: raise Exception("publish feature failed.\nresponse headers:{}\nreason:{}".format(headers,response)) feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None, keywords=None, title=None, abstract=None, nativeName=None, jdbc_virtual_table=None, nativeBoundingBox=None, latLonBoundingBox=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") if native_crs == "EPSG:0": raise ValueError( "CRS was set as EPSG:0! Check that the Input object is specified with a valid CRS" ) srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs if nativeName: feature_type.dirty["nativeName"] = nativeName else: feature_type.dirty["nativeName"] = name if title: feature_type.dirty['title'] = title else: feature_type.title = name if latLonBoundingBox: feature_type.dirty["latLonBoundingBox"] = latLonBoundingBox if nativeBoundingBox: feature_type.dirty["nativeBoundingBox"] = nativeBoundingBox if abstract: feature_type.dirty['abstract'] = abstract if keywords: feature_type.dirty['keywords'] = keywords feature_type.enabled = True headers = {"Content-type": "application/xml", "Accept": "application/xml"} resource_url = store.resource_url if jdbc_virtual_table is not None: feature_type.metadata = ({ 'JDBC_VIRTUAL_TABLE': jdbc_virtual_table, 'cachingEnabled': 'false' }) params = dict() resource_url = url(self.service_url, [ "workspaces", store.workspace.name, "datastores", store.name, "featuretypes.json" ], params) headers, response = self.http.request(resource_url, "POST", feature_type.message(), headers) if int(headers['status']) >= 400: raise Exception( "publish feature failed.\nresponse headers:{}\nreason:{}".format( headers, response)) feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None, native_name=None): '''Publish a featuretype from data in an existing store''' # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") if jdbc_virtual_table is None and native_name is None: raise ValueError("must specify native_name") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.advertised = True feature_type.title = name if native_name is not None: feature_type.native_name = native_name headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url = store.resource_url if jdbc_virtual_table is not None: feature_type.metadata = ({'JDBC_VIRTUAL_TABLE': jdbc_virtual_table}) params = dict() resource_url = build_url( self.service_url, [ "workspaces", store.workspace.name, "datastores", store.name, "featuretypes.xml" ], params ) resp = self.http_request(resource_url, method='post', data=feature_type.message(), headers=headers) if resp.status_code not in (200, 201, 202): FailedRequestError('Failed to publish feature type {} : {}, {}'.format(name, resp.status_code, resp.text)) self._cache.clear() feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None, native_bbox=None): """ Publish a featuretype from data in an existing store """ # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs if native_bbox is not None: feature_type.native_bbox = native_bbox feature_type.enabled = True feature_type.title = name headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url = store.resource_url if jdbc_virtual_table is not None: feature_type.metadata = ({ 'JDBC_VIRTUAL_TABLE': jdbc_virtual_table }) params = dict() resource_url = urljoin( self.service_url, "workspaces/{}/datastores/{}/featuretypes.json".format( store.workspace.name, store.name ) ) # What is the use of this request? r = self.session.post(resource_url, data=feature_type.message(), headers=headers, params=params) if r.status_code < 200 or r.status_code > 299: raise UploadError(r.text) feature_type.fetch() return feature_type
def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None): """Publish a featuretype from data in an existing store""" # @todo native_srs doesn't seem to get detected, even when in the DB # metadata (at least for postgis in geometry_columns) and then there # will be a misconfigured layer if native_crs is None: raise ValueError("must specify native_crs") srs = srs or native_crs feature_type = FeatureType(self, store.workspace, store, name) # because name is the in FeatureType base class, work around that # and hack in these others that don't have xml properties feature_type.dirty['name'] = name feature_type.dirty['srs'] = srs feature_type.dirty['nativeCRS'] = native_crs feature_type.enabled = True feature_type.title = name headers = { "Content-type": "application/xml", "Accept": "application/xml" } resource_url = store.resource_url if jdbc_virtual_table is not None: feature_type.metadata = ({ 'JDBC_VIRTUAL_TABLE': jdbc_virtual_table }) resource_url = url(self.service_url, [ "workspaces", store.workspace.name, "datastores", store.name, "featuretypes.json" ]) self.request(method='post', url=resource_url, headers=headers, data=feature_type.message()) feature_type.fetch() return feature_type