FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
agent-ecc.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2014-2015, Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***********************************************************/
18 
20 
26 {
27  public function __construct() {
28  $this->Name = "agent_ecc";
29  $this->Title = _("ECC Analysis, scanning for text fragments potentially relevant for export control");
30  $this->AgentName = "ecc";
31 
32  parent::__construct();
33  }
34 
39  function AgentHasResults($uploadId=0)
40  {
41  return CheckARS($uploadId, $this->AgentName, "ecc scanner", "ecc_ars");
42  }
43 
48  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
49  {
50  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
51  if ($this->AgentHasResults($uploadId) == 1) {
52  return 0;
53  }
54 
55  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
56  if ($jobQueueId != 0) {
57  return $jobQueueId;
58  }
59 
60  $args = $unpackArgs;
61  if (!empty($unpackArgs)) {
62  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
63  } else {
64  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
65  }
66  }
67 
74  protected function isAgentIncluded($dependencies, $agentName)
75  {
76  foreach ($dependencies as $dependency) {
77  if ($dependency == $agentName) {
78  return true;
79  }
80  if (is_array($dependency) && $agentName == $dependency['name']) {
81  return true;
82  }
83  }
84  return false;
85  }
86 }
87 
88 register_plugin(new EccAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
Create UI plugin for ECC agent.
Definition: agent-ecc.php:25
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-ecc.php:48
isAgentIncluded($dependencies, $agentName)
Definition: agent-ecc.php:74
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
AgentHasResults($uploadId=0)
Definition: agent-ecc.php:39
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)