rgeoserver 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ {<img src="https://gemnasium.com/rnz0/rgeoserver.png" alt="Dependency Status" />}[https://gemnasium.com/rnz0/rgeoserver]
2
+
1
3
  == RGeoServer
2
4
 
3
5
  RGeoServer is a Ruby client for the GeoServer RESTful administrative interface.
@@ -62,7 +64,7 @@ A full sample script creating coverage stores in a small cluster:
62
64
  (1..7).each do |cat_id|
63
65
  cat = RGeoServer::Catalog.new :user=>'admin', :url => "http://geoserver-app#{cat_id}/rest", :password => "osgeo!"
64
66
  ws = cat.get_workspace('cite')
65
- RGeoServer::ResourceInfo.list(RGeoServer::CoverageStore, cat, layers.keys, :workspace => ws) do |cs|
67
+ cat.list(RGeoServer::CoverageStore, layers.keys, :workspace => ws) do |cs|
66
68
  cs.description = layers[cs.name]['description']
67
69
  cs.url = layers[cs.name]['url']
68
70
  cs.data_type = layers[cs.name]['type']
@@ -116,11 +118,12 @@ or set an environment variable, for example:
116
118
 
117
119
  == TODO
118
120
  - Handle default resources transparently.
119
- - Complete data stores and coverages functionality, handle layers, styles, wmsstores and data upload.
121
+ - Complete data stores and coverages functionality and data upload.
120
122
  - Complete documentation.
121
123
  - Complete test coverage:
122
124
  - Add functional tests
123
125
  - Add more flexibility for integration tests with embedded Jetty and other containers.
126
+ - Hook to CI service.
124
127
  - Provide more examples:
125
128
  - Customize configuration.
126
129
  - Connect under SSL.
@@ -138,7 +141,7 @@ or set an environment variable, for example:
138
141
 
139
142
 
140
143
  == Acknowledgements
141
- Inspired on the Rubydora and RSolr gems. Followed somewhat closely to {gsconfig.py}[https://github.com/dwins/gsconfig.py]
144
+ Inspired on the {Rubydora}[https://github.com/cbeer/rubydora] and RSolr gems. Followed somewhat closely to {gsconfig.py}[https://github.com/dwins/gsconfig.py]
142
145
 
143
146
  == Contributors
144
147
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.6
@@ -33,6 +33,17 @@ module RGeoServer
33
33
  end
34
34
 
35
35
  #== Resources
36
+
37
+ # Shortcut to ResourceInfo.list to this catalog. See ResourceInfo#list
38
+ # @param [RGeoServer::ResourceInfo.class] klass
39
+ # @param [RGeoServer::Catalog] catalog
40
+ # @param [Array<String>] names
41
+ # @param [Hash] options
42
+ # @param [bool] check_remote if already exists in catalog and cache it
43
+ # @yield [RGeoServer::ResourceInfo]
44
+ def list klass, names, options, check_remote = false, &block
45
+ ResourceInfo.list klass, self, names, options, check_remote, &block
46
+ end
36
47
 
37
48
  #= Workspaces
38
49
 
@@ -42,7 +53,7 @@ module RGeoServer
42
53
  response = self.search :workspaces => nil
43
54
  doc = Nokogiri::XML(response)
44
55
  workspaces = doc.xpath(Workspace.root_xpath).collect{|w| w.text.to_s }
45
- ResourceInfo.list Workspace, self, workspaces, {}, &block
56
+ list Workspace, workspaces, {}, &block
46
57
  end
47
58
 
48
59
  # @param [String] workspace name
@@ -80,7 +91,7 @@ module RGeoServer
80
91
  response = self.search :layers => nil
81
92
  doc = Nokogiri::XML(response)
82
93
  layers = doc.xpath(Layer.root_xpath).collect{|l| l.text.to_s }
83
- ResourceInfo.list Layer, self, layers, {}, &block
94
+ list Layer, layers, {}, &block
84
95
  end
85
96
 
86
97
  # @param [String] layer name
@@ -100,7 +111,7 @@ module RGeoServer
100
111
  response = self.search :styles => nil
101
112
  doc = Nokogiri::XML(response)
102
113
  styles = doc.xpath(Style.root_xpath).collect{|l| l.text.to_s }
103
- ResourceInfo.list Style, self, styles, {}, &block
114
+ list Style, styles, {}, &block
104
115
  end
105
116
 
106
117
  # @param [String] style name
@@ -184,10 +195,13 @@ module RGeoServer
184
195
  # @param [String] coveragestore
185
196
  # @return [RGeoServer::CoverageStore]
186
197
  def get_coverage_store workspace, coveragestore
187
- response = self.search({:workspaces => workspace, :name => coveragestore})
188
- doc = Nokogiri::XML(response)
189
- name = doc.at_xpath(CoverageStore.member_xpath)
190
- return CoverageStore.new self, workspace, name.text if name
198
+ cs = CoverageStore.new self, :workspace => workspace, :name => coveragestore
199
+ return cs.new?? nil : cs
200
+ end
201
+
202
+ def get_coverage workspace, coverage_store, coverage
203
+ c = Coverage.new self, :workspace => workspace, :coverage_store => coverage_store, :name => coverage
204
+ return c.new?? nil : c
191
205
  end
192
206
 
193
207
  #= WMS Stores (Web Map Services)
@@ -211,7 +225,19 @@ module RGeoServer
211
225
  name = doc.at_xpath(WmsStore.member_xpath)
212
226
  return WmsStore.new self, workspace, name.text if name
213
227
  end
214
-
228
+
229
+ #= Configuration reloading
230
+ # 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.
231
+ def reload
232
+ do_url 'reload', method = :put
233
+ end
234
+
235
+ #= Resource reset
236
+ # 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.
237
+ def reset
238
+ do_url 'reset', method = :put
239
+ end
240
+
215
241
  end
216
242
 
217
243
  end
@@ -1,88 +1,87 @@
1
1
 
2
2
  module RGeoServer
3
+ # A coverage is a raster based data set which originates from a coverage store.
4
+ class Coverage < ResourceInfo
3
5
 
4
- class Coverage < ResourceInfo
5
-
6
- OBJ_ATTRIBUTES = {:catalog => "catalog", :name => "name", :workspace => "workspace", :enabled => "enabled" }
7
- OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :coverage_store => nil, :name => nil, :enabled => "false" }
8
-
9
- define_attribute_methods OBJ_ATTRIBUTES.keys
10
- update_attribute_accessors OBJ_ATTRIBUTES
6
+ OBJ_ATTRIBUTES = {:catalog => "catalog", :workspace => "workspace", :coverage_store => "coverage_store", :name => "name", :title => "title" }
7
+ OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :coverage_store => nil, :name => nil, :title => nil }
8
+
9
+ define_attribute_methods OBJ_ATTRIBUTES.keys
10
+ update_attribute_accessors OBJ_ATTRIBUTES
11
11
 
12
- @@r = Confstruct::Configuration.new(
13
- :route => "workspaces/%s/coveragestores/%s/coverages",
14
- :root => "coverages",
15
- :resource_name => "coverage"
16
- )
12
+ @@route = "workspaces/%s/coveragestores/%s/coverages"
13
+ @@root = "coverages"
14
+ @@resource_name = "coverage"
17
15
 
18
- def self.root
19
- @@r.root
20
- end
21
-
22
- def self.create_method
23
- :put
24
- end
16
+ def self.root
17
+ @@root
18
+ end
25
19
 
26
- def self.update_method
27
- :put
28
- end
20
+ def self.member_xpath
21
+ "//#{resource_name}"
22
+ end
29
23
 
30
- def self.member_xpath
31
- "//#{resource_name}"
32
- end
24
+ def self.resource_name
25
+ @@resource_name
26
+ end
33
27
 
34
- def self.resource_name
35
- @@r.resource_name
36
- end
28
+ def route
29
+ @@route % [@workspace.name , @coverage_store.name]
30
+ end
37
31
 
38
- def route
39
- @@r.route % [@workspace.name , @coverage_store.name]
32
+ def message
33
+ builder = Nokogiri::XML::Builder.new do |xml|
34
+ xml.coverage {
35
+ xml.name @name
36
+ xml.title @title
37
+ }
40
38
  end
39
+ @message = builder.doc.to_xml
40
+ end
41
41
 
42
+ # @param [RGeoServer::Catalog] catalog
43
+ # @param [Hash] options
44
+ def initialize catalog, options
45
+ super({})
46
+ _run_initialize_callbacks do
47
+ @catalog = catalog
48
+ workspace = options[:workspace] || 'default'
49
+ if workspace.instance_of? String
50
+ @workspace = @catalog.get_workspace(workspace)
51
+ elsif workspace.instance_of? Workspace
52
+ @workspace = workspace
53
+ else
54
+ raise "Not a valid workspace"
55
+ end
56
+ coverage_store = options[:coverage_store]
57
+ if coverage_store.instance_of? String
58
+ @coverage_store = CoverageStore.new @catalog, :workspace => @workspace, :name => coverage_store
59
+ elsif coverage_store.instance_of? CoverageStore
60
+ @coverage_store = coverage_store
61
+ else
62
+ raise "Not a valid coverage store"
63
+ end
42
64
 
43
- # @param [RGeoServer::Catalog] catalog
44
- # @param [Hash] options
45
- def initialize catalog, options
46
- super({})
47
- _run_initialize_callbacks do
48
- @catalog = catalog
49
- workspace = options[:workspace] || 'default'
50
- if workspace.instance_of? String
51
- @workspace = @catalog.get_workspace(workspace)
52
- elsif workspace.instance_of? Workspace
53
- @workspace = workspace
54
- else
55
- raise "Not a valid workspace"
56
- end
57
- coverage_store = options[:coverage_store]
58
- if coverage_store.instance_of? String
59
- @coverage_store = CoverageStore.new @catalog, :workspace => @workspace, :name => coverage_store
60
- elsif coverage_store.instance_of? CoverageStore
61
- @coverage_store = coverage_store
62
- else
63
- raise "Not a valid coverage store"
64
- end
65
-
66
- @name = options[:name]
67
- @type = options[:type]
68
- @enabled = options[:enabled] || true
69
- @route = route
70
- end
71
- end
65
+ @name = options[:name]
66
+ @title = options[:title]
67
+ @enabled = options[:enabled] || true
68
+ @route = route
69
+ end
70
+ end
72
71
 
73
- def profile_xml_to_hash profile_xml
74
- doc = profile_xml_to_ng profile_xml
75
- h = {
76
- "coverage_store" => @coverage_store.name,
77
- "workspace" => @workspace.name,
78
- "name" => doc.at_xpath('//name').text.strip,
79
- "nativeName" => doc.at_xpath('//nativeName').to_s,
80
- "title" => doc.at_xpath('//title').to_s,
81
- "supportedFormats" => doc.xpath('//supportedFormats/string').collect{ |t| t.to_s }
82
- }.freeze
83
- h
84
- end
72
+ def profile_xml_to_hash profile_xml
73
+ doc = profile_xml_to_ng profile_xml
74
+ h = {
75
+ "coverage_store" => @coverage_store.name,
76
+ "workspace" => @workspace.name,
77
+ "name" => doc.at_xpath('//name').text.strip,
78
+ "nativeName" => doc.at_xpath('//nativeName').to_s,
79
+ "title" => doc.at_xpath('//title').to_s,
80
+ "supportedFormats" => doc.xpath('//supportedFormats/string').collect{ |t| t.to_s }
81
+ }.freeze
82
+ h
83
+ end
85
84
 
86
85
 
87
- end
86
+ end
88
87
  end
@@ -1,99 +1,89 @@
1
1
 
2
2
  module RGeoServer
3
+ # A coverage store is a source of spatial data that is raster based.
4
+ class CoverageStore < ResourceInfo
3
5
 
4
- class CoverageStore < ResourceInfo
6
+ OBJ_ATTRIBUTES = {:catalog => 'catalog', :workspace => 'workspace', :url => 'url', :data_type => 'type', :name => 'name', :enabled => 'enabled', :description => 'description'}
7
+ OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :url => '', :data_type => 'GeoTIFF', :name => nil, :enabled => 'true', :description=>nil}
8
+ define_attribute_methods OBJ_ATTRIBUTES.keys
9
+ update_attribute_accessors OBJ_ATTRIBUTES
5
10
 
6
- OBJ_ATTRIBUTES = {:catalog => 'catalog', :workspace => 'workspace', :url => 'url', :data_type => 'type', :name => 'name', :enabled => 'enabled', :description => 'description'}
7
- OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :url => '', :data_type => 'GeoTIFF', :name => nil, :enabled => 'true', :description=>nil}
8
- define_attribute_methods OBJ_ATTRIBUTES.keys
9
- update_attribute_accessors OBJ_ATTRIBUTES
10
-
11
- @@r = Confstruct::Configuration.new(
12
- :route => "workspaces/%s/coveragestores",
13
- :root => "coverageStores",
14
- :resource_name => "coverageStore"
15
- )
11
+ @@route = "workspaces/%s/coveragestores"
12
+ @@root = "coverageStores"
13
+ @@resource_name = "coverageStore"
16
14
 
17
- def self.root
18
- @@r.root
19
- end
20
-
21
- def self.create_method
22
- :post
23
- end
15
+ def self.root
16
+ @@root
17
+ end
24
18
 
25
- def self.update_method
26
- :put
27
- end
19
+ def self.resource_name
20
+ @@resource_name
21
+ end
28
22
 
29
- def self.resource_name
30
- @@r.resource_name
31
- end
32
-
33
- def self.root_xpath
34
- "//#{root}/#{resource_name}"
35
- end
23
+ def self.root_xpath
24
+ "//#{root}/#{resource_name}"
25
+ end
36
26
 
37
- def self.member_xpath
38
- "//#{resource_name}"
39
- end
27
+ def self.member_xpath
28
+ "//#{resource_name}"
29
+ end
40
30
 
41
- def route
42
- @@r.route % @workspace.name
43
- end
31
+ def route
32
+ @@route % @workspace.name
33
+ end
44
34
 
45
- def message
46
- builder = Nokogiri::XML::Builder.new do |xml|
47
- xml.coverageStore {
48
- xml.name @name if new?
49
- xml.workspace {
50
- xml.name @workspace.name
51
- }
52
- xml.enabled @enabled if (enabled_changed? || new?)
53
- xml.type_ @data_type if (data_type_changed? || new?)
54
- xml.description @description if (description_changed? || new?)
55
- xml.url @url if (url_changed? || new?)
35
+ def message
36
+ builder = Nokogiri::XML::Builder.new do |xml|
37
+ xml.coverageStore {
38
+ xml.name @name if new?
39
+ xml.workspace {
40
+ xml.name @workspace.name
56
41
  }
57
- end
58
- @message = builder.doc.to_xml
59
- end
60
-
61
- # @param [RGeoServer::Catalog] catalog
62
- # @param [RGeoServer::Workspace|String] workspace
63
- # @param [String] name
64
- def initialize catalog, options
65
- super({})
66
- _run_initialize_callbacks do
67
- @catalog = catalog
68
- workspace = options[:workspace] || 'default'
69
- if workspace.instance_of? String
70
- @workspace = @catalog.get_workspace(workspace)
71
- elsif workspace.instance_of? Workspace
72
- @workspace = workspace
73
- else
74
- raise "Not a valid workspace"
75
- end
76
- @name = options[:name].strip
77
- @route = route
78
- end
42
+ xml.enabled @enabled if (enabled_changed? || new?)
43
+ xml.type_ @data_type if (data_type_changed? || new?)
44
+ xml.description @description if (description_changed? || new?)
45
+ xml.url @url if (url_changed? || new?)
46
+ }
79
47
  end
48
+ @message = builder.doc.to_xml
49
+ end
80
50
 
81
- def coverages &block
82
- self.class.list Coverage, @catalog, profile['coverages'], {:workspace => @workspace}, check_remote = true, &block
83
- end
51
+ # @param [RGeoServer::Catalog] catalog
52
+ # @param [RGeoServer::Workspace|String] workspace
53
+ # @param [String] name
54
+ def initialize catalog, options
55
+ super({})
56
+ _run_initialize_callbacks do
57
+ @catalog = catalog
58
+ workspace = options[:workspace] || 'default'
59
+ if workspace.instance_of? String
60
+ @workspace = @catalog.get_workspace(workspace)
61
+ elsif workspace.instance_of? Workspace
62
+ @workspace = workspace
63
+ else
64
+ raise "Not a valid workspace"
65
+ end
66
+ @name = options[:name].strip
67
+ @route = route
68
+ end
69
+ end
84
70
 
85
- def profile_xml_to_hash profile_xml
86
- doc = profile_xml_to_ng profile_xml
87
- h = {
88
- 'name' => doc.at_xpath('//name').text.strip,
89
- 'workspace' => @workspace.name,
90
- 'type' => doc.at_xpath('//type/text()').to_s,
91
- 'enabled' => doc.at_xpath('//enabled/text()').to_s,
92
- 'description' => doc.at_xpath('//description/text()').to_s,
93
- 'url' => doc.at_xpath('//url/text()').to_s
94
- }.freeze
95
- h
96
- end
71
+ def coverages &block
72
+ self.class.list Coverage, @catalog, profile['coverages'], {:workspace => @workspace}, check_remote = true, &block
73
+ end
97
74
 
75
+ def profile_xml_to_hash profile_xml
76
+ doc = profile_xml_to_ng profile_xml
77
+ h = {
78
+ 'name' => doc.at_xpath('//name').text.strip,
79
+ 'workspace' => @workspace.name,
80
+ 'type' => doc.at_xpath('//type/text()').to_s,
81
+ 'enabled' => doc.at_xpath('//enabled/text()').to_s,
82
+ 'description' => doc.at_xpath('//description/text()').to_s,
83
+ 'url' => doc.at_xpath('//url/text()').to_s
84
+ }.freeze
85
+ h
98
86
  end
87
+
88
+ end
99
89
  end
@@ -1,112 +1,102 @@
1
1
 
2
2
  module RGeoServer
3
+ # A data store is a source of spatial data that is vector based. It can be a file in the case of a Shapefile, a database in the case of PostGIS, or a server in the case of a remote Web Feature Service.
4
+ class DataStore < ResourceInfo
3
5
 
4
- class DataStore < ResourceInfo
5
-
6
- OBJ_ATTRIBUTES = {:enabled => "enabled", :catalog => "catalog", :workspace => "workspace", :name => "name", :connection_parameters => "connectionParameters"}
7
- OBJ_DEFAULT_ATTRIBUTES = {:enabled => true, :catalog => nil, :workspace => nil, :name => nil, :connection_parameters => {}}
8
- define_attribute_methods OBJ_ATTRIBUTES.keys
9
- update_attribute_accessors OBJ_ATTRIBUTES
10
-
11
- attr_accessor :message
12
-
13
- @@r = Confstruct::Configuration.new(
14
- :route => "workspaces/%s/datastores",
15
- :root => "dataStores",
16
- :resource_name => "dataStore"
17
- )
6
+ OBJ_ATTRIBUTES = {:enabled => "enabled", :catalog => "catalog", :workspace => "workspace", :name => "name", :connection_parameters => "connectionParameters"}
7
+ OBJ_DEFAULT_ATTRIBUTES = {:enabled => true, :catalog => nil, :workspace => nil, :name => nil, :connection_parameters => {}}
8
+ define_attribute_methods OBJ_ATTRIBUTES.keys
9
+ update_attribute_accessors OBJ_ATTRIBUTES
18
10
 
19
- def self.root
20
- @@r.root
21
- end
11
+ attr_accessor :message
22
12
 
23
- def self.create_method
24
- :post
25
- end
13
+ @@route = "workspaces/%s/datastores"
14
+ @@root = "dataStores"
15
+ @@resource_name = "dataStore"
26
16
 
27
- def self.save_method
28
- :put
29
- end
17
+ def self.root
18
+ @@root
19
+ end
30
20
 
31
- def self.resource_name
32
- @@r.resource_name
33
- end
34
-
35
- def self.root_xpath
36
- "//#{root}/#{resource_name}"
37
- end
21
+ def self.resource_name
22
+ @@resource_name
23
+ end
38
24
 
39
- def self.member_xpath
40
- "//#{resource_name}"
41
- end
25
+ def self.root_xpath
26
+ "//#{root}/#{resource_name}"
27
+ end
42
28
 
43
- def route
44
- @@r.route % @workspace.name
45
- end
29
+ def self.member_xpath
30
+ "//#{resource_name}"
31
+ end
46
32
 
47
- def update_route
48
- "#{route}/#{@name}"
49
- end
33
+ def route
34
+ @@route % @workspace.name
35
+ end
50
36
 
51
- def message
52
- builder = Nokogiri::XML::Builder.new do |xml|
53
- xml.dataStore {
54
- xml.enabled true
55
- xml.name @name
56
- xml.connectionParameters { # this could be empty
57
- @connection_parameters.each_pair { |k,v|
58
- xml.entry(:key => k) {
59
- xml.text v
60
- }
61
- } unless @connection_parameters.empty?
62
- }
37
+ def update_route
38
+ "#{route}/#{@name}"
39
+ end
40
+
41
+ def message
42
+ builder = Nokogiri::XML::Builder.new do |xml|
43
+ xml.dataStore {
44
+ xml.enabled true
45
+ xml.name @name
46
+ xml.connectionParameters { # this could be empty
47
+ @connection_parameters.each_pair { |k,v|
48
+ xml.entry(:key => k) {
49
+ xml.text v
50
+ }
51
+ } unless @connection_parameters.empty?
63
52
  }
64
- end
65
- builder.doc.to_xml
53
+ }
66
54
  end
55
+ builder.doc.to_xml
56
+ end
67
57
 
68
- # @param [RGeoServer::Catalog] catalog
69
- # @param [RGeoServer::Workspace|String] workspace
70
- # @param [String] name
71
- def initialize catalog, options
72
- super({})
73
- _run_initialize_callbacks do
74
- @catalog = catalog
75
- workspace = options[:workspace] || 'default'
76
- if workspace.instance_of? String
77
- @workspace = @catalog.get_workspace(workspace)
78
- elsif workspace.instance_of? Workspace
79
- @workspace = workspace
80
- else
81
- raise "Not a valid workspace"
82
- end
83
- @name = options[:name].strip
84
- @connection_parameters = options[:connection_parameters] || {}
85
- @route = route
86
- end
87
- end
58
+ # @param [RGeoServer::Catalog] catalog
59
+ # @param [RGeoServer::Workspace|String] workspace
60
+ # @param [String] name
61
+ def initialize catalog, options
62
+ super({})
63
+ _run_initialize_callbacks do
64
+ @catalog = catalog
65
+ workspace = options[:workspace] || 'default'
66
+ if workspace.instance_of? String
67
+ @workspace = @catalog.get_workspace(workspace)
68
+ elsif workspace.instance_of? Workspace
69
+ @workspace = workspace
70
+ else
71
+ raise "Not a valid workspace"
72
+ end
73
+ @name = options[:name].strip
74
+ @connection_parameters = options[:connection_parameters] || {}
75
+ @route = route
76
+ end
77
+ end
88
78
 
89
- def featuretypes &block
90
- self.class.list FeatureType, @catalog, profile['featureTypes'], {:workspace => @workspace}, check_remote = true, &block
91
- end
79
+ def featuretypes &block
80
+ self.class.list FeatureType, @catalog, profile['featureTypes'], {:workspace => @workspace}, check_remote = true, &block
81
+ end
92
82
 
93
- def profile_xml_to_hash profile_xml
94
- doc = profile_xml_to_ng profile_xml
95
- h = {
96
- "name" => doc.at_xpath('//name').text.strip,
97
- "enabled" => doc.at_xpath('//enabled/text()').to_s,
98
- "connectionParameters" => doc.xpath('//connectionParameters/entry').inject({}){ |h, e| h.merge(e['key']=> e.text.to_s) }
99
- }
100
- doc.xpath('//featureTypes/atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom" ).each{ |l|
101
- h["featureTypes"] = begin
102
- response = @catalog.fetch_url l.text
103
- Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text.strip }
104
- rescue RestClient::ResourceNotFound
105
- []
106
- end.freeze
107
-
108
- }
109
- h
110
- end
83
+ def profile_xml_to_hash profile_xml
84
+ doc = profile_xml_to_ng profile_xml
85
+ h = {
86
+ "name" => doc.at_xpath('//name').text.strip,
87
+ "enabled" => doc.at_xpath('//enabled/text()').to_s,
88
+ "connectionParameters" => doc.xpath('//connectionParameters/entry').inject({}){ |h, e| h.merge(e['key']=> e.text.to_s) }
89
+ }
90
+ doc.xpath('//featureTypes/atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom" ).each{ |l|
91
+ h["featureTypes"] = begin
92
+ response = @catalog.do_url l.text
93
+ Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text.strip }
94
+ rescue RestClient::ResourceNotFound
95
+ []
96
+ end.freeze
97
+
98
+ }
99
+ h
111
100
  end
101
+ end
112
102
  end