Example #1
0
 /**
  * Run the job by ID
  * @param string $id
  * @param string $client Client that is trying to run the job
  * @return bool|string true on success, false on job failure, error message on failure to run
  */
 public static function runJobId($id, $client)
 {
     $job = new self();
     $job->retrieve($id);
     if (empty($job->id)) {
         $GLOBALS['log']->fatal("Job {$id} not found.");
         return "Job {$id} not found.";
     }
     if ($job->status != self::JOB_STATUS_RUNNING) {
         $GLOBALS['log']->fatal("Job {$id} is not marked as running.");
         return "Job {$id} is not marked as running.";
     }
     if ($job->client != $client) {
         $GLOBALS['log']->fatal("Job {$id} belongs to client {$job->client}, can not run as {$client}.");
         return "Job {$id} belongs to another client, can not run as {$client}.";
     }
     $job->job_done = false;
     register_shutdown_function(array($job, "unexpectedExit"));
     $res = $job->runJob();
     $job->job_done = true;
     return $res;
 }
Example #2
0
 /**
  * Load token by ID
  * @param string $token
  * @return OAuthToken
  */
 static function load($token)
 {
     $ltoken = new self();
     $ltoken->retrieve($token);
     if (empty($ltoken->id)) {
         return null;
     }
     $ltoken->token = $ltoken->id;
     if (!empty($ltoken->consumer)) {
         $ltoken->consumer_obj = BeanFactory::getBean("OAuthKeys", $ltoken->consumer);
         if (empty($ltoken->consumer_obj->id)) {
             return null;
         }
     }
     return $ltoken;
 }
 /**
  * Load token by ID
  * @param string $token
  * @return OAuthToken
  */
 static function load($token)
 {
     $ltoken = new self();
     $ltoken->retrieve($token);
     if (empty($ltoken->id)) {
         return null;
     }
     $ltoken->token = $ltoken->id;
     if (!empty($ltoken->consumer)) {
         $ltoken->consumer_obj = new OAuthKey();
         $ltoken->consumer_obj->retrieve($ltoken->consumer);
         if (empty($ltoken->consumer_obj->id)) {
             return null;
         }
     }
     return $ltoken;
 }
Example #4
0
 /**
  * @param $nodes
  *
  * @return Node
  */
 public static function buildTreeFromAwl($nodes)
 {
     $prevStep = false;
     $conj = false;
     $builder = new self();
     foreach ($nodes as $node) {
         $key = key($node);
         $contents = current($node);
         if (is_array($contents)) {
             $contents = self::buildTreeFromAwl($contents);
         }
         $contents = [$contents];
         if ($key === 'workflow') {
             $builder->add('workflow', $contents)->start();
             continue;
         }
         if ($key === 'step') {
             if ($prevStep) {
                 $builder->end();
             }
             $prevStep = true;
             $builder->add('step', $contents)->start();
             continue;
         }
         if ($key === 'conj') {
             $conj = true;
             $builder->start();
             continue;
         }
         $builder->add($key, $contents);
         if ($conj) {
             $conj = false;
             $builder->end();
         }
     }
     return $builder->retrieve(0);
 }
Example #5
0
 /**
  * Load token by ID
  * @param string $token
  * @param string $oauth_type Either "oauth1" or "oauth2", defaults to "oauth1"
  * @return OAuthToken
  */
 static function load($token, $oauth_type = "oauth1")
 {
     $ltoken = new self();
     $ltoken->retrieve($token);
     if (empty($ltoken->id)) {
         return null;
     }
     $ltoken->token = $ltoken->id;
     if (!empty($ltoken->consumer)) {
         $ltoken->consumer_obj = BeanFactory::getBean('OAuthKeys', $ltoken->consumer);
         if (empty($ltoken->consumer_obj->id) || $ltoken->consumer_obj->oauth_type != $oauth_type) {
             return null;
         }
     }
     return $ltoken;
 }