Initial CMS API commmit.

This commit is contained in:
jvelilla
2014-10-01 12:17:39 -03:00
parent 588827b495
commit 27a11f2eea
170 changed files with 12459 additions and 14 deletions

View File

@@ -0,0 +1,19 @@
note
description: "Summary description for {ESA_APPLICATION_CONSTANTS}."
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
class
APPLICATION_CONSTANTS
feature -- Access
major: INTEGER = 0
minor: INTEGER = 1
built: STRING = "0001"
version: STRING
do
Result := major.out + "." + minor.out + "." + built
end
end

View File

@@ -0,0 +1,70 @@
note
description: "API configuration factory"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
class
CONFIGURATION_FACTORY
inherit
SHARED_EXECUTION_ENVIRONMENT
SHARED_ERROR
feature -- Factory
roc_config (a_dir: detachable STRING): ROC_CONFIG
local
l_layout: APPLICATION_LAYOUT
l_email_service: ROC_EMAIL_SERVICE
l_database: DATABASE_CONNECTION
l_api_service: ROC_API_SERVICE
l_retried: BOOLEAN
do
if not l_retried then
if attached a_dir then
create l_layout.make_with_path (create {PATH}.make_from_string (a_dir))
else
create l_layout.make_default
end
log.write_information (generator + ".roc_config " + l_layout.path.name.out)
create l_email_service.make ((create {JSON_CONFIGURATION}).new_smtp_configuration(l_layout.application_config_path))
if attached (create {JSON_CONFIGURATION}).new_database_configuration (l_layout.application_config_path) as l_database_config then
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
create l_api_service.make (create {CMS_STORAGE_MYSQL}.make (l_database))
create Result.make (l_database, l_api_service, l_email_service, l_layout)
if (create {ROC_JSON_CONFIGURATION}).is_web_mode(l_layout.application_config_path) then
Result.mark_web
elseif (create {ROC_JSON_CONFIGURATION}).is_html_mode(l_layout.application_config_path) then
Result.mark_html
end
set_successful
else
create {DATABASE_CONNECTION_NULL} l_database.make_common
create l_api_service.make (create {CMS_STORAGE_NULL})
create Result.make (l_database, l_api_service, l_email_service, l_layout)
set_last_error ("Database Connections", generator + ".roc_config")
log.write_error (generator + ".roc_config Error database connection" )
end
else
if attached a_dir then
create l_layout.make_with_path (create {PATH}.make_from_string (a_dir))
else
create l_layout.make_default
end
create l_email_service.make ((create {JSON_CONFIGURATION}).new_smtp_configuration(l_layout.application_config_path))
create {DATABASE_CONNECTION_NULL} l_database.make_common
create l_api_service.make (create {CMS_STORAGE_NULL})
create Result.make (l_database, l_api_service, l_email_service, l_layout)
end
rescue
set_last_error_from_exception ("Database Connection execution")
log.write_critical (generator + ".roc_config Database Connection execution exceptions")
l_retried := True
retry
end
end

View File

@@ -0,0 +1,48 @@
note
description: "Summary description for {ROC_JSON_CONFIGURATION}."
date: "$Date$"
revision: "$Revision$"
class
ROC_JSON_CONFIGURATION
inherit
JSON_CONFIGURATION
feature -- Access
is_html_mode (a_path: PATH): BOOLEAN
-- Is the server running on web mode?
local
l_parser: JSON_PARSER
do
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
attached {JSON_OBJECT} jv.item ("server") as l_server and then
attached {JSON_STRING} l_server.item ("mode") as l_mode then
Result := l_mode.item.is_case_insensitive_equal_general ("html")
end
end
end
is_web_mode (a_path: PATH): BOOLEAN
-- Is the server running on web mode?
local
l_parser: JSON_PARSER
do
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
attached {JSON_OBJECT} jv.item ("server") as l_server and then
attached {JSON_STRING} l_server.item ("mode") as l_mode then
Result := l_mode.item.is_case_insensitive_equal_general ("web")
end
end
end
end