FOSSology  4.4.0
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)
116  {
117  $parametersSent = false;
118  $analysis = new Analysis();
119 
120  if (array_key_exists("analysis", $scanOptionsJSON) && ! empty($scanOptionsJSON["analysis"])) {
121  $analysis->setUsingArray($scanOptionsJSON["analysis"]);
122  $parametersSent = true;
123  }
124 
125  $decider = new Decider();
126  if (array_key_exists("decider", $scanOptionsJSON) && ! empty($scanOptionsJSON["decider"])) {
127  $decider->setUsingArray($scanOptionsJSON["decider"]);
128  $parametersSent = true;
129  }
130 
131  $scancode = new Scancode();
132  if (array_key_exists("scancode", $scanOptionsJSON) && ! empty($scanOptionsJSON["scancode"])) {
133  $scancode->setUsingArray($scanOptionsJSON["scancode"]);
134  $parametersSent = true;
135  }
136 
137  $reuser = new Reuser(0, 'groupName', false, false);
138  try {
139  if (array_key_exists("reuse", $scanOptionsJSON) && ! empty($scanOptionsJSON["reuse"])) {
140  $reuser->setUsingArray($scanOptionsJSON["reuse"]);
141  $parametersSent = true;
142  }
143  } catch (\UnexpectedValueException $e) {
144  throw new HttpBadRequestException($e->getMessage(), $e);
145  }
146 
147  if (! $parametersSent) {
148  throw new HttpBadRequestException("No parameters selected for agents!");
149  }
150 
151  $scanOptions = new ScanOptions($analysis, $reuser, $decider, $scancode);
152  return $scanOptions->scheduleAgents($folderId, $uploadId, $newUpload);
153  }
154 
155 
171  public function createNewUpload($reqBody, $folderId, $fileDescription,
172  $isPublic, $ignoreScm, $uploadType,
173  $applyGlobal = false)
174  {
175  $symReq = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
176  $uploadedFile = $symReq->files->get($this->uploadFilePage::FILE_INPUT_NAME,
177  null);
178 
179  if ($applyGlobal) {
180  // If global decisions should be ignored
181  $applyGlobal = 1;
182  } else {
183  $applyGlobal = 0;
184  }
185 
186  if (! empty($ignoreScm) && ($ignoreScm == "true")) {
187  // If SCM should be ignored
188  $ignoreScm = 1;
189  } else {
190  $ignoreScm = 0;
191  }
192  if (empty($uploadedFile)) {
193  if (empty($uploadType)) {
194  return array(false, "Missing 'uploadType' header",
195  "Send file with parameter " . $this->uploadFilePage::FILE_INPUT_NAME .
196  " or define 'uploadType' header with appropriate body.",
197  - 1
198  );
199  }
200  return $this->handleUpload($reqBody, $uploadType, $folderId,
201  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
202  } else {
203  return $this->createFileUpload($uploadedFile, $folderId,
204  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
205  }
206  }
207 
219  private function createFileUpload($uploadedFile, $folderId, $fileDescription,
220  $isPublic, $ignoreScm = 0, $applyGlobal = 0)
221  {
222  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
223  $symfonySession = $GLOBALS['container']->get('session');
224  $symfonySession->set(
225  $this->uploadFilePage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
226 
227  $symfonyRequest->request->set($this->uploadFilePage::FOLDER_PARAMETER_NAME,
228  $folderId);
229  $symfonyRequest->request->set(
230  $this->uploadFilePage::DESCRIPTION_INPUT_NAME,
231  [$fileDescription]);
232  $symfonyRequest->files->set($this->uploadFilePage::FILE_INPUT_NAME,
233  [$uploadedFile]);
234  $symfonyRequest->setSession($symfonySession);
235  $symfonyRequest->request->set(
236  $this->uploadFilePage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
237  $symfonyRequest->request->set('public', $isPublic);
238  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
239  $symfonyRequest->request->set('scm', $ignoreScm);
240 
241  return $this->uploadFilePage->handleRequest($symfonyRequest);
242  }
243 
256  private function handleUpload($body, $uploadType, $folderId, $fileDescription,
257  $isPublic, $ignoreScm = 0, $applyGlobal = 0)
258  {
259  $sanity = false;
260  switch ($uploadType) {
261  case "vcs":
262  $sanity = $this->sanitizeVcsData($body);
263  break;
264  case "url":
265  $sanity = $this->sanitizeUrlData($body);
266  break;
267  case "server":
268  $sanity = $this->sanitizeSrvData($body);
269  break;
270  default:
271  $message = "Invalid 'uploadType'";
272  $statusDescription = "uploadType should be any of (" .
273  implode(",", self::VALID_UPLOAD_TYPES) . ")";
274  $code = 400;
275  $sanity = array(false, $message, $statusDescription, $code);
276  }
277  if ($sanity !== true) {
278  return $sanity;
279  }
280  $uploadResponse = false;
281  switch ($uploadType) {
282  case "vcs":
283  $uploadResponse = $this->generateVcsUpload($body, $folderId,
284  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
285  break;
286  case "url":
287  $uploadResponse = $this->generateUrlUpload($body, $folderId,
288  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
289  break;
290  case "server":
291  $uploadResponse = $this->generateSrvUpload($body, $folderId,
292  $fileDescription, $isPublic, $ignoreScm, $applyGlobal);
293  break;
294  }
295  return $uploadResponse;
296  }
297 
308  private function sanitizeVcsData(&$vcsData)
309  {
310  $message = "";
311  $statusDescription = "";
312  $code = 0;
313 
314  if (! array_key_exists("vcsType", $vcsData) ||
315  ! in_array($vcsData["vcsType"], self::VALID_VCS_TYPES)) {
316  $message = "Missing vcsType";
317  $statusDescription = "vcsType should be any of (" .
318  implode(", ", self::VALID_VCS_TYPES) . ")";
319  $code = 400;
320  }
321  $vcsType = "";
322  if ($vcsData["vcsType"] == "git") {
323  $vcsType = "Git";
324  } else {
325  $vcsType = "SVN";
326  }
327 
328  if (! array_key_exists("vcsUrl", $vcsData)) {
329  $message = "Missing vcsUrl";
330  $statusDescription = "vcsUrl should be passed.";
331  $code = 400;
332  }
333 
334  if (! array_key_exists("vcsName", $vcsData)) {
335  $vcsData["vcsName"] = "";
336  }
337  if (! array_key_exists("vcsUsername", $vcsData)) {
338  $vcsData["vcsUsername"] = "";
339  }
340  if (! array_key_exists("vcsPassword", $vcsData)) {
341  $vcsData["vcsPassword"] = "";
342  }
343  if (! array_key_exists("vcsBranch", $vcsData)) {
344  $vcsData["vcsBranch"] = "";
345  }
346  $vcsData["vcsType"] = $vcsType;
347  if ($code !== 0) {
348  return array(false, $message, $statusDescription, $code);
349  } else {
350  return true;
351  }
352  }
353 
363  private function sanitizeUrlData(&$urlData)
364  {
365  $message = "";
366  $statusDescription = "";
367  $code = 0;
368 
369  if (! array_key_exists("url", $urlData)) {
370  $message = "Missing url";
371  $statusDescription = "Missing upload url from request";
372  $code = 400;
373  }
374 
375  if (! array_key_exists("name", $urlData)) {
376  $urlData["name"] = "";
377  }
378  if (! array_key_exists("accept", $urlData)) {
379  $urlData["accept"] = "";
380  }
381  if (! array_key_exists("reject", $urlData)) {
382  $urlData["reject"] = "";
383  }
384  if (! array_key_exists("maxRecursionDepth", $urlData)) {
385  $urlData["maxRecursionDepth"] = "";
386  }
387  if ($code !== 0) {
388  return array(false, $message, $statusDescription, $code);
389  } else {
390  return true;
391  }
392  }
393 
403  private function sanitizeSrvData(&$srvData)
404  {
405  $message = "";
406  $statusDescription = "";
407  $code = 0;
408 
409  if (! array_key_exists("path", $srvData)) {
410  $message = "Missing path";
411  $statusDescription = "Missing upload path from request";
412  $code = 400;
413  }
414 
415  if (! array_key_exists("name", $srvData)) {
416  $srvData["name"] = "";
417  }
418  if ($code !== 0) {
419  return array(false, $message, $statusDescription, $code);
420  } else {
421  return true;
422  }
423  }
424 
435  private function generateVcsUpload($vcsData, $folderId, $fileDescription,
436  $isPublic, $ignoreScm, $applyGlobal)
437  {
438  $vcsType = $vcsData["vcsType"];
439  $vcsUrl = $vcsData["vcsUrl"];
440  $vcsName = $vcsData["vcsName"];
441  $vcsUsername = $vcsData["vcsUsername"];
442  $vcsPasswd = $vcsData["vcsPassword"];
443  $vcsBranch = $vcsData["vcsBranch"];
444 
445  $symfonySession = $GLOBALS['container']->get('session');
446  $symfonySession->set($this->uploadVcsPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
447  "restUpload");
448 
449  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
450  $symfonyRequest->setSession($symfonySession);
451 
452  $symfonyRequest->request->set($this->uploadVcsPage::FOLDER_PARAMETER_NAME,
453  $folderId);
454  $symfonyRequest->request->set($this->uploadVcsPage::DESCRIPTION_INPUT_NAME,
455  $fileDescription);
456  $symfonyRequest->request->set($this->uploadVcsPage::GETURL_PARAM, $vcsUrl);
457  $symfonyRequest->request->set(
458  $this->uploadVcsPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
459  $symfonyRequest->request->set('public', $isPublic);
460  $symfonyRequest->request->set('name', $vcsName);
461  $symfonyRequest->request->set('vcstype', $vcsType);
462  $symfonyRequest->request->set('username', $vcsUsername);
463  $symfonyRequest->request->set('passwd', $vcsPasswd);
464  $symfonyRequest->request->set('branch', $vcsBranch);
465  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
466  $symfonyRequest->request->set('scm', $ignoreScm);
467 
468  return $this->uploadVcsPage->handleRequest($symfonyRequest);
469  }
470 
481  private function generateUrlUpload($urlData, $folderName, $fileDescription,
482  $isPublic, $ignoreScm, $applyGlobal)
483  {
484  $url = $urlData["url"];
485  $name = $urlData["name"];
486  $accept = $urlData["accept"];
487  $reject = $urlData["reject"];
488  $maxRecursionDepth = $urlData["maxRecursionDepth"];
489 
490  $symfonySession = $GLOBALS['container']->get('session');
491  $symfonySession->set($this->uploadUrlPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
492  "restUpload");
493 
494  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
495  $symfonyRequest->setSession($symfonySession);
496 
497  $symfonyRequest->request->set($this->uploadUrlPage::FOLDER_PARAMETER_NAME,
498  $folderName);
499  $symfonyRequest->request->set($this->uploadUrlPage::DESCRIPTION_INPUT_NAME,
500  $fileDescription);
501  $symfonyRequest->request->set(
502  $this->uploadUrlPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
503  $symfonyRequest->request->set('public', $isPublic);
504  $symfonyRequest->request->set($this->uploadUrlPage::NAME_PARAM, $name);
505  $symfonyRequest->request->set($this->uploadUrlPage::ACCEPT_PARAM, $accept);
506  $symfonyRequest->request->set($this->uploadUrlPage::REJECT_PARAM, $reject);
507  $symfonyRequest->request->set($this->uploadUrlPage::GETURL_PARAM, $url);
508  $symfonyRequest->request->set($this->uploadUrlPage::LEVEL_PARAM,
509  $maxRecursionDepth);
510  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
511  $symfonyRequest->request->set('scm', $ignoreScm);
512 
513  return $this->uploadUrlPage->handleRequest($symfonyRequest);
514  }
515 
526  private function generateSrvUpload($srvData, $folderName, $fileDescription,
527  $isPublic, $ignoreScm, $applyGlobal)
528  {
529  $path = $srvData["path"];
530  $name = $srvData["name"];
531 
532  $symfonySession = $GLOBALS['container']->get('session');
533  $symfonySession->set($this->uploadSrvPage::UPLOAD_FORM_BUILD_PARAMETER_NAME,
534  "restUpload");
535 
536  $symfonyRequest = new \Symfony\Component\HttpFoundation\Request();
537  $symfonyRequest->setSession($symfonySession);
538 
539  $symfonyRequest->request->set($this->uploadSrvPage::FOLDER_PARAMETER_NAME,
540  $folderName);
541  $symfonyRequest->request->set($this->uploadSrvPage::DESCRIPTION_INPUT_NAME,
542  $fileDescription);
543  $symfonyRequest->request->set(
544  $this->uploadSrvPage::UPLOAD_FORM_BUILD_PARAMETER_NAME, "restUpload");
545  $symfonyRequest->request->set('public', $isPublic);
546  $symfonyRequest->request->set($this->uploadSrvPage::SOURCE_FILES_FIELD,
547  $path);
548  $symfonyRequest->request->set($this->uploadSrvPage::NAME_PARAM, $name);
549  $symfonyRequest->request->set('globalDecisions', $applyGlobal);
550  $symfonyRequest->request->set('scm', $ignoreScm);
551 
552  return $this->uploadSrvPage->handleRequest($symfonyRequest);
553  }
554 
561  public function generateUploadSummary($uploadId, $groupId)
562  {
563  global $container;
564  $restHelper = $container->get('helper.restHelper');
565  $uploadDao = $restHelper->getUploadDao();
566  $dbManager = $restHelper->getDbHelper()->getDbManager();
567  $copyrightDao = $container->get('dao.copyright');
568  $agentDao = $container->get('dao.agent');
569 
570  $agentName = "copyright";
571  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
572 
573  $noLicenseUploadTreeView = new UploadTreeProxy($uploadId,
574  array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense",
575  UploadTreeProxy::OPT_GROUP_ID => $groupId),
576  $uploadTreeTableName,
577  'no_license_uploadtree' . $uploadId);
578  $clearingCount = $noLicenseUploadTreeView->count();
579 
580  $nonClearedUploadTreeView = new UploadTreeProxy($uploadId,
581  array(UploadTreeProxy::OPT_SKIP_THESE => "alreadyCleared",
582  UploadTreeProxy::OPT_GROUP_ID => $groupId),
583  $uploadTreeTableName,
584  'already_cleared_uploadtree' . $uploadId);
585  $filesToBeCleared = $nonClearedUploadTreeView->count();
586 
587  $itemTreeBounds = $uploadDao->getParentItemBounds($uploadId,
588  $uploadTreeTableName);
589  $scanProx = new ScanJobProxy($agentDao, $uploadId);
590  $scanProx->createAgentStatus([$agentName]);
591  $agents = $scanProx->getLatestSuccessfulAgentIds();
592  $copyrightCount = 0;
593  if (array_key_exists($agentName, $agents) && ! empty($agents[$agentName])) {
594  $copyrightCount = count(
595  $copyrightDao->getAllEntriesReport($agentName, $uploadId,
596  $uploadTreeTableName, null, false, null, "C.agent_fk = " .
597  $agents[$agentName], $groupId));
598  }
599 
600  $mainLicenses = $this->getMainLicenses($dbManager, $uploadId, $groupId);
601 
603  $uiLicense = $restHelper->getPlugin("license");
604  $hist = $uiLicense->getUploadHist($itemTreeBounds);
605  if (!is_array($hist) || !array_key_exists('uniqueLicenseCount', $hist)) {
606  $hist = [];
607  $hist['uniqueLicenseCount'] = 0;
608  $hist['scannerLicenseCount'] = 0;
609  $hist['editedUniqueLicenseCount'] = 0;
610  $hist['editedLicenseCount'] = 0;
611  }
612 
613  $summary = new UploadSummary();
614  $summary->setUploadId($uploadId);
615  $summary->setUploadName($uploadDao->getUpload($uploadId)->getFilename());
616  $summary->setAssignee($uploadDao->getAssignee($uploadId, $groupId));
617  if ($mainLicenses !== null) {
618  $summary->setMainLicense(implode(",", $mainLicenses));
619  }
620  $summary->setUniqueLicenses($hist['uniqueLicenseCount']);
621  $summary->setTotalLicenses($hist['scannerLicenseCount']);
622  $summary->setUniqueConcludedLicenses($hist['editedUniqueLicenseCount']);
623  $summary->setTotalConcludedLicenses($hist['editedLicenseCount']);
624  $summary->setFilesToBeCleared($filesToBeCleared);
625  $summary->setFilesCleared($clearingCount);
626  $summary->setClearingStatus($uploadDao->getStatus($uploadId, $groupId));
627  $summary->setCopyrightCount($copyrightCount);
628  return $summary;
629  }
630 
638  private function getMainLicenses($dbManager, $uploadId, $groupId)
639  {
640  $sql = "SELECT rf_shortname FROM license_ref lf JOIN upload_clearing_license ucl"
641  . " ON lf.rf_pk=ucl.rf_fk WHERE upload_fk=$1 AND ucl.group_fk=$2";
642  $stmt = __METHOD__.'.collectMainLicenses';
643  $rows = $dbManager->getRows($sql, array($uploadId, $groupId), $stmt);
644  if (empty($rows)) {
645  return null;
646  }
647  $mainLicenses = [];
648  foreach ($rows as $row) {
649  $mainLicenses[] = $row['rf_shortname'];
650  }
651  return $mainLicenses;
652  }
653 
660  public function getUploadCopyrightList($uploadId)
661  {
662  global $container;
663  $restHelper = $container->get('helper.restHelper');
664  $uploadDao = $restHelper->getUploadDao();
665 
666  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
667  $parent = $uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
668 
672  $copyrightListObj = $restHelper->getPlugin('export-list');
673  $copyrightList = $copyrightListObj->getCopyrights($uploadId,
674  $parent->getItemId(), $uploadTreeTableName, -1, '');
675  if (array_key_exists("warn", $copyrightList)) {
676  unset($copyrightList["warn"]);
677  }
678 
679  $responseList = array();
680  foreach ($copyrightList as $copyFilepath) {
681  $flag=0;
682  foreach ($responseList as $response) {
683  if ($copyFilepath['content'] == $response['copyright']) {
684  $flag=1;
685  break;
686  }
687  }
688  if ($flag==0) {
689  $copyrightContent = array();
690  foreach ($copyrightList as $copy) {
691  if (strcasecmp($copyFilepath['content'], $copy['content']) == 0) {
692  $copyrightContent[] = $copy['filePath'];
693  }
694  }
695  $responseRow = array();
696  $responseRow['copyright'] = $copyFilepath['content'];
697  $responseRow['filePath'] = $copyrightContent;
698  $responseList[] = $responseRow;
699  }
700  }
701  return $responseList;
702  }
703 
712  public function fetchClearingStatus($itemTreeBounds, $clearingDao, $groupId)
713  {
714  $decTypes = new DecisionTypes;
715  if ($itemTreeBounds !== null) {
716  $clearingList = $clearingDao->getFileClearings($itemTreeBounds, $groupId);
717  } else {
718  $clearingList = [];
719  }
720 
721  $clearingArray = [];
722  foreach ($clearingList as $clearingDecision) {
723  $clearingArray[] = $clearingDecision->getType();
724  }
725 
726  if (empty($clearingArray) || $clearingArray[0] === null) {
727  return "NOASSERTION";
728  } else {
729  return $decTypes->getTypeName($clearingArray[0]);
730  }
731  }
732 
743  public function getUploadLicenseList($uploadId, $agents, $printContainers, $boolLicense, $boolCopyright, $page = 0, $limit = 50, $apiVersion=ApiVersion::V1)
744  {
745  global $container;
746  $restHelper = $container->get('helper.restHelper');
747  $uploadDao = $restHelper->getUploadDao();
748  $agentDao = $container->get('dao.agent');
749  $uploadTreeTableName = $uploadDao->getUploadtreeTableName($uploadId);
750  $parent = $uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
751  $groupId = $restHelper->getGroupId();
752  $scanProx = new ScanJobProxy($agentDao, $uploadId);
753  $scanProx->createAgentStatus($agents);
754  $agent_ids = $scanProx->getLatestSuccessfulAgentIds();
755  $clearingDao = $container->get("dao.clearing");
756 
760  if ($boolLicense) {
761  $licenseListObj = $restHelper->getPlugin('export-list');
762  $licenseList = $licenseListObj->createListOfLines($uploadTreeTableName,
763  $parent->getItemId(), $agent_ids, -1, true, '', !$printContainers);
764  if (array_key_exists("warn", $licenseList)) {
765  unset($licenseList["warn"]);
766  }
767  }
768 
772  if ($boolCopyright) {
773  $copyrightListObj = $restHelper->getPlugin('export-list');
774  $copyrightList = $copyrightListObj->getCopyrights($uploadId,
775  $parent->getItemId(), $uploadTreeTableName, -1, '');
776  if (array_key_exists("warn", $copyrightList)) {
777  unset($copyrightList["warn"]);
778  }
779  }
780 
781  $responseList = array();
782 
783  if ($boolLicense) {
784  foreach ($licenseList as $license) {
785  $copyrightContent = null;
786  if ($boolCopyright) {
787  $copyrightContent = [];
788  foreach ($copyrightList as $copy) {
789  if (($license['filePath'] == $copy['filePath']) !== false ) {
790  $copyrightContent[] = $copy['content'];
791  }
792  }
793  if (count($copyrightContent)==0) {
794  $copyrightContent = null;
795  }
796  }
797 
798  $findings = new Findings($license['agentFindings'],
799  $license['conclusions'], $copyrightContent);
800  $uploadTreeTableId = $license['uploadtree_pk'];
801  $uploadtree_tablename = $uploadDao->getUploadtreeTableName($uploadId);
802  if ($uploadTreeTableId!==null) {
803  $itemTreeBounds = $uploadDao->getItemTreeBounds($uploadTreeTableId,$uploadtree_tablename);
804  } else {
805  $itemTreeBounds=null;
806  }
807  $clearingDecision = $this->fetchClearingStatus($itemTreeBounds,
808  $clearingDao, $groupId);
809  $responseRow = new FileLicenses($license['filePath'], $findings,
810  $clearingDecision);
811  $responseList[] = $responseRow->getArray($apiVersion);
812  }
813  } elseif (!$boolLicense && $boolCopyright) {
814  foreach ($copyrightList as $copyFilepath) {
815  $copyrightContent = array();
816  foreach ($copyrightList as $copy) {
817  if (($copyFilepath['filePath'] == $copy['filePath']) === true) {
818  $copyrightContent[] = $copy['content'];
819  }
820  }
821  $findings = new Findings();
822  $findings->setCopyright($copyrightContent);
823  $responseRow = new FileLicenses($copyFilepath['filePath'], $findings);
824  $responseList[] = $responseRow->getArray($apiVersion);
825  }
826  }
827  $offset = $page * $limit;
828  $paginatedResponseList = array_slice($responseList, $offset, $limit);
829  $paginatedResponseListSize = sizeof($responseList);
830  return array($paginatedResponseList, $paginatedResponseListSize);
831  }
832 }
Fossology exception.
Definition: Exception.php:15
Handle new file uploads from Slim framework and move to FOSSology.
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)
handleScheduleAnalysis($uploadId, $folderId, $scanOptionsJSON, $newUpload=false)
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:30
Model class to hold Upload info.
REST api helper classes.