public function newreleaseAction() { $this->_helper->layout->disableLayout(); $userid = $this->session->userid; if (is_numeric($userid) == false || $_SERVER["Repository_Enabled"] !== 'true') { $this->_helper->viewRenderer->setNoRender(); header("Status: 404 Not Found"); return; } $this->view->error = ""; if ($_SERVER['REQUEST_METHOD'] == "POST") { $this->_helper->viewRenderer->setNoRender(); $swid = isset($_POST["swid"]) ? $_POST["swid"] : null; $swname = isset($_POST["swname"]) ? $_POST["swname"] : null; $repoareaid = isset($_POST["repoareaname"]) ? $_POST["repoareaname"] : null; if (Repository::canManageRelease($swid, $userid) === false) { header("Status: 404 Not Found"); return; } header("Content-Type: text/xml"); if (is_numeric($swid) == false) { echo "<response error='No software id given to create new release.' ></response>"; return; } $parentid = isset($_POST["parentid"]) ? $_POST["parentid"] : ""; if (trim($parentid) == "") { $parentid = 0; } if (is_numeric($parentid) == false) { echo "<response error='Release update is not associated with any release.' ></response>"; return; } $displayVersion = isset($_POST["displayversion"]) ? $_POST["displayversion"] : null; if (trim($displayVersion) == "") { echo "<response error='No display version given for the release.' ></response>"; return; } $id = Repository::createRelease($swid, $swname, $displayVersion, $repoareaid, $parentid, $userid); if (is_numeric($id) == true) { Repository::addReleaseByExternalId($id, $this->session->userid, "1"); Repository::addReleaseByExternalId($id, $this->session->userid, "2"); $rel = new Repository_Model_MetaProductReleases(); $rel->filter->id->equals($id); if (count($rel->items) > 0) { $r = $rel->items[0]; $newrel = new RestRepositoryAreaItem(array("id" => $r->repoareaid)); echo "<response id='" . $id . "'>"; echo $newrel->get(); echo "</response>"; } else { echo "<response error='Could not retrieve new product release information.'></response>"; } } else { if (is_numeric($id) == false) { echo "<response error='" . $id . "'></response>"; } else { echo "<response error='Unkown error occured during release creation.'></response>"; } } } else { if ($_SERVER['REQUEST_METHOD'] == "GET") { $swid = $this->_getParam("swid"); if (is_numeric($swid) == false) { $this->view->error = "No software id given"; return; } $rtype = strtolower(trim($this->_getParam("releasetype"))); if ($rtype == "") { $rtype = "major"; } switch ($rtype) { case "update": break; case "major": break; default: $this->view->error = "Invalid release type given. The release type can be either major or update."; return; } $this->view->appName = $this->_getParam("name"); $this->view->baselist = Repository::getProductBaseReleases($swid); $this->view->type = $rtype; } else { $this->_helper->viewRenderer->setNoRender(); header("Status: 404 Not Found"); return; } } }
public static function unmarkpackagesAction() { $ids = isset($_POST["ids"]) ? $_POST["ids"] : null; $releaseid = isset($_POST["releaseid"]) ? $_POST["releaseid"] : null; $swid = isset($_POST["swid"]) ? $_POST["swid"] : null; $userid = $this->session->userid; if ($ids !== null && is_array($ids) == false && is_numeric($ids) == true) { $ids = array($ids); } if ($_SERVER['REQUEST_METHOD'] != "POST" || $_SERVER["Repository_Enabled"] !== 'true' || is_numeric($userid) == false || is_array($ids) === false || is_numeric($releaseid) == false || is_numeric($swid) == false || Repository::canManageRelease($swid, $userid) == false) { header("Status: 404 Not Found"); return; } $res = Repository::unmarkPoaPackage($ids, $releaseid, $userid); header("Content-Type: text/xml"); if ($res === true) { echo "<response success='true'>OK</response>"; return; } else { echo "<response success='false'>"; for ($i = 0; $i < count($res); $i += 1) { echo "<package id='" . $res[$i]["id"] . "' result='" . $res[$i]["result"] . "' />"; } echo "</response>"; } }
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; }