text stringlengths 0 234 |
|---|
Ctx : constant ASC.Service_Context_Access := ASC.Current; |
begin |
if Ctx /= null then |
return AWA.Services.Contexts.Get_Session (Ctx); |
else |
return Manager.Get_Application.Get_Session; |
end if; |
end Get_Session; |
Session : constant ADO.Sessions.Session := Get_Session; |
Query : ADO.Statements.Query_Statement := Session.Create_Statement (Handler.SQL); |
Result : Integer; |
begin |
-- Build the query |
Query.Bind_Param (Name => "entity_id", Value => Entity_Id); |
Query.Bind_Param (Name => "user_id", Value => User_Id); |
if Handler.Entities (2) /= ADO.NO_ENTITY_TYPE then |
for I in Handler.Entities'Range loop |
exit when Handler.Entities (I) = ADO.NO_ENTITY_TYPE; |
Query.Bind_Param (Name => "entity_type_" & Util.Strings.Image (I), |
Value => Handler.Entities (I)); |
end loop; |
else |
Query.Bind_Param (Name => "entity_type", Value => Handler.Entities (1)); |
end if; |
-- Run the query. We must get a single row result and the value must be > 0. |
Query.Execute; |
Result := Query.Get_Result_Integer; |
if Result >= 0 and Query.Has_Elements then |
Log.Info ("Permission granted to {0} on entity {1}", |
ADO.Identifier'Image (User_Id), |
ADO.Identifier'Image (Entity_Id)); |
return True; |
else |
Log.Info ("Permission denied to {0} on entity {1}", |
ADO.Identifier'Image (User_Id), |
ADO.Identifier'Image (Entity_Id)); |
return False; |
end if; |
Function Definition: procedure Free is |
Function Body: new Ada.Unchecked_Deallocation (Object => AWA.Events.Module_Event'Class, |
Name => AWA.Events.Module_Event_Access); |
-- ------------------------------ |
-- Get the queue name. |
-- ------------------------------ |
overriding |
function Get_Name (From : in Fifo_Queue) return String is |
begin |
return From.Name; |
end Get_Name; |
-- ------------------------------ |
-- Get the model queue reference object. |
-- Returns a null object if the queue is not persistent. |
-- ------------------------------ |
overriding |
function Get_Queue (From : in Fifo_Queue) return AWA.Events.Models.Queue_Ref is |
pragma Unreferenced (From); |
begin |
return AWA.Events.Models.Null_Queue; |
end Get_Queue; |
-- ------------------------------ |
-- Queue the event. |
-- ------------------------------ |
procedure Enqueue (Into : in out Fifo_Queue; |
Event : in AWA.Events.Module_Event'Class) is |
E : constant Module_Event_Access := Copy (Event); |
begin |
Log.Debug ("Enqueue event on queue {0}", Into.Name); |
E.Set_Event_Kind (Event.Get_Event_Kind); |
Into.Fifo.Enqueue (E); |
end Enqueue; |
-- ------------------------------ |
-- Dequeue an event and process it with the <b>Process</b> procedure. |
-- ------------------------------ |
procedure Dequeue (From : in out Fifo_Queue; |
Process : access procedure (Event : in Module_Event'Class)) is |
E : Module_Event_Access; |
begin |
Log.Debug ("Dequeue event queue {0}", From.Name); |
From.Fifo.Dequeue (E, 0.0); |
begin |
Process (E.all); |
exception |
when E : others => |
Log.Error ("Exception when processing event", E); |
Function Definition: procedure Free is |
Function Body: new Ada.Unchecked_Deallocation (Object => Name_Pair_Array, |
Name => Name_Pair_Array_Access); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.