FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
agent-monk.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2008-2013 Hewlett-Packard Development Company, L.P.
4  * Copyright (C) 2014-2015, Siemens AG
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
19 
21 
23 {
24  public function __construct()
25  {
26  $this->Name = "agent_monk";
27  $this->Title = _("Monk License Analysis, scanning for licenses performing a text comparison");
28  $this->AgentName = "monk";
29 
30  parent::__construct();
31  }
32 
33  function AgentHasResults($uploadId=0)
34  {
35  return CheckARS($uploadId, $this->AgentName, "monk agent", "monk_ars");
36  }
37 
42  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
43  {
44  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
45  if ($this->AgentHasResults($uploadId) == 1) {
46  return 0;
47  }
48 
49  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
50  if ($jobQueueId != 0) {
51  return $jobQueueId;
52  }
53 
54  $args = $unpackArgs;
55  if (!empty($unpackArgs)) {
56  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
57  } else {
58  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
59  }
60  }
61 
68  protected function isAgentIncluded($dependencies, $agentName)
69  {
70  foreach ($dependencies as $dependency) {
71  if ($dependency == $agentName) {
72  return true;
73  }
74  if (is_array($dependency) && $agentName == $dependency['name']) {
75  return true;
76  }
77  }
78  return false;
79  }
80 }
81 
82 register_plugin(new MonkAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-monk.php:42
isAgentIncluded($dependencies, $agentName)
Definition: agent-monk.php:68
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)