public function getPrimaryItem()
{
try {
$primary_item = null;
$item_name = $this->getPrimaryNodeType()->getPrimaryItemName();
if ($item_name !== null) {
$primary_item = $this->session->getItem($this->path . '/' . $item_name);
}
} catch (Exception $ex) {
throw new RepositoryException("An error occured while reading the primary item of the node '{$this->path}': " . $ex->getMessage());
}
if ($primary_item === null) {
throw new ItemNotFoundException("No primary item found for node '{$this->path}'");
}
return $primary_item;
}