Class: Ace

Inherits:
ACL_Object show all
Defined in:
lib/ace.rb

Instance Attribute Summary

Attributes inherited from ACL_Object

#col_path, #doc

Instance Method Summary collapse

Methods inherited from ACL_Object

#add_membership, #del_membership, #delete, #find_parents, #ge

Constructor Details

#initialize(connector, col_path, report = false) ⇒ Ace

Returns a new instance of Ace.



3
4
5
6
# File 'lib/ace.rb', line 3

def initialize(connector, col_path, report = false)
  super(connector, col_path, report)
  @doc = "doc(\"#{@col_path}acl.xml\")"
end

Instance Method Details

#create_new(prin_id, acc_type, priv_id, res_ob_id) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ace.rb', line 54

def create_new(prin_id, acc_type, priv_id, res_ob_id)
  if(acc_type == "deny" || acc_type == "allow")
    id = find_ace(prin_id, acc_type, priv_id, res_ob_id)
    if(id == nil) #this ace doesnt exist
      id = "a" + Random.rand(1000000000).to_s
      while(exists?(id))
        id = "a" + Random.rand(1000000000).to_s
      end
      expr = generate_expr(id, prin_id, acc_type, priv_id, res_ob_id)
      expr_loc = "#{@doc}//#{self.class.name}s/#{self.class.name}[last()]"
      #puts expr_loc
      @connector.update_insert(expr, "following", expr_loc)
      if(exists?(id))
        #puts "New #{self.class.name} \"#{name}\" created."
        return id
      else
        puts "#{self.class.name} \"#{id}\" was not able to create."
        raise RubyACLException.new(self.class.name, __method__, 
          "#{self.class.name} \"#{id}\" was not able to create.", 221), caller
        return nil
      end
    else #already exists
      return id
    end
  else
    raise RubyACLException.new(self.class.name, __method__, 
      "Access type \"#{acc_type}\" is not allowed. Only allowed type is \"deny\" or \"allow\".", 222), caller
    return nil
  end
rescue => e
  raise e
end

#renameObject

def create_new

Raises:

  • (RubyACLException.new(self.class.name, __method__, "Rename method is not supported for ACE.", 223))


87
88
89
90
# File 'lib/ace.rb', line 87

def rename()
  raise RubyACLException.new(self.class.name, __method__, 
    "Rename method is not supported for ACE.", 223), caller
end