/usr/share/otrs/Kernel/System/Scheduler.pm is in otrs2 6.0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | # --
# Copyright (C) 2001-2018 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::System::Scheduler;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Daemon::SchedulerDB',
'Kernel::System::Log',
);
=head1 NAME
Kernel::System::Scheduler - Scheduler lib
=head1 DESCRIPTION
Includes the functions to add a new task to the scheduler daemon.
=head1 PUBLIC INTERFACE
=head2 new()
create a scheduler object. Do not use it directly, instead use:
my $SchedulerObject = $Kernel::OM->Get('Kernel::System::Scheduler');
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 TaskAdd()
add a task to scheduler
my $Success = $SchedulerObject->TaskAdd(
ExecutionTime => '2015-01-01 00:00:00', # task will be executed immediately if no execution
# time is given
Type => 'GenericInterface', # e. g. GenericInterface, Test
Name => 'any name', # optional
Attempts => 5, # optional (default 1)
MaximumParallelInstances => 2, # optional, number of tasks with the same type
# (and name if provided) that can exists at
# the same time, value of 0 means unlimited
Data => { # data payload
...
},
);
=cut
sub TaskAdd {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Key (qw(Type Data)) {
if ( !$Param{$Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Key!",
);
return;
}
}
# get scheduler database object
my $SchedulerDBObject = $Kernel::OM->Get('Kernel::System::Daemon::SchedulerDB');
my $TaskID;
if ( $Param{ExecutionTime} ) {
$TaskID = $SchedulerDBObject->FutureTaskAdd(%Param);
}
else {
$TaskID = $SchedulerDBObject->TaskAdd(%Param);
}
return 1 if $TaskID;
return;
}
=head2 FutureTaskList()
get the list of scheduler future tasks
my @List = $SchedulerObject->FutureTaskList(
Type => 'some type', # optional
);
Returns:
@List = (
{
TaskID => 123,
ExecutionTime => '2015-01-01 00:00:00',
Name => 'any name',
Type => 'GenericInterface',
},
{
TaskID => 456,
ExecutionTime => '2015-01-01 00:00:00',
Name => 'any other name',
Type => 'GenericInterface',
},
# ...
);
=cut
sub FutureTaskList {
my ( $Self, %Param ) = @_;
my @List = $Kernel::OM->Get('Kernel::System::Daemon::SchedulerDB')->FutureTaskList(%Param);
return @List;
}
=head2 TaskList()
get the list of scheduler tasks
my @List = $SchedulerObject->TaskList(
Type => 'some type', # optional
);
Returns:
@List = (
{
TaskID => 123,
Name => 'any name',
Type => 'GenericInterface',
},
{
TaskID => 456,
Name => 'any other name',
Type => 'GenericInterface',
},
# ...
);
=cut
sub TaskList {
my ( $Self, %Param ) = @_;
return $Kernel::OM->Get('Kernel::System::Daemon::SchedulerDB')->TaskList(%Param);
}
=head2 FutureTaskDelete()
delete a task from scheduler future task list
my $Success = $Schedulerbject->FutureTaskDelete(
TaskID => 123,
);
=cut
sub FutureTaskDelete {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{TaskID} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need TaskID!',
);
return;
}
my $Success = $Kernel::OM->Get('Kernel::System::Daemon::SchedulerDB')->FutureTaskDelete(%Param);
return $Success;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<http://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.
=cut
|