Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Check for Model IRI prior to creation #129

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/Erfurt/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
class Erfurt_Exception extends Exception {

//Used for exceptions that found invalid URI/IRI's
const INVALID_IRI_ERROR = 7;

function display($pre = true) {
if ($pre) print '<pre>';
echo "Erfurt_Exception: code $this->code ($this->message) " .
Expand Down
7 changes: 7 additions & 0 deletions library/Erfurt/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,13 @@ public function getModel($modelIri, $useAc = true)
*/
public function getNewModel($modelIri, $baseIri = '', $type = Erfurt_Store::MODEL_TYPE_OWL, $useAc = true)
{
//check if the $modelIri is a valid IRI
if (!Erfurt_Uri::check($modelIri)) {
$message = defined('_EFDEBUG')
? 'Failed creating the model. The chosen IRI is not valid.'
: 'Failed creating the model.';
throw new Erfurt_Store_Exception($message, Erfurt_Exception::INVALID_IRI_ERROR);
}
// check model availablity
if ($this->isModelAvailable($modelIri, false)) {
// if debug mode is enabled create a more detailed exception description. If debug mode is disabled the
Expand Down