[
https://issues.apache.org/jira/browse/DISPATCH-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15022244#comment-15022244
]
ASF GitHub Bot commented on DISPATCH-179:
-----------------------------------------
Github user ted-ross commented on a diff in the pull request:
https://github.com/apache/qpid-dispatch/pull/36#discussion_r45614279
--- Diff: src/router_core/management_agent.c ---
@@ -268,6 +269,62 @@ static void qd_core_agent_read_handler(qd_dispatch_t
*qd,
}
+/**
+ * Returns true if all the keys contained in the body map are applicable
to a waypoints, false otherwise
+ * @see qdr_waypoint_columns
+ */
+static bool qd_is_valid_waypoint_keys(qd_parsed_field_t *in_body)
+{
+ if(in_body != 0 && qd_parse_is_map(in_body)) {
+ //
+ // A map containing attributes with invalid values for an entity
MUST result in a failure response with a statusCode of 400 (Bad Request).
+ //
+ int j=0;
+ qd_parsed_field_t *field = qd_parse_sub_key(in_body, j);
+ while (field) {
+ bool found = false;
+ for(int i = 1; i < QDR_WAYPOINT_COLUMN_COUNT; i++) {
+ if (qd_field_iterator_equal(qd_parse_raw(field), (unsigned
char*)qdr_waypoint_columns[i])) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) // Some bad field was specified in the body map.
Reject this request
+ return false;
+ j++;
+ field = qd_parse_sub_key(in_body, j);
+ }
+ }
+ else
+ // The body is either empty or the body is not a map, return false
+ return false;
+
+ return true;
+}
+
+
+/**
+ * The body map containing any attributes that are not applicable for the
entity being updated MUST result in a failure response with a statusCode of 400
(Bad Request).
+ */
+static bool qd_check_body(qd_router_entity_type_t entity_type,
+ qd_parsed_field_t *in_body,
+ qd_composed_field_t *out_body,
+ qd_management_context_t *ctx)
+{
+ if (entity_type == QD_ROUTER_WAYPOINT) {
+ if(!qd_is_valid_waypoint_keys(in_body)){
--- End diff --
Rather than have a proliferation of nearly identical type-specific
validation functions, why not do a more general check on the appropriate
attribute-name array? This way, you can write the logic once for all types.
> Refactor Router Core
> --------------------
>
> Key: DISPATCH-179
> URL: https://issues.apache.org/jira/browse/DISPATCH-179
> Project: Qpid Dispatch
> Issue Type: Improvement
> Components: Router Node
> Reporter: Ted Ross
> Assignee: Ted Ross
> Fix For: 0.6
>
>
> Refactor the core router function to clean up the architecture and to fix the
> significant lock contention issue that exists in 0.5.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]