text
stringlengths
0
234
procedure Check_Permission (Manager : in Permission_Manager;
Entity : in ADO.Identifier;
Kind : in ADO.Entity_Type;
Permission : in Permission_Type) is
pragma Unreferenced (Manager, Permission);
use AWA.Services;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
DB : constant Session := AWA.Services.Contexts.Get_Session (Ctx);
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Permissions.Models.Query_Check_Entity_Permission);
Query.Bind_Param ("user_id", User);
Query.Bind_Param ("entity_id", Entity);
Query.Bind_Param ("entity_type", Integer (Kind));
declare
Stmt : ADO.Statements.Query_Statement := DB.Create_Statement (Query);
begin
Stmt.Execute;
if not Stmt.Has_Elements then
Log.Info ("User {0} does not have permission to access entity {1}/{2}",
ADO.Identifier'Image (User), ADO.Identifier'Image (Entity),
ADO.Entity_Type'Image (Kind));
raise NO_PERMISSION;
end if;
Function Definition: procedure Dispatch (Manager : in Action_Dispatcher;
Function Body: Event : in Module_Event'Class) is
use Util.Beans.Objects;
-- Dispatch the event to the event action identified by <b>Action</b>.
procedure Dispatch_One (Action : in Event_Action);
type Event_Bean is new Util.Beans.Basic.Readonly_Bean with null record;
overriding
function Get_Value (From : in Event_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Event_Bean;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (From);
begin
return Event.Get_Value (Name);
end Get_Value;
Variables : aliased EL.Variables.Default.Default_Variable_Mapper;
-- ------------------------------
-- Default Resolver
-- ------------------------------
type Event_ELResolver is limited new EL.Contexts.ELResolver with record
Request : ASF.Requests.Request_Access;
Application : AWA.Applications.Application_Access;
end record;
overriding
function Get_Value (Resolver : Event_ELResolver;
Context : EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : Unbounded_String) return Util.Beans.Objects.Object;
overriding
procedure Set_Value (Resolver : in out Event_ELResolver;
Context : in EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Bean'Class;
Name : in Unbounded_String;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Get the value associated with a base object and a given property.
-- ------------------------------
overriding
function Get_Value (Resolver : Event_ELResolver;
Context : EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : Unbounded_String) return Util.Beans.Objects.Object is
use Util.Beans.Basic;
use EL.Variables;
use type ASF.Requests.Request_Access;
Result : Object;
Bean : Util.Beans.Basic.Readonly_Bean_Access;
Scope : ASF.Beans.Scope_Type;
Key : constant String := To_String (Name);
begin
if Base /= null then
return Base.Get_Value (Key);
end if;
if Resolver.Request /= null then
Result := Resolver.Request.Get_Attribute (Key);
if not Util.Beans.Objects.Is_Null (Result) then
return Result;