class Domain

Attributes

namespace[RW]
user[RW]
uuid[RW]

Public Class Methods

find(user, id) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 39
def self.find(user, id)
  domain = super(user.login, id)
  domain.user = user if domain
  return nil unless domain
  domain
end
find_all(user, namespace=nil) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 46
def self.find_all(user, namespace=nil)
  domains = super(user.login) 
  unless namespace
    user.domains = domains
    return domains
  else
    filtered_domains = nil
    domains.each do |domain|
      if domain.namespace == namespace
        filtered_domains.push(domain)
      end
    end
    return filtered_domains
  end    
end
hash_to_obj(hash) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 85
def self.hash_to_obj(hash)
  domain = super(hash)
  domain
end
namespace_available?(namespace) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 79
def self.namespace_available?(namespace)
  Rails.logger.debug "Checking to see if namesspace #{namespace} is available"
  dns_service = StickShift::DnsService.instance
  return dns_service.namespace_available?(namespace)
end
new(namespace=nil, user=nil) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 8
def initialize(namespace=nil, user=nil)
  self.user = user
  self.namespace = namespace
  self.uuid = StickShift::Model.gen_uuid
end

Public Instance Methods

delete() click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 62
def delete
  Rails.logger.debug "Deleting domain #{self.namespace} uuid #{self.uuid}"
  resultIO = ResultIO.new
  dns_service = StickShift::DnsService.instance
  begin
    dns_service.deregister_namespace(self.namespace)
    dns_service.publish
    Rails.logger.debug "notifying the domain observer of domain delete"
    notify_observers(:after_domain_destroy) 
    Rails.logger.debug "done notifying the domain observer"
  ensure
    dns_service.close
  end
  super(user.login)
  resultIO
end
hasAccess?(user) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 23
def hasAccess?(user)
  #TODO 
  #if user.domains.include? self.uuid
    return true
  #end
  #return false
end
hasFullAccess?(user) click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 31
def hasFullAccess?(user)
  #TODO
  #if self.user.login == user.login
    return true
  #end
  #return false
end
save() click to toggle source
# File lib/stickshift-controller/app/models/domain.rb, line 13
def save
  resultIO = ResultIO.new
  if not persisted?
    resultIO.append(create())
  else
    resultIO.append(update())
  end
  super(self.user.login)
  resultIO
end