13 namespace Fossology\UI\Api\Controllers;
22 use Psr\Container\ContainerInterface;
23 use Psr\Http\Message\ServerRequestInterface;
55 $this->fileHelper = $this->container->get(
'helper.fileHelper');
56 $this->clearingDao = $this->container->get(
'dao.clearing');
57 $this->licenseDao = $this->container->get(
'dao.license');
68 public function getFiles($request, $response, $args)
75 foreach ($inputFileList as $inputFile) {
76 if ($inputFile->getMessage() == File::INVALID) {
77 $nonExistsList[] = $inputFile;
82 if ($pfileId !==
false) {
83 $existsList[$pfileId] = $inputFile;
85 $inputFile->setMessage(File::NOT_FOUND);
86 $nonExistsList[] = $inputFile;
91 $existsList = array_values($existsList);
93 foreach ($nonExistsList as $file) {
94 $existsList[] = $file;
96 return $response->withJson(array_map(
function ($file) {
97 return $file->getArray();
98 }, $existsList), 200);
110 $hash = $file->getHash();
111 $pfile = $this->fileHelper->getPfile($hash);
112 if ($pfile ===
null) {
115 $newHash =
new Hash($pfile[
'pfile_sha1'], $pfile[
'pfile_md5'],
116 $pfile[
'pfile_sha256'], $pfile[
'pfile_size']);
117 $file->setHash($newHash);
118 return intval($pfile[
'pfile_pk']);
129 foreach ($inputFileList as $pfileId => $file) {
131 if (! empty($uploads)) {
132 $scannerFindings = [];
141 $findings->setScanner($scannerFindings);
142 $findings->setConclusion($conclusions);
143 $findings->setCopyright($copyright);
144 $inputFileList[$pfileId]->setFindings($findings);
145 $inputFileList[$pfileId]->setUploads($uploads);
156 return $this->fileHelper->pfileScannerFindings($pfileId);
166 return $this->fileHelper->pfileConclusions($this->restHelper->getGroupId(),
177 return $this->fileHelper->pfileCopyright($pfileId);
187 $this->fileHelper->getPackageUpload($pfileId));
197 if (empty($uploads)) {
200 return array_filter($uploads,
function ($upload) {
201 return $this->restHelper->getUploadDao()->isAccessible($upload,
202 $this->restHelper->getGroupId());
213 $mainLicenses = array();
214 foreach ($uploads as $upload) {
215 $licenses = $this->clearingDao->getMainLicenseIds($upload,
216 $this->restHelper->getGroupId());
217 foreach ($licenses as $licenseId) {
218 $license = $this->licenseDao->getLicenseById($licenseId,
219 $this->restHelper->getGroupId());
220 if ($license !==
null) {
221 $mainLicenses[$license->getId()] = $license->getShortName();
225 natcasesort($mainLicenses);
226 return array_values($mainLicenses);
Controller for file searching.
getPackageUpload($pfileId)
getFileFindings($pfileId)
getFileCopyright($pfileId)
getInfoForFiles(&$inputFileList)
getMainLicenses($uploads)
getFileConclusions($pfileId)
filterAccessibleUploads($uploads)
getFiles($request, $response, $args)
Base controller for REST calls.
getParsedBody(ServerRequestInterface $request)
Parse request body as JSON and return associative PHP array.
Handle file related queries.
Override Slim response for withJson function.
File model holding information about a single file.
static parseFromArray($inputList)
Model holding information about license findings and conclusions.
Hash model holding information about file like checksums and size.