You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2008/06/09 06:00:48 UTC
svn commit: r664617 - /webservices/axis2/trunk/c/src/core/util/core_utils.c
Author: nandika
Date: Sun Jun 8 21:00:48 2008
New Revision: 664617
URL: http://svn.apache.org/viewvc?rev=664617&view=rev
Log:
axis2_core_utils_get_rest_op_with_method_and_location function added
Modified:
webservices/axis2/trunk/c/src/core/util/core_utils.c
Modified: webservices/axis2/trunk/c/src/core/util/core_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/util/core_utils.c?rev=664617&r1=664616&r2=664617&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/util/core_utils.c (original)
+++ webservices/axis2/trunk/c/src/core/util/core_utils.c Sun Jun 8 21:00:48 2008
@@ -423,3 +423,115 @@
return AXIS2_FAILURE;
}
+
+axis2_op_t *AXIS2_CALL
+axis2_core_utils_get_rest_op_with_method_and_location(
+ const axis2_svc_t * svc,
+ const axutil_env_t * env,
+ const axis2_char_t * method,
+ const axis2_char_t * location,
+ int * param_count,
+ axis2_char_t **** params)
+ {
+ axutil_array_list_t *op_list = NULL;
+ axis2_char_t *loc_str = NULL;
+ axis2_char_t *loc_str_tmp = NULL;
+ axis2_char_t *rindex = NULL;
+ axis2_bool_t pass_one = AXIS2_TRUE;
+ axis2_bool_t loop_state = AXIS2_TRUE;
+ AXIS2_PARAM_CHECK(env->error, location, NULL);
+ AXIS2_PARAM_CHECK(env->error, method, NULL);
+
+ loc_str = axutil_strtrim(env, location, NULL);
+ if (!loc_str)
+ {
+ return NULL;
+ }
+ loc_str_tmp = loc_str;
+ if (loc_str_tmp[0] == '/')
+ {
+ loc_str_tmp++;
+ }
+ if (strchr(loc_str_tmp, '?'))
+ {
+ axis2_char_t *temp = NULL;
+
+ temp = strchr(loc_str_tmp, '?');
+ temp[0] = '\0';
+ }
+ while(loop_state)
+ {
+ rindex = axutil_rindex(loc_str_tmp, '/');
+
+ if (rindex && *rindex)
+ {
+ loc_str_tmp = axutil_string_substring_ending_at(loc_str_tmp, (int)(rindex - loc_str_tmp));
+ /* We are sure that the difference lies within the int range */
+ }
+ else if (pass_one)
+ {
+ pass_one = AXIS2_FALSE;
+ }
+ else
+ {
+ int i = 0;
+ i = (int)strlen(loc_str_tmp);
+ /* We are sure that the difference lies within the int range */
+ if (i == 0)
+ {
+ break;
+ }
+ loc_str_tmp[i - 1] = '\0';
+ }
+
+ if (!loc_str_tmp || !*loc_str_tmp)
+ {
+ break;
+ }
+ op_list = axis2_svc_get_rest_op_list_with_method_and_location(svc, env,
+ method, loc_str_tmp);
+ if (op_list && axutil_array_list_size(op_list, env) != 0)
+ {
+ int i = 0;
+ int size = 0;
+
+ size = axutil_array_list_size(op_list, env);
+ for (i = 0; i < size; i++)
+ {
+ axis2_op_t *op_temp = NULL;
+ axis2_char_t *op_location = NULL;
+ int match_count = 0;
+ axis2_char_t ***matches = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ op_temp = axutil_array_list_get(op_list, env, i);
+ op_location = axis2_op_get_rest_http_location(op_temp, env);
+ if (!op_location)
+ {
+ continue;
+ }
+ status = axutil_parse_rest_url_for_params(env, op_location, location,
+ &match_count, &matches);
+ if (status == AXIS2_SUCCESS)
+ {
+ *params = matches;
+ *param_count = match_count;
+ AXIS2_FREE (env->allocator, loc_str);
+ return op_temp;
+ }
+ else if (matches)
+ {
+ for (i = 0; i < match_count; i++)
+ {
+ AXIS2_FREE (env->allocator, matches[i]);
+ }
+ AXIS2_FREE (env->allocator, matches);
+ }
+ }
+ }
+ }
+ AXIS2_FREE (env->allocator, loc_str);
+ return NULL;
+ }
+
+