Adapted ROC CMS to concurrent EWF.
Revisited the shared logger to reduced number of useless calls.
This commit is contained in:
@@ -1,58 +1,81 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo">
|
||||
<description>Example/demo for Eiffel ROC CMS library</description>
|
||||
<target name="common" abstract="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/>
|
||||
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
|
||||
<library name="cms_blog_module" location="modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
|
||||
<!--
|
||||
<library name="persistence_mysql" location="..\..\library\persistence\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
-->
|
||||
<library name="persistence_sqlite" location="..\..\library\persistence\sqlite\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
</target>
|
||||
<target name="demo_any" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_nino" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_cgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_libfcgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo" extends="demo_nino">
|
||||
</target>
|
||||
<description>Example/demo for Eiffel ROC CMS library</description>
|
||||
<target name="common" abstract="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option debug="true" warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<debug name="dbglog" enabled="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/>
|
||||
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
|
||||
<library name="cms_blog_module" location="modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_sqlite" location="..\..\library\persistence\sqlite\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
</target>
|
||||
<target name="demo_any" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
|
||||
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_standalone" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<option debug="true">
|
||||
<debug name="dbglog" enabled="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_standalone_none" extends="demo_standalone">
|
||||
<setting name="concurrency" value="none"/>
|
||||
</target>
|
||||
<target name="demo_standalone_mt" extends="demo_standalone">
|
||||
<setting name="concurrency" value="thread"/>
|
||||
</target>
|
||||
<target name="demo_standalone_scoop" extends="demo_standalone">
|
||||
<option debug="true">
|
||||
<debug name="dbglog" enabled="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
</target>
|
||||
<target name="demo_nino" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_cgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_libfcgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo" extends="demo_standalone">
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -8,10 +8,10 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G]
|
||||
|
||||
feature -- Custom
|
||||
|
||||
|
||||
@@ -10,24 +10,28 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
nature: like launcher_nature
|
||||
do
|
||||
nature := launcher_nature
|
||||
if nature = Void or else nature = nature_nino then
|
||||
launch_nino (a_service, opts)
|
||||
if nature = Void then
|
||||
launch_standalone (opts)
|
||||
elseif nature = nature_standalone then
|
||||
launch_standalone (opts)
|
||||
elseif nature = nature_nino then
|
||||
launch_nino (opts)
|
||||
elseif nature = nature_cgi then
|
||||
launch_cgi (a_service, opts)
|
||||
launch_cgi (opts)
|
||||
elseif nature = nature_libfcgi then
|
||||
launch_libfcgi (a_service, opts)
|
||||
launch_libfcgi (opts)
|
||||
else
|
||||
-- bye bye
|
||||
(create {EXCEPTIONS}).die (-1)
|
||||
@@ -43,14 +47,16 @@ feature {NONE} -- Access
|
||||
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
|
||||
local
|
||||
p: PATH
|
||||
l_entry_name: READABLE_STRING_32
|
||||
ext: detachable READABLE_STRING_32
|
||||
do
|
||||
create p.make_from_string (execution_environment.arguments.command_name)
|
||||
if attached p.entry as l_entry then
|
||||
ext := l_entry.extension
|
||||
ext := l_entry.extension
|
||||
end
|
||||
if ext /= Void then
|
||||
if ext.same_string (nature_standalone) then
|
||||
Result := nature_standalone
|
||||
end
|
||||
if ext.same_string (nature_nino) then
|
||||
Result := nature_nino
|
||||
end
|
||||
@@ -61,39 +67,58 @@ feature {NONE} -- Access
|
||||
Result := nature_libfcgi
|
||||
end
|
||||
end
|
||||
Result := default_nature
|
||||
end
|
||||
|
||||
feature {NONE} -- standalone
|
||||
|
||||
nature_standalone: STRING = "standalone"
|
||||
|
||||
launch_standalone (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- nino
|
||||
|
||||
nature_nino: STRING = "nino"
|
||||
|
||||
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_nino (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- cgi
|
||||
|
||||
nature_cgi: STRING = "cgi"
|
||||
|
||||
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_cgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_CGI_SERVICE_LAUNCHER
|
||||
launcher: WSF_CGI_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- libfcgi
|
||||
|
||||
nature_libfcgi: STRING = "libfcgi"
|
||||
|
||||
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_libfcgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER
|
||||
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature -- Default
|
||||
|
||||
default_nature: STRING
|
||||
do
|
||||
Result := nature_standalone
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G]
|
||||
|
||||
feature -- Custom
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ note
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_DEFAULT_SERVICE_LAUNCHER
|
||||
launcher: WSF_DEFAULT_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
"server": "localhost"
|
||||
},
|
||||
"logger": {
|
||||
"level":"debug",
|
||||
"level":"error",
|
||||
"type":"stderr",
|
||||
"backup_count":"4"
|
||||
},
|
||||
"server": {
|
||||
|
||||
BIN
examples/demo/site/themes/bootstrap/assets/favicon.ico
Normal file
BIN
examples/demo/site/themes/bootstrap/assets/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 994 B |
@@ -4,10 +4,10 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- EWF CMS -->
|
||||
<link rel="stylesheet" href="{$site_url/}/theme/css/style.css">
|
||||
<link rel="stylesheet" href="{$site_url/}/theme/css/node.css">
|
||||
<script src="{$site_url/}/theme/js/jquery-1.10.2.min.js"></script>
|
||||
<script src="{$site_url/}/theme/js/roc_auth.js"></script>
|
||||
<link rel="stylesheet" href="{$site_url/}theme/css/style.css">
|
||||
<link rel="stylesheet" href="{$site_url/}theme/css/node.css">
|
||||
<script src="{$site_url/}theme/js/jquery-1.10.2.min.js"></script>
|
||||
<script src="{$site_url/}theme/js/roc_auth.js"></script>
|
||||
|
||||
<!-- bootstrap framework -->
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
|
||||
@@ -16,11 +16,6 @@ inherit
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_SERVICE
|
||||
redefine
|
||||
execute
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
@@ -40,37 +35,26 @@ feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Initialize current service.
|
||||
local
|
||||
env: CMS_ENVIRONMENT
|
||||
do
|
||||
-- Launcher
|
||||
Precursor
|
||||
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("demo.ini")
|
||||
|
||||
-- CMS
|
||||
initialize_cms
|
||||
end
|
||||
|
||||
feature -- Service
|
||||
|
||||
cms_service: CMS_SERVICE
|
||||
-- cms service.
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
cms_service.execute (req, res)
|
||||
create env.make_default
|
||||
initialize_logger (env)
|
||||
end
|
||||
|
||||
feature {NONE} -- Launch operation
|
||||
|
||||
launcher: APPLICATION_LAUNCHER
|
||||
launcher: APPLICATION_LAUNCHER [EWF_ROC_SERVER_EXECUTION]
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
l_retry: BOOLEAN
|
||||
l_message: STRING
|
||||
do
|
||||
if not l_retry then
|
||||
write_debug_log (generator + ".launch")
|
||||
launcher.launch (a_service, opts)
|
||||
launcher.launch (opts)
|
||||
else
|
||||
-- error hanling.
|
||||
create l_message.make (1024)
|
||||
@@ -89,77 +73,12 @@ feature {NONE} -- Launch operation
|
||||
l_message.append ("The application crash without available information")
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
-- notify shutdown
|
||||
write_debug_log (generator + ".launch shutdown")
|
||||
-- send email shutdown
|
||||
end
|
||||
rescue
|
||||
l_retry := True
|
||||
retry
|
||||
end
|
||||
|
||||
feature -- CMS Initialization
|
||||
|
||||
initialize_cms
|
||||
local
|
||||
l_setup: CMS_DEFAULT_SETUP
|
||||
utf: UTF_CONVERTER
|
||||
cms_env: CMS_ENVIRONMENT
|
||||
do
|
||||
-- Application Environment initialization
|
||||
if attached execution_environment.arguments.separate_character_option_value ('d') as l_dir then
|
||||
create cms_env.make_with_directory_name (l_dir)
|
||||
else
|
||||
create cms_env.make_default
|
||||
end
|
||||
initialize_logger (cms_env)
|
||||
|
||||
-- CMS Setup
|
||||
write_debug_log (generator + ".initialize_cms / SETUP based directory=%"" + utf.escaped_utf_32_string_to_utf_8_string_8 (cms_env.path.name) + "%"")
|
||||
create l_setup.make (cms_env)
|
||||
|
||||
-- CMS
|
||||
write_debug_log (generator + ".initialize_cms / CMS")
|
||||
setup_storage (l_setup)
|
||||
setup_modules (l_setup)
|
||||
create cms_service.make (l_setup)
|
||||
end
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create {NODE_MODULE} m.make (a_setup)
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {BASIC_AUTH_MODULE} m.make
|
||||
if not a_setup.module_with_same_type_registered (m) then
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
create {CMS_DEBUG_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_BLOG_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
-- Setup storage by declaring storage builder.
|
||||
do
|
||||
-- a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
|
||||
a_setup.storage_drivers.force (create {CMS_STORAGE_SQLITE_BUILDER}.make, "sqlite")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
81
examples/demo/src/ewf_roc_server_execution.e
Normal file
81
examples/demo/src/ewf_roc_server_execution.e
Normal file
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description: "Summary description for {EWF_ROC_SERVER_EXECUTION}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_ROC_SERVER_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
end
|
||||
|
||||
initial_cms_setup: CMS_DEFAULT_SETUP
|
||||
-- CMS setup.
|
||||
local
|
||||
l_env: CMS_ENVIRONMENT
|
||||
do
|
||||
if attached execution_environment.arguments.separate_character_option_value ('d') as l_dir then
|
||||
create l_env.make_with_directory_name (l_dir)
|
||||
else
|
||||
create l_env.make_default
|
||||
end
|
||||
create Result.make (l_env)
|
||||
end
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
to_implement ("To implement custom storage")
|
||||
end
|
||||
-- a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
|
||||
a_setup.storage_drivers.force (create {CMS_STORAGE_SQLITE_BUILDER}.make, "sqlite")
|
||||
end
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create {NODE_MODULE} m.make (a_setup)
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {BASIC_AUTH_MODULE} m.make
|
||||
if not a_setup.module_with_same_type_registered (m) then
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
create {CMS_DEBUG_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_BLOG_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -30,6 +30,7 @@ feature -- Initialization
|
||||
backup_count := 4
|
||||
level := Log_debug
|
||||
location := Void
|
||||
type := {STRING_32} "null"
|
||||
ensure then
|
||||
backup_count_set: backup_count = 4
|
||||
level_set: level = Log_debug
|
||||
@@ -48,6 +49,9 @@ feature -- Access
|
||||
level: INTEGER
|
||||
-- Logger level.
|
||||
|
||||
type: IMMUTABLE_STRING_32
|
||||
-- Type of logging.
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_location (a_location: detachable PATH)
|
||||
@@ -65,6 +69,15 @@ feature -- Element Change
|
||||
set_location (create {PATH}.make_from_string (a_location))
|
||||
end
|
||||
|
||||
set_type_with_string (a_type: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if a_type /= Void and then not a_type.is_whitespace then
|
||||
create type.make_from_string_general (a_type)
|
||||
else
|
||||
create type.make_from_string_general ("null")
|
||||
end
|
||||
end
|
||||
|
||||
set_backup_count (a_backup: NATURAL)
|
||||
-- Set backup_count to `a_backup'.
|
||||
do
|
||||
|
||||
@@ -32,7 +32,7 @@ feature {NONE} -- Initialization
|
||||
create log.make
|
||||
end
|
||||
|
||||
make_with_environment (app: APPLICATION_ENVIRONMENT)
|
||||
make_with_environment (app: separate APPLICATION_ENVIRONMENT)
|
||||
-- Initialize a logger object with an application environment `app'.
|
||||
do
|
||||
make
|
||||
@@ -49,7 +49,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Change
|
||||
|
||||
apply_environment (app: APPLICATION_ENVIRONMENT)
|
||||
apply_environment (app: separate APPLICATION_ENVIRONMENT)
|
||||
do
|
||||
initialize_logger (app, log)
|
||||
end
|
||||
@@ -58,75 +58,107 @@ feature {NONE} -- Internal
|
||||
|
||||
log: LOGGING_FACILITY
|
||||
|
||||
feature -- Settings
|
||||
|
||||
level: INTEGER
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_debug (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at debug level.
|
||||
do
|
||||
if level >= log_debug then
|
||||
log.write_debug (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
put_information (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at information level.
|
||||
do
|
||||
log.write_information (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_error (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at error level.
|
||||
do
|
||||
log.write_error (create {STRING}.make_from_separate (a_message))
|
||||
if level >= log_information then
|
||||
log.write_information (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
put_warning (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at warning level.
|
||||
do
|
||||
log.write_warning (create {STRING}.make_from_separate (a_message))
|
||||
if level >= log_warning then
|
||||
log.write_warning (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
put_error (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at error level.
|
||||
do
|
||||
if level >= log_error then
|
||||
log.write_error (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
put_critical (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at critical level.
|
||||
do
|
||||
log.write_critical (create {STRING}.make_from_separate (a_message))
|
||||
if level >= log_critical then
|
||||
log.write_critical (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
put_alert (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at alert level.
|
||||
do
|
||||
log.write_alert (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_debug (a_message: separate READABLE_STRING_8)
|
||||
-- Put message `a_message' to the log at debug level.
|
||||
do
|
||||
log.write_debug (create {STRING}.make_from_separate (a_message))
|
||||
if level >= log_alert then
|
||||
log.write_alert (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
initialize_logger (app: APPLICATION_ENVIRONMENT; a_log: like log)
|
||||
initialize_logger (app: separate APPLICATION_ENVIRONMENT; a_log: like log)
|
||||
local
|
||||
l_log_writer_file: LOG_ROLLING_WRITER_FILE
|
||||
l_log_writer: LOG_WRITER
|
||||
l_log_writer: detachable LOG_WRITER
|
||||
l_logs_path: detachable PATH
|
||||
l_logger_config: LOGGER_CONFIGURATION
|
||||
ut: FILE_UTILITIES
|
||||
p: PATH
|
||||
l_name: IMMUTABLE_STRING_32
|
||||
do
|
||||
l_logger_config := new_logger_level_configuration (app.application_config_path)
|
||||
l_logs_path := l_logger_config.location
|
||||
if l_logs_path = Void then
|
||||
l_logs_path := app.logs_path
|
||||
create l_name.make_from_separate (app.name)
|
||||
create p.make_from_separate (app.application_config_path)
|
||||
-- l_name := app.name
|
||||
-- p := app.application_config_path
|
||||
|
||||
l_logger_config := new_logger_level_configuration (p)
|
||||
if l_logger_config.type.is_case_insensitive_equal_general ("file") then
|
||||
l_logs_path := l_logger_config.location
|
||||
if l_logs_path = Void then
|
||||
create l_logs_path.make_from_separate (app.logs_path)
|
||||
end
|
||||
if ut.directory_path_exists (l_logs_path) then
|
||||
create l_log_writer_file.make_at_location (l_logs_path.extended (l_name).appended_with_extension ("log"))
|
||||
l_log_writer_file.set_max_file_size ({NATURAL_64} 1024 * 1204)
|
||||
l_log_writer_file.set_max_backup_count (l_logger_config.backup_count)
|
||||
l_log_writer := l_log_writer_file
|
||||
else
|
||||
-- Should we create the directory anyway ?
|
||||
end
|
||||
elseif l_logger_config.type.is_case_insensitive_equal_general ("stderr") then
|
||||
create {LOG_WRITER_STDERR} l_log_writer
|
||||
end
|
||||
if ut.directory_path_exists (l_logs_path) then
|
||||
create l_log_writer_file.make_at_location (l_logs_path.extended (app.name).appended_with_extension ("log"))
|
||||
l_log_writer_file.set_max_file_size ({NATURAL_64} 1024 * 1204)
|
||||
l_log_writer_file.set_max_backup_count (l_logger_config.backup_count)
|
||||
l_log_writer := l_log_writer_file
|
||||
else
|
||||
-- Should we create the directory anyway ?
|
||||
if l_log_writer = Void then
|
||||
create {LOG_WRITER_NULL} l_log_writer
|
||||
set_logger_level (l_log_writer, log_notice)
|
||||
else
|
||||
set_logger_level (l_log_writer, 0) -- None
|
||||
end
|
||||
set_logger_level (l_log_writer, l_logger_config.level)
|
||||
a_log.register_log_writer (l_log_writer)
|
||||
end
|
||||
|
||||
set_logger_level (a_log_writer: LOG_WRITER; a_priority: INTEGER)
|
||||
-- Setup the logger level based on `a_priority'
|
||||
do
|
||||
level := a_priority
|
||||
if a_priority = log_debug then
|
||||
a_log_writer.enable_debug_log_level
|
||||
elseif a_priority = Log_emergency then
|
||||
@@ -167,6 +199,9 @@ feature {NONE} -- Implementation
|
||||
attached l_parser.parsed_json_object as jv and then
|
||||
attached {JSON_OBJECT} jv.item ("logger") as l_logger
|
||||
then
|
||||
if attached {JSON_STRING} l_logger.item ("type") as l_type then
|
||||
Result.set_type_with_string (l_type.item)
|
||||
end
|
||||
if attached {JSON_STRING} l_logger.item ("location") as l_location then
|
||||
Result.set_location_with_string (l_location.item)
|
||||
end
|
||||
|
||||
@@ -35,72 +35,113 @@ feature -- Logging
|
||||
|
||||
write_debug_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_debug_log_to (m, logger)
|
||||
-- write_debug_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_information_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_information_log_to (m, logger)
|
||||
-- write_information_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_warning_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_warning_log_to (m, logger)
|
||||
-- write_warning_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_error_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_error_log_to (m, logger)
|
||||
-- write_error_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_critical_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_critical_log_to (m, logger)
|
||||
-- write_critical_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_alert_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_alert_log_to (m, logger)
|
||||
-- write_alert_log_to (m, logger)
|
||||
end
|
||||
|
||||
feature {NONE} -- Logger: separate implementation
|
||||
|
||||
write_debug_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_debug (m)
|
||||
if not retried then
|
||||
a_log.put_debug (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
write_information_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_information (m)
|
||||
if not retried then
|
||||
a_log.put_information (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
write_warning_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_warning (m)
|
||||
if not retried then
|
||||
a_log.put_warning (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
write_error_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_error (m)
|
||||
if not retried then
|
||||
a_log.put_error (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
write_critical_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_critical (m)
|
||||
if not retried then
|
||||
a_log.put_critical (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
write_alert_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
a_log.put_alert (m)
|
||||
if not retried then
|
||||
a_log.put_alert (m)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
initialize_logger (app: APPLICATION_ENVIRONMENT)
|
||||
local
|
||||
l_logger: LOGGER
|
||||
l_logger: separate LOGGER
|
||||
do
|
||||
create l_logger.make_with_environment (app)
|
||||
set_logger_to (l_logger, logger_cell)
|
||||
|
||||
@@ -32,6 +32,15 @@ feature -- Status report
|
||||
Result := connection.is_connected
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
close
|
||||
-- <Precursor>
|
||||
-- Disconnect from SQL database.
|
||||
do
|
||||
connection.disconnect
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
|
||||
@@ -29,15 +29,25 @@ feature -- Factory
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_SQLITE
|
||||
local
|
||||
s: STRING
|
||||
conn: DATABASE_CONNECTION
|
||||
conn: detachable DATABASE_CONNECTION
|
||||
do
|
||||
if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.environment.application_config_path) as l_database_config then
|
||||
if
|
||||
attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.environment.application_config_path) as l_database_config
|
||||
then
|
||||
s := "Driver=SQLite3 ODBC Driver;Database="
|
||||
if attached l_database_config.database_name as db_name then
|
||||
s.append (db_name)
|
||||
end
|
||||
s.append (";LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
|
||||
create {DATABASE_CONNECTION_ODBC} conn.login_with_connection_string (s)
|
||||
if attached reuseable_connection.item as d then
|
||||
if s.same_string (d.name) then
|
||||
conn := d.connection
|
||||
end
|
||||
end
|
||||
if conn = Void or else not conn.is_connected then
|
||||
create {DATABASE_CONNECTION_ODBC} conn.login_with_connection_string (s)
|
||||
reuseable_connection.replace ([s, conn])
|
||||
end
|
||||
if conn.is_connected then
|
||||
create Result.make (conn)
|
||||
set_map_zero_null_value (False) --| This way we map 0 to 0, instead of Null as default.
|
||||
@@ -50,4 +60,9 @@ feature -- Factory
|
||||
end
|
||||
end
|
||||
|
||||
reuseable_connection: CELL [detachable TUPLE [name: STRING; connection: DATABASE_CONNECTION]]
|
||||
once
|
||||
create Result.put (Void)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -22,12 +22,13 @@ feature -- Basic operations
|
||||
-- Execute the filter.
|
||||
local
|
||||
l_auth: HTTP_AUTHORIZATION
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
api.logger.put_debug (generator + ".execute ", Void)
|
||||
create l_auth.make (req.http_authorization)
|
||||
if attached req.raw_header_data as l_raw_data then
|
||||
api.logger.put_debug (generator + ".execute " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_raw_data), Void)
|
||||
debug
|
||||
if attached req.raw_header_data as l_raw_data then
|
||||
api.logger.put_debug (generator + ".execute " + (create {UTF_CONVERTER}).escaped_utf_32_string_to_utf_8_string_8 (l_raw_data), Void)
|
||||
end
|
||||
end
|
||||
-- A valid user
|
||||
if
|
||||
|
||||
@@ -63,7 +63,7 @@ feature -- HTTP Methods
|
||||
create s_pager.make_empty
|
||||
create l_page_helper.make ("nodes/?page={page}&size={size}", node_api.nodes_count, 25) -- FIXME: Make this default page size a global CMS settings
|
||||
l_page_helper.get_setting_from_request (req)
|
||||
if l_page_helper.pages_count > 1 then
|
||||
if l_page_helper.has_upper_limit and then l_page_helper.pages_count > 1 then
|
||||
l_page_helper.append_to_html (l_response, s_pager)
|
||||
if l_page_helper.page_size > 25 then
|
||||
s.append (s_pager)
|
||||
|
||||
@@ -47,9 +47,8 @@ feature -- HTTP Methods
|
||||
-- get them from the configuration file and load them into
|
||||
-- the setup class.
|
||||
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
|
||||
if attached current_user (req) as l_user then
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
|
||||
l_page.add_variable (node_api.trashed_nodes (l_user), "nodes")
|
||||
|
||||
@@ -72,6 +71,9 @@ feature -- HTTP Methods
|
||||
l_page.set_main_content (s)
|
||||
-- l_page.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet fully implemented<br/>", Void), "highlighted")
|
||||
l_page.execute
|
||||
else
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.execute
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -39,6 +39,13 @@ feature -- Status report
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
close
|
||||
-- Close/disconnect current storage.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Error Handling
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
|
||||
@@ -45,6 +45,13 @@ feature -- Status report
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
close
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- URL aliases
|
||||
|
||||
set_path_alias (a_source: READABLE_STRING_8; a_alias: READABLE_STRING_8)
|
||||
|
||||
286
src/service/cms_execution.e
Normal file
286
src/service/cms_execution.e
Normal file
@@ -0,0 +1,286 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the CMS service
|
||||
|
||||
It could be used to implement the main EWF service, or
|
||||
even for a specific handler.
|
||||
]"
|
||||
|
||||
deferred class
|
||||
CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_FILTERED_ROUTED_SKELETON_EXECUTION
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
create_router, router,
|
||||
execute_default,
|
||||
filter_execute,
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
--create
|
||||
-- make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Build a CMS service with `a_api'
|
||||
local
|
||||
l_setup: CMS_SETUP
|
||||
do
|
||||
l_setup := initial_cms_setup
|
||||
setup_storage (l_setup)
|
||||
setup_modules (l_setup)
|
||||
create api.make (l_setup)
|
||||
modules := setup.enabled_modules
|
||||
|
||||
initialize_cms
|
||||
Precursor
|
||||
end
|
||||
|
||||
initialize_cms
|
||||
do
|
||||
write_debug_log (generator + ".initialize_cms")
|
||||
|
||||
-- CMS Initialization
|
||||
|
||||
-- initialize_router
|
||||
-- initialize_filter: expanded here, for void-safety concern.
|
||||
create_filter
|
||||
initialize_router
|
||||
setup_filter
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize modules and keep only enabled modules.
|
||||
do
|
||||
modules := setup.enabled_modules
|
||||
ensure
|
||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
initial_cms_setup: CMS_SETUP
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS Setup.
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Settings: router
|
||||
|
||||
router: CMS_ROUTER
|
||||
-- <Precursor>
|
||||
|
||||
create_router
|
||||
-- Create `router'.
|
||||
do
|
||||
create router.make (api, 30)
|
||||
end
|
||||
|
||||
setup_router
|
||||
-- <Precursor>
|
||||
local
|
||||
l_api: like api
|
||||
l_router: like router
|
||||
do
|
||||
api.logger.put_debug (generator + ".setup_router", Void)
|
||||
-- Configure root of api handler.
|
||||
|
||||
l_router := router
|
||||
configure_api_root (l_router)
|
||||
|
||||
-- Include routes from modules.
|
||||
l_api := api
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
ic.item.setup_router (l_router, l_api)
|
||||
end
|
||||
-- Configure files handler.
|
||||
configure_api_file_handler (l_router)
|
||||
end
|
||||
|
||||
configure_api_root (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_root_handler: CMS_ROOT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
api.logger.put_debug (generator + ".configure_api_root", Void)
|
||||
create l_root_handler.make (api)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
a_router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("", l_root_handler, l_methods)
|
||||
map_uri_agent_with_request_methods ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||
end
|
||||
|
||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
do
|
||||
api.logger.put_information (generator + ".configure_api_file_handler", Void)
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.theme_assets_location)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/theme/", fhdl, router.methods_GET)
|
||||
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.environment.www_path)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
end
|
||||
|
||||
feature -- Execute Filter
|
||||
|
||||
filter_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
do
|
||||
res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string)
|
||||
res.put_header_line ("X-EWF-Server: CMS_v1.0")
|
||||
Precursor (req, res)
|
||||
end
|
||||
|
||||
feature -- Filters
|
||||
|
||||
create_filter
|
||||
-- Create `filter'.
|
||||
local
|
||||
f, l_filter: detachable WSF_FILTER
|
||||
l_module: CMS_MODULE
|
||||
l_api: like api
|
||||
do
|
||||
api.logger.put_debug (generator + ".create_filter", Void)
|
||||
l_filter := Void
|
||||
|
||||
-- Maintenance
|
||||
create {WSF_MAINTENANCE_FILTER} f
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- -- Error Filter
|
||||
-- create {CMS_ERROR_FILTER} f.make (api)
|
||||
-- f.set_next (l_filter)
|
||||
-- l_filter := f
|
||||
|
||||
-- Include filters from modules
|
||||
l_api := api
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if
|
||||
l_module.is_enabled and then
|
||||
attached l_module.filters (l_api) as l_m_filters
|
||||
then
|
||||
across l_m_filters as f_ic loop
|
||||
f := f_ic.item
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
filter := l_filter
|
||||
end
|
||||
|
||||
setup_filter
|
||||
-- Setup `filter'.
|
||||
local
|
||||
f: WSF_FILTER
|
||||
do
|
||||
api.logger.put_debug (generator + ".setup_filter", Void)
|
||||
|
||||
from
|
||||
f := filter
|
||||
until
|
||||
not attached f.next as l_next
|
||||
loop
|
||||
f := l_next
|
||||
end
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
handle_favicon (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
ut: FILE_UTILITIES
|
||||
p: PATH
|
||||
r: NOT_FOUND_ERROR_CMS_RESPONSE
|
||||
f: WSF_FILE_RESPONSE
|
||||
do
|
||||
p := api.setup.theme_assets_location.extended ("favicon.ico")
|
||||
if ut.file_path_exists (p) then
|
||||
create f.make_with_path (p)
|
||||
res.send (f)
|
||||
else
|
||||
create r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
end
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default request handler if no other are relevant
|
||||
local
|
||||
r: NOT_FOUND_ERROR_CMS_RESPONSE
|
||||
do
|
||||
to_implement ("Default response for CMS_SERVICE")
|
||||
create r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -22,7 +22,9 @@ feature -- Basic operations
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check if it's ok to add new features CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
end
|
||||
if not api.has_error then
|
||||
api.logger.put_information (generator + ".execute with req: " + req.debug_output, Void)
|
||||
if attached req.raw_header_data as l_header_data then
|
||||
|
||||
71
tools/install.bat
Normal file
71
tools/install.bat
Normal file
@@ -0,0 +1,71 @@
|
||||
@echo off
|
||||
setlocal
|
||||
set TMP_EXCLUDE=%~dp0.install_ROC-copydir-exclude
|
||||
set COPYCMD= xcopy /EXCLUDE:%TMP_EXCLUDE% /I /E /Y
|
||||
set TMP_DIR=%~dp0..
|
||||
set SAFE_RMDIR=rd /q/s
|
||||
|
||||
echo EIFGENs > %TMP_EXCLUDE%
|
||||
echo .git >> %TMP_EXCLUDE%
|
||||
echo .svn >> %TMP_EXCLUDE%
|
||||
|
||||
set TMP_TARGET_DIR=%1
|
||||
if -%TMP_TARGET_DIR%- == -- goto ask_target_dir
|
||||
goto start
|
||||
|
||||
:ask_target_dir
|
||||
echo Please provide a installation directory (target library)
|
||||
if -%ISE_LIBRARY%- == -- set ISE_LIBRARY=%EIFFEL_LIBRARY%
|
||||
if -%ISE_LIBRARY%- == -- set ISE_LIBRARY=%ISE_EIFFEL%
|
||||
if -%EIFFEL_LIBRARY%- == -- set EIFFEL_LIBRARY=%ISE_LIBRARY%
|
||||
echo 1: using $EIFFEL_LIBRARY=%EIFFEL_LIBRARY%
|
||||
echo 2: using $ISE_LIBRARY=%ISE_LIBRARY%
|
||||
echo 3: using current directory=%CD%\ewf
|
||||
CHOICE /C 123q /M " > selection:"
|
||||
if .%ERRORLEVEL%. == .1. goto use_eiffel_library
|
||||
if .%ERRORLEVEL%. == .2. goto use_ise_library
|
||||
if .%ERRORLEVEL%. == .3. goto use_current_dir
|
||||
echo No target directory were specified, you can pass it using the command line
|
||||
echo Usage: install_ewf {target_directory}
|
||||
echo Bye ...
|
||||
goto end
|
||||
|
||||
:use_eiffel_library
|
||||
if -%EIFFEL_LIBRARY%- == -- goto use_ise_library
|
||||
set TMP_TARGET_DIR=%EIFFEL_LIBRARY%
|
||||
goto start
|
||||
|
||||
:use_ise_library
|
||||
if -%ISE_LIBRARY%- == -- goto use_current_dir
|
||||
set TMP_TARGET_DIR=%ISE_LIBRARY%
|
||||
goto start
|
||||
|
||||
:use_current_dir
|
||||
set TMP_TARGET_DIR=%CD%\ewf
|
||||
goto start
|
||||
|
||||
:start
|
||||
set TMP_CONTRIB_DIR=%TMP_TARGET_DIR%\contrib
|
||||
set TMP_UNSTABLE_DIR=%TMP_TARGET_DIR%\unstable
|
||||
|
||||
echo Install ROC as CMS ewf
|
||||
%SAFE_RMDIR% %TMP_UNSTABLE_DIR%\library\cms\library
|
||||
%SAFE_RMDIR% %TMP_UNSTABLE_DIR%\library\cms\src
|
||||
%SAFE_RMDIR% %TMP_UNSTABLE_DIR%\library\cms\doc
|
||||
%SAFE_RMDIR% %TMP_UNSTABLE_DIR%\library\cms\modules
|
||||
%SAFE_RMDIR% %TMP_UNSTABLE_DIR%\library\cms\examples
|
||||
|
||||
%COPYCMD% %TMP_DIR%\library %TMP_UNSTABLE_DIR%\library\web\cms\library
|
||||
%COPYCMD% %TMP_DIR%\src %TMP_UNSTABLE_DIR%\library\web\cms\src
|
||||
%COPYCMD% %TMP_DIR%\doc %TMP_UNSTABLE_DIR%\library\web\cms\doc
|
||||
%COPYCMD% %TMP_DIR%\modules %TMP_UNSTABLE_DIR%\library\web\cms\modules
|
||||
%COPYCMD% %TMP_DIR%\examples %TMP_UNSTABLE_DIR%\library\web\cms\examples
|
||||
|
||||
copy %TMP_DIR%\cms.ecf %TMP_UNSTABLE_DIR%\cms.ecf
|
||||
copy %TMP_DIR%\cms-safe.ecf %TMP_UNSTABLE_DIR%\cms-safe.ecf
|
||||
copy %TMP_DIR%\README.md %TMP_UNSTABLE_DIR%\README.md
|
||||
copy %TMP_DIR%\package.iron %TMP_UNSTABLE_DIR%\package.iron
|
||||
|
||||
:end
|
||||
del %TMP_EXCLUDE%
|
||||
|
||||
Reference in New Issue
Block a user