summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-11 14:00:24 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-11 14:00:24 +0100
commita6399f9ceffcf9865b8a2be155dc4f98bd2ee5dc (patch)
tree513f0a0dac1049c21c42538e39dc4d886d3e6f3b /lib/public
parent72f134cfce05eb089a6d8271e73d6eb95cbe94a4 (diff)
downloadnextcloud-server-a6399f9ceffcf9865b8a2be155dc4f98bd2ee5dc.tar.gz
nextcloud-server-a6399f9ceffcf9865b8a2be155dc4f98bd2ee5dc.zip
Add the background job list to the public server container
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/backgroundjob.php14
-rw-r--r--lib/public/backgroundjob/ijob.php29
-rw-r--r--lib/public/backgroundjob/ijoblist.php73
-rw-r--r--lib/public/iservercontainer.php7
4 files changed, 116 insertions, 7 deletions
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index a7f54491dfa..bcaf6e35454 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -33,7 +33,7 @@ use \OC\BackgroundJob\JobList;
/**
* This class provides functions to register backgroundjobs in ownCloud
*
- * To create a new backgroundjob create a new class that inharits from either \OC\BackgroundJob\Job,
+ * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job,
* \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using
* \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function
* of the job when the job is executed.
@@ -73,7 +73,7 @@ class BackgroundJob {
* @param mixed $argument
*/
public static function registerJob($job, $argument = null) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$jobList->add($job, $argument);
}
@@ -99,7 +99,7 @@ class BackgroundJob {
* key is string "$klass-$method", value is array( $klass, $method )
*/
static public function allRegularTasks() {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$regularJobs = array();
foreach ($allJobs as $job) {
@@ -118,7 +118,7 @@ class BackgroundJob {
* @return associative array
*/
public static function findQueuedTask($id) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
return $jobList->getById($id);
}
@@ -128,7 +128,7 @@ class BackgroundJob {
* @return array with associative arrays
*/
public static function allQueuedTasks() {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$queuedJobs = array();
foreach ($allJobs as $job) {
@@ -148,7 +148,7 @@ class BackgroundJob {
* @return array with associative arrays
*/
public static function queuedTaskWhereAppIs($app) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$queuedJobs = array();
foreach ($allJobs as $job) {
@@ -186,7 +186,7 @@ class BackgroundJob {
* Deletes a report
*/
public static function deleteQueuedTask($id) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$job = $jobList->getById($id);
if ($job) {
$jobList->remove($job);
diff --git a/lib/public/backgroundjob/ijob.php b/lib/public/backgroundjob/ijob.php
new file mode 100644
index 00000000000..c427b50401d
--- /dev/null
+++ b/lib/public/backgroundjob/ijob.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\BackgroundJob;
+
+interface IJob {
+ /**
+ * @param \OCP\BackgroundJob\IJobList $jobList
+ * @param \OC\Log $logger
+ */
+ public function execute($jobList, $logger = null);
+
+ public function setId($id);
+
+ public function setLastRun($lastRun);
+
+ public function setArgument($argument);
+
+ public function getId();
+
+ public function getLastRun();
+
+ public function getArgument();
+}
diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php
new file mode 100644
index 00000000000..7e80d51755b
--- /dev/null
+++ b/lib/public/backgroundjob/ijoblist.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\BackgroundJob;
+
+interface IJobList {
+ /**
+ * @param \OCP\BackgroundJob\IJob |string $job
+ * @param mixed $argument
+ */
+ public function add($job, $argument = null);
+
+ /**
+ * @param \OCP\BackgroundJob\IJob|string $job
+ * @param mixed $argument
+ */
+ public function remove($job, $argument = null);
+
+ /**
+ * check if a job is in the list
+ *
+ * @param $job
+ * @param mixed $argument
+ * @return bool
+ */
+ public function has($job, $argument);
+
+ /**
+ * get all jobs in the list
+ *
+ * @return \OCP\BackgroundJob\IJob[]
+ */
+ public function getAll();
+
+ /**
+ * get the next job in the list
+ *
+ * @return \OCP\BackgroundJob\IJob
+ */
+ public function getNext();
+
+ /**
+ * @param int $id
+ * @return \OCP\BackgroundJob\IJob
+ */
+ public function getById($id);
+
+ /**
+ * set the job that was last ran
+ *
+ * @param \OCP\BackgroundJob\IJob $job
+ */
+ public function setLastJob($job);
+
+ /**
+ * get the id of the last ran job
+ *
+ * @return int
+ */
+ public function getLastJob();
+
+ /**
+ * set the lastRun of $job to now
+ *
+ * @param \OCP\BackgroundJob\IJob $job
+ */
+ public function setLastRun($job);
+}
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index 5473f3ee334..0658bd0b022 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -176,4 +176,11 @@ interface IServerContainer {
*/
function getAvatarManager();
+ /**
+ * Returns an job list for controlling background jobs
+ *
+ * @return \OCP\BackgroundJob\IJobList
+ */
+ function getJobList();
+
}