Class: RGeoServer::Catalog
- Inherits:
-
Object
- Object
- RGeoServer::Catalog
- Includes:
- RestApiClient
- Defined in:
- lib/rgeoserver/catalog.rb
Overview
This class represents the main class of the data model, and provides all REST APIs to GeoServer. Refer to
Constant Summary
Constants included from GeoServerUrlHelpers
GeoServerUrlHelpers::URI_FORMATS, GeoServerUrlHelpers::URI_REGEX, GeoServerUrlHelpers::URI_SEQUENCES
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#each_layer(options = {}) ⇒ Array<RGeoServer::Layer>
List of available layers.
- #get_coverage(workspace, coverage_store, coverage) ⇒ Object
- #get_coverage_store(workspace, coveragestore) ⇒ RGeoServer::CoverageStore
-
#get_coverage_stores(workspace = nil) ⇒ Array<RGeoServer::CoverageStore>
List of coverage stores.
- #get_data_store(workspace, datastore) ⇒ RGeoServer::DataStore
-
#get_data_stores(workspace = nil) ⇒ Array<RGeoServer::DataStore>
List of vector based spatial data.
- #get_default_namespace ⇒ RGeoServer::Namespace
-
#get_default_workspace ⇒ RGeoServer::Workspace
Get_workspace(‘default’).
- #get_feature_type(workspace, datastore, featuretype_id) ⇒ RGeoServer::FeatureType
-
#get_feature_types(workspace, datastore, &block) ⇒ Array<RGeoServer::FeatureType>
List of feature types.
- #get_layer(layername) ⇒ RGeoServer::Layer
- #get_layergroup(layergroup) ⇒ RGeoServer::LayerGroup
-
#get_layergroups(options = {}) ⇒ Array<RGeoServer::LayerGroup>
List of available layer groups.
-
#get_namespaces ⇒ Array<RGeoServer::Namespace>
List of available namespaces.
- #get_style(style) ⇒ RGeoServer::Style
-
#get_styles ⇒ Array<RGeoServer::Style>
List of available styles.
- #get_wms_store(workspace, wmsstore) ⇒ RGeoServer::WmsStore
-
#get_wms_stores(workspace = nil) ⇒ Array<RGeoServer::WmsStore>
List of WMS stores.
- #get_workspace(ws) ⇒ RGeoServer::Workspace
-
#get_workspaces ⇒ Array<RGeoServer::Workspace>
List of available workspaces.
- #headers(format = :xml) ⇒ Object
-
#initialize(options = nil) ⇒ Catalog
constructor
A new instance of Catalog.
-
#list(klass, names, options = {}, check_remote = false) {|RGeoServer::ResourceInfo| ... } ⇒ Object
Shortcut to ResourceInfo.list to this catalog.
-
#reassign_workspace(store, workspace) ⇒ Object
deprecated
Deprecated.
see RGeoServer::Workspace
-
#reload ⇒ Object
Configuration reloading Reloads the catalog and configuration from disk.
-
#reset ⇒ Object
Resource reset Resets all store/raster/schema caches and starts fresh.
- #set_default_namespace(id, prefix, uri) ⇒ Object
-
#set_default_workspace(workspace) ⇒ Object
Assign default workspace.
- #to_s ⇒ Object
Methods included from RestApiClient
#add, #client, #do_url, #gwc_client, #modify, #purge, #rest_client, #search
Methods included from GeoServerUrlHelpers
Constructor Details
#initialize(options = nil) ⇒ Catalog
Returns a new instance of Catalog.
16 17 18 19 20 21 22 |
# File 'lib/rgeoserver/catalog.rb', line 16 def initialize = nil @config = || RGeoServer::Config[:geoserver] unless config.include?(:url) raise ArgumentError.new("Catalog: Requires :url option: #{config}") end RestClient.log = config[:logfile] || nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/rgeoserver/catalog.rb', line 10 def config @config end |
Instance Method Details
#each_layer(options = {}) ⇒ Array<RGeoServer::Layer>
List of available layers
95 96 97 98 99 100 101 102 |
# File 'lib/rgeoserver/catalog.rb', line 95 def each_layer = {} doc = Nokogiri::XML(self.search :layers => nil) ap({:each_layer_doc => doc, :xpath => Layer.root_xpath}) if $DEBUG doc.xpath(Layer.root_xpath + '/name/text()').each { |l| ap({:layer => l.to_s.strip}) if $DEBUG yield get_layer l.to_s.strip unless l.nil? } end |
#get_coverage(workspace, coverage_store, coverage) ⇒ Object
225 226 227 228 229 230 231 |
# File 'lib/rgeoserver/catalog.rb', line 225 def get_coverage workspace, coverage_store, coverage c = Coverage.new self, :workspace => workspace, :coverage_store => coverage_store, :name => coverage return c.new?? nil : c end |
#get_coverage_store(workspace, coveragestore) ⇒ RGeoServer::CoverageStore
220 221 222 223 |
# File 'lib/rgeoserver/catalog.rb', line 220 def get_coverage_store workspace, coveragestore cs = CoverageStore.new self, :workspace => workspace, :name => coveragestore return cs.new?? nil : cs end |
#get_coverage_stores(workspace = nil) ⇒ Array<RGeoServer::CoverageStore>
List of coverage stores
212 213 214 215 |
# File 'lib/rgeoserver/catalog.rb', line 212 def get_coverage_stores workspace = nil ws = workspace.nil?? get_workspaces : [get_workspace(workspace)] ws.map { |w| w.coverage_stores }.flatten end |
#get_data_store(workspace, datastore) ⇒ RGeoServer::DataStore
185 186 187 188 189 |
# File 'lib/rgeoserver/catalog.rb', line 185 def get_data_store workspace, datastore doc = Nokogiri::XML(search :workspaces => workspace, :datastores => datastore) DataStore.new self, :workspace => workspace, :name => parse_name(doc, DataStore) end |
#get_data_stores(workspace = nil) ⇒ Array<RGeoServer::DataStore>
List of vector based spatial data
177 178 179 180 |
# File 'lib/rgeoserver/catalog.rb', line 177 def get_data_stores workspace = nil ws = workspace.nil?? get_workspaces : [get_workspace(workspace)] ws.map { |w| w.data_stores }.flatten end |
#get_default_namespace ⇒ RGeoServer::Namespace
162 163 164 165 166 |
# File 'lib/rgeoserver/catalog.rb', line 162 def get_default_namespace doc = Nokogiri::XML(search :namespaces => 'default') Namespace.new self, :name => parse_name(doc, Namespace, 'prefix'), :uri => parse_name(doc, Namespace, 'uri') end |
#get_default_workspace ⇒ RGeoServer::Workspace
Returns get_workspace(‘default’).
70 71 72 |
# File 'lib/rgeoserver/catalog.rb', line 70 def get_default_workspace get_workspace 'default' end |
#get_feature_type(workspace, datastore, featuretype_id) ⇒ RGeoServer::FeatureType
203 204 205 |
# File 'lib/rgeoserver/catalog.rb', line 203 def get_feature_type workspace, datastore, featuretype_id raise NotImplementedError end |
#get_feature_types(workspace, datastore, &block) ⇒ Array<RGeoServer::FeatureType>
List of feature types
195 196 197 |
# File 'lib/rgeoserver/catalog.rb', line 195 def get_feature_types workspace, datastore, &block raise NotImplementedError end |
#get_layer(layername) ⇒ RGeoServer::Layer
106 107 108 109 110 111 |
# File 'lib/rgeoserver/catalog.rb', line 106 def get_layer layername raise ArgumentError, "#get_layer requires String #{layername}" unless layername.is_a? String ap({:layers => layername}) if $DEBUG doc = Nokogiri::XML(search :layers => layername) Layer.new self, :name => layername end |
#get_layergroup(layergroup) ⇒ RGeoServer::LayerGroup
130 131 132 133 |
# File 'lib/rgeoserver/catalog.rb', line 130 def get_layergroup layergroup doc = Nokogiri::XML(search :layergroups => layergroup) LayerGroup.new self, :name => parse_name(doc, LayerGroup) end |
#get_layergroups(options = {}) ⇒ Array<RGeoServer::LayerGroup>
List of available layer groups
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rgeoserver/catalog.rb', line 117 def get_layergroups = {} response = unless [:workspace] self.search :layergroups => nil else self.search :workspaces => [:workspace], :layergroups => nil end doc = Nokogiri::XML(response) layer_groups = doc.xpath(LayerGroup.root_xpath).collect{|l| l.text.to_s }.map(&:strip) list LayerGroup, layer_groups, :workspace => [:workspace] end |
#get_namespaces ⇒ Array<RGeoServer::Namespace>
List of available namespaces
157 158 159 |
# File 'lib/rgeoserver/catalog.rb', line 157 def get_namespaces raise NotImplementedError end |
#get_style(style) ⇒ RGeoServer::Style
147 148 149 150 |
# File 'lib/rgeoserver/catalog.rb', line 147 def get_style style doc = Nokogiri::XML(search :styles => style) Style.new self, :name => parse_name(doc, Style) end |
#get_styles ⇒ Array<RGeoServer::Style>
List of available styles
139 140 141 142 143 |
# File 'lib/rgeoserver/catalog.rb', line 139 def get_styles doc = Nokogiri::XML(search :styles => nil) styles = doc.xpath("#{Style.root_xpath}/name/text()").collect {|s| s.to_s } list Style, styles end |
#get_wms_store(workspace, wmsstore) ⇒ RGeoServer::WmsStore
246 247 248 249 |
# File 'lib/rgeoserver/catalog.rb', line 246 def get_wms_store workspace, wmsstore doc = Nokogiri::XML(search :workspaces => workspace, :name => wmsstore) WmsStore.new self, workspace, parse_name(doc, WmsStore) end |
#get_wms_stores(workspace = nil) ⇒ Array<RGeoServer::WmsStore>
List of WMS stores.
238 239 240 241 |
# File 'lib/rgeoserver/catalog.rb', line 238 def get_wms_stores workspace = nil ws = workspace.nil?? get_workspaces : [get_workspace(workspace)] ws.map { |w| w.wms_stores }.flatten end |
#get_workspace(ws) ⇒ RGeoServer::Workspace
63 64 65 66 |
# File 'lib/rgeoserver/catalog.rb', line 63 def get_workspace ws doc = Nokogiri::XML(search :workspaces => ws) Workspace.new self, :name => parse_name(doc, Workspace) end |
#get_workspaces ⇒ Array<RGeoServer::Workspace>
List of available workspaces
55 56 57 58 59 |
# File 'lib/rgeoserver/catalog.rb', line 55 def get_workspaces doc = Nokogiri::XML(search :workspaces => nil) workspaces = doc.xpath("#{Workspace.root_xpath}/name/text()").collect {|w| w.to_s } list Workspace.class, workspaces end |
#headers(format = :xml) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rgeoserver/catalog.rb', line 28 def headers format = :xml { :accept => format.to_sym, :content_type => format.to_sym } end |
#list(klass, names, options = {}, check_remote = false) {|RGeoServer::ResourceInfo| ... } ⇒ Object
Shortcut to ResourceInfo.list to this catalog. See ResourceInfo#list
44 45 46 47 48 49 |
# File 'lib/rgeoserver/catalog.rb', line 44 def list klass, names, = {}, check_remote = false, &block unless names.is_a? Array and not names.empty? raise ArgumentError, "Missing names #{names}" end ResourceInfo.list klass, self, names, , check_remote, &block end |
#reassign_workspace(store, workspace) ⇒ Object
see RGeoServer::Workspace
87 88 89 |
# File 'lib/rgeoserver/catalog.rb', line 87 def reassign_workspace store, workspace raise NotImplementedError end |
#reload ⇒ Object
Configuration reloading
Reloads the catalog and configuration from disk. This operation is used to reload GeoServer in cases where an external tool has modified the on disk configuration. This operation will also force GeoServer to drop any internal caches and reconnect to all data stores.
253 254 255 |
# File 'lib/rgeoserver/catalog.rb', line 253 def reload do_url 'reload', :put end |
#reset ⇒ Object
Resource reset
Resets all store/raster/schema caches and starts fresh. This operation is used to force GeoServer to drop all caches and stores and reconnect fresh to each of them first time they are needed by a request. This is useful in case the stores themselves cache some information about the data structures they manage that changed in the meantime.
259 260 261 |
# File 'lib/rgeoserver/catalog.rb', line 259 def reset do_url 'reset', :put end |
#set_default_namespace(id, prefix, uri) ⇒ Object
168 169 170 |
# File 'lib/rgeoserver/catalog.rb', line 168 def set_default_namespace id, prefix, uri raise NotImplementedError end |
#set_default_workspace(workspace) ⇒ Object
Assign default workspace
76 77 78 79 80 81 82 |
# File 'lib/rgeoserver/catalog.rb', line 76 def set_default_workspace workspace raise TypeError, "Workspace name must be a string" unless workspace.instance_of? String dws = Workspace.new self, :name => 'default' dws.name = workspace # This creates a new workspace if name is new dws.save dws end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/rgeoserver/catalog.rb', line 24 def to_s "Catalog: #{config[:url]}" end |