# HG changeset patch # User Sebastien Jodogne # Date 1697698147 -7200 # Node ID c8f19e93ff9904e6b4ca6f1e4130a75cd72656d3 # Parent 9032ffb3a7d596336fb934ca256e98708ba2de18 reorganization diff -r 9032ffb3a7d5 -r c8f19e93ff99 CodeGeneration/CppNativeSDK.mustache --- a/CodeGeneration/CppNativeSDK.mustache Thu Oct 19 08:22:23 2023 +0200 +++ b/CodeGeneration/CppNativeSDK.mustache Thu Oct 19 08:49:07 2023 +0200 @@ -49,7 +49,7 @@ {{#args}}, {{c_accessor}}{{/args}}); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } {{/return.is_exception}} @@ -65,7 +65,7 @@ {{#args}}, {{c_accessor}}{{/args}}); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -80,7 +80,7 @@ {{#args}}, {{c_accessor}}{{/args}})); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -88,7 +88,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -108,7 +108,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -119,7 +119,7 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } {{/return.is_bytes}} @@ -130,7 +130,7 @@ {{#args}}, {{c_accessor}}{{/args}}); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -147,12 +147,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} } } diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/CMakeLists.txt --- a/Plugin/CMakeLists.txt Thu Oct 19 08:22:23 2023 +0200 +++ b/Plugin/CMakeLists.txt Thu Oct 19 08:49:07 2023 +0200 @@ -106,10 +106,12 @@ ) add_library(OrthancJava SHARED - Plugin.cpp - Mutex.cpp ${JSONCPP_SOURCES} ${PLUGIN_RESOURCES} + JavaEnvironment.cpp + JavaVirtualMachine.cpp + Mutex.cpp + Plugin.cpp ) set_target_properties( diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/JavaEnvironment.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugin/JavaEnvironment.cpp Thu Oct 19 08:49:07 2023 +0200 @@ -0,0 +1,284 @@ +/** + * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Java plugin for Orthanc + * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "JavaEnvironment.h" + +#include +#include + +extern OrthancPluginContext* context_; + + +static const char* ORTHANC_EXCEPTION_JAVA_CLASS = "be/uclouvain/orthanc/OrthancException"; + + +JavaEnvironment::JavaEnvironment(JNIEnv* env) : + jvm_(NULL), + env_(env) +{ + if (env_ == NULL) + { + throw std::runtime_error("Null pointer"); + } +} + + +JavaEnvironment::JavaEnvironment(JavaVirtualMachine& jvm) : + jvm_(&jvm.GetValue()) +{ + jint status = jvm_->GetEnv((void **) &env_, JNI_VERSION_1_6); + + switch (status) + { + case JNI_OK: + break; + + case JNI_EDETACHED: + { + jint code = jvm_->AttachCurrentThread((void **) &env_, NULL); + if (code != JNI_OK) + { + throw std::runtime_error("Cannot attach thread"); + } + break; + } + + case JNI_EVERSION: + throw std::runtime_error("JNI version not supported"); + + default: + throw std::runtime_error("Not implemented"); + } + + if (env_ == NULL) + { + throw std::runtime_error("Error inside JNI"); + } +} + + +JavaEnvironment::~JavaEnvironment() +{ + if (jvm_ != NULL) + { + jvm_->DetachCurrentThread(); + } +} + + +JNIEnv& JavaEnvironment::GetValue() +{ + assert(env_ != NULL); + return *env_; +} + + +void JavaEnvironment::CheckException() +{ + if (env_->ExceptionCheck() == JNI_TRUE) + { + env_->ExceptionClear(); + throw std::runtime_error("An exception has occurred in Java"); + } +} + + +void JavaEnvironment::ThrowException(const std::string& fqn, + const std::string& message) +{ + if (GetValue().ThrowNew(FindClass(fqn), message.c_str()) != 0) + { + std::string message = "Cannot throw exception " + fqn; + OrthancPluginLogError(context_, message.c_str()); + } +} + + +void JavaEnvironment::ThrowOrthancException(const std::string& message) +{ + ThrowException(ORTHANC_EXCEPTION_JAVA_CLASS, message); +} + + +void JavaEnvironment::ThrowOrthancException(OrthancPluginErrorCode code) +{ + ThrowException(ORTHANC_EXCEPTION_JAVA_CLASS, OrthancPluginGetErrorDescription(context_, code)); +} + + +void JavaEnvironment::ThrowOrthancException(JNIEnv* env, + const std::string& message) +{ + JavaEnvironment e(env); + e.ThrowOrthancException(message); +} + + +void JavaEnvironment::ThrowOrthancException(JNIEnv* env, + OrthancPluginErrorCode code) +{ + JavaEnvironment e(env); + e.ThrowOrthancException(code); +} + + +void JavaEnvironment::RegisterNatives(const std::string& fqn, + const std::vector& methods) +{ + if (!methods.empty()) + { + if (env_->RegisterNatives(FindClass(fqn), &methods[0], methods.size()) < 0) + { + throw std::runtime_error("Unable to register the native methods"); + } + } +} + + +void JavaEnvironment::RunGarbageCollector() +{ + assert(env_ != NULL); + + jclass system = FindClass("java/lang/System"); + + jmethodID runFinalization = env_->GetStaticMethodID(system, "gc", "()V"); + if (runFinalization != NULL) + { + env_->CallStaticVoidMethod(system, runFinalization); + CheckException(); + } + else + { + throw std::runtime_error("Cannot run garbage collector"); + } +} + + +jclass JavaEnvironment::FindClass(const std::string& fqn) +{ + jclass c = GetValue().FindClass(fqn.c_str()); + + if (c == NULL) + { + throw std::runtime_error("Unable to find class: " + fqn); + } + else + { + return c; + } +} + + +jclass JavaEnvironment::GetObjectClass(jobject obj) +{ + jclass c = GetValue().GetObjectClass(obj); + + if (c == NULL) + { + throw std::runtime_error("Unable to get class of object"); + } + else + { + return c; + } +} + + +jmethodID JavaEnvironment::GetMethodID(jclass c, + const std::string& method, + const std::string& signature) +{ + jmethodID m = GetValue().GetMethodID(c, method.c_str(), signature.c_str()); + + if (m == NULL) + { + throw std::runtime_error("Unable to locate method in class"); + } + else + { + return m; + } +} + + +jobject JavaEnvironment::ConstructJavaWrapper(const std::string& fqn, + void* nativeObject) +{ + jclass cls = FindClass(fqn); + jmethodID constructor = GetMethodID(cls, "", "(J)V"); + jobject obj = env_->NewObject(cls, constructor, reinterpret_cast(nativeObject)); + + if (obj == NULL) + { + throw std::runtime_error("Cannot create Java wrapper around C/C++ object: " + fqn); + } + else + { + return obj; + } +} + + +jbyteArray JavaEnvironment::ConstructByteArray(const size_t size, + const void* data) +{ + assert(env_ != NULL); + jbyteArray obj = env_->NewByteArray(size); + if (obj == NULL) + { + throw std::runtime_error("Cannot create a byte array"); + } + else + { + if (size > 0) + { + env_->SetByteArrayRegion(obj, 0, size, reinterpret_cast(data)); + } + + return obj; + } +} + + +jobject JavaEnvironment::ConstructEnumValue(const std::string& fqn, + int value) +{ + assert(env_ != NULL); + jclass cls = FindClass(fqn); + + std::string signature = "(I)L" + fqn + ";"; + jmethodID constructor = env_->GetStaticMethodID(cls, "getInstance", signature.c_str()); + if (constructor != NULL) + { + jobject obj = env_->CallStaticObjectMethod(cls, constructor, static_cast(value)); + CheckException(); + return obj; + } + else + { + char buf[16]; + sprintf(buf, "%d", value); + throw std::runtime_error("Cannot create enumeration value: " + fqn + " " + buf); + } +} diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/JavaEnvironment.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugin/JavaEnvironment.h Thu Oct 19 08:49:07 2023 +0200 @@ -0,0 +1,90 @@ +/** + * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Java plugin for Orthanc + * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "JavaVirtualMachine.h" + +#include + +#include + + +class JavaEnvironment : public NonCopyable +{ +private: + JavaVM *jvm_; + JNIEnv *env_; + +public: + JavaEnvironment(JNIEnv* env); + + JavaEnvironment(JavaVirtualMachine& jvm); + + ~JavaEnvironment(); + + JNIEnv& GetValue(); + + void CheckException(); + + void ThrowException(const std::string& fqn, + const std::string& message); + + void ThrowOrthancException(const std::string& message); + + void ThrowOrthancException(OrthancPluginErrorCode code); + + static void ThrowOrthancException(JNIEnv* env, + const std::string& message); + + static void ThrowOrthancException(JNIEnv* env, + OrthancPluginErrorCode code); + + void RegisterNatives(const std::string& fqn, + const std::vector& methods); + + void RunGarbageCollector(); + + jclass FindClass(const std::string& fqn); + + jclass GetObjectClass(jobject obj); + + jmethodID GetMethodID(jclass c, + const std::string& method, + const std::string& signature); + + jobject ConstructJavaWrapper(const std::string& fqn, + void* nativeObject); + + jbyteArray ConstructByteArray(const size_t size, + const void* data); + + jbyteArray ConstructByteArray(const std::string& data) + { + return ConstructByteArray(data.size(), data.c_str()); + } + + jobject ConstructEnumValue(const std::string& fqn, + int value); +}; diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/JavaVirtualMachine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugin/JavaVirtualMachine.cpp Thu Oct 19 08:49:07 2023 +0200 @@ -0,0 +1,79 @@ +/** + * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Java plugin for Orthanc + * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "JavaVirtualMachine.h" + +#include +#include +#include + + +JavaVirtualMachine::JavaVirtualMachine(const std::string& classPath) +{ + std::string classPathOption = "-Djava.class.path=" + classPath; + + std::vector options; + + options.resize(1); + options[0].optionString = const_cast(classPathOption.c_str()); + options[0].extraInfo = NULL; + +#if !defined(NDEBUG) + // Debug mode + { + JavaVMOption option; + option.optionString = const_cast("-Xcheck:jni"); + option.extraInfo = NULL; + options.push_back(option); + } +#endif + + JavaVMInitArgs vm_args; + vm_args.version = JNI_VERSION_1_6; + vm_args.nOptions = options.size(); + vm_args.options = (options.empty() ? NULL : &options[0]); + vm_args.ignoreUnrecognized = false; + + JNIEnv* env = NULL; + jint res = JNI_CreateJavaVM(&jvm_, (void **) &env, &vm_args); + if (res != JNI_OK || + jvm_ == NULL || + env == NULL) + { + throw std::runtime_error("Cannot create the JVM"); + } +} + + +JavaVirtualMachine::~JavaVirtualMachine() +{ + jvm_->DestroyJavaVM(); +} + + +JavaVM& JavaVirtualMachine::GetValue() +{ + assert(jvm_ != NULL); + return *jvm_; +} diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/JavaVirtualMachine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugin/JavaVirtualMachine.h Thu Oct 19 08:49:07 2023 +0200 @@ -0,0 +1,43 @@ +/** + * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Java plugin for Orthanc + * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "NonCopyable.h" + +#include +#include + +class JavaVirtualMachine : public NonCopyable +{ +private: + JavaVM *jvm_; + +public: + JavaVirtualMachine(const std::string& classPath); + + ~JavaVirtualMachine(); + + JavaVM& GetValue(); +}; diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/NativeSDK.cpp --- a/Plugin/NativeSDK.cpp Thu Oct 19 08:22:23 2023 +0200 +++ b/Plugin/NativeSDK.cpp Thu Oct 19 08:49:07 2023 +0200 @@ -32,12 +32,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -52,12 +52,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -73,11 +73,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -92,11 +92,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -111,11 +111,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -133,7 +133,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -144,18 +144,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -174,7 +174,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -185,18 +185,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -215,7 +215,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -226,18 +226,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -257,7 +257,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -268,18 +268,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -299,7 +299,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -310,18 +310,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -336,16 +336,16 @@ , c_arg0.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -359,16 +359,16 @@ , c_arg0.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -387,7 +387,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -398,18 +398,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -429,7 +429,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -440,18 +440,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -466,7 +466,7 @@ , c_arg0.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -474,7 +474,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -485,12 +485,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -505,7 +505,7 @@ , c_arg0.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -513,7 +513,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -524,12 +524,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -544,7 +544,7 @@ , c_arg0.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -552,7 +552,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -563,12 +563,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -583,7 +583,7 @@ , c_arg0.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -591,7 +591,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -602,12 +602,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -622,7 +622,7 @@ , c_arg0.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -630,7 +630,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -641,12 +641,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -660,7 +660,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -668,7 +668,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -679,12 +679,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -698,7 +698,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -706,7 +706,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -717,12 +717,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -736,7 +736,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -744,7 +744,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -755,12 +755,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -776,11 +776,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -795,11 +795,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -814,11 +814,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -832,7 +832,7 @@ , arg0, c_arg1.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -840,7 +840,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -851,12 +851,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -871,16 +871,16 @@ , arg0, c_arg1.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -894,12 +894,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -913,7 +913,7 @@ , arg0)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -921,7 +921,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -932,12 +932,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -952,12 +952,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -971,7 +971,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -979,7 +979,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -990,12 +990,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1014,7 +1014,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1025,18 +1025,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1055,7 +1055,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1066,18 +1066,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1093,16 +1093,16 @@ , c_arg0.GetValue(), c_arg1.GetData(), c_arg1.GetSize()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1115,7 +1115,7 @@ , static_cast(arg0)); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1125,12 +1125,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1145,7 +1145,7 @@ , c_arg0.GetData(), c_arg0.GetSize(), static_cast(arg2)); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -1155,12 +1155,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1179,7 +1179,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1190,18 +1190,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1220,7 +1220,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1231,18 +1231,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1263,7 +1263,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1274,18 +1274,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1307,7 +1307,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1318,18 +1318,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1351,7 +1351,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1362,18 +1362,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1390,16 +1390,16 @@ , c_arg0.GetValue(), c_arg1.GetValue(), c_arg2.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1413,12 +1413,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1432,7 +1432,7 @@ , arg0); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1442,12 +1442,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1462,12 +1462,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1482,16 +1482,16 @@ , arg0, arg1, c_arg2.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1505,16 +1505,16 @@ , arg0, arg1, static_cast(arg2), c_arg3.GetValue(), arg4, arg5); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1529,16 +1529,16 @@ , arg0, arg1, static_cast(arg2), c_arg3.GetValue(), arg4, arg5, c_arg6.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1552,7 +1552,7 @@ , c_arg0.GetData(), c_arg0.GetSize(), static_cast(arg2), static_cast(arg3), arg4)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1560,7 +1560,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1571,12 +1571,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1591,7 +1591,7 @@ , c_arg0.GetValue(), static_cast(arg1), static_cast(arg2), arg3)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1599,7 +1599,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1610,12 +1610,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1634,7 +1634,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1645,18 +1645,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1670,7 +1670,7 @@ , static_cast(arg0), arg1, arg2); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -1680,12 +1680,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1700,7 +1700,7 @@ , c_arg0.GetData(), c_arg0.GetSize(), arg2); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -1710,12 +1710,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1730,7 +1730,7 @@ , c_arg0.GetData(), c_arg0.GetSize())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1738,7 +1738,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1749,12 +1749,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1769,7 +1769,7 @@ , c_arg0.GetData(), c_arg0.GetSize())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1777,7 +1777,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1788,12 +1788,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1807,7 +1807,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1815,7 +1815,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1826,12 +1826,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1846,7 +1846,7 @@ , c_arg0.GetData(), c_arg0.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -1856,12 +1856,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1875,7 +1875,7 @@ ); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -1885,12 +1885,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -1905,7 +1905,7 @@ , c_arg0.GetValue()); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1915,12 +1915,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1936,11 +1936,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -1954,7 +1954,7 @@ , arg0, arg1, c_arg2.GetValue())); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -1962,7 +1962,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -1973,12 +1973,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -1993,7 +1993,7 @@ , c_arg0.GetData(), c_arg0.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -2003,12 +2003,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2024,7 +2024,7 @@ , c_arg0.GetData(), c_arg0.GetSize(), c_arg2.GetValue()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -2034,12 +2034,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2053,7 +2053,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2061,7 +2061,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2072,12 +2072,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2097,7 +2097,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2108,18 +2108,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2135,11 +2135,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2153,7 +2153,7 @@ ); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2163,12 +2163,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2184,12 +2184,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2204,7 +2204,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2212,7 +2212,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2223,12 +2223,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2243,7 +2243,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2251,7 +2251,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2262,12 +2262,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2284,12 +2284,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2305,7 +2305,7 @@ , c_arg0.GetValue()); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2315,12 +2315,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2336,12 +2336,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2356,7 +2356,7 @@ )); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2364,7 +2364,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2375,12 +2375,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2396,12 +2396,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2417,12 +2417,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2441,7 +2441,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2452,18 +2452,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2478,7 +2478,7 @@ , arg0); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -2488,12 +2488,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2512,7 +2512,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2523,18 +2523,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2549,7 +2549,7 @@ , static_cast(arg0), static_cast(arg1), arg2)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2557,7 +2557,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2568,12 +2568,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2589,16 +2589,16 @@ , c_arg0.GetData(), c_arg0.GetSize()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2612,16 +2612,16 @@ ); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2636,11 +2636,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2656,12 +2656,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2677,12 +2677,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2697,7 +2697,7 @@ , arg0)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2705,7 +2705,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2716,12 +2716,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2736,7 +2736,7 @@ , arg0)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2744,7 +2744,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2755,12 +2755,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2776,11 +2776,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2795,12 +2795,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2816,12 +2816,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2837,12 +2837,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2858,12 +2858,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2878,7 +2878,7 @@ , static_cast(arg0)); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } else @@ -2888,12 +2888,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -2909,16 +2909,16 @@ , arg0, c_arg1.GetValue(), arg2, arg3, arg4, arg5, arg6); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2933,11 +2933,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -2951,7 +2951,7 @@ , arg0)); if (s.GetValue() == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -2959,7 +2959,7 @@ jstring t = env->NewStringUTF(s.GetValue()); if (t == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -2970,12 +2970,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -2991,11 +2991,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3010,12 +3010,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -3030,7 +3030,7 @@ , arg0); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -3040,12 +3040,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -3060,7 +3060,7 @@ , arg0); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -3070,12 +3070,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -3091,7 +3091,7 @@ , arg0, c_arg1.GetValue()); if (s == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } else @@ -3101,12 +3101,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -3124,11 +3124,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3144,11 +3144,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3164,11 +3164,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3183,11 +3183,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3203,11 +3203,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3223,11 +3223,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3244,11 +3244,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3265,11 +3265,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3285,16 +3285,16 @@ , c_arg0.GetValue(), c_arg1.GetValue()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3309,16 +3309,16 @@ , c_arg0.GetData(), c_arg0.GetSize()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3334,11 +3334,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3354,11 +3354,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3374,11 +3374,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3394,16 +3394,16 @@ , c_arg0.GetValue(), c_arg1.GetData(), arg2, static_cast(arg3)); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3422,7 +3422,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -3433,18 +3433,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } @@ -3460,16 +3460,16 @@ , c_arg0.GetValue(), static_cast(arg1)); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3483,16 +3483,16 @@ , static_cast(arg0)); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3507,16 +3507,16 @@ , reinterpret_cast(static_cast(arg0)), c_arg1.GetData(), c_arg1.GetSize()); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3530,16 +3530,16 @@ ); if (code != OrthancPluginErrorCode_Success) { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -3555,12 +3555,12 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return 0; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return 0; } } @@ -3579,7 +3579,7 @@ jbyteArray answer = env->NewByteArray(b.GetSize()); if (answer == NULL) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); return NULL; } else @@ -3590,18 +3590,18 @@ } else { - JavaEnvironment::ThrowException(env, code); + JavaEnvironment::ThrowOrthancException(env, code); return NULL; } } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); return NULL; } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); return NULL; } } diff -r 9032ffb3a7d5 -r c8f19e93ff99 Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Thu Oct 19 08:22:23 2023 +0200 +++ b/Plugin/Plugin.cpp Thu Oct 19 08:49:07 2023 +0200 @@ -22,6 +22,9 @@ **/ +#include "JavaEnvironment.h" +#include "JavaVirtualMachine.h" + #include #include @@ -38,313 +41,7 @@ #include "Mutex.h" -static OrthancPluginContext* context_ = NULL; - - - -static const char* JAVA_EXCEPTION_CLASS = "be/uclouvain/orthanc/OrthancException"; - -class JavaVirtualMachine : public NonCopyable -{ -private: - JavaVM *jvm_; - -public: - JavaVirtualMachine(const std::string& classPath) - { - std::string classPathOption = "-Djava.class.path=" + classPath; - - std::vector options; - options.resize(2); - options[0].optionString = const_cast(classPathOption.c_str()); - options[0].extraInfo = NULL; - options[1].optionString = const_cast("-Xcheck:jni"); - options[1].extraInfo = NULL; - - JavaVMInitArgs vm_args; - vm_args.version = JNI_VERSION_1_6; - vm_args.nOptions = options.size(); - vm_args.options = (options.empty() ? NULL : &options[0]); - vm_args.ignoreUnrecognized = false; - - JNIEnv* env = NULL; - jint res = JNI_CreateJavaVM(&jvm_, (void **) &env, &vm_args); - if (res != JNI_OK || - jvm_ == NULL || - env == NULL) - { - throw std::runtime_error("Cannot create the JVM"); - } - } - - ~JavaVirtualMachine() - { - jvm_->DestroyJavaVM(); - } - - JavaVM& GetValue() - { - assert(jvm_ != NULL); - return *jvm_; - } -}; - - -class JavaEnvironment : public NonCopyable -{ -private: - JavaVM *jvm_; - JNIEnv *env_; - -public: - JavaEnvironment(JNIEnv* env) : - jvm_(NULL), - env_(env) - { - if (env_ == NULL) - { - throw std::runtime_error("Null pointer"); - } - } - - JavaEnvironment(JavaVirtualMachine& jvm) : - jvm_(&jvm.GetValue()) - { - jint status = jvm_->GetEnv((void **) &env_, JNI_VERSION_1_6); - - switch (status) - { - case JNI_OK: - break; - - case JNI_EDETACHED: - { - jint code = jvm_->AttachCurrentThread((void **) &env_, NULL); - if (code != JNI_OK) - { - throw std::runtime_error("Cannot attach thread"); - } - break; - } - - case JNI_EVERSION: - throw std::runtime_error("JNI version not supported"); - - default: - throw std::runtime_error("Not implemented"); - } - - if (env_ == NULL) - { - throw std::runtime_error("Error inside JNI"); - } - } - - ~JavaEnvironment() - { - if (jvm_ != NULL) - { - jvm_->DetachCurrentThread(); - } - } - - void CheckException() - { - if (env_->ExceptionCheck() == JNI_TRUE) - { - env_->ExceptionClear(); - throw std::runtime_error("An exception has occurred in Java"); - } - } - - JNIEnv& GetValue() - { - assert(env_ != NULL); - return *env_; - } - - void RunGarbageCollector() - { - assert(env_ != NULL); - - jclass system = FindClass("java/lang/System"); - - jmethodID runFinalization = env_->GetStaticMethodID(system, "gc", "()V"); - if (runFinalization != NULL) - { - env_->CallStaticVoidMethod(system, runFinalization); - CheckException(); - } - else - { - throw std::runtime_error("Cannot run garbage collector"); - } - } - - jclass FindClass(const std::string& fqn) - { - jclass c = GetValue().FindClass(fqn.c_str()); - - if (c == NULL) - { - throw std::runtime_error("Unable to find class: " + fqn); - } - else - { - return c; - } - } - - jclass GetObjectClass(jobject obj) - { - jclass c = GetValue().GetObjectClass(obj); - - if (c == NULL) - { - throw std::runtime_error("Unable to get class of object"); - } - else - { - return c; - } - } - - jmethodID GetMethodID(jclass c, - const std::string& method, - const std::string& signature) - { - jmethodID m = GetValue().GetMethodID(c, method.c_str(), signature.c_str()); - - if (m == NULL) - { - throw std::runtime_error("Unable to locate method in class"); - } - else - { - return m; - } - } - - jobject ConstructJavaWrapper(const std::string& fqn, - void* nativeObject) - { - jclass cls = FindClass(fqn); - jmethodID constructor = GetMethodID(cls, "", "(J)V"); - jobject obj = env_->NewObject(cls, constructor, reinterpret_cast(nativeObject)); - - if (obj == NULL) - { - throw std::runtime_error("Cannot create Java wrapper around C/C++ object: " + fqn); - } - else - { - return obj; - } - } - - jbyteArray ConstructByteArray(const size_t size, - const void* data) - { - assert(env_ != NULL); - jbyteArray obj = env_->NewByteArray(size); - if (obj == NULL) - { - throw std::runtime_error("Cannot create a byte array"); - } - else - { - if (size > 0) - { - env_->SetByteArrayRegion(obj, 0, size, reinterpret_cast(data)); - } - - return obj; - } - } - - jbyteArray ConstructByteArray(const std::string& data) - { - return ConstructByteArray(data.size(), data.c_str()); - } - - void RegisterNatives(const std::string& fqn, - const std::vector& methods) - { - if (!methods.empty()) - { - if (env_->RegisterNatives(FindClass(fqn), &methods[0], methods.size()) < 0) - { - throw std::runtime_error("Unable to register the native methods"); - } - } - } - - void ThrowException(const std::string& fqn, - const std::string& message) - { - if (GetValue().ThrowNew(FindClass(fqn), message.c_str()) != 0) - { - std::string message = "Cannot throw exception " + fqn; - OrthancPluginLogError(context_, message.c_str()); - } - } - - void ThrowException(const std::string& message) - { - ThrowException(JAVA_EXCEPTION_CLASS, message); - } - - void ThrowException(OrthancPluginErrorCode code) - { - ThrowException(JAVA_EXCEPTION_CLASS, OrthancPluginGetErrorDescription(context_, code)); - } - - jobject ConstructEnumValue(const std::string& fqn, - int value) - { - assert(env_ != NULL); - jclass cls = FindClass(fqn); - - std::string signature = "(I)L" + fqn + ";"; - jmethodID constructor = env_->GetStaticMethodID(cls, "getInstance", signature.c_str()); - if (constructor != NULL) - { - jobject obj = env_->CallStaticObjectMethod(cls, constructor, static_cast(value)); - CheckException(); - return obj; - } - else - { - char buf[16]; - sprintf(buf, "%d", value); - throw std::runtime_error("Cannot create enumeration value: " + fqn + " " + buf); - } - } - - - static void ThrowException(JNIEnv* env, - const std::string& fqn, - const std::string& message) - { - JavaEnvironment e(env); - e.ThrowException(fqn, message); - } - - static void ThrowException(JNIEnv* env, - const std::string& message) - { - JavaEnvironment e(env); - e.ThrowException(message); - } - - static void ThrowException(JNIEnv* env, - OrthancPluginErrorCode code) - { - JavaEnvironment e(env); - e.ThrowException(code); - } -}; - +OrthancPluginContext* context_ = NULL; static std::unique_ptr java_; @@ -933,11 +630,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } } @@ -952,11 +649,11 @@ } catch (std::runtime_error& e) { - JavaEnvironment::ThrowException(env, e.what()); + JavaEnvironment::ThrowOrthancException(env, e.what()); } catch (...) { - JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); + JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); } }