FOSSology  4.5.1
Open Source License Compliance by Open Source Software
UploadHelper.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2018, 2020 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
13 namespace Fossology\UI\Api\Helper;
14 
40 use Symfony\Component\HttpFoundation\File\UploadedFile;
41 use UIExportList;
42 
48 {
53  private $uploadFilePage;
54 
59  private $uploadVcsPage;
60 
65  private $uploadUrlPage;
66 
71  private $uploadSrvPage;
72 
77  const VALID_VCS_TYPES = array(
78  "git",
79  "svn"
80  );
81 
86  const VALID_UPLOAD_TYPES = array(
87  "vcs",
88  "url",
89  "server"
90  );
91 
95  public function __construct()
96  {
97  $this->uploadFilePage = new HelperToUploadFilePage();
98  $this->uploadVcsPage = new HelperToUploadVcsPage();
99  $this->uploadUrlPage = new HelperToUploadUrlPage();
100  $this->uploadSrvPage = new HelperToUploadSrvPage();
101  }
102 
114  public function handleScheduleAnalysis($uploadId, $folderId, $scanOptionsJSON,
115  $newUpload = false, $apiVersion = ApiVersion::V1)
116  {
117  global $container;
118  $restHelper = $container->get('helper.restHelper');
119 
120  $parametersSent = false;
121  $analysis = new Analysis();
122 
123  if (array_key_exists("analysis", $scanOptionsJSON) && ! empty($scanOptionsJSON["analysis"])) {
124  $analysis->setUsingArray($scanOptionsJSON["analysis"], $apiVersion);
125  $parametersSent = true;
126  }
127 
128  $decider = new Decider();
129  $decider->setDeciderAgentPlugin($restHelper->getPlugin('agent_decider'));
130  if (array_key_exists("decider", $scanOptionsJSON) && ! empty($scanOptionsJSON["decider"])) {
131  $decider->setUsingArray($scanOptionsJSON["decider"], $apiVersion);
132  $parametersSent = true;
133  }
134 
135  $scancode = new Scancode();
136  if (array_key_exists("scancode", $scanOptionsJSON) && ! empty($scanOptionsJSON["scancode"])) {
137  $scancode->setUsingArray($scanOptionsJSON["scancode"]);
138  $parametersSent = true;
139  }
140 
141  $reuser = new Reuser(0, 'groupName', false, false);
142  try {
143  if (array_key_exists("reuse", $scanOptionsJSON) && ! empty($scanOptionsJSON["reuse"])) {
144  $reuser->setUsingArray($scanOptionsJSON["reuse"], $apiVersion);
145  $parametersSent = true;
146  }
147  } catch (\UnexpectedValueException $e) {
148  throw new HttpBadRequestException($e->getMessage(), $e);
149  }
150 
151  if (! $parametersSent) {
152  throw new HttpBadRequestException("No parameters selected for agents!");
153  }
154 
155  $scanOptions = new ScanOptions($analysis, $reuser, $decider, $scancode);
156  return $scanOptions->scheduleAgents($folderId, $uploadId, $newUpload);
157  }
158 
159 
175  public function createNewUpload($reqBody, $folderId, $fileDescription,
176  $isPublic, $ignoreScm, $uploadType,
177  $applyGlobal = false)
178  {
179  $symReq = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
180  $uploadedFile = $symReq->files->get($this->uploadFilePage::FILE_INPUT_NAME,
181  null);
182 
183  if ($applyGlobal) {
184  // If global decisions should be ignored
185  $applyGlobal = 1;
186  } else {
187  $applyGlobal = 0;
188  }
189 
190  if (! empty($ignoreScm) && ($ignoreScm == "true")) {
191  // If SCM should be ignored
192  $ignoreScm = 1;
193  } else {
194  $ignoreScm = 0;
195  }
196  if (empty($uploadedFile)) {
197  if (empty($uploadType)) {
198  return array(false, "Missing 'uploadType' header",
199  "Send file with parameter " . $this->uploadFilePage::FILE_INPUT_NAME .
200  " or define 'uploadType' header with appropriate body.",
201  - 1
202  );
203  }
204  return $this->handleUpload($reqBody, $uploadType, $folderId,
205  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
206  } else {
207  return $this->createFileUpload($uploadedFile, $folderId,
208  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
209  }
210  }
211 
223  private function createFileUpload($uploadedFile, $folderId, $fileDescription,
224  $isPublic, $ignoreScm = 0, $applyGlobal = 0)
225  {
226  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
227  $symfonySession = $GLOBALS['container']->get('session');
228  $symfonySession->set(
229  $this->uploadFilePage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
230 
231  $symfonyRequest->request->set($this->uploadFilePage::FOLDER_PARAMETER_NAME,
232  $folderId);
233  $symfonyRequest->request->set(
234  $this->uploadFilePage::DESCRIPTION_INPUT_NAME,
235  [$fileDescription]);
236  $symfonyRequest->files->set($this->uploadFilePage::FILE_INPUT_NAME,
237  [$uploadedFile]);
238  $symfonyRequest->setSession($symfonySession);
239  $symfonyRequest->request->set(
240  $this->uploadFilePage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
241  $symfonyRequest->request->set('public', $isPublic);
242  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
243  $symfonyRequest->request->set('scm', $ignoreScm);
244 
245  return $this->uploadFilePage->handleRequest($symfonyRequest);
246  }
247 
260  private function handleUpload($body, $uploadType, $folderId, $fileDescription,
261  $isPublic, $ignoreScm = 0, $applyGlobal = 0)
262  {
263  $sanity = false;
264  switch ($uploadType) {
265  case "vcs":
266  $sanity = $this->sanitizeVcsData($body);
267  break;
268  case "url":
269  $sanity = $this->sanitizeUrlData($body);
270  break;
271  case "server":
272  $sanity = $this->sanitizeSrvData($body);
273  break;
274  default:
275  $message = "Invalid 'uploadType'";
276  $statusDescription = "uploadType should be any of (" .
277  implode(",", self::VALID_UPLOAD_TYPES) . ")";
278  $code = 400;
279  $sanity = array(false, $message, $statusDescription, $code);
280  }
281  if ($sanity !== true) {
282  return $sanity;
283  }
284  $uploadResponse = false;
285  switch ($uploadType) {
286  case "vcs":
287  $uploadResponse = $this->generateVcsUpload($body, $folderId,
288  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
289  break;
290  case "url":
291  $uploadResponse = $this->generateUrlUpload($body, $folderId,
292  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
293  break;
294  case "server":
295  $uploadResponse = $this->generateSrvUpload($body, $folderId,
296  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
297  break;
298  }
299  return $uploadResponse;
300  }
301 
312  private function sanitizeVcsData(&$vcsData)
313  {
314  $message = "";
315  $statusDescription = "";
316  $code = 0;
317 
318  if (! array_key_exists("vcsType", $vcsData) ||
319  ! in_array($vcsData["vcsType"], self::VALID_VCS_TYPES)) {
320  $message = "Missing vcsType";
321  $statusDescription = "vcsType should be any of (" .
322  implode(", ", self::VALID_VCS_TYPES) . ")";
323  $code = 400;
324  }
325  $vcsType = "";
326  if ($vcsData["vcsType"] == "git") {
327  $vcsType = "Git";
328  } else {
329  $vcsType = "SVN";
330  }
331 
332  if (! array_key_exists("vcsUrl", $vcsData)) {
333  $message = "Missing vcsUrl";
334  $statusDescription = "vcsUrl should be passed.";
335  $code = 400;
336  }
337 
338  if (! array_key_exists("vcsName", $vcsData)) {
339  $vcsData["vcsName"] = "";
340  }
341  if (! array_key_exists("vcsUsername", $vcsData)) {
342  $vcsData["vcsUsername"] = "";
343  }
344  if (! array_key_exists("vcsPassword", $vcsData)) {
345  $vcsData["vcsPassword"] = "";
346  }
347  if (! array_key_exists("vcsBranch", $vcsData)) {
348  $vcsData["vcsBranch"] = "";
349  }
350  $vcsData["vcsType"] = $vcsType;
351  if ($code !== 0) {
352  return array(false, $message, $statusDescription, $code);
353  } else {
354  return true;
355  }
356  }
357 
367  private function sanitizeUrlData(&$urlData)
368  {
369  $message = "";
370  $statusDescription = "";
371  $code = 0;
372 
373  if (! array_key_exists("url", $urlData)) {
374  $message = "Missing url";
375  $statusDescription = "Missing upload url from request";
376  $code = 400;
377  }
378 
379  if (! array_key_exists("name", $urlData)) {
380  $urlData["name"] = "";
381  }
382  if (! array_key_exists("accept", $urlData)) {
383  $urlData["accept"] = "";
384  }
385  if (! array_key_exists("reject", $urlData)) {
386  $urlData["reject"] = "";
387  }
388  if (! array_key_exists("maxRecursionDepth", $urlData)) {
389  $urlData["maxRecursionDepth"] = "";
390  }
391  if ($code !== 0) {
392  return array(false, $message, $statusDescription, $code);
393  } else {
394  return true;
395  }
396  }
397 
407  private function sanitizeSrvData(&$srvData)
408  {
409  $message = "";
410  $statusDescription = "";
411  $code = 0;
412 
413  if (! array_key_exists("path", $srvData)) {
414  $message = "Missing path";
415  $statusDescription = "Missing upload path from request";
416  $code = 400;
417  }
418 
419  if (! array_key_exists("name", $srvData)) {
420  $srvData["name"] = "";
421  }
422  if ($code !== 0) {
423  return array(false, $message, $statusDescription, $code);
424  } else {
425  return true;
426  }
427  }
428 
439  private function generateVcsUpload($vcsData, $folderId, $fileDescription,
440  $isPublic, $ignoreScm, $applyGlobal)
441  {
442  $vcsType = $vcsData["vcsType"];
443  $vcsUrl = $vcsData["vcsUrl"];
444  $vcsName = $vcsData["vcsName"];
445  $vcsUsername = $vcsData["vcsUsername"];
446  $vcsPasswd = $vcsData["vcsPassword"];
447  $vcsBranch = $vcsData["vcsBranch"];
448 
449  $symfonySession = $GLOBALS['container']->get('session');
450  $symfonySession->set($this->uploadVcsPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
451  "restUpload");
452 
453  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
454  $symfonyRequest->setSession($symfonySession);
455 
456  $symfonyRequest->request->set($this->uploadVcsPage::FOLDER_PARAMETER_NAME,
457  $folderId);
458  $symfonyRequest->request->set($this->uploadVcsPage::DESCRIPTION_INPUT_NAME,
459  $fileDescription);
460  $symfonyRequest->request->set($this->uploadVcsPage::GETURL_PARAM, $vcsUrl);
461  $symfonyRequest->request->set(
462  $this->uploadVcsPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
463  $symfonyRequest->request->set('public', $isPublic);
464  $symfonyRequest->request->set('name', $vcsName);
465  $symfonyRequest->request->set('vcstype', $vcsType);
466  $symfonyRequest->request->set('username', $vcsUsername);
467  $symfonyRequest->request->set('passwd', $vcsPasswd);
468  $symfonyRequest->request->set('branch', $vcsBranch);
469  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
470  $symfonyRequest->request->set('scm', $ignoreScm);
471 
472  return $this->uploadVcsPage->handleRequest($symfonyRequest);
473  }
474 
485  private function generateUrlUpload($urlData, $folderName, $fileDescription,
486  $isPublic, $ignoreScm, $applyGlobal)
487  {
488  $url = $urlData["url"];
489  $name = $urlData["name"];
490  $accept = $urlData["accept"];
491  $reject = $urlData["reject"];
492  $maxRecursionDepth = $urlData["maxRecursionDepth"];
493 
494  $symfonySession = $GLOBALS['container']->get('session');
495  $symfonySession->set($this->uploadUrlPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
496  "restUpload");
497 
498  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
499  $symfonyRequest->setSession($symfonySession);
500 
501  $symfonyRequest->request->set($this->uploadUrlPage::FOLDER_PARAMETER_NAME,
502  $folderName);
503  $symfonyRequest->request->set($this->uploadUrlPage::DESCRIPTION_INPUT_NAME,
504  $fileDescription);
505  $symfonyRequest->request->set(
506  $this->uploadUrlPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
507  $symfonyRequest->request->set('public', $isPublic);
508  $symfonyRequest->request->set($this->uploadUrlPage::NAME_PARAM, $name);
509  $symfonyRequest->request->set($this->uploadUrlPage::ACCEPT_PARAM, $accept);
510  $symfonyRequest->request->set($this->uploadUrlPage::REJECT_PARAM, $reject);
511  $symfonyRequest->request->set($this->uploadUrlPage::GETURL_PARAM, $url);
512  $symfonyRequest->request->set($this->uploadUrlPage::LEVEL_PARAM,
513  $maxRecursionDepth);
514  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
515  $symfonyRequest->request->set('scm', $ignoreScm);
516 
517  return $this->uploadUrlPage->handleRequest($symfonyRequest);
518  }
519 
530  private function generateSrvUpload($srvData, $folderName, $fileDescription,
531  $isPublic, $ignoreScm, $applyGlobal)
532  {
533  $path = $srvData["path"];
534  $name = $srvData["name"];
535 
536  $symfonySession = $GLOBALS['container']->get('session');
537  $symfonySession->set($this->uploadSrvPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
538  "restUpload");
539 
540  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
541  $symfonyRequest->setSession($symfonySession);
542 
543  $symfonyRequest->request->set($this->uploadSrvPage::FOLDER_PARAMETER_NAME,
544  $folderName);
545  $symfonyRequest->request->set($this->uploadSrvPage::DESCRIPTION_INPUT_NAME,
546  $fileDescription);
547  $symfonyRequest->request->set(
548  $this->uploadSrvPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
549  $symfonyRequest->request->set('public', $isPublic);
550  $symfonyRequest->request->set($this->uploadSrvPage::SOURCE_FILES_FIELD,
551  $path);
552  $symfonyRequest->request->set($this->uploadSrvPage::NAME_PARAM, $name);
553  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
554  $symfonyRequest->request->set('scm', $ignoreScm);
555 
556  return $this->uploadSrvPage->handleRequest($symfonyRequest);
557  }
558 
565  public function generateUploadSummary($uploadId, $groupId)
566  {
567  global $container;
568  $restHelper = $container->get('helper.restHelper');
569  $uploadDao = $restHelper->getUploadDao();
570  $dbManager = $restHelper->getDbHelper()->getDbManager();
571  $copyrightDao = $container->get('dao.copyright');
572  $agentDao = $container->get('dao.agent');
573 
574  $agentName = "copyright";
575  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
576 
577  $noLicenseUploadTreeView = new UploadTreeProxy($uploadId,
578  array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense",
579  UploadTreeProxy::OPT_GROUP_ID => $groupId),
580  $uploadTreeTableName,
581  'no_license_uploadtree' . $uploadId);
582  $clearingCount = $noLicenseUploadTreeView->count();
583 
584  $nonClearedUploadTreeView = new UploadTreeProxy($uploadId,
585  array(UploadTreeProxy::OPT_SKIP_THESE => "alreadyCleared",
586  UploadTreeProxy::OPT_GROUP_ID => $groupId),
587  $uploadTreeTableName,
588  'already_cleared_uploadtree' . $uploadId);
589  $filesToBeCleared = $nonClearedUploadTreeView->count();
590 
591  $itemTreeBounds = $uploadDao->getParentItemBounds($uploadId,
592  $uploadTreeTableName);
593  $scanProx = new ScanJobProxy($agentDao, $uploadId);
594  $scanProx->createAgentStatus([$agentName]);
595  $agents = $scanProx->getLatestSuccessfulAgentIds();
596  $copyrightCount = 0;
597  if (array_key_exists($agentName, $agents) && ! empty($agents[$agentName])) {
598  $copyrightCount = count(
599  $copyrightDao->getAllEntriesReport($agentName, $uploadId,
600  $uploadTreeTableName, null, false, null, "C.agent_fk = " .
601  $agents[$agentName], $groupId));
602  }
603 
604  $mainLicenses = $this->getMainLicenses($dbManager, $uploadId, $groupId);
605 
607  $uiLicense = $restHelper->getPlugin("license");
608  $hist = $uiLicense->getUploadHist($itemTreeBounds);
609  if (!is_array($hist) || !array_key_exists('uniqueLicenseCount', $hist)) {
610  $hist = [];
611  $hist['uniqueLicenseCount'] = 0;
612  $hist['scannerLicenseCount'] = 0;
613  $hist['editedUniqueLicenseCount'] = 0;
614  $hist['editedLicenseCount'] = 0;
615  }
616 
617  $summary = new UploadSummary();
618  $summary->setUploadId($uploadId);
619  $summary->setUploadName($uploadDao->getUpload($uploadId)->getFilename());
620  $summary->setAssignee($uploadDao->getAssignee($uploadId, $groupId));
621  if ($mainLicenses !== null) {
622  $summary->setMainLicense(implode(",", $mainLicenses));
623  }
624  $summary->setUniqueLicenses($hist['uniqueLicenseCount']);
625  $summary->setTotalLicenses($hist['scannerLicenseCount']);
626  $summary->setUniqueConcludedLicenses($hist['editedUniqueLicenseCount']);
627  $summary->setTotalConcludedLicenses($hist['editedLicenseCount']);
628  $summary->setFilesToBeCleared($filesToBeCleared);
629  $summary->setFilesCleared($clearingCount);
630  $summary->setClearingStatus($uploadDao->getStatus($uploadId, $groupId));
631  $summary->setCopyrightCount($copyrightCount);
632  return $summary;
633  }
634 
642  private function getMainLicenses($dbManager, $uploadId, $groupId)
643  {
644  $sql = "SELECT rf_shortname FROM license_ref lf JOIN upload_clearing_license ucl"
645  . " ON lf.rf_pk=ucl.rf_fk WHERE upload_fk=$1 AND ucl.group_fk=$2";
646  $stmt = __METHOD__.'.collectMainLicenses';
647  $rows = $dbManager->getRows($sql, array($uploadId, $groupId), $stmt);
648  if (empty($rows)) {
649  return null;
650  }
651  $mainLicenses = [];
652  foreach ($rows as $row) {
653  $mainLicenses[] = $row['rf_shortname'];
654  }
655  return $mainLicenses;
656  }
657 
664  public function getUploadCopyrightList($uploadId)
665  {
666  global $container;
667  $restHelper = $container->get('helper.restHelper');
668  $uploadDao = $restHelper->getUploadDao();
669 
670  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
671  $parent = $uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
672 
676  $copyrightListObj = $restHelper->getPlugin('export-list');
677  $copyrightList = $copyrightListObj->getCopyrights($uploadId,
678  $parent->getItemId(), $uploadTreeTableName, -1, '');
679  if (array_key_exists("warn", $copyrightList)) {
680  unset($copyrightList["warn"]);
681  }
682 
683  $responseList = array();
684  foreach ($copyrightList as $copyFilepath) {
685  $flag=0;
686  foreach ($responseList as $response) {
687  if ($copyFilepath['content'] == $response['copyright']) {
688  $flag=1;
689  break;
690  }
691  }
692  if ($flag==0) {
693  $copyrightContent = array();
694  foreach ($copyrightList as $copy) {
695  if (strcasecmp($copyFilepath['content'], $copy['content']) == 0) {
696  $copyrightContent[] = $copy['filePath'];
697  }
698  }
699  $responseRow = array();
700  $responseRow['copyright'] = $copyFilepath['content'];
701  $responseRow['filePath'] = $copyrightContent;
702  $responseList[] = $responseRow;
703  }
704  }
705  return $responseList;
706  }
707 
716  public function fetchClearingStatus($itemTreeBounds, $clearingDao, $groupId)
717  {
718  $decTypes = new DecisionTypes;
719  if ($itemTreeBounds !== null) {
720  $clearingList = $clearingDao->getFileClearings($itemTreeBounds, $groupId);
721  } else {
722  $clearingList = [];
723  }
724 
725  $clearingArray = [];
726  foreach ($clearingList as $clearingDecision) {
727  $clearingArray[] = $clearingDecision->getType();
728  }
729 
730  if (empty($clearingArray) || $clearingArray[0] === null) {
731  return "NOASSERTION";
732  } else {
733  return $decTypes->getTypeName($clearingArray[0]);
734  }
735  }
736 
747  public function getUploadLicenseList($uploadId, $agents, $printContainers, $boolLicense, $boolCopyright, $page = 0, $limit = 50, $apiVersion=ApiVersion::V1)
748  {
749  global $container;
750  $restHelper = $container->get('helper.restHelper');
751  $uploadDao = $restHelper->getUploadDao();
752  $agentDao = $container->get('dao.agent');
753  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
754  $parent = $uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
755  $groupId = $restHelper->getGroupId();
756  $scanProx = new ScanJobProxy($agentDao, $uploadId);
757  $scanProx->createAgentStatus($agents);
758  $agent_ids = $scanProx->getLatestSuccessfulAgentIds();
759  $clearingDao = $container->get("dao.clearing");
760 
764  if ($boolLicense) {
765  $licenseListObj = $restHelper->getPlugin('export-list');
766  $licenseList = $licenseListObj->createListOfLines($uploadTreeTableName,
767  $parent->getItemId(), $agent_ids, -1, true, '', !$printContainers);
768  if (array_key_exists("warn", $licenseList)) {
769  unset($licenseList["warn"]);
770  }
771  }
772 
776  if ($boolCopyright) {
777  $copyrightListObj = $restHelper->getPlugin('export-list');
778  $copyrightList = $copyrightListObj->getCopyrights($uploadId,
779  $parent->getItemId(), $uploadTreeTableName, -1, '');
780  if (array_key_exists("warn", $copyrightList)) {
781  unset($copyrightList["warn"]);
782  }
783  }
784 
785  $responseList = array();
786 
787  if ($boolLicense) {
788  foreach ($licenseList as $license) {
789  $copyrightContent = null;
790  if ($boolCopyright) {
791  $copyrightContent = [];
792  foreach ($copyrightList as $copy) {
793  if (($license['filePath'] == $copy['filePath']) !== false ) {
794  $copyrightContent[] = $copy['content'];
795  }
796  }
797  if (count($copyrightContent)==0) {
798  $copyrightContent = null;
799  }
800  }
801 
802  $findings = new Findings($license['agentFindings'],
803  $license['conclusions'], $copyrightContent);
804  $uploadTreeTableId = $license['uploadtree_pk'];
805  $uploadtree_tablename = $uploadDao->getUploadtreeTableName($uploadId);
806  if ($uploadTreeTableId!==null) {
807  $itemTreeBounds = $uploadDao->getItemTreeBounds($uploadTreeTableId,$uploadtree_tablename);
808  } else {
809  $itemTreeBounds=null;
810  }
811  $clearingDecision = $this->fetchClearingStatus($itemTreeBounds,
812  $clearingDao, $groupId);
813  $responseRow = new FileLicenses($license['filePath'], $findings,
814  $clearingDecision);
815  $responseList[] = $responseRow->getArray($apiVersion);
816  }
817  } elseif (!$boolLicense && $boolCopyright) {
818  foreach ($copyrightList as $copyFilepath) {
819  $copyrightContent = array();
820  foreach ($copyrightList as $copy) {
821  if (($copyFilepath['filePath'] == $copy['filePath']) === true) {
822  $copyrightContent[] = $copy['content'];
823  }
824  }
825  $findings = new Findings();
826  $findings->setCopyright($copyrightContent);
827  $responseRow = new FileLicenses($copyFilepath['filePath'], $findings);
828  $responseList[] = $responseRow->getArray($apiVersion);
829  }
830  }
831  $offset = $page * $limit;
832  $paginatedResponseList = array_slice($responseList, $offset, $limit);
833  $paginatedResponseListSize = sizeof($responseList);
834  return array($paginatedResponseList, $paginatedResponseListSize);
835  }
836 }
Fossology exception.
Definition: Exception.php:15
Handle new file uploads from Slim framework and move to FOSSology.
handleScheduleAnalysis($uploadId, $folderId, $scanOptionsJSON, $newUpload=false, $apiVersion=ApiVersion::V1)
sanitizeUrlData(&$urlData)
Check if the passed URL object is correct or not.
generateUrlUpload($urlData, $folderName, $fileDescription, $isPublic, $ignoreScm, $applyGlobal)
getMainLicenses($dbManager, $uploadId, $groupId)
createNewUpload($reqBody, $folderId, $fileDescription, $isPublic, $ignoreScm, $uploadType, $applyGlobal=false)
generateVcsUpload($vcsData, $folderId, $fileDescription, $isPublic, $ignoreScm, $applyGlobal)
fetchClearingStatus($itemTreeBounds, $clearingDao, $groupId)
sanitizeSrvData(&$srvData)
Check if the passed server upload object is correct or not.
generateSrvUpload($srvData, $folderName, $fileDescription, $isPublic, $ignoreScm, $applyGlobal)
createFileUpload($uploadedFile, $folderId, $fileDescription, $isPublic, $ignoreScm=0, $applyGlobal=0)
handleUpload($body, $uploadType, $folderId, $fileDescription, $isPublic, $ignoreScm=0, $applyGlobal=0)
sanitizeVcsData(&$vcsData)
Check if the passed VCS object is correct or not.
Model to hold analysis settings.
Definition: Analysis.php:21
Model holding information about license findings and conclusions.
Definition: Findings.php:18
Info model to contain general error and return values.
Definition: Info.php:19
Model to hold info required by Reuser agent.
Definition: Reuser.php:18
Model to hold add settings for new scan.
Definition: ScanOptions.php:32
Model class to hold Upload info.
REST api helper classes.