static bool do_local_process_test(const Omega::string_t& strPrefix) { output(" %-43s ",("'" + strPrefix + "/' registry key").c_str()); // Test the simplest case OTL::ObjectPtr<Omega::TestSuite::ISimpleTest> ptrSimpleTest(Omega::TestSuite::OID_TestProcess,Omega::Activation::Process); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Kill the running version try { ptrSimpleTest->Abort(); } catch (Omega::Remoting::IChannelClosedException* pE) { add_success(); pE->Release(); } ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Process"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Kill the running version try { ptrSimpleTest->Abort(); } catch (Omega::Remoting::IChannelClosedException* pE) { add_success(); pE->Release(); } // Test unregistering TEST(unregister_process(strPrefix)); // Check its gone try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Process"); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } return true; }
void Media::upload_image_treat() { LOGIN_REQUIRED(); forms::media::UploadImage form; form.load(context()); form.image.load(context()); if (!form.validate()) { if (!form.image.validate()) { add_error(MEDIA_SAVE_INVALID_ERROR_TEXT); } go_back_to_previous_page(); return; } std::string fileURL = uploadsModel->save( form.image.value() ); if (fileURL.empty()) { add_error(MEDIA_SAVE_INTERNAL_ERROR_TEXT); go_back_to_previous_page(); return; } const std::string fileUploaded = (cppcms::locale::format( _("File uploaded successfully. at this address: {1} ") ) % fileURL).str(); add_success(fileUploaded); go_back_to_previous_page(); }
void Articles::remove(const std::string slug) { LOGIN_REQUIRED(); const bool success = articlesModel->remove( get_interface_lang(), slug ); if (success) { add_success(_("The article has been removed")); } else { add_error(_("A problem occured while trying to remove")); } go_to_main_page(); }
static bool do_local_library_test(const Omega::string_t& strPrefix) { output(" %-43s ",("'" + strPrefix + "/' registry key").c_str()); // Test the simplest case OTL::ObjectPtr<Omega::TestSuite::ISimpleTest> ptrSimpleTest(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Library); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary.ToString()); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation with '@local' ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation with '@local' ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary.ToString() + "@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test redirecting the registration OTL::ObjectPtr<Omega::Registry::IKey> ptrKey("/Local User/Objects",Omega::Registry::IKey::OpenCreate); OTL::ObjectPtr<Omega::Registry::IKey> ptrSubKey = ptrKey->OpenKey("MyLittleTest",Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("CurrentVersion","Test.Library"); ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("MyLittleTest@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test it has gone ptrKey->DeleteSubKey("MyLittleTest"); try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("MyLittleTest"); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } // Test for surrogate activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Process); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); ptrSimpleTest.Release(); // Test unregistering TEST(unregister_library(strPrefix)); try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library"); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } // Now test the sand-box surrogate activation /* // Register the library TEST(register_library("/System/Sandbox",strLibName,bSkipped)); if (bSkipped) return true; // Test for surrogate activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Sandbox); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); TEST(unregister_library("/System/Sandbox"));*/ return true; }