/**
  * Update the URI of an entity
  * 
  * @param mixed $oldUri
  * @param mixed $newUri
  * @param mixed $advancedIndexation
  *  
  * @author Frederick Giasson, Structured Dynamics LLC.
  */
 public function updateEntityUri($oldUri, $newUri, $advancedIndexation)
 {
     $this->initiateOwlBridgeSession();
     $this->getOntologyReference();
     if ($this->isValid()) {
         if ($oldUri == "") {
             $this->ws->returnError(400, "Bad Request", "_202");
             return;
         }
         if ($newUri == "") {
             $this->ws->returnError(400, "Bad Request", "_203");
             return;
         }
         $this->ws->ontology->updateEntityUri($oldUri, $newUri);
         if ($advancedIndexation === TRUE) {
             // Find the type of entity manipulated here
             $entity = $this->ws->ontology->_getEntity($newUri);
             $function = "";
             $params = "";
             if ((bool) java_values($entity->isOWLClass())) {
                 $function = "getClass";
                 $params = "uri=" . $newUri;
             } elseif ((bool) java_values($entity->isOWLDataProperty()) || (bool) java_values($entity->isOWLObjectProperty()) || (bool) java_values($entity->isOWLAnnotationProperty())) {
                 $function = "getProperty";
                 $params = "uri=" . $newUri;
             } elseif ((bool) java_values($entity->isNamedIndividual())) {
                 $function = "getNamedIndividual";
                 $params = "uri=" . $newUri;
             } else {
                 return;
             }
             // Get the description of the newly updated entity.
             $ontologyRead = new OntologyRead($this->ws->ontologyUri, $function, $params, $this->ws->registered_ip, $this->ws->requester_ip);
             // Since we are in pipeline mode, we have to set the owlapisession using the current one.
             // otherwise the java bridge will return an error
             $ontologyRead->setOwlApiSession($this->OwlApiSession);
             $ontologyRead->ws_conneg("application/rdf+xml", $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
             if ($this->ws->reasoner) {
                 $ontologyRead->useReasoner();
             } else {
                 $ontologyRead->stopUsingReasoner();
             }
             $ontologyRead->process();
             if ($ontologyRead->pipeline_getResponseHeaderStatus() != 200) {
                 $this->ws->conneg->setStatus($ontologyRead->pipeline_getResponseHeaderStatus());
                 $this->ws->conneg->setStatusMsg($ontologyRead->pipeline_getResponseHeaderStatusMsg());
                 $this->ws->conneg->setStatusMsgExt($ontologyRead->pipeline_getResponseHeaderStatusMsgExt());
                 $this->ws->conneg->setError($ontologyRead->pipeline_getError()->id, $ontologyRead->pipeline_getError()->webservice, $ontologyRead->pipeline_getError()->name, $ontologyRead->pipeline_getError()->description, $ontologyRead->pipeline_getError()->debugInfo, $ontologyRead->pipeline_getError()->level);
                 return;
             }
             $entitySerialized = $ontologyRead->pipeline_serialize();
             unset($ontologyRead);
             // Delete the old entity in Solr
             // Update the classes and properties into the Solr index
             $crudDelete = new CrudDelete($oldUri, $this->ws->ontologyUri, $this->ws->registered_ip, $this->ws->requester_ip);
             $crudDelete->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
             $crudDelete->process();
             if ($crudDelete->pipeline_getResponseHeaderStatus() != 200) {
                 $this->ws->conneg->setStatus($crudDelete->pipeline_getResponseHeaderStatus());
                 $this->ws->conneg->setStatusMsg($crudDelete->pipeline_getResponseHeaderStatusMsg());
                 $this->ws->conneg->setStatusMsgExt($crudDelete->pipeline_getResponseHeaderStatusMsgExt());
                 $this->ws->conneg->setError($crudDelete->pipeline_getError()->id, $crudDelete->pipeline_getError()->webservice, $crudDelete->pipeline_getError()->name, $crudDelete->pipeline_getError()->description, $crudDelete->pipeline_getError()->debugInfo, $crudDelete->pipeline_getError()->level);
                 return;
             }
             unset($crudDelete);
             // Add the new entity in Solr
             // Update the classes and properties into the Solr index
             $crudCreate = new CrudCreate($entitySerialized, "application/rdf+xml", "full", $this->ws->ontologyUri, $this->ws->registered_ip, $this->ws->requester_ip);
             $crudCreate->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
             $crudCreate->process();
             if ($crudCreate->pipeline_getResponseHeaderStatus() != 200) {
                 $this->ws->conneg->setStatus($crudCreate->pipeline_getResponseHeaderStatus());
                 $this->ws->conneg->setStatusMsg($crudCreate->pipeline_getResponseHeaderStatusMsg());
                 $this->ws->conneg->setStatusMsgExt($crudCreate->pipeline_getResponseHeaderStatusMsgExt());
                 $this->ws->conneg->setError($crudCreate->pipeline_getError()->id, $crudCreate->pipeline_getError()->webservice, $crudCreate->pipeline_getError()->name, $crudCreate->pipeline_getError()->description, $crudCreate->pipeline_getError()->debugInfo, $crudCreate->pipeline_getError()->level);
                 return;
             }
             unset($crudCreate);
         }
         // Update the name of the file of the ontology to mark it as "changed"
         $this->ws->ontology->addOntologyAnnotation("http://purl.org/ontology/wsf#ontologyModified", "true");
     }
 }
Exemple #2
0
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$start_datetime = date("Y-m-d h:i:s");
$requester_ip = "0.0.0.0";
if (isset($_SERVER['REMOTE_ADDR'])) {
    $requester_ip = $_SERVER['REMOTE_ADDR'];
}
$parameters = "";
if (isset($_SERVER['REQUEST_URI'])) {
    $parameters = $_SERVER['REQUEST_URI'];
    $pos = strpos($parameters, "?");
    if ($pos !== FALSE) {
        $parameters = substr($parameters, $pos, strlen($parameters) - $pos);
    }
} elseif (isset($_SERVER['PHP_SELF'])) {
    $parameters = $_SERVER['PHP_SELF'];
}
$ws_crudcreate = new CrudCreate($document, $mime, $mode, $dataset, $registered_ip, $requester_ip, $interface, $version);
$ws_crudcreate->ws_conneg(isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : "", isset($_SERVER['HTTP_ACCEPT_CHARSET']) ? $_SERVER['HTTP_ACCEPT_CHARSET'] : "", isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : "", isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : "");
$ws_crudcreate->process();
$ws_crudcreate->ws_respond($ws_crudcreate->ws_serialize());
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = $endtime - $starttime;
if ($ws_crudcreate->isLoggingEnabled()) {
    $logger = new Logger("crud_create", $requester_ip, "?document=" . substr($document, 0, 64) . "&mime=" . $mime . "&dataset=" . $dataset . "&registered_ip=" . $registered_ip . "&requester_ip={$requester_ip}", isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : "", $start_datetime, $totaltime, $ws_crudcreate->pipeline_getResponseHeaderStatus(), isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "");
}
//@}
 /** Update all ontological structures used by the WSF
 
         @author Frederick Giasson, Structured Dynamics LLC.
     */
 public function createOntology()
 {
     // Make sure there was no conneg error prior to this process call
     if ($this->ws->conneg->getStatus() == 200) {
         $this->ws->validateQuery();
         // If the query is still valid
         if ($this->ws->conneg->getStatus() == 200) {
             // Starts the OWLAPI process/bridge
             require_once $this->ws->owlapiBridgeURI;
             // Create the OWLAPI session object that could have been persisted on the OWLAPI instance.
             // Second param "false" => we re-use the pre-created session without destroying the previous one
             // third param "0" => it nevers timeout.
             $OwlApiSession = java_session("OWLAPI", false, 0);
             $register = java_values($OwlApiSession->get("ontologiesRegister"));
             // Check if the ontology is already existing
             if (!is_null(java_values($OwlApiSession->get($this->getOntologySessionID($this->ws->ontologyUri)))) || $register != NULL && array_search($this->getOntologySessionID($this->ws->ontologyUri), $register) !== FALSE) {
                 $this->ws->returnError(400, "Bad Request", "_302", "");
                 return;
             }
             try {
                 $ontology = new OWLOntology($this->ws->ontologyUri, $OwlApiSession, FALSE);
                 if (strtolower($this->ws->owlapiReasoner) == "pellet") {
                     $ontology->usePelletReasoner();
                 } elseif (strtolower($this->ws->owlapiReasoner) == "hermit") {
                     $ontology->useHermitReasoner();
                 } elseif (strtolower($this->ws->owlapiReasoner) == "factpp") {
                     $ontology->useFactppReasoner();
                 }
             } catch (Exception $e) {
                 $this->ws->returnError(400, "Bad Request", "_300", (string) java_values($e));
                 return;
             }
             // Get the description of the ontology
             $ontologyDescription = $ontology->getOntologyDescription();
             $ontologyName = $this->getLabel($this->ws->ontologyUri, $ontologyDescription);
             $ontologyDescription = $this->getDescription($ontologyDescription);
             // Get the list of webservices that will be accessible for this ontology dataset.
             $authLister = new AuthLister("ws", $this->ws->ontologyUri, $this->ws->requester_ip, $this->ws->wsf_local_ip);
             $authLister->pipeline_conneg($this->ws->conneg->getAccept(), $this->ws->conneg->getAcceptCharset(), $this->ws->conneg->getAcceptEncoding(), $this->ws->conneg->getAcceptLanguage());
             $authLister->process();
             if ($authLister->pipeline_getResponseHeaderStatus() != 200) {
                 $this->ws->conneg->setStatus($authLister->pipeline_getResponseHeaderStatus());
                 $this->ws->conneg->setStatusMsg($authLister->pipeline_getResponseHeaderStatusMsg());
                 $this->ws->conneg->setStatusMsgExt($authLister->pipeline_getResponseHeaderStatusMsgExt());
                 $this->ws->conneg->setError($authLister->pipeline_getError()->id, $authLister->pipeline_getError()->webservice, $authLister->pipeline_getError()->name, $authLister->pipeline_getError()->description, $authLister->pipeline_getError()->debugInfo, $authLister->pipeline_getError()->level);
                 return;
             }
             /* Get all web services */
             $webservices = "";
             $xml = new ProcessorXML();
             $xml->loadXML($authLister->pipeline_getResultset());
             $webServiceElements = $xml->getXPath('//predicate/object[attribute::type="wsf:WebService"]');
             foreach ($webServiceElements as $element) {
                 if (stristr($xml->getURI($element), "/wsf/ws/search/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/browse/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/sparql/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/crud/create/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/crud/update/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/crud/delete/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/crud/read/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/ontology/create/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/ontology/read/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/ontology/update/") !== FALSE || stristr($xml->getURI($element), "/wsf/ws/ontology/delete/") !== FALSE) {
                     $webservices .= $xml->getURI($element) . ";";
                 }
             }
             $webservices = rtrim($webservices, ";");
             unset($xml);
             unset($authLister);
             // Create a new dataset for this ontology
             $globalPermissions = "";
             if ($this->ws->globalPermissionCreate === FALSE) {
                 $globalPermissions .= "False;";
             } else {
                 $globalPermissions .= "True;";
             }
             if ($this->ws->globalPermissionRead === FALSE) {
                 $globalPermissions .= "False;";
             } else {
                 $globalPermissions .= "True;";
             }
             if ($this->ws->globalPermissionUpdate === FALSE) {
                 $globalPermissions .= "False;";
             } else {
                 $globalPermissions .= "True;";
             }
             if ($this->ws->globalPermissionDelete === FALSE) {
                 $globalPermissions .= "False";
             } else {
                 $globalPermissions .= "True";
             }
             $datasetCreate = new DatasetCreate($this->ws->ontologyUri, $ontologyName, $ontologyDescription, "", $this->ws->registered_ip, $this->ws->requester_ip, $webservices, $globalPermissions);
             $datasetCreate->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
             $datasetCreate->process();
             if ($datasetCreate->pipeline_getResponseHeaderStatus() != 200) {
                 if ($datasetCreate->pipeline_getError()->id != "WS-DATASET-CREATE-202") {
                     $this->ws->conneg->setStatus($datasetCreate->pipeline_getResponseHeaderStatus());
                     $this->ws->conneg->setStatusMsg($datasetCreate->pipeline_getResponseHeaderStatusMsg());
                     $this->ws->conneg->setStatusMsgExt($datasetCreate->pipeline_getResponseHeaderStatusMsgExt());
                     $this->ws->conneg->setError($datasetCreate->pipeline_getError()->id, $datasetCreate->pipeline_getError()->webservice, $datasetCreate->pipeline_getError()->name, $datasetCreate->pipeline_getError()->description, $datasetCreate->pipeline_getError()->debugInfo, $datasetCreate->pipeline_getError()->level);
                 }
                 // If the dataset already exists, then we simply stop the processing of the advancedIndexation
                 // mode. This means that the tomcat instance has been rebooted, and that the datasets
                 // have been leaved there, and that a procedure, normally using the advancedIndexation mode
                 // is currently being re-processed.
                 return;
             }
             unset($datasetCreate);
             // Tag the new dataset as being a dataset that host an ontology description
             $query = "insert into <" . $this->ws->wsf_graph . "datasets/>\n                  {\n                    <" . $this->ws->ontologyUri . "> <http://purl.org/ontology/wsf#holdOntology> \"true\" .\n                  }";
             @$this->ws->db->query($this->ws->db->build_sparql_query(str_replace(array("\n", "\r", "\t"), " ", $query), array(), FALSE));
             if (odbc_error()) {
                 $this->ws->conneg->setStatus(500);
                 $this->ws->conneg->setStatusMsg("Internal Error");
                 $this->ws->conneg->setStatusMsgExt($this->ws->errorMessenger->_301->name);
                 $this->ws->conneg->setError($this->ws->errorMessenger->_301->id, $this->ws->errorMessenger->ws, $this->ws->errorMessenger->_301->name, $this->ws->errorMessenger->_301->description, odbc_errormsg(), $this->ws->errorMessenger->_301->level);
                 return;
             }
             // Check if we want to enable the advanced indexation: so, if we want to import all the ontologies
             // description into the other structWSF data stores to enable search and filtering using the other
             // endpoints such as search, sparql, read, etc.
             if ($this->ws->advancedIndexation) {
                 // Once we start the ontology creation process, we have to make sure that even if the server
                 // loose the connection with the user the process will still finish.
                 ignore_user_abort(true);
                 // However, maybe there is an issue with the server handling that file tht lead to some kind of infinite
                 // or near infinite loop; so we have to limit the execution time of this procedure to 45 mins.
                 set_time_limit(86400);
                 // Get the description of the classes, properties and named individuals of this ontology.
                 // Check the size of the Ontology file to import. If the size is bigger than 8MB, then we will
                 // use another method that incurs some Virtuoso indexing. If it is the case, you have to make sure
                 // that Virtuoso is properly configured so that it can access (DirsAllowed Virtuoso config option)
                 // the folder where the ontology file has been saved.
                 if (filesize($this->ws->ontologyUri) > 8000000) {
                     $sliceSize = 100;
                     // Import the big file into Virtuoso
                     $sqlQuery = "DB.DBA.RDF_LOAD_RDFXML_MT(file_to_string_output('" . str_replace("file://localhost", "", $this->ws->ontologyUri) . "'),'" . $this->ws->ontologyUri . "/import','" . $this->ws->ontologyUri . "/import')";
                     $resultset = $this->ws->db->query($sqlQuery);
                     if (odbc_error()) {
                         // If there is an error, try to load it using the Turtle parser
                         $sqlQuery = "DB.DBA.TTLP_MT(file_to_string_output('" . str_replace("file://localhost", "", $this->ws->ontologyUri) . "'),'" . $this->ws->ontologyUri . "/import','" . $this->ws->ontologyUri . "/import')";
                         $resultset = $this->ws->db->query($sqlQuery);
                         if (odbc_error()) {
                             //            echo "Error: can't import the file: $file, into the triple store.\n";
                             //            return;
                         }
                     }
                     unset($resultset);
                     // count the number of records
                     $sparqlQuery = "\n              \n                select count(distinct ?s) as ?nb from <" . $this->ws->ontologyUri . "/import>\n                where\n                {\n                  ?s a ?o .\n                }\n              \n              ";
                     $resultset = $this->ws->db->query($this->ws->db->build_sparql_query($sparqlQuery, array('nb'), FALSE));
                     $nb = odbc_result($resultset, 1);
                     unset($resultset);
                     $nbRecordsDone = 0;
                     while ($nbRecordsDone < $nb && $nb > 0) {
                         // Create slices of 100 records.
                         $sparqlQuery = "\n                  \n                  select ?s ?p ?o (DATATYPE(?o)) as ?otype (LANG(?o)) as ?olang\n                  where \n                  {\n                    {\n                      select distinct ?s from <" . $this->ws->ontologyUri . "/import> \n                      where \n                      {\n                        ?s a ?type.\n                      } \n                      limit " . $sliceSize . " \n                      offset " . $nbRecordsDone . "\n                    } \n                    \n                    ?s ?p ?o\n                  }\n                \n                ";
                         $resultset = $this->ws->db->query($this->ws->db->build_sparql_query($sparqlQuery, array('s', 'p', 'o', 'otype', 'olang'), FALSE));
                         if (odbc_error()) {
                             //              echo "Error: can't get records slices.\n";
                             //              return;
                         }
                         $crudCreates = "";
                         $crudUpdates = "";
                         $crudDeletes = array();
                         $rdfDocumentN3 = "";
                         $currentSubject = "";
                         $subjectDescription = "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n";
                         while (odbc_fetch_row($resultset)) {
                             $s = odbc_result($resultset, 1);
                             $p = odbc_result($resultset, 2);
                             $o = $this->ws->db->odbc_getPossibleLongResult($resultset, 3);
                             $otype = odbc_result($resultset, 4);
                             $olang = odbc_result($resultset, 5);
                             if ($otype != "" || $olang != "") {
                                 $subjectDescription .= "<{$s}> <{$p}> \"\"\"" . $this->n3Encode($o) . "\"\"\" .\n";
                             } else {
                                 $subjectDescription .= "<{$s}> <{$p}> <{$o}> .\n";
                             }
                         }
                         unset($resultset);
                         $wsq = new WebServiceQuerier(rtrim($this->ws->wsf_base_url, "/") . "/ws/crud/create/", "post", "application/rdf+xml", "document=" . urlencode($subjectDescription) . "&dataset=" . urlencode($this->ws->ontologyUri) . "&mime=" . urlencode("application/rdf+n3") . "&mode=full" . "&registered_ip=" . urlencode($this->ws->registered_ip));
                         if ($wsq->getStatus() != 200) {
                             $this->ws->conneg->setStatus($wsq->getStatus());
                             $this->ws->conneg->setStatusMsg($wsq->getStatusMessage());
                             $this->ws->conneg->setStatusMsgExt($wsq->getStatusMessageDescription());
                             /*
                             $this->ws->conneg->setError($wsq->pipeline_getError()->id,
                               $crudCreate->pipeline_getError()->webservice, $crudCreate->pipeline_getError()->name,
                               $crudCreate->pipeline_getError()->description, $crudCreate->pipeline_getError()->debugInfo,
                               $crudCreate->pipeline_getError()->level);               
                             */
                             // In case of error, we delete the dataset we previously created.
                             $ontologyDelete = new OntologyDelete($this->ws->ontologyUri, $this->ws->registered_ip, $this->ws->requester_ip);
                             $ontologyDelete->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                             $ontologyDelete->deleteOntology();
                             if ($ontologyDelete->pipeline_getResponseHeaderStatus() != 200) {
                                 $this->ws->conneg->setStatus($ontologyDelete->pipeline_getResponseHeaderStatus());
                                 $this->ws->conneg->setStatusMsg($ontologyDelete->pipeline_getResponseHeaderStatusMsg());
                                 $this->ws->conneg->setStatusMsgExt($ontologyDelete->pipeline_getResponseHeaderStatusMsgExt());
                                 $this->ws->conneg->setError($ontologyDelete->pipeline_getError()->id, $ontologyDelete->pipeline_getError()->webservice, $ontologyDelete->pipeline_getError()->name, $ontologyDelete->pipeline_getError()->description, $ontologyDelete->pipeline_getError()->debugInfo, $ontologyDelete->pipeline_getError()->level);
                                 //return;
                             }
                             //return;
                         }
                         $nbRecordsDone += $sliceSize;
                     }
                     // Now delete the graph we used to import the file
                     $sqlQuery = "sparql clear graph <" . $this->ws->ontologyUri . "/import>";
                     $resultset = $this->ws->db->query($sqlQuery);
                     if (odbc_error()) {
                         //            echo "Error: can't delete the graph sued for importing the file\n";
                         //            return;
                     }
                     unset($resultset);
                 } else {
                     $nbClasses = $ontology->getNbClasses();
                     $sliceSize = 200;
                     // Note: in OntologyCreate, we have to merge all the classes, properties and named individuals
                     //       together. This is needed to properly handle possible punning used in imported ontologies.
                     //       If we don't do this, and that a resource is both a class and an individual, then only
                     //       the individual will be in the Solr index because it would overwrite the Class
                     //       record document with the same URI.
                     include_once "../../framework/arc2/ARC2.php";
                     $rdfxmlParser = ARC2::getRDFParser();
                     $rdfxmlSerializer = ARC2::getRDFXMLSerializer();
                     $resourcesIndex = $rdfxmlParser->getSimpleIndex(0);
                     for ($i = 0; $i < $nbClasses; $i += $sliceSize) {
                         $ontologyRead = new OntologyRead($this->ws->ontologyUri, "getClasses", "mode=descriptions;limit={$sliceSize};offset={$i}", $this->ws->registered_ip, $this->ws->requester_ip);
                         // Since we are in pipeline mode, we have to set the owlapisession using the current one.
                         // otherwise the java bridge will return an error
                         $ontologyRead->setOwlApiSession($OwlApiSession);
                         $ontologyRead->ws_conneg("application/rdf+xml", $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                         if ($this->ws->reasoner) {
                             $ontologyRead->useReasoner();
                         } else {
                             $ontologyRead->stopUsingReasoner();
                         }
                         $ontologyRead->process();
                         $classesRDF = $ontologyRead->ws_serialize();
                         $rdfxmlParser->parse($this->ws->ontologyUri, $classesRDF);
                         $resourceIndex = $rdfxmlParser->getSimpleIndex(0);
                         $resourcesIndex = ARC2::getMergedIndex($resourcesIndex, $resourceIndex);
                         unset($ontologyRead);
                     }
                     $nbProperties = 0;
                     $nbProperties += $ontology->getNbObjectProperties();
                     $nbProperties += $ontology->getNbDataProperties();
                     $nbProperties += $ontology->getNbAnnotationProperties();
                     $sliceSize = 200;
                     for ($i = 0; $i < $nbProperties; $i += $sliceSize) {
                         $ontologyRead = new OntologyRead($this->ws->ontologyUri, "getProperties", "mode=descriptions;limit={$sliceSize};offset={$i};type=all", $this->ws->registered_ip, $this->ws->requester_ip);
                         // Since we are in pipeline mode, we have to set the owlapisession using the current one.
                         // otherwise the java bridge will return an error
                         $ontologyRead->setOwlApiSession($OwlApiSession);
                         $ontologyRead->ws_conneg("application/rdf+xml", $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                         if ($this->ws->reasoner) {
                             $ontologyRead->useReasoner();
                         } else {
                             $ontologyRead->stopUsingReasoner();
                         }
                         $ontologyRead->process();
                         $propertiesRDF = $ontologyRead->ws_serialize();
                         $rdfxmlParser->parse($this->ws->ontologyUri, $propertiesRDF);
                         $resourceIndex = $rdfxmlParser->getSimpleIndex(0);
                         $resourcesIndex = ARC2::getMergedIndex($resourcesIndex, $resourceIndex);
                         unset($ontologyRead);
                     }
                     $nbNamedIndividuals = $ontology->getNbNamedIndividuals();
                     $sliceSize = 200;
                     for ($i = 0; $i < $nbNamedIndividuals; $i += $sliceSize) {
                         $ontologyRead = new OntologyRead($this->ws->ontologyUri, "getNamedIndividuals", "classuri=all;mode=descriptions;limit={$sliceSize};offset={$i}", $this->ws->registered_ip, $this->ws->requester_ip);
                         // Since we are in pipeline mode, we have to set the owlapisession using the current one.
                         // otherwise the java bridge will return an error
                         $ontologyRead->setOwlApiSession($OwlApiSession);
                         $ontologyRead->ws_conneg("application/rdf+xml", $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                         if ($this->ws->reasoner) {
                             $ontologyRead->useReasoner();
                         } else {
                             $ontologyRead->stopUsingReasoner();
                         }
                         $ontologyRead->process();
                         $namedIndividualsRDF = $ontologyRead->ws_serialize();
                         $rdfxmlParser->parse($this->ws->ontologyUri, $namedIndividualsRDF);
                         $resourceIndex = $rdfxmlParser->getSimpleIndex(0);
                         $resourcesIndex = ARC2::getMergedIndex($resourcesIndex, $resourceIndex);
                         unset($ontologyRead);
                     }
                     // Now, let's index the resources of this ontology within structWSF (for the usage of browse, search
                     // and sparql)
                     // Split the aggregated resources in multiple slices
                     $nbResources = count($resourcesIndex);
                     $sliceSize = 200;
                     for ($i = 0; $i < $nbResources; $i += $sliceSize) {
                         $slicedResourcesIndex = array_slice($resourcesIndex, $i, $sliceSize);
                         $resourcesRDF = $rdfxmlSerializer->getSerializedIndex($slicedResourcesIndex);
                         $crudCreate = new CrudCreate($resourcesRDF, "application/rdf+xml", "full", $this->ws->ontologyUri, $this->ws->registered_ip, $this->ws->requester_ip);
                         $crudCreate->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                         $crudCreate->process();
                         if ($crudCreate->pipeline_getResponseHeaderStatus() != 200) {
                             $this->ws->conneg->setStatus($crudCreate->pipeline_getResponseHeaderStatus());
                             $this->ws->conneg->setStatusMsg($crudCreate->pipeline_getResponseHeaderStatusMsg());
                             $this->ws->conneg->setStatusMsgExt($crudCreate->pipeline_getResponseHeaderStatusMsgExt());
                             $this->ws->conneg->setError($crudCreate->pipeline_getError()->id, $crudCreate->pipeline_getError()->webservice, $crudCreate->pipeline_getError()->name, $crudCreate->pipeline_getError()->description, $crudCreate->pipeline_getError()->debugInfo, $crudCreate->pipeline_getError()->level);
                             // In case of error, we delete the dataset we previously created.
                             $ontologyDelete = new OntologyDelete($this->ws->ontologyUri, $this->ws->registered_ip, $this->ws->requester_ip);
                             $ontologyDelete->ws_conneg($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_ACCEPT_CHARSET'], $_SERVER['HTTP_ACCEPT_ENCODING'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                             $ontologyDelete->deleteOntology();
                             if ($ontologyDelete->pipeline_getResponseHeaderStatus() != 200) {
                                 $this->ws->conneg->setStatus($ontologyDelete->pipeline_getResponseHeaderStatus());
                                 $this->ws->conneg->setStatusMsg($ontologyDelete->pipeline_getResponseHeaderStatusMsg());
                                 $this->ws->conneg->setStatusMsgExt($ontologyDelete->pipeline_getResponseHeaderStatusMsgExt());
                                 $this->ws->conneg->setError($ontologyDelete->pipeline_getError()->id, $ontologyDelete->pipeline_getError()->webservice, $ontologyDelete->pipeline_getError()->name, $ontologyDelete->pipeline_getError()->description, $ontologyDelete->pipeline_getError()->debugInfo, $ontologyDelete->pipeline_getError()->level);
                                 return;
                             }
                             return;
                         }
                         unset($crudCreate);
                     }
                 }
             }
         }
     }
 }