public function unpublishAction() { $id = isset($_POST["id"]) ? $_POST["id"] : null; $type = isset($_POST["type"]) ? $_POST["type"] : null; if ($_SERVER['REQUEST_METHOD'] != "POST" || $_SERVER["Repository_Enabled"] !== 'true' || is_numeric($this->session->userid) == false || is_numeric($id) === false || $type == null || Repository::canManageEntity($this->session->userid, $id, "release") == false) { header("Status: 404 Not Found"); return; } $typename = ""; if (trim($type) !== "") { switch (strtolower(trim($type))) { case "candidate": $typename = "candidate"; break; case "production": $typename = "production"; default: break; } } $output = ""; $result = true; $result = RepositoryBackend::unpublish($id, $typename, $output); echo $output; }
public static function removePoaPackages($ids, $releaseid, $userid) { $release = self::getReleaseById($releaseid); $errors = array(); if (!$release) { return "Could not retrieve release"; } //this is candidate if ($release->currentStateId == 2) { return "Cannot remove package in a production release"; } //this is candidate if ($release->currentStateId == 3) { RepositoryBackend::unpublish($releaseid, "candidate"); } $poastocheck = array(); for ($i = 0; $i < count($ids); $i += 1) { $pckg = self::releaseHasPackage($release, $ids[$i]); if (is_string($pckg) == true) { $errors[] = array("id" => $ids[$i], "error" => $pckg); continue; } if (in_array($pckg->poaId, $poastocheck) == false) { $poastocheck[] = $pckg->poaId; } $poa = Repository::getPoaById($pckg->poaId); $filepath = ""; if ($poa) { $error = ""; $filepath = RepositoryFS::getStoragePath($error) . $poa->poaPath . $pckg->pkgFilename; } self::call_delete_package($pckg->id, $userid); if (trim($filepath) !== "" && file_exists($filepath)) { @rename($filepath, $filepath . ".deleted." . $ids[$i]); } } //Clear poas if (count($poastocheck) > 0) { for ($i = 0; $i < count($poastocheck); $i += 1) { $poas = new Repository_Model_MetaPoaReleases(); $poas->filter->id->equals($poastocheck[$i]); if (count($poas) > 0) { $poa = $poas->items[0]; $pckgs = $poa->getPackages(); if (count($pckgs) == 0) { self::call_delete_poa($poa->id, $userid); //$poas->remove($poa); } } } } if (count($errors) == 0) { return true; } return count($errors) == 0 ? true : $errors; }
public function uploadAction() { ob_start(); ob_get_clean(); ob_end_clean(); $this->_helper->viewRenderer->setNoRender(); $releaseid = $this->_getParam("releaseid"); $targetid = $this->_getParam("targetid"); $swid = $this->_getParam("swid"); $userid = $this->session->userid; if ($_SERVER["Repository_Enabled"] !== 'true' || is_numeric($this->session->userid) === false || is_numeric($releaseid) === false || is_numeric($targetid) === false || is_numeric($swid) === false || $releaseid <= 0 || $targetid <= 0 || $swid <= 0 || Repository::canManageRelease($swid, $userid) === false) { header("Status: 404 Not Found"); return; } //Get release $rl = new RestProductReleaseItem(array("id" => $releaseid)); $release = $rl->getRawData(); if (!$this->handleresterror($rl, "release")) { return; } //retrieve upload target directory $targetDir = RepositoryFS::getScratchSpaceForRelease($release, $error, true); $targetDir .= $targetid; //If cannot find or create the target upload directory... if ($targetDir === false) { return $this->chunkUploadResponse('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "' . $error . '"}, "id" : "id"}'); } $file = $this->chunkUploadHandling($targetDir); if ($file === false) { return; } /***************************************************** * THIS CODE WILL BE REACHED IF UPLOADING IS COMPLETE * ******************************************************/ //check if release is a candidate revert it to unverified if ($release->currentStateId == 3) { RepositoryBackend::unpublish($release->id, "candidate", $output); //TODO: Send command to commrepo backend to remove candidate repositories } //get uploaded filename (full path) $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; //Get target (os arch combination) $rl = new RestTargetItem(array("id" => $targetid)); $target = $rl->getRawData(); if (!$this->handleresterror($rl, "target")) { return; } $warnings = null; $res = RepositoryFS::storeUploadedFile($file, $release, $target, $userid, $warnings); ob_start(); ob_get_clean(); ob_end_clean(); header("Content-Type: text/xml"); if (file_exists($file)) { @unlink($file); } if ($res !== true && (is_numeric($res) === false || $res === false)) { echo '<repository datatype="item" content="upload" ><upload result="error" releaseid="' . $releaseid . '" targetid="' . $targetid . '" filename="' . $file . '" error="' . $res . '"></upload></repository>'; return; } echo '<repository datatype="item" content="upload"><upload result="success" releaseid="' . $releaseid . '" targetid="' . $targetid . '" filename="' . $file . '"'; if ($warnings !== null) { echo 'warning="' . $warnings . '"'; } echo '>'; $pcks = new Repository_Model_MetaPoaReleasePackages(); $pcks->filter->id->equals($res); if (count($pcks->items) > 0) { $pck = $pcks->items[0]; $xml = $pck->toXML(true); $xml = RepositoryXSLT::transform($xml, "poapackage"); debug_log($xml); echo $xml; } echo '</upload></repository>'; return; }