class RGeoServer::Workspace

A workspace is a grouping of data stores. More commonly known as a namespace, it is commonly used to group data that is related in some way.

Constants

OBJ_ATTRIBUTES
OBJ_DEFAULT_ATTRIBUTES

Public Class Methods

member_xpath() click to toggle source
# File lib/rgeoserver/workspace.rb, line 31
def self.member_xpath
  "//#{resource_name}"
end
new(catalog, options) click to toggle source

@param [RGeoServer::Catalog] catalog @param [Hash] options

Calls superclass method RGeoServer::ResourceInfo::new
# File lib/rgeoserver/workspace.rb, line 51
def initialize catalog, options
  super(catalog)
  _run_initialize_callbacks do
    @name = options[:name].strip
  end        
  @route = route
end
resource_name() click to toggle source
# File lib/rgeoserver/workspace.rb, line 23
def self.resource_name
  @@resource_name
end
root_xpath() click to toggle source
# File lib/rgeoserver/workspace.rb, line 27
def self.root_xpath
  "//#{@@route}/#{@@resource_name}"
end

Public Instance Methods

coverage_stores(&block) click to toggle source
# File lib/rgeoserver/workspace.rb, line 63
def coverage_stores &block
  self.class.list CoverageStore, @catalog, profile['coverageStores'], {:workspace => self}, true, &block
end
data_stores(&block) click to toggle source
# File lib/rgeoserver/workspace.rb, line 59
def data_stores &block
  self.class.list DataStore, @catalog, profile['dataStores'], {:workspace => self}, true, &block
end
message() click to toggle source
# File lib/rgeoserver/workspace.rb, line 39
def message
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.workspace { 
      xml.enabled @enabled if enabled_changed?
      xml.name @name 
    }
  end
  return builder.doc.to_xml 
end
profile_xml_to_hash(profile_xml) click to toggle source
# File lib/rgeoserver/workspace.rb, line 71
def profile_xml_to_hash profile_xml
  doc = profile_xml_to_ng profile_xml 
  h = {
    'name' => doc.at_xpath('//name').text.strip, 
    'enabled' => @enabled 
  }
  doc.xpath('//atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom").each{ |l| 
    target = l.text.match(/([a-zA-Z]+)\.xml$/)[1]
    if !target.nil? && target != l.parent.parent.name.to_s.downcase
      begin
        h[l.parent.parent.name.to_s] << target
      rescue
        h[l.parent.parent.name.to_s] = []
      end
    else
      h[l.parent.parent.name.to_s] = begin
        response = @catalog.do_url l.text
        Nokogiri::XML(response).xpath('//name').collect{ |a| a.text.strip }
      rescue RestClient::ResourceNotFound
        []
      end.freeze
    end
   }
  h  
end
route() click to toggle source
# File lib/rgeoserver/workspace.rb, line 35
def route
  @@route  
end
wms_stores(&block) click to toggle source
# File lib/rgeoserver/workspace.rb, line 67
def wms_stores &block
  self.class.list WmsStore, @catalog, profile['wmsStores'], {:workspace => self}, true, &block
end

Private Instance Methods

each_store(klass) { |x| ... } click to toggle source
# File lib/rgeoserver/workspace.rb, line 98
def each_store klass
  list(klass, @catalog, profile[klass.root], {:workspace => self}, true) {|x| yield x}
end