Got rid of CMS_GENERIC_RESPONSE, and replace with CMS_RESPONSE_MESSAGE descendants.
Update node module to use new uri mapping, and cleaned dev purpose code.
This commit is contained in:
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,7 +102,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,7 +118,7 @@ feature -- HTTP Methods
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.value.to_integer_64)
|
||||
node_api.update_node_content (l_user.id, u_node.id, u_node.content)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
redirect_to (req.absolute_script_url (""), res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
@@ -126,7 +126,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
feature -- Error
|
||||
|
||||
@@ -111,10 +111,10 @@ feature -- HTTP Methods
|
||||
update_node_from_data_form (req, u_node)
|
||||
u_node.set_author (l_user)
|
||||
node_api.new_node (u_node)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
redirect_to (req.absolute_script_url (""), res)
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -131,7 +131,7 @@ feature -- HTTP Methods
|
||||
update_node_from_data_form (req, l_node)
|
||||
l_node.set_author (l_user)
|
||||
node_api.update_node (l_node)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
redirect_to (req.absolute_script_url (""), res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
@@ -139,7 +139,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -153,7 +153,7 @@ feature -- HTTP Methods
|
||||
attached node_api.node (l_id.integer_value) as l_node
|
||||
then
|
||||
node_api.delete_node (l_node)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (req.absolute_script_url ("")))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
@@ -161,7 +161,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -196,7 +196,7 @@ feature {NONE} -- Node
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.execute
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,7 +102,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ feature -- HTTP Methods
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.value.to_integer_64)
|
||||
node_api.update_node_summary (l_user.id,u_node.id, u_node.summary)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
redirect_to (req.absolute_script_url (""), res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ feature -- HTTP Methods
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.value.to_integer_64)
|
||||
node_api.update_node_title (l_user.id, u_node.id, u_node.title)
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
redirect_to (req.absolute_script_url (""), res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
send_access_denied (res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {NODES_HANDLER}."
|
||||
description: "Request handler related to /nodes."
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
@@ -38,12 +38,40 @@ feature -- HTTP Methods
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
s: STRING
|
||||
l_user: CMS_USER
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
-- At the moment the template is hardcoded, but we can
|
||||
-- get them from the configuration file and load them into
|
||||
-- the setup class.
|
||||
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.add_variable (node_api.nodes, "nodes")
|
||||
|
||||
|
||||
-- NOTE: for development purposes we have the following hardcode output.
|
||||
create s.make_from_string ("<p>Nodes:</p>")
|
||||
if attached node_api.nodes as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
s.append ("<a href=%"")
|
||||
s.append (req.script_url ("/node/" + ic.item.id.out))
|
||||
s.append ("%">")
|
||||
s.append (api.html_encoded (ic.item.title))
|
||||
s.append (" (")
|
||||
s.append (ic.item.id.out)
|
||||
s.append (")")
|
||||
s.append ("</a>")
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ feature {NONE} -- Implementation: routes
|
||||
l_methods.enable_put
|
||||
l_methods.enable_delete
|
||||
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, a_api, a_node_api)), a_router.methods_get)
|
||||
-- a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, a_api, a_node_api)), a_router.methods_get)
|
||||
end
|
||||
|
||||
configure_api_nodes (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||
@@ -97,7 +97,7 @@ feature {NONE} -- Implementation: routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
a_router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/field/summary", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_node_title (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||
@@ -110,7 +110,7 @@ feature {NONE} -- Implementation: routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/field/title", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_node_content (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||
@@ -123,7 +123,7 @@ feature {NONE} -- Implementation: routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/field/content", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
@@ -156,50 +156,4 @@ feature -- Hooks
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
feature -- Handler
|
||||
|
||||
do_get_nodes (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API; a_node_api: CMS_NODE_API)
|
||||
local
|
||||
r: CMS_RESPONSE
|
||||
s: STRING
|
||||
l_user: CMS_USER
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
|
||||
|
||||
if attached a_api.user_api.user_by_name ("foo") as u then
|
||||
l_user := u
|
||||
else
|
||||
create l_user.make ("foo")
|
||||
l_user.set_password ("foobar#")
|
||||
l_user.set_email ("test@example.com")
|
||||
a_api.user_api.new_user (l_user)
|
||||
end
|
||||
if a_node_api.nodes_count = 0 then
|
||||
if l_user /= Void then
|
||||
create l_node.make ({STRING_32} "This is a content", {STRING_32} "And a summary", {STRING_32} "Nice title")
|
||||
l_node.set_author (l_user)
|
||||
a_node_api.new_node (l_node)
|
||||
end
|
||||
end
|
||||
|
||||
create s.make_from_string ("<p>Nodes:</p>")
|
||||
if attached a_node_api.nodes as lst then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
s.append ("<li>")
|
||||
s.append (a_api.html_encoded (ic.item.title))
|
||||
s.append (" (")
|
||||
s.append (ic.item.id.out)
|
||||
s.append (")")
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
end
|
||||
|
||||
r.set_main_content (s)
|
||||
r.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet fully implemented<br/>", Void), "highlighted")
|
||||
r.execute
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_GENERIC_RESPONSE}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_GENERIC_RESPONSE
|
||||
|
||||
feature -- Responses
|
||||
|
||||
new_response_redirect (req: WSF_REQUEST; res: WSF_RESPONSE; a_location: READABLE_STRING_32)
|
||||
-- Redirect to `a_location'
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
h.put_location (a_location)
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.see_other)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_authenticate (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle authenticate.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
h.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, "Basic realm=%"CMSRoc-User%"")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_denied (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle access denied.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_unauthorized (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle not authorized.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_RESPONSE_MESSAGE}."
|
||||
author: ""
|
||||
description: "Response message interface specific to the CMS component."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user