示例#1
0
 private function processOntology()
 {
     $path = $this->ontologyPath();
     if ($path === false) {
         return false;
     }
     try {
         $name = OntologyReader::getName($path);
         // check that namespace is known
         OntologyNamespaces::getUri($name, 'http://example.com/');
     } catch (\Exception $e) {
         $this->response(400, 'Invalid ontology page title ' . $path);
         return true;
         // we're done, give up
     }
     // TODO: add the following two lines? or at least the first line?
     // if (! $this->parsePage()) return true; // we're done, give up
     // if (! $this->hasTemplate(self::$ontologyTemplates)) ignore data? send error response?
     // forward source to ultrapedia
     // Ontology pages don't exist @ Ultrapedia
     //if (! $this->sendWiki()) return true; // error response already sent
     try {
         $configHolder = $this->configHandler->updateOntology($path, $this->rawPage);
     } catch (\Exception $e) {
         $this->response(500, 'Internal server error', 'Failed to update ontology: ' . $e);
         return true;
         // give up
     }
     $writer = new OWLOntologyWriter();
     $owl = $writer->toOWL($configHolder->ontology);
     if (!$this->sendOwl($owl)) {
         return true;
     }
     // error response already sent
     return $this->response(200, 'Successfully updated ontology schema');
 }