public function vmc2appdbAction() { $this->_helper->viewRenderer->setNoRender(); if (ApplicationConfiguration::isProductionInstance()) { header('HTTP/1.0 404 Not Found'); header("Status: 404 Not Found"); return; } if ($_SERVER['REQUEST_METHOD'] === "GET") { echo '<form action="/apps/vmc2appdb" id="vmc2appdb" name="vmc2appdb" method="post" target="_blank">'; echo '<textarea rows="30" cols="100" name="data" id="data" ></textarea>'; echo '<div><label for="appid">Application Id:</label><input type="text" value="" name="appdbid" id="appdbid"></div>'; echo '<div><input type="submit" value="view transformed xml"></div>'; echo '<div><input type="button" id="submitxml" value="Call API" ></div>'; echo '<div class="reply"></div>'; echo '</form>'; echo '<script type="text/javascript">'; echo 'appdb.utils.Vm2Appdb.init();'; echo '</script>'; } else { $this->_helper->layout->disableLayout(); if (isset($_POST["data"]) === false) { echo '<html><head></head><body>'; echo '<div>no data posted</div>'; echo '</body></html>'; } else { header('Content-type: text/xml'); $data = $_POST["data"]; echo VMCaster::transformXml($data); } } }
public function parse($xml) { $vapp = null; $app = null; $originalxml = '' . $xml; if (!is_null($this->_user)) { try { $xml = new SimpleXMLElement($xml); $xml->registerXPathNamespace('virtualization', 'http://appdb.egi.eu/api/1.0/virtualization'); } catch (Exception $e) { $this->_error = RestErrorEnum::RE_INVALID_REPRESENTATION; $this->_extError = 'Could not parse xml'; return new Default_Model_VA(); } $this->_xml = $xml; if (count($xml->xpath("//vmc2appdb")) > 0) { $xml = VMCaster::transformXml($originalxml); try { $xml = new SimpleXMLElement($xml); $xml->registerXPathNamespace('virtualization', 'http://appdb.egi.eu/api/1.0/virtualization'); $this->isexternalrequest = true; } catch (Exception $e) { $this->_error = RestErrorEnum::RE_INVALID_REPRESENTATION; $this->_extError = 'Could not parse xml'; return new Default_Model_VA(); } } if (count($xml->xpath("./virtualization:appliance")) > 0) { $xml = $xml->xpath("./virtualization:appliance"); $xml = $xml[0]; } $vapp = $this->parseVAppliance($xml); if ($vapp === false) { return false; } /* * Check if an external action is required, such as publishing a version */ $service = $this->createVApplianceService(); $result = $service->dispatch(); if ($result !== true) { $this->_setErrorMessage($result); return false; } return $vapp; } else { $this->_error = RestErrorEnum::RE_ACCESS_DENIED; return false; } }