private function _cleanupDb() { $tx = $this->_neoGateway->factoryTransaction(); try { $nodes = $this->_neoGateway->getGraphDb()->getAllNodes()->iterator(); while (java_values($nodes->hasNext())) { $node = $nodes->next(); $nodeRels = $node->getRelationships(); while (java_values($nodeRels->hasNext())) { $nodeRels->next()->delete(); } if (!java_values($node->equals($this->_neoGateway->getGraphDb()->getReferenceNode()))) { $node->delete(); } } $tx->success(); } catch (Exception $e) { java_last_exception_get()->printStackTrace(); $tx->failure(); } $tx->finish(); }
#!/usr/bin/php <?php include_once "java/Java.inc"; // the following tests if a class "NoClassDefFound" which contains a // constructor and a method which internally reference an external // class "DoesNotExist" can be referenced, and, if an exception is // thrown if the two classes are loaded by different class loaders. // make sure to start the backend at log_level 3, to see the "loading..." // messages. java_reset(); $here = realpath(dirname($_SERVER["SCRIPT_FILENAME"])); if (!$here) { $here = getcwd(); } java_require("{$here}/doesNotExist.jar"); java_require("{$here}/noClassDefFound.jar"); java_require("{$here}/doesNotExist.jar;{$here}/noClassDefFound.jar"); $v = new JavaClass("NoClassDefFound"); // must fail: the second loader is selected, which does not include // DoesNotExist. echo "must fail\n"; $v->call(null); exit(java_last_exception_get() ? 0 : 1);
if (!(PHP_SHLIB_SUFFIX == "so" && @dl('java.so')) && !(PHP_SHLIB_SUFFIX == "dll" && @dl('php_java.dll')) && !(include_once "java/Java.php")) { echo "java extension not installed."; exit(2); } } else { echo "java extension not installed."; } } } check_extension(); if (1) { phpinfo(); print "\n\n"; $v = new Java("java.lang.System"); $p = @$v->getProperties(); if ($ex = java_last_exception_get()) { $trace = new Java("java.io.ByteArrayOutputStream"); $ex->printStackTrace(new java("java.io.PrintStream", $trace)); echo "Exception {$ex} occured:<br>\n" . $trace . "\n"; exit(1); } $arr = $p; foreach ($arr as $key => $value) { print $key . " -> " . $value . "<br>\n"; } echo "<br>\n"; echo "<br>\n"; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); print $formatter->format(new Java('java.util.Date')); echo "<br>\n";
/** * Get all the groups with the specified search criteria and search Type. * * @param object mixed $searchCriteria (original type: java.io.Serializable) * @param object Type $groupSearchType * * @return object AgentIterator * * @throws object AgentException An exception with one of the * following messages defined in org.osid.agent.AgentException may * be thrown: {@link * org.osid.agent.AgentException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.agent.AgentException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.agent.AgentException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.agent.AgentException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.agent.AgentException#UNKNOWN_TYPE UNKNOWN_TYPE} * * @access public */ function getGroupsBySearch($searchCriteria, $groupSearchType) { $result = $this->_javaClass->getGroupsBySearch($searchCriteria, $groupSearchType); $ex = java_last_exception_get(); if ($ex) { java_last_exception_clear(); return $ex->toString(); } java_last_exception_clear(); return $result; }
#!/usr/bin/php <?php include_once "java/Java.inc"; // the following tests if a class "NoClassDefFound" which contains a // constructor and a method which internally reference an external // class "DoesNotExist" can be referenced, and, if an exception is // thrown if the two classes are loaded by different class loaders. // make sure to start the backend at log_level 3, to see the "loading..." // messages. $here = realpath(dirname($_SERVER["SCRIPT_FILENAME"])); if (!$here) { $here = getcwd(); } java_reset(); echo "must succeed\n"; // must succeed java_require("{$here}/doesNotExist.jar;{$here}/noClassDefFound.jar"); $v = new java("NoClassDefFound"); $v->call(null); exit(java_last_exception_get() ? 1 : 0);
/** * Updates a node with a set of properties. A property value may be set to null to remove * corresponding property. * * @param $node - org.neo4j.graphdb.Node * @param $data array - properties */ public function update($node, $data) { $tx = $this->getGateway()->factoryTransaction(); try { $this->_populateData($node, $data); $tx->success(); } catch (Exception $e) { java_last_exception_get()->printStackTrace(); $tx->failure(); } $tx->finish(); }