Permalink
Browse files

catch exceptions in custom filter, dont import then

  • Loading branch information...
1 parent ce45dbd commit 0e1652ba2f89aa3559d7d68b896978ddd8a760a0 @jbrekle jbrekle committed Mar 23, 2012
Showing with 17 additions and 8 deletions.
  1. +17 −8 extensions/datagathering/DatagatheringController.php
@@ -57,6 +57,8 @@ class DatagatheringController extends OntoWiki_Controller_Component
CONST IMPORT_NOT_EDITABLE = 50;
CONST IMPORT_WRAPPER_EXCEPTION = 60;
CONST IMPORT_WRAPPER_NOT_AVAILABLE = 70;
+ CONST IMPORT_CUSTOMFILTER_EXCEPTION = 80;
+
// ------------------------------------------------------------------------
// --- Import and Sync related private properties -------------------------
@@ -957,6 +959,20 @@ public static function import (
if (in_array(Erfurt_Wrapper::RESULT_HAS_ADD, $wrapperResult['status_codes'])) {
$newStatements = $wrapperResult['add'];
+ //default filter
+ $newStatements = self::filterStatements(
+ $newStatements, $uri, $all, $presets, $exceptedProperties, $fetchMode
+ );
+
+ //custom filter
+ if ($filterCallback != null && is_array($filterCallback)) {
+ try {
+ $newStatements = call_user_func($filterCallback, $newStatements);
+ } catch (Exception $e) {
+ return self::IMPORT_CUSTOMFILTER_EXCEPTION;
+ }
+ }
+
$stmtBeforeCount = $store->countWhereMatches(
$graphUri,
'{ ?s ?p ?o }',
@@ -975,14 +991,7 @@ public static function import (
// Start action, add statements, finish action.
$versioning->startAction($actionSpec);
}
-
- $newStatements = self::filterStatements(
- $newStatements, $uri, $all, $presets, $exceptedProperties, $fetchMode
- );
- if ($filterCallback != null && is_array($filterCallback)) {
- $newStatements = call_user_func($filterCallback, $newStatements);
- }
-
+
if ($action == 'add') {
$store->addMultipleStatements($graphUri, $newStatements);
} else if ($action == 'update') {

0 comments on commit 0e1652b

Please sign in to comment.