/** * Service to check if the uploaded file archive is a valid and non-existing one * * JSON structure: * { * "valid" : true/false (if is a valid package) * "exists" : true/false (if the package is valid, check if the typeIdentifier is already used in the registry) * } */ public function verify() { $result = array('valid' => false, 'exists' => false); $file = tao_helpers_Http::getUploadedFile('content'); $creatorPackageParser = new CreatorPackageParser($file['tmp_name']); $creatorPackageParser->validate(); if ($creatorPackageParser->isValid()) { $result['valid'] = true; $manifest = $creatorPackageParser->getManifest(); $result['typeIdentifier'] = $manifest['typeIdentifier']; $result['label'] = $manifest['label']; $interaction = $this->registry->get($manifest['typeIdentifier']); if (!is_null($interaction)) { $result['exists'] = true; } } else { $result['package'] = $creatorPackageParser->getErrors(); } $this->returnJson($result); }