diff options
author | gmcdonald | 2010-02-13 01:32:03 +0000 |
---|---|---|
committer | gmcdonald | 2010-02-13 01:32:03 +0000 |
commit | 0425aadc78680e53000fd0108b540d6eca048516 (patch) | |
tree | 8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /src/core/description | |
download | axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2 |
Moving axis svn, part of TLP move INFRA-2441
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/core/description')
-rw-r--r-- | src/core/description/Makefile.am | 24 | ||||
-rw-r--r-- | src/core/description/desc.c | 261 | ||||
-rw-r--r-- | src/core/description/flow.c | 130 | ||||
-rw-r--r-- | src/core/description/flow_container.c | 173 | ||||
-rw-r--r-- | src/core/description/handler_desc.c | 333 | ||||
-rw-r--r-- | src/core/description/module_desc.c | 470 | ||||
-rw-r--r-- | src/core/description/msg.c | 407 | ||||
-rw-r--r-- | src/core/description/op.c | 1383 | ||||
-rw-r--r-- | src/core/description/phase_rule.c | 254 | ||||
-rw-r--r-- | src/core/description/policy_include.c | 612 | ||||
-rw-r--r-- | src/core/description/svc.c | 1543 | ||||
-rw-r--r-- | src/core/description/svc_grp.c | 600 | ||||
-rw-r--r-- | src/core/description/transport_in_desc.c | 305 | ||||
-rw-r--r-- | src/core/description/transport_out_desc.c | 299 |
14 files changed, 6794 insertions, 0 deletions
diff --git a/src/core/description/Makefile.am b/src/core/description/Makefile.am new file mode 100644 index 0000000..5c3618c --- /dev/null +++ b/src/core/description/Makefile.am @@ -0,0 +1,24 @@ +noinst_LTLIBRARIES = libaxis2_description.la + +libaxis2_description_la_SOURCES =desc.c \ + op.c \ + policy_include.c \ + svc.c \ + module_desc.c \ + svc_grp.c \ + phase_rule.c \ + handler_desc.c \ + flow.c \ + flow_container.c \ + transport_in_desc.c \ + transport_out_desc.c \ + msg.c + +libaxis2_description_la_LDFLAGS = -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/core/engine \ + -I$(top_builddir)/util/include \ + -I$(top_builddir)/axiom/include \ + -I$(top_builddir)/neethi/include + diff --git a/src/core/description/desc.c b/src/core/description/desc.c new file mode 100644 index 0000000..bd5a80a --- /dev/null +++ b/src/core/description/desc.c @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_desc.h> +#include <axutil_property.h> +#include <axis2_policy_include.h> +#include <axis2_msg.h> + +struct axis2_desc +{ + + /** parameter container */ + axutil_param_container_t *param_container; + + /** children of this description */ + axutil_hash_t *children; + + axis2_desc_t *parent; + + axis2_policy_include_t *policy_include; +}; + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_desc_create( + const axutil_env_t * env) +{ + axis2_desc_t *desc = NULL; + + desc = (axis2_desc_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_desc_t)); + + if(!desc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + desc->param_container = NULL; + desc->children = NULL; + desc->parent = NULL; + desc->policy_include = NULL; + + desc->param_container = (axutil_param_container_t *)axutil_param_container_create(env); + if(!(desc->param_container)) + { + axis2_desc_free(desc, env); + return NULL; + } + + desc->children = axutil_hash_make(env); + if(!(desc->children)) + { + axis2_desc_free(desc, env); + return NULL; + } + + desc->policy_include = axis2_policy_include_create_with_desc(env, desc); + + return desc; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_desc_free( + axis2_desc_t * desc, + const axutil_env_t * env) +{ + if(desc->children) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + + for(hi = axutil_hash_first(desc->children, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axis2_msg_free((axis2_msg_t *)val, env); + } + } + + axutil_hash_free(desc->children, env); + } + + if(desc->param_container) + { + axutil_param_container_free(desc->param_container, env); + } + + if(desc->policy_include) + { + axis2_policy_include_free(desc->policy_include, env); + } + + if(desc) + { + AXIS2_FREE(env->allocator, desc); + } + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_desc_add_param( + axis2_desc_t * desc, + const axutil_env_t * env, + axutil_param_t * param) +{ + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FALSE); + + return axutil_param_container_add_param(desc->param_container, env, param); +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_desc_get_param( + const axis2_desc_t * desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + AXIS2_PARAM_CHECK(env->error, param_name, NULL); + return axutil_param_container_get_param(desc->param_container, env, param_name); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_desc_get_all_params( + const axis2_desc_t * desc, + const axutil_env_t * env) +{ + AXIS2_PARAM_CHECK(env->error, desc->param_container, AXIS2_FALSE); + + return axutil_param_container_get_params(desc->param_container, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_desc_is_param_locked( + const axis2_desc_t * desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axutil_param_t *param_l = NULL; + + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE); + + param_l = axis2_desc_get_param(desc, env, param_name); + + return (param_l && axutil_param_is_locked(param_l, env)); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_desc_add_child( + const axis2_desc_t * desc, + const axutil_env_t * env, + const axis2_char_t * key, + const axis2_msg_t *child) +{ + if(desc->children) + { + axis2_msg_t* msg = (axis2_msg_t *)axutil_hash_get(desc->children, key, + AXIS2_HASH_KEY_STRING); + if(msg != NULL) + { + axis2_msg_free(msg, env); + msg = NULL; + } + axutil_hash_set(desc->children, key, AXIS2_HASH_KEY_STRING, (void *)child); + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_desc_get_all_children( + const axis2_desc_t * desc, + const axutil_env_t * env) +{ + return desc->children; +} + +AXIS2_EXTERN void *AXIS2_CALL +axis2_desc_get_child( + const axis2_desc_t * desc, + const axutil_env_t * env, + const axis2_char_t * key) +{ + return axutil_hash_get(desc->children, key, AXIS2_HASH_KEY_STRING); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_desc_remove_child( + const axis2_desc_t * desc, + const axutil_env_t * env, + const axis2_char_t * key) +{ + if(desc->children) + { + axutil_hash_set(desc->children, key, AXIS2_HASH_KEY_STRING, NULL); + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_desc_get_parent( + const axis2_desc_t * desc, + const axutil_env_t * env) +{ + return desc->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_desc_set_parent( + axis2_desc_t * desc, + const axutil_env_t * env, + axis2_desc_t * parent) +{ + desc->parent = parent; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_desc_set_policy_include( + axis2_desc_t * desc, + const axutil_env_t * env, + axis2_policy_include_t * policy_include) +{ + if(desc->policy_include) + { + axis2_policy_include_free(desc->policy_include, env); + desc->policy_include = NULL; + } + + desc->policy_include = policy_include; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_policy_include_t *AXIS2_CALL +axis2_desc_get_policy_include( + axis2_desc_t * desc, + const axutil_env_t * env) +{ + if(!desc->policy_include) + { + /*desc->policy_include = axis2_policy_include_create(env); */ + desc->policy_include = axis2_policy_include_create_with_desc(env, desc); + } + return desc->policy_include; +} + diff --git a/src/core/description/flow.c b/src/core/description/flow.c new file mode 100644 index 0000000..554d666 --- /dev/null +++ b/src/core/description/flow.c @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_flow.h> + +struct axis2_flow +{ + axutil_array_list_t *list; +}; + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_flow_create( + const axutil_env_t * env) +{ + axis2_flow_t *flow = NULL; + + flow = (axis2_flow_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_flow_t)); + + if(!flow) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + flow->list = NULL; + + flow->list = axutil_array_list_create(env, 20); + if(!(flow->list)) + { + axis2_flow_free(flow, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + return flow; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_flow_free( + axis2_flow_t * flow, + const axutil_env_t * env) +{ + if(flow->list) + { + int i = 0; + int size = 0; + + size = axutil_array_list_size(flow->list, env); + for(i = 0; i < size; i++) + { + axis2_handler_desc_t *handler_desc = NULL; + + handler_desc = (axis2_handler_desc_t *)axutil_array_list_get(flow->list, env, i); + axis2_handler_desc_free(handler_desc, env); + } + axutil_array_list_free(flow->list, env); + } + + if(flow) + { + AXIS2_FREE(env->allocator, flow); + } + + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_flow_free_void_arg( + void *flow, + const axutil_env_t * env) +{ + axis2_flow_t *flow_l = NULL; + + flow_l = (axis2_flow_t *)flow; + axis2_flow_free(flow_l, env); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_flow_add_handler( + axis2_flow_t * flow, + const axutil_env_t * env, + axis2_handler_desc_t * handler) +{ + AXIS2_PARAM_CHECK(env->error, handler, AXIS2_FAILURE); + + if(!flow->list) + { + flow->list = axutil_array_list_create(env, 0); + if(!flow->list) + { + axis2_flow_free(flow, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + return axutil_array_list_add(flow->list, env, handler); +} + +AXIS2_EXTERN axis2_handler_desc_t *AXIS2_CALL +axis2_flow_get_handler( + const axis2_flow_t * flow, + const axutil_env_t * env, + const int index) +{ + return axutil_array_list_get(flow->list, env, index); +} + +AXIS2_EXTERN int AXIS2_CALL +axis2_flow_get_handler_count( + const axis2_flow_t * flow, + const axutil_env_t * env) +{ + return axutil_array_list_size(flow->list, env); +} + diff --git a/src/core/description/flow_container.c b/src/core/description/flow_container.c new file mode 100644 index 0000000..e39be01 --- /dev/null +++ b/src/core/description/flow_container.c @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_flow.h> +#include <axis2_flow_container.h> + +struct axis2_flow_container +{ + axis2_flow_t *in; + axis2_flow_t *out; + axis2_flow_t *in_fault; + axis2_flow_t *out_fault; +}; + +AXIS2_EXTERN axis2_flow_container_t *AXIS2_CALL +axis2_flow_container_create( + const axutil_env_t * env) +{ + axis2_flow_container_t *flow_container = NULL; + + flow_container = (axis2_flow_container_t *)AXIS2_MALLOC(env-> allocator, + sizeof(axis2_flow_container_t)); + + if(!flow_container) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + flow_container->in = NULL; + flow_container->out = NULL; + flow_container->in_fault = NULL; + flow_container->out_fault = NULL; + + return flow_container; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_flow_container_free( + axis2_flow_container_t * flow_container, + const axutil_env_t * env) +{ + if(flow_container->in) + { + axis2_flow_free(flow_container->in, env); + } + + if(flow_container->out) + { + axis2_flow_free(flow_container->out, env); + } + + if(flow_container->in_fault) + { + axis2_flow_free(flow_container->in_fault, env); + } + + if(flow_container->out_fault) + { + axis2_flow_free(flow_container->out_fault, env); + } + + if(flow_container) + { + AXIS2_FREE(env->allocator, flow_container); + } + + return; +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_flow_container_get_in_flow( + const axis2_flow_container_t * flow_container, + const axutil_env_t * env) +{ + return flow_container->in; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_flow_container_set_in_flow( + axis2_flow_container_t * flow_container, + const axutil_env_t * env, + axis2_flow_t * in_flow) +{ + if(flow_container->in) + { + axis2_flow_free(flow_container->in, env); + } + flow_container->in = in_flow; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_flow_container_get_out_flow( + const axis2_flow_container_t * flow_container, + const axutil_env_t * env) +{ + return flow_container->out; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_flow_container_set_out_flow( + axis2_flow_container_t * flow_container, + const axutil_env_t * env, + axis2_flow_t * out_flow) +{ + if(flow_container->out) + { + axis2_flow_free(flow_container->out, env); + } + flow_container->out = out_flow; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_flow_container_get_fault_in_flow( + const axis2_flow_container_t * flow_container, + const axutil_env_t * env) +{ + return flow_container->in_fault; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_flow_container_set_fault_in_flow( + axis2_flow_container_t * flow_container, + const axutil_env_t * env, + axis2_flow_t * falut_in_flow) +{ + if(flow_container->in_fault) + { + axis2_flow_free(flow_container->in_fault, env); + } + flow_container->in_fault = falut_in_flow; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_flow_container_get_fault_out_flow( + const axis2_flow_container_t * flow_container, + const axutil_env_t * env) +{ + return flow_container->out_fault; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_flow_container_set_fault_out_flow( + axis2_flow_container_t * flow_container, + const axutil_env_t * env, + axis2_flow_t * fault_out_flow) +{ + AXIS2_PARAM_CHECK(env->error, fault_out_flow, AXIS2_FAILURE); + if(flow_container->out_fault) + { + axis2_flow_free(flow_container->out_fault, env); + } + flow_container->out_fault = fault_out_flow; + return AXIS2_SUCCESS; +} + diff --git a/src/core/description/handler_desc.c b/src/core/description/handler_desc.c new file mode 100644 index 0000000..c3281f5 --- /dev/null +++ b/src/core/description/handler_desc.c @@ -0,0 +1,333 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_handler_desc.h> +#include <axutil_param_container.h> +#include <axutil_string.h> +#include <axis2_handler.h> + +struct axis2_handler_desc +{ + + /** name */ + axutil_string_t *name; + + /** phase rules */ + axis2_phase_rule_t *rules; + + /** handler represented by meta information*/ + axis2_handler_t *handler; + + /** class name */ + axis2_char_t *class_name; + + /** parent param container */ + axutil_param_container_t *parent; + + /** parameter container */ + axutil_param_container_t *param_container; +}; + +AXIS2_EXTERN axis2_handler_desc_t *AXIS2_CALL +axis2_handler_desc_create( + const axutil_env_t * env, + axutil_string_t * name) +{ + axis2_handler_desc_t *handler_desc = NULL; + + handler_desc = AXIS2_MALLOC(env->allocator, sizeof(axis2_handler_desc_t)); + if(!handler_desc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return NULL; + } + + handler_desc->param_container = NULL; + handler_desc->name = NULL; + handler_desc->rules = NULL; + handler_desc->handler = NULL; + handler_desc->class_name = NULL; + handler_desc->parent = NULL; + + handler_desc->param_container = axutil_param_container_create(env); + if(!handler_desc->param_container) + { + + /** error code is already set by last param container create */ + axis2_handler_desc_free(handler_desc, env); + return NULL; + } + + handler_desc->rules = axis2_phase_rule_create(env, NULL); + if(!handler_desc->rules) + { + + /** error code is already set by last param container create */ + axis2_handler_desc_free(handler_desc, env); + return NULL; + } + + if(name) + { + handler_desc->name = axutil_string_clone(name, env); + } + + return handler_desc; +} + +AXIS2_EXTERN const axutil_string_t *AXIS2_CALL +axis2_handler_desc_get_name( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_set_name( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + axutil_string_t * name) +{ + if(handler_desc->name) + { + axutil_string_free(handler_desc->name, env); + handler_desc->name = NULL; + } + + if(name) + { + handler_desc->name = axutil_string_clone(name, env); + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_phase_rule_t *AXIS2_CALL +axis2_handler_desc_get_rules( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->rules; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_set_rules( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + axis2_phase_rule_t * phase_rule) +{ + const axutil_string_t *str_name = axis2_handler_desc_get_name(handler_desc, env); + const axis2_char_t *name = axutil_string_get_buffer(str_name, env); + if(handler_desc->rules) + { + axis2_phase_rule_free(handler_desc->rules, env); + } + + if(phase_rule) + { + handler_desc->rules = axis2_phase_rule_clone(phase_rule, env); + if(!(handler_desc->rules)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Phase rule cloning failed for handler description %s", name); + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_handler_desc_get_param( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + const axis2_char_t * name) +{ + return axutil_param_container_get_param(handler_desc->param_container, env, name); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_add_param( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + axutil_param_t * param) +{ + const axutil_string_t *str_name = axis2_handler_desc_get_name(handler_desc, env); + const axis2_char_t *name = axutil_string_get_buffer(str_name, env); + axis2_char_t *param_name = axutil_param_get_name(param, env); + if(axutil_param_container_is_param_locked(handler_desc->parent, env, param_name)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked for handler %s", + param_name, name); + return AXIS2_FAILURE; + } + + return axutil_param_container_add_param(handler_desc->param_container, env, param); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_handler_desc_get_all_params( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return axutil_param_container_get_params(handler_desc->param_container, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_handler_desc_is_param_locked( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + /* See if it is locked in parent */ + if(axutil_param_container_is_param_locked(handler_desc->parent, env, param_name)) + { + return AXIS2_TRUE; + } + + return axutil_param_container_is_param_locked(handler_desc->param_container, env, param_name); +} + +AXIS2_EXTERN axis2_handler_t *AXIS2_CALL +axis2_handler_desc_get_handler( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->handler; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_set_handler( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + axis2_handler_t * handler) +{ + /* Handler description is the place where the handler really lives. + Hence this is a deep copy and should be freed by the free function. */ + + if(handler_desc->handler && (handler_desc->handler != handler)) + { + axis2_handler_free(handler_desc->handler, env); + } + + if(handler) + handler_desc->handler = handler; /* Shallow copy, but free method + should free this */ + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_handler_desc_get_class_name( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->class_name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_set_class_name( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + const axis2_char_t * class_name) +{ + if(handler_desc->class_name) + { + AXIS2_FREE(env->allocator, handler_desc->class_name); + } + + if(class_name) + { + handler_desc->class_name = axutil_strdup(env, class_name); + if(!handler_desc->class_name) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_handler_desc_get_parent( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_handler_desc_set_parent( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env, + axutil_param_container_t * parent) +{ + handler_desc->parent = parent; /* Shallow copy, because + the parent lives somewhere else */ + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_handler_desc_free( + axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + if(handler_desc->param_container) + { + axutil_param_container_free(handler_desc->param_container, env); + } + + if(handler_desc->name) + { + axutil_string_free(handler_desc->name, env); + } + + if(handler_desc->rules) + { + axis2_phase_rule_free(handler_desc->rules, env); + } + + if(handler_desc->handler) + { + axis2_handler_free(handler_desc->handler, env); + } + + if(handler_desc->class_name) + { + AXIS2_FREE(env->allocator, handler_desc->class_name); + } + if(handler_desc) + { + AXIS2_FREE(env->allocator, handler_desc); + } + + return; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_handler_desc_get_param_container( + const axis2_handler_desc_t * handler_desc, + const axutil_env_t * env) +{ + return handler_desc->param_container; +} + diff --git a/src/core/description/module_desc.c b/src/core/description/module_desc.c new file mode 100644 index 0000000..a5b27c7 --- /dev/null +++ b/src/core/description/module_desc.c @@ -0,0 +1,470 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_module_desc.h> +#include <axis2_module.h> + +struct axis2_module_desc +{ + axis2_module_t *module; + axutil_qname_t *qname; + axis2_conf_t *parent; + + /** + * To store module operations , which are supposed to be added to a service + * the module is engaged to a service + */ + axutil_hash_t *ops; + + /** + * flow container that encapsulates the flows associated with the + * module + */ + axis2_flow_container_t *flow_container; + + /** + * parameter container that stores all the parameters associated with + * the module + */ + axutil_param_container_t *params; +}; + +AXIS2_EXTERN axis2_module_desc_t *AXIS2_CALL +axis2_module_desc_create( + const axutil_env_t * env) +{ + axis2_module_desc_t *module_desc = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + module_desc = (axis2_module_desc_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_module_desc_t)); + + if(!module_desc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + module_desc->qname = NULL; + module_desc->module = NULL; + module_desc->parent = NULL; + module_desc->params = NULL; + module_desc->flow_container = NULL; + module_desc->ops = NULL; + + module_desc->params = axutil_param_container_create(env); + if(!module_desc->params) + { + axis2_module_desc_free(module_desc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + module_desc->flow_container = axis2_flow_container_create(env); + if(!module_desc->flow_container) + { + axis2_module_desc_free(module_desc, env); +AXIS2_ERROR_SET (env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE) + return NULL; +} + +module_desc->ops = axutil_hash_make(env); +if (!module_desc->ops) +{ + axis2_module_desc_free(module_desc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; +} + +return module_desc; +} + +AXIS2_EXTERN axis2_module_desc_t *AXIS2_CALL +axis2_module_desc_create_with_qname( + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + axis2_module_desc_t *module_desc = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + module_desc = axis2_module_desc_create(env); + if(!module_desc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + module_desc->qname = (axutil_qname_t *)qname; + + return module_desc; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_module_desc_free( + axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(module_desc->module) + { + axis2_module_shutdown(module_desc->module, env); + } + + if(module_desc->params) + { + axutil_param_container_free(module_desc->params, env); + } + + if(module_desc->flow_container) + { + axis2_flow_container_free(module_desc->flow_container, env); + } + + module_desc->parent = NULL; + + if(module_desc->qname) + { + axutil_qname_free(module_desc->qname, env); + } + + if(module_desc->ops) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + for(hi = axutil_hash_first(module_desc->ops, env); hi; hi = axutil_hash_next(env, hi)) + { + struct axis2_op *op = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + op = (struct axis2_op *)val; + if(op) + axis2_op_free(op, env); + val = NULL; + op = NULL; + + } + axutil_hash_free(module_desc->ops, env); + } + + if(module_desc) + { + AXIS2_FREE(env->allocator, module_desc); + } + + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_module_desc_free_void_arg( + void *module_desc, + const axutil_env_t * env) +{ + axis2_module_desc_t *module_desc_l = NULL; + + AXIS2_ENV_CHECK(env, void); + module_desc_l = (axis2_module_desc_t *)module_desc; + axis2_module_desc_free(module_desc_l, env); + return; +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_module_desc_get_in_flow( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return axis2_flow_container_get_in_flow(module_desc->flow_container, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_in_flow( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_flow_t * in_flow) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, in_flow, AXIS2_FAILURE); + + return axis2_flow_container_set_in_flow(module_desc->flow_container, env, in_flow); +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_module_desc_get_out_flow( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return axis2_flow_container_get_out_flow(module_desc->flow_container, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_out_flow( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_flow_t * out_flow) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, out_flow, AXIS2_FAILURE); + + return axis2_flow_container_set_out_flow(module_desc->flow_container, env, out_flow); +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_module_desc_get_fault_in_flow( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return axis2_flow_container_get_fault_in_flow(module_desc->flow_container, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_fault_in_flow( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_flow_t * falut_in_flow) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, falut_in_flow, AXIS2_FAILURE); + + return axis2_flow_container_set_fault_in_flow(module_desc->flow_container, env, falut_in_flow); +} + +AXIS2_EXTERN axis2_flow_t *AXIS2_CALL +axis2_module_desc_get_fault_out_flow( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return axis2_flow_container_get_fault_out_flow(module_desc->flow_container, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_fault_out_flow( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_flow_t * fault_out_flow) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, fault_out_flow, AXIS2_FAILURE); + + return axis2_flow_container_set_fault_out_flow(module_desc->flow_container, env, fault_out_flow); +} + +AXIS2_EXTERN const axutil_qname_t *AXIS2_CALL +axis2_module_desc_get_qname( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->qname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_qname( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, qname, AXIS2_FAILURE); + + if(module_desc->qname) + { + axutil_qname_free(module_desc->qname, env); + } + + module_desc->qname = axutil_qname_clone((axutil_qname_t *)qname, env); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_add_op( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_op_t * op) +{ + const axutil_qname_t *op_qname = NULL; + axis2_char_t *op_name = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op, AXIS2_FAILURE); + + if(!(module_desc->ops)) + { + module_desc->ops = axutil_hash_make(env); + if(!module_desc->ops) + return AXIS2_FAILURE; + } + + op_qname = axis2_op_get_qname(op, env); + + if(!op_qname) + { + return AXIS2_FAILURE; + } + op_name = axutil_qname_to_string((axutil_qname_t *)op_qname, env); + axutil_hash_set(module_desc->ops, op_name, AXIS2_HASH_KEY_STRING, op); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_module_desc_get_all_ops( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->ops; +} + +AXIS2_EXTERN axis2_conf_t *AXIS2_CALL +axis2_module_desc_get_parent( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_parent( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_conf_t * parent) +{ + AXIS2_PARAM_CHECK(env->error, parent, AXIS2_FAILURE); + + module_desc->parent = parent; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_add_param( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axutil_param_t * param) +{ + axis2_char_t *param_name_l = NULL; + axis2_status_t ret_status = AXIS2_FAILURE; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + param_name_l = axutil_param_get_name(param, env); + if(!param_name_l) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PARAM, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(AXIS2_TRUE == axis2_module_desc_is_param_locked(module_desc, env, param_name_l)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + ret_status = axutil_param_container_add_param(module_desc->params, env, param); + } + return ret_status; +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_module_desc_get_param( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env, + const axis2_char_t * name) +{ + AXIS2_PARAM_CHECK(env->error, name, NULL); + + return axutil_param_container_get_param(module_desc->params, env, name); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_module_desc_get_all_params( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return axutil_param_container_get_params(module_desc->params, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_module_desc_is_param_locked( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axis2_bool_t locked = AXIS2_FALSE; + axis2_bool_t ret_state = AXIS2_FALSE; + axutil_param_t *param_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FAILURE); + + /* checking the locked value of parent */ + if(!module_desc->parent) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_MODULE_DESC, AXIS2_FAILURE); + return AXIS2_FALSE; + } + locked = axis2_conf_is_param_locked(module_desc->parent, env, param_name); + + if(AXIS2_TRUE == locked) + { + ret_state = AXIS2_TRUE; + } + else + { + param_l = axis2_module_desc_get_param(module_desc, env, param_name); + if(param_l && AXIS2_TRUE == axutil_param_is_locked(param_l, env)) + ret_state = AXIS2_TRUE; + else + ret_state = AXIS2_FALSE; + + } + return ret_state; +} + +AXIS2_EXTERN axis2_module_t *AXIS2_CALL +axis2_module_desc_get_module( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->module; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_module_desc_set_module( + axis2_module_desc_t * module_desc, + const axutil_env_t * env, + axis2_module_t * module) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, module, AXIS2_FAILURE); + module_desc->module = module; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_module_desc_get_param_container( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->params; +} + +AXIS2_EXTERN axis2_flow_container_t *AXIS2_CALL +axis2_module_desc_get_flow_container( + const axis2_module_desc_t * module_desc, + const axutil_env_t * env) +{ + return module_desc->flow_container; +} diff --git a/src/core/description/msg.c b/src/core/description/msg.c new file mode 100644 index 0000000..241253a --- /dev/null +++ b/src/core/description/msg.c @@ -0,0 +1,407 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_msg.h> +#include <axutil_property.h> + +struct axis2_msg +{ + + /** parent operation */ + axis2_op_t *parent; + + /** list of phases that represent the flow */ + axutil_array_list_t *flow; + + /** name of the message */ + axis2_char_t *name; + + /** XML schema element qname */ + axutil_qname_t *element_qname; + + /** direction of message */ + axis2_char_t *direction; + + /** parameter container to hold message parameters */ + struct axutil_param_container *param_container; + + /** base description struct */ + axis2_desc_t *base; + + /** reference count of this object*/ + int ref; + +}; + +AXIS2_EXTERN axis2_msg_t *AXIS2_CALL +axis2_msg_create( + const axutil_env_t * env) +{ + axis2_msg_t *msg = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + msg = (axis2_msg_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_msg_t)); + + if(!msg) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + msg->param_container = NULL; + msg->parent = NULL; + msg->flow = NULL; + msg->name = NULL; + msg->element_qname = NULL; + msg->direction = NULL; + msg->base = NULL; + msg->ref = 1; + + msg->param_container = (axutil_param_container_t *)axutil_param_container_create(env); + if(!msg->param_container) + { + axis2_msg_free(msg, env); + return NULL; + } + + msg->flow = axutil_array_list_create(env, 0); + if(!msg->flow) + { + axis2_msg_free(msg, env); + return NULL; + } + + msg->base = axis2_desc_create(env); + if(!msg->base) + { + axis2_msg_free(msg, env); + return NULL; + } + + return msg; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_msg_free( + axis2_msg_t * msg, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(--(msg->ref) > 0) + { + return; + } + + if(msg->flow) + { + int i = 0, size = 0; + size = axutil_array_list_size(msg->flow, env); + for(i = 0; i < size; i++) + { + axis2_phase_t *phase = NULL; + phase = axutil_array_list_get(msg->flow, env, i); + if(phase) + axis2_phase_free(phase, env); + } + axutil_array_list_free(msg->flow, env); + } + + if(msg->name) + { + AXIS2_FREE(env->allocator, msg->name); + } + + if(msg->element_qname) + { + axutil_qname_free(msg->element_qname, env); + } + + if(msg->direction) + { + AXIS2_FREE(env->allocator, msg->direction); + } + + if(msg->param_container) + { + axutil_param_container_free(msg->param_container, env); + } + + if(msg->base) + { + axis2_desc_free(msg->base, env); + } + + msg->parent = NULL; + + if(msg) + { + AXIS2_FREE(env->allocator, msg); + } + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_add_param( + axis2_msg_t * msg, + const axutil_env_t * env, + axutil_param_t * param) +{ + axis2_char_t *param_name = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FALSE); + + param_name = axutil_param_get_name(param, env); + if(AXIS2_TRUE == axis2_msg_is_param_locked(msg, env, param_name)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return axutil_param_container_add_param(msg->param_container, env, param); +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_msg_get_param( + const axis2_msg_t * msg, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + AXIS2_PARAM_CHECK(env->error, param_name, NULL); + + return axutil_param_container_get_param(msg->param_container, env, param_name); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_msg_get_all_params( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + AXIS2_PARAM_CHECK(env->error, msg->param_container, AXIS2_FALSE); + + return axutil_param_container_get_params(msg->param_container, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_set_parent( + axis2_msg_t * msg, + const axutil_env_t * env, + axis2_op_t * op) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + msg->parent = op; + if(op) + { + axis2_desc_set_parent(msg->base, env, axis2_op_get_base(op, env)); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_msg_get_parent( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->parent; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_msg_get_flow( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->flow; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_msg_is_param_locked( + axis2_msg_t * msg, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axis2_op_t *parent_l = NULL; + axutil_param_t *param_l = NULL; + axis2_bool_t locked = AXIS2_FALSE; + + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE); + + /* checking the locked status in parent */ + parent_l = axis2_msg_get_parent(msg, env); + if(parent_l) + { + locked = axis2_op_is_param_locked(parent_l, env, param_name); + } + if(AXIS2_TRUE == locked) + { + return AXIS2_TRUE; + } + else + { + param_l = axis2_msg_get_param(msg, env, param_name); + } + return (param_l && axutil_param_is_locked(param_l, env)); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_set_flow( + axis2_msg_t * msg, + const axutil_env_t * env, + axutil_array_list_t * flow) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(msg->flow) + { + axutil_array_list_free(msg->flow, env); + msg->flow = NULL; + } + if(flow) + { + msg->flow = flow; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_msg_get_direction( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->direction; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_set_direction( + axis2_msg_t * msg, + const axutil_env_t * env, + const axis2_char_t * direction) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(msg->direction) + { + AXIS2_FREE(env->allocator, msg->direction); + msg->direction = NULL; + } + + if(direction) + { + msg->direction = axutil_strdup(env, direction); + if(!(msg->direction)) + { + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axutil_qname_t *AXIS2_CALL +axis2_msg_get_element_qname( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->element_qname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_set_element_qname( + axis2_msg_t * msg, + const axutil_env_t * env, + const axutil_qname_t * element_qname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(msg->element_qname) + { + axutil_qname_free(msg->element_qname, env); + msg->element_qname = NULL; + } + + if(element_qname) + { + msg->element_qname = axutil_qname_clone((axutil_qname_t *)element_qname, env); + if(!(msg->element_qname)) + { + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_msg_get_name( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_set_name( + axis2_msg_t * msg, + const axutil_env_t * env, + const axis2_char_t * name) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(msg->name) + { + AXIS2_FREE(env->allocator, msg->name); + msg->name = NULL; + } + + if(name) + { + msg->name = axutil_strdup(env, name); + if(!(msg->name)) + { + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_msg_get_base( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->base; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_msg_get_param_container( + const axis2_msg_t * msg, + const axutil_env_t * env) +{ + return msg->param_container; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_msg_increment_ref( + axis2_msg_t * msg, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + msg->ref++; + return AXIS2_SUCCESS; +} diff --git a/src/core/description/op.c b/src/core/description/op.c new file mode 100644 index 0000000..0cf926c --- /dev/null +++ b/src/core/description/op.c @@ -0,0 +1,1383 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_op.h> +#include <axutil_property.h> +#include <axis2_msg.h> +#include <axis2_desc.h> +#include <axis2_conf_ctx.h> +#include <axis2_module.h> + +struct axis2_op +{ + axis2_svc_t *parent; + axis2_desc_t *base; + axis2_msg_recv_t *msg_recv; + + int mep; + /* To store deploy time modules */ + axutil_array_list_t *module_qnames; + axutil_array_list_t *engaged_module_list; + axutil_array_list_t *wsamapping_list; + axis2_bool_t from_module; + axutil_qname_t *qname; + axis2_char_t *msg_exchange_pattern; + axis2_char_t *style; + + /* For REST support */ + axis2_char_t *rest_http_method; + axis2_char_t *rest_http_location; + + /** Parameter container to hold operation related parameters */ + struct axutil_param_container *param_container; +}; + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_op_create( + const axutil_env_t * env) +{ + axis2_op_t *op = NULL; + axis2_msg_t *msg = NULL; + + op = (axis2_op_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_op_t)); + + if(!op) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, ""); + return NULL; + } + + op->parent = NULL; + op->base = NULL; + op->msg_recv = NULL; + op->mep = AXIS2_MEP_CONSTANT_INVALID; + op->param_container = NULL; + op->module_qnames = axutil_array_list_create(env, 0); + op->engaged_module_list = NULL; + op->from_module = AXIS2_FALSE; + op->wsamapping_list = NULL; + op->qname = NULL; + op->msg_exchange_pattern = NULL; + op->style = NULL; + op->rest_http_method = NULL; + op->rest_http_location = NULL; + op->style = axutil_strdup(env, AXIS2_STYLE_DOC); + + op->param_container = (axutil_param_container_t *)axutil_param_container_create(env); + if(!op->param_container) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Param container creation failed"); + return NULL; + } + + op->base = axis2_desc_create(env); + if(!op->base) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation base creation failed"); + return NULL; + } + + /* Create and set up children messages */ + msg = axis2_msg_create(env); + if(!msg) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Child message creation failed"); + return NULL; + } + axis2_msg_set_direction(msg, env, AXIS2_WSDL_MESSAGE_DIRECTION_IN); + axis2_msg_set_parent(msg, env, op); + axis2_op_add_msg(op, env, AXIS2_MSG_IN, msg); + + msg = axis2_msg_create(env); + if(!msg) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Child message creation failed"); + return NULL; + } + axis2_msg_set_direction(msg, env, AXIS2_WSDL_MESSAGE_DIRECTION_OUT); + axis2_msg_set_parent(msg, env, op); + axis2_op_add_msg(op, env, AXIS2_MSG_OUT, msg); + + msg = axis2_msg_create(env); + if(!msg) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Child message creation failed"); + return NULL; + } + axis2_msg_set_parent(msg, env, op); + axis2_msg_set_flow(msg, env, NULL); + axis2_op_add_msg(op, env, AXIS2_MSG_IN_FAULT, msg); + + msg = axis2_msg_create(env); + if(!msg) + { + axis2_op_free(op, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Child message creation failed"); + return NULL; + } + axis2_msg_set_parent(msg, env, op); + axis2_msg_set_flow(msg, env, NULL); + axis2_op_add_msg(op, env, AXIS2_MSG_OUT_FAULT, msg); + + axis2_op_set_msg_exchange_pattern(op, env, (axis2_char_t *)AXIS2_MEP_URI_IN_OUT); + + return op; +} + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_op_create_from_module( + const axutil_env_t * env) +{ + axis2_op_t *op = NULL; + + op = (axis2_op_t *)axis2_op_create(env); + op->from_module = AXIS2_TRUE; + return op; +} + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_op_create_with_qname( + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + axis2_op_t *op = NULL; + axis2_status_t status = AXIS2_FAILURE; + + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + op = (axis2_op_t *)axis2_op_create(env); + + if(!op) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation creation failed for %s", + axutil_qname_get_localpart(qname, env)); + return NULL; + } + + status = axis2_op_set_qname(op, env, qname); + if(AXIS2_SUCCESS != status) + { + axis2_op_free(op, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting name failed for operation %s", + axutil_qname_get_localpart(qname, env)); + return NULL; + } + + return op; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_op_free( + axis2_op_t * op, + const axutil_env_t * env) +{ + if(op->base) + { + axis2_desc_free(op->base, env); + } + if(op->param_container) + { + axutil_param_container_free(op->param_container, env); + } + + op->parent = NULL; + + if(op->msg_recv) + { + axis2_msg_recv_free(op->msg_recv, env); + } + if(op->module_qnames) + { + int i = 0; + for(i = 0; i < axutil_array_list_size(op->module_qnames, env); i++) + { + axutil_qname_t *module_ref = NULL; + module_ref = axutil_array_list_get(op->module_qnames, env, i); + + if(module_ref) + { + axutil_qname_free(module_ref, env); + } + } + axutil_array_list_free(op->module_qnames, env); + } + if(op->engaged_module_list) + { + axutil_array_list_free(op->engaged_module_list, env); + } + if(op->wsamapping_list) + { + int i = 0; + int size = 0; + size = axutil_array_list_size(op->wsamapping_list, env); + for(i = 0; i < size; i++) + { + axis2_char_t *temp_str = axutil_array_list_get(op->wsamapping_list, env, i); + if(temp_str) + AXIS2_FREE(env->allocator, temp_str); + } + axutil_array_list_free(op->wsamapping_list, env); + } + + if(op->qname) + { + axutil_qname_free(op->qname, env); + } + + if(op->msg_exchange_pattern) + { + AXIS2_FREE(env->allocator, op->msg_exchange_pattern); + } + + if(op->style) + { + AXIS2_FREE(env->allocator, op->style); + } + + if(op->rest_http_method) + { + AXIS2_FREE(env->allocator, op->rest_http_method); + } + + if(op->rest_http_location) + { + AXIS2_FREE(env->allocator, op->rest_http_location); + } + + if(op) + { + AXIS2_FREE(env->allocator, op); + } + + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_op_free_void_arg( + void *op, + const axutil_env_t * env) +{ + axis2_op_t *op_l = NULL; + + op_l = (axis2_op_t *)op; + axis2_op_free(op_l, env); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_param( + axis2_op_t * op, + const axutil_env_t * env, + axutil_param_t * param) +{ + axis2_char_t *param_name = NULL; + axis2_status_t status = AXIS2_FAILURE; + + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FALSE); + + param_name = axutil_param_get_name(param, env); + if(AXIS2_TRUE == axis2_op_is_param_locked(op, env, param_name)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked, cannot override", + param_name); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + status = axutil_param_container_add_param(op->param_container, env, param); + } + + return status; +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_op_get_param( + const axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axutil_param_t *param = NULL; + + AXIS2_PARAM_CHECK(env->error, param_name, NULL); + + param = axutil_param_container_get_param(op->param_container, env, param_name); + if(!param && op->parent) + { + param = axis2_svc_get_param(op->parent, env, param_name); + } + return param; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_remove_param + (axis2_op_t *op, + const axutil_env_t *env, + const axis2_char_t *param_name) +{ + axis2_status_t status = AXIS2_FAILURE; + status = axutil_param_container_delete_param(op->param_container, env, param_name); + return status; + + +} + + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_all_params( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return axutil_param_container_get_params(op->param_container, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_op_is_param_locked( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axis2_svc_t *parent = NULL; + axutil_param_t *param = NULL; + axis2_bool_t locked = AXIS2_FALSE; + + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE); + + /* Checking the locked value of parent */ + parent = axis2_op_get_parent(op, env); + if(parent) + { + locked = axis2_svc_is_param_locked(parent, env, param_name); + } + if(locked) + { + return AXIS2_TRUE; + } + param = axis2_op_get_param(op, env, param_name); + return (param && AXIS2_TRUE == axutil_param_is_locked(param, env)); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_rest_http_method( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * rest_http_method) +{ + AXIS2_PARAM_CHECK(env->error, rest_http_method, AXIS2_FAILURE); + + if(op->rest_http_method) + { + AXIS2_FREE(env->allocator, op->rest_http_method); + } + op->rest_http_method = NULL; + if(rest_http_method) + { + op->rest_http_method = axutil_strdup(env, rest_http_method); + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axis2_op_get_rest_http_method( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(!op) + { + return NULL; + } + if(op->rest_http_method) + { + return op->rest_http_method; + } + else + { + axutil_param_t *param = NULL; + + param = axis2_op_get_param(op, env, AXIS2_DEFAULT_REST_HTTP_METHOD); + + if(!param) + { + return "POST"; /* Added hard-coded string to avoid inclusion of HTTP + * Transport header + */ + } + return (axis2_char_t *)axutil_param_get_value(param, env); + } +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_rest_http_location( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * rest_http_location) +{ + axis2_char_t *opname = NULL; + AXIS2_PARAM_CHECK(env->error, rest_http_location, AXIS2_FAILURE); + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + if(op->rest_http_location) + { + AXIS2_FREE(env->allocator, op->rest_http_location); + } + op->rest_http_location = NULL; + if(rest_http_location) + { + op->rest_http_location = axutil_strdup(env, rest_http_location); + return AXIS2_SUCCESS; + } + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting rest http location failed for operation %s", + opname); + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axis2_op_get_rest_http_location( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(!op) + { + return NULL; + } + return op->rest_http_location; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_parent( + axis2_op_t * op, + const axutil_env_t * env, + axis2_svc_t * svc) +{ + AXIS2_PARAM_CHECK(env->error, svc, AXIS2_FAILURE); + + if(op->parent) + { + op->parent = NULL; + } + op->parent = svc; + if(svc) + { + axis2_desc_set_parent(op->base, env, axis2_svc_get_base(svc, env)); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_svc_t *AXIS2_CALL +axis2_op_get_parent( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_msg_recv( + axis2_op_t * op, + const axutil_env_t * env, + struct axis2_msg_recv * msg_recv) +{ + AXIS2_PARAM_CHECK(env->error, msg_recv, AXIS2_FAILURE); + + if(op->msg_recv == msg_recv) + { + return AXIS2_SUCCESS; + } + if(op->msg_recv) + { + axis2_msg_recv_free(op->msg_recv, env); + op->msg_recv = NULL; + } + + op->msg_recv = msg_recv; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN struct axis2_msg_recv *AXIS2_CALL +axis2_op_get_msg_recv( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->msg_recv; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_qname( + axis2_op_t * op, + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + if(op->qname) + { + axutil_qname_free(op->qname, env); + op->qname = NULL; + } + + if(qname) + { + op->qname = axutil_qname_clone((axutil_qname_t *)qname, env); + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axutil_qname_t *AXIS2_CALL +axis2_op_get_qname( + void *op, + const axutil_env_t * env) +{ + return ((axis2_op_t *)op)->qname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_msg_exchange_pattern( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * pattern) +{ + AXIS2_PARAM_CHECK(env->error, pattern, AXIS2_FAILURE); + + if(op->msg_exchange_pattern) + { + AXIS2_FREE(env->allocator, op->msg_exchange_pattern); + op->msg_exchange_pattern = NULL; + } + + op->msg_exchange_pattern = axutil_strdup(env, pattern); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_op_get_msg_exchange_pattern( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->msg_exchange_pattern; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_op_get_style( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->style; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_style( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * style) +{ + AXIS2_PARAM_CHECK(env->error, style, AXIS2_FAILURE); + + if(op->style) + { + AXIS2_FREE(env->allocator, op->style); + op->style = NULL; + } + + op->style = axutil_strdup(env, style); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_engage_module( + axis2_op_t * op, + const axutil_env_t * env, + axis2_module_desc_t * moduleref, + axis2_conf_t * conf) +{ + int index = 0; + int size = 0; + axutil_array_list_t *collection_module = NULL; + axis2_module_desc_t *module_desc = NULL; + axis2_phase_resolver_t *pr = NULL; + axis2_bool_t need_to_add = AXIS2_FALSE; + axis2_char_t *opname = NULL; + axis2_char_t *modname = NULL; + + AXIS2_PARAM_CHECK(env->error, moduleref, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE); + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + collection_module = op->engaged_module_list; + if(collection_module) + { + size = axutil_array_list_size(collection_module, env); + } + for(index = 0; index < size; index++) + { + const axutil_qname_t *qname1 = NULL; + const axutil_qname_t *qname2 = NULL; + + module_desc = (axis2_module_desc_t *)axutil_array_list_get(collection_module, env, index); + if(!module_desc) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Retrieving a module failed from operation %s engaged module" + " list", opname); + return AXIS2_FAILURE; + } + qname1 = axis2_module_desc_get_qname(module_desc, env); + qname2 = axis2_module_desc_get_qname(moduleref, env); + modname = axutil_qname_get_localpart(qname2, env); + if(axutil_qname_equals(qname1, env, qname2)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Module %s already engaged to operation %s", + modname, opname); + + need_to_add = AXIS2_FALSE; + return AXIS2_FAILURE; + } + + } + pr = axis2_phase_resolver_create_with_config(env, conf); + if(pr) + { + axis2_module_t *module = NULL; + axis2_status_t status = AXIS2_FAILURE; + + status = axis2_phase_resolver_engage_module_to_op(pr, env, op, moduleref); + if(AXIS2_SUCCESS != status) + { + /* Ignore the status */ + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_SUCCESS); + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, + "Engaging module %s to operaion %s failed. But ignore this.", modname, opname); + } + module = axis2_module_desc_get_module(moduleref, env); + + if(need_to_add) + { + axutil_array_list_add(collection_module, env, moduleref); + } + } + else + { + return AXIS2_FAILURE; + } + axis2_phase_resolver_free(pr, env); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_to_engaged_module_list( + axis2_op_t * op, + const axutil_env_t * env, + axis2_module_desc_t * module_desc) +{ + axis2_module_desc_t *module_desc_l = NULL; + int size = 0; + int index = 0; + const axutil_qname_t *module_qname = NULL; + + AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); + + if(!op->engaged_module_list) + { + op->engaged_module_list = axutil_array_list_create(env, 0); + } + size = axutil_array_list_size(op->engaged_module_list, env); + + module_qname = axis2_module_desc_get_qname(module_desc, env); + for(index = 0; index < size; index++) + { + const axutil_qname_t *module_qname_l = NULL; + + module_desc_l = (axis2_module_desc_t *)axutil_array_list_get(op-> engaged_module_list, env, + index); + module_qname_l = axis2_module_desc_get_qname(module_desc_l, env); + + if(axutil_qname_equals(module_qname, env, module_qname_l)) + { + return AXIS2_SUCCESS; + } + + } + + return axutil_array_list_add(op->engaged_module_list, env, module_desc); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_remove_from_engaged_module_list( + axis2_op_t * op, + const axutil_env_t * env, + axis2_module_desc_t * module_desc) +{ + axis2_module_desc_t *module_desc_l = NULL; + int size = 0; + int index = 0; + const axutil_qname_t *module_qname = NULL; + + AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op->engaged_module_list, AXIS2_FAILURE); + + size = axutil_array_list_size(op->engaged_module_list, env); + + module_qname = axis2_module_desc_get_qname(module_desc, env); + for(index = 0; index < size; index++) + { + const axutil_qname_t *module_qname_l = NULL; + + module_desc_l = (axis2_module_desc_t *)axutil_array_list_get(op-> engaged_module_list, env, + index); + module_qname_l = axis2_module_desc_get_qname(module_desc_l, env); + + if(axutil_qname_equals(module_qname, env, module_qname_l)) + { + axutil_array_list_remove(op->engaged_module_list, env, index); + return AXIS2_SUCCESS; + } + + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_all_modules( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->engaged_module_list; +} + +AXIS2_EXTERN int AXIS2_CALL +axis2_op_get_axis_specific_mep_const( + axis2_op_t * op, + const axutil_env_t * env) +{ + int temp = 0; + axis2_char_t *opname = NULL; + + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + if(op->mep != AXIS2_MEP_CONSTANT_INVALID) + { + return op->mep; + } + + temp = AXIS2_MEP_CONSTANT_INVALID; + + if((axutil_strcmp(AXIS2_MEP_URI_IN_OUT, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_IN_OUT_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_IN_OUT; + } + else if((axutil_strcmp(AXIS2_MEP_URI_IN_ONLY, axis2_op_get_msg_exchange_pattern(op, env)) == 0) + || (axutil_strcmp(AXIS2_MEP_URI_IN_ONLY_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_IN_ONLY; + } + else if((axutil_strcmp(AXIS2_MEP_URI_IN_OPTIONAL_OUT, axis2_op_get_msg_exchange_pattern(op, env))== 0) || + (axutil_strcmp(AXIS2_MEP_URI_IN_OPTIONAL_OUT_WSDL2, axis2_op_get_msg_exchange_pattern(op, env))== 0)) + { + temp = AXIS2_MEP_CONSTANT_IN_OPTIONAL_OUT; + } + else if((axutil_strcmp(AXIS2_MEP_URI_OUT_IN, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_OUT_IN_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_OUT_IN; + } + else if((axutil_strcmp(AXIS2_MEP_URI_OUT_ONLY, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_OUT_ONLY_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_OUT_ONLY; + } + else if((axutil_strcmp(AXIS2_MEP_URI_OUT_OPTIONAL_IN, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_OUT_OPTIONAL_IN_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_OUT_OPTIONAL_IN; + } + else if((axutil_strcmp(AXIS2_MEP_URI_ROBUST_IN_ONLY, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_ROBUST_IN_ONLY; + } + else if((axutil_strcmp(AXIS2_MEP_URI_ROBUST_OUT_ONLY, axis2_op_get_msg_exchange_pattern(op, env)) == 0) || + (axutil_strcmp(AXIS2_MEP_URI_ROBUST_OUT_ONLY_WSDL2, axis2_op_get_msg_exchange_pattern(op, env)) == 0)) + { + temp = AXIS2_MEP_CONSTANT_ROBUST_OUT_ONLY; + } + if(temp == AXIS2_MEP_CONSTANT_INVALID) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Could not map the MEP URI %s to an Axis2/C MEP constant value " + "in retrieving MEP for operation %s", axis2_op_get_msg_exchange_pattern(op, env), + opname); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_COULD_NOT_MAP_MEP_URI_TO_MEP_CONSTANT, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + op->mep = temp; + return op->mep; + +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_fault_in_flow( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_IN_FAULT); + if(msg) + { + return axis2_msg_get_flow(msg, env); + } + } + return NULL; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_fault_out_flow( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_OUT_FAULT); + if(msg) + { + return axis2_msg_get_flow(msg, env); + } + } + return NULL; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_out_flow( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_OUT); + if(msg) + { + return axis2_msg_get_flow(msg, env); + } + } + return NULL; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_in_flow( + const axis2_op_t * op, + const axutil_env_t * env) +{ + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_IN); + if(msg) + { + return axis2_msg_get_flow(msg, env); + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_fault_in_flow( + axis2_op_t * op, + const axutil_env_t * env, + axutil_array_list_t * list) +{ + AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE); + + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_IN_FAULT); + if(msg) + { + return axis2_msg_set_flow(msg, env, list); + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_fault_out_flow( + axis2_op_t * op, + const axutil_env_t * env, + axutil_array_list_t * list) +{ + AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE); + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_OUT_FAULT); + if(msg) + { + return axis2_msg_set_flow(msg, env, list); + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_out_flow( + axis2_op_t * op, + const axutil_env_t * env, + axutil_array_list_t * list) +{ + AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE); + + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_OUT); + if(msg) + { + return axis2_msg_set_flow(msg, env, list); + } + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_in_flow( + axis2_op_t * op, + const axutil_env_t * env, + axutil_array_list_t * list) +{ + AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE); + + if(op->base) + { + axis2_msg_t *msg = NULL; + msg = axis2_desc_get_child(op->base, env, AXIS2_MSG_IN); + if(msg) + { + return axis2_msg_set_flow(msg, env, list); + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_module_qname( + axis2_op_t * op, + const axutil_env_t * env, + const axutil_qname_t * module_qname) +{ + axutil_qname_t *module_qname_l = NULL; + + AXIS2_PARAM_CHECK(env->error, module_qname, AXIS2_FAILURE); + module_qname_l = axutil_qname_clone((axutil_qname_t *)module_qname, env); + + return axutil_array_list_add(op->module_qnames, env, module_qname_l); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_all_module_qnames( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->module_qnames; +} + +AXIS2_EXTERN axis2_op_ctx_t *AXIS2_CALL +axis2_op_find_op_ctx( + axis2_op_t * op, + const axutil_env_t * env, + struct axis2_msg_ctx * msg_ctx, + struct axis2_svc_ctx * svc_ctx) +{ + axis2_op_ctx_t *op_ctx = NULL; + axis2_relates_to_t *relates_to = NULL; + axis2_status_t status = AXIS2_FAILURE; + axis2_char_t *opname = NULL; + + AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL); + AXIS2_PARAM_CHECK(env->error, svc_ctx, NULL); + + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env); + if(!relates_to) + { + op_ctx = axis2_op_ctx_create(env, op, svc_ctx); + if(!op_ctx) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Creating operation context failed for operation %s", opname); + return NULL; + } + } + else + { + axis2_conf_ctx_t *conf_ctx = NULL; + const axis2_char_t *value = NULL; + + conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); + value = axis2_relates_to_get_value(relates_to, env); + op_ctx = axis2_conf_ctx_get_op_ctx(conf_ctx, env, value); + if(!op_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Cannot correlate message to %s for operation %s", value, opname); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_CANNOT_CORRELATE_MSG, AXIS2_FAILURE); + return NULL; + } + } + + status = axis2_op_register_op_ctx(op, env, msg_ctx, op_ctx); + if(AXIS2_FAILURE == status) + { + axis2_op_ctx_free(op_ctx, env); + return NULL; + } + else + { + return op_ctx; + } +} + +AXIS2_EXTERN axis2_op_ctx_t *AXIS2_CALL +axis2_op_find_existing_op_ctx( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_msg_ctx_t * msg_ctx) +{ + axis2_op_ctx_t *op_ctx = NULL; + axis2_relates_to_t *relates_to = NULL; + axis2_char_t *opname = NULL; + + AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL); + + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); + if(op_ctx) + { + return op_ctx; + } + + relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env); + if(!relates_to) + { + return NULL; + } + else + { + axis2_conf_ctx_t *conf_ctx = NULL; + const axis2_char_t *value = NULL; + conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); + value = axis2_relates_to_get_value(relates_to, env); + op_ctx = axis2_conf_ctx_get_op_ctx(conf_ctx, env, value); + + if(!op_ctx) + { + AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, + "Cannot correlate message to %s for operation %s", value, opname); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_CANNOT_CORRELATE_MSG, AXIS2_FAILURE); + return NULL; + } + } + + return op_ctx; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_register_op_ctx( + axis2_op_t * op, + const axutil_env_t * env, + axis2_msg_ctx_t * msg_ctx, + axis2_op_ctx_t * op_ctx) +{ + axis2_conf_ctx_t *conf_ctx = NULL; + const axis2_char_t *msg_id = NULL; + axis2_status_t status = AXIS2_FAILURE; + axis2_char_t *opname = NULL; + + AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_ctx, AXIS2_FAILURE); + + opname = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); + conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); + if(!conf_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Configuration context not found for message context while " + "registering operation context for operation %s", opname); + return AXIS2_FAILURE; + } + + status = axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx); + + if(AXIS2_SUCCESS != status) + { + axutil_hash_t *op_ctx_map = NULL; + + msg_id = axis2_msg_ctx_get_msg_id(msg_ctx, env); + if(msg_id) + { + op_ctx_map = (axutil_hash_t *)axis2_conf_ctx_get_op_ctx_map(conf_ctx, env); + axutil_hash_set(op_ctx_map, msg_id, AXIS2_HASH_KEY_STRING, NULL); + } + else + { + AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, + "Message id not found for message context while registering operation context " + "for operation %s. The reason could be that there is no addressing enabled for " + "communication", opname); + } + } + if(axis2_op_ctx_get_is_complete(op_ctx, env)) + { + axis2_op_ctx_cleanup(op_ctx, env); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_msg_ctx_in_only( + axis2_op_t * op, + const axutil_env_t * env, + axis2_msg_ctx_t * msg_ctx, + axis2_op_ctx_t * op_ctx) +{ + AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_ctx, AXIS2_FAILURE); + + if(!axis2_op_ctx_get_is_complete(op_ctx, env)) + { + axis2_msg_ctx_t **msg_ctxs = NULL; + msg_ctxs = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); + msg_ctxs[AXIS2_WSDL_MESSAGE_LABEL_IN] = msg_ctx; + axis2_op_ctx_set_complete(op_ctx, env, AXIS2_TRUE); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid message; adding operation context for the " + "operation :%s is already completed", axutil_qname_get_localpart( + axis2_op_get_qname(op, env), env)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_MESSAGE_ADDITION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_msg_ctx_out_only( + axis2_op_t * op, + const axutil_env_t * env, + axis2_msg_ctx_t * msg_ctx, + axis2_op_ctx_t * op_ctx) +{ + AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_ctx, AXIS2_FAILURE); + + if(!axis2_op_ctx_get_is_complete(op_ctx, env)) + { + axis2_msg_ctx_t **msg_ctxs = NULL; + msg_ctxs = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); + msg_ctxs[AXIS2_WSDL_MESSAGE_LABEL_OUT] = msg_ctx; + axis2_op_ctx_set_complete(op_ctx, env, AXIS2_TRUE); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid message; adding operation context for the " + "operation :%s is already completed", axutil_qname_get_localpart( + axis2_op_get_qname(op, env), env)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_MESSAGE_ADDITION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_msg_ctx_in_out( + axis2_op_t * op, + const axutil_env_t * env, + axis2_msg_ctx_t * msg_ctx, + axis2_op_ctx_t * op_ctx) +{ + axis2_msg_ctx_t **mep = NULL; + axis2_msg_ctx_t *in_msg_ctx = NULL; + axis2_msg_ctx_t *out_msg_ctx = NULL; + + AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_ctx, AXIS2_FAILURE); + + mep = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); + in_msg_ctx = mep[AXIS2_WSDL_MESSAGE_LABEL_IN]; + out_msg_ctx = mep[AXIS2_WSDL_MESSAGE_LABEL_OUT]; + + if(in_msg_ctx && out_msg_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid message; adding operation context for the " + "operation :%s is invalid", axutil_qname_get_localpart(axis2_op_get_qname(op, env), + env)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_MESSAGE_ADDITION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(!in_msg_ctx) + { + mep[AXIS2_WSDL_MESSAGE_LABEL_IN] = msg_ctx; + } + else + { + mep[AXIS2_WSDL_MESSAGE_LABEL_OUT] = msg_ctx; + axis2_op_ctx_set_complete(op_ctx, env, AXIS2_TRUE); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_msg_ctx_out_in( + axis2_op_t * op, + const axutil_env_t * env, + axis2_msg_ctx_t * msg_ctx, + axis2_op_ctx_t * op_ctx) +{ + axis2_msg_ctx_t **mep = NULL; + axis2_msg_ctx_t *in_msg_ctx = NULL; + axis2_msg_ctx_t *out_msg_ctx = NULL; + + AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_ctx, AXIS2_FAILURE); + + mep = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); + in_msg_ctx = mep[AXIS2_WSDL_MESSAGE_LABEL_IN]; + out_msg_ctx = mep[AXIS2_WSDL_MESSAGE_LABEL_OUT]; + if(in_msg_ctx && out_msg_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid message; adding operation context for the " + "operation :%s is invalid", axutil_qname_get_localpart(axis2_op_get_qname(op, env), + env)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_MESSAGE_ADDITION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(!out_msg_ctx) + { + mep[AXIS2_WSDL_MESSAGE_LABEL_OUT] = msg_ctx; + } + else + { + mep[AXIS2_WSDL_MESSAGE_LABEL_IN] = msg_ctx; + axis2_op_ctx_set_complete(op_ctx, env, AXIS2_TRUE); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_msg_t *AXIS2_CALL +axis2_op_get_msg( + const axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * label) +{ + AXIS2_PARAM_CHECK(env->error, label, NULL); + + return (axis2_msg_t *)axis2_desc_get_child(op->base, env, label); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_add_msg( + axis2_op_t * op, + const axutil_env_t * env, + const axis2_char_t * label, + const axis2_msg_t * msg) +{ + AXIS2_PARAM_CHECK(env->error, label, AXIS2_FAILURE); + + return axis2_desc_add_child(op->base, env, label, msg); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_op_is_from_module( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->from_module; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_op_set_wsamapping_list( + axis2_op_t * op, + const axutil_env_t * env, + axutil_array_list_t * mapping_list) +{ + AXIS2_PARAM_CHECK(env->error, mapping_list, AXIS2_FAILURE); + + if(op->wsamapping_list) + { + int i = 0; + int size = 0; + size = axutil_array_list_size(op->wsamapping_list, env); + for(i = 0; i < size; i++) + { + axis2_char_t *temp_str = axutil_array_list_get(op->wsamapping_list, env, i); + if(temp_str) + AXIS2_FREE(env->allocator, temp_str); + } + axutil_array_list_free(op->wsamapping_list, env); + op->wsamapping_list = NULL; + } + op->wsamapping_list = mapping_list; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_op_get_wsamapping_list( + axis2_op_t * op, + const axutil_env_t * env) +{ + return op->wsamapping_list; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_op_get_param_container( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->param_container; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_op_get_base( + const axis2_op_t * op, + const axutil_env_t * env) +{ + return op->base; +} + diff --git a/src/core/description/phase_rule.c b/src/core/description/phase_rule.c new file mode 100644 index 0000000..bb4cfea --- /dev/null +++ b/src/core/description/phase_rule.c @@ -0,0 +1,254 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_const.h> +#include <axis2_phase_rule.h> +#include <axutil_string.h> + +struct axis2_phase_rule +{ + + /** name of phase or handler before */ + axis2_char_t *before; + + /** name of phase or handler after */ + axis2_char_t *after; + + /** phase name */ + axis2_char_t *name; + + /** Is this first in phase? */ + axis2_bool_t first; + + /** Is this last in phase? */ + axis2_bool_t last; + +}; + +AXIS2_EXTERN axis2_phase_rule_t *AXIS2_CALL +axis2_phase_rule_create( + const axutil_env_t * env, + const axis2_char_t * name) +{ + axis2_phase_rule_t *phase_rule = NULL; + + phase_rule = AXIS2_MALLOC(env->allocator, sizeof(axis2_phase_rule_t)); + if(!phase_rule) + { + AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); + return NULL; + } + + phase_rule->before = NULL; + phase_rule->after = NULL; + phase_rule->name = NULL; + phase_rule->first = AXIS2_FALSE; + phase_rule->last = AXIS2_FALSE; + + if(name) + { + phase_rule->name = axutil_strdup(env, name); + } + + return phase_rule; +} + +const axis2_char_t *AXIS2_CALL +axis2_phase_rule_get_before( + const axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + return phase_rule->before; +} + +axis2_status_t AXIS2_CALL +axis2_phase_rule_set_before( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env, + const axis2_char_t * before) +{ + if(phase_rule->before) + { + AXIS2_FREE(env->allocator, phase_rule->before); + } + + if(before) + { + phase_rule->before = axutil_strdup(env, before); + if(!phase_rule->before) + { + AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +const axis2_char_t *AXIS2_CALL +axis2_phase_rule_get_after( + const axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + return phase_rule->after; +} + +axis2_status_t AXIS2_CALL +axis2_phase_rule_set_after( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env, + const axis2_char_t * after) +{ + if(phase_rule->after) + { + AXIS2_FREE(env->allocator, phase_rule->after); + } + + if(after) + { + phase_rule->after = axutil_strdup(env, after); + if(!phase_rule->after) + { + AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +const axis2_char_t *AXIS2_CALL +axis2_phase_rule_get_name( + const axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + return phase_rule->name; +} + +axis2_status_t AXIS2_CALL +axis2_phase_rule_set_name( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env, + const axis2_char_t * name) +{ + if(phase_rule->name) + { + AXIS2_FREE(env->allocator, phase_rule->name); + } + + if(name) + { + phase_rule->name = axutil_strdup(env, name); + if(!phase_rule->name) + { + AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +axis2_bool_t AXIS2_CALL +axis2_phase_rule_is_first( + const axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + return phase_rule->first; +} + +axis2_status_t AXIS2_CALL +axis2_phase_rule_set_first( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env, + axis2_bool_t first) +{ + phase_rule->first = first; + return AXIS2_SUCCESS; +} + +axis2_bool_t AXIS2_CALL +axis2_phase_rule_is_last( + const axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + return phase_rule->last; +} + +axis2_status_t AXIS2_CALL +axis2_phase_rule_set_last( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env, + axis2_bool_t last) +{ + phase_rule->last = last; + return AXIS2_SUCCESS; +} + +void AXIS2_CALL +axis2_phase_rule_free( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + if(phase_rule->before) + { + AXIS2_FREE(env->allocator, phase_rule->before); + } + + if(phase_rule->after) + { + AXIS2_FREE(env->allocator, phase_rule->after); + } + + if(phase_rule->name) + { + AXIS2_FREE(env->allocator, phase_rule->name); + } + + AXIS2_FREE(env->allocator, phase_rule); + + return; +} + +axis2_phase_rule_t *AXIS2_CALL +axis2_phase_rule_clone( + axis2_phase_rule_t * phase_rule, + const axutil_env_t * env) +{ + axis2_phase_rule_t *phase_rule_new = NULL; + + phase_rule_new = axis2_phase_rule_create(env, NULL); + if(!phase_rule_new) + return NULL; + + axis2_phase_rule_set_before(phase_rule_new, env, axis2_phase_rule_get_before(phase_rule, env)); + + axis2_phase_rule_set_after(phase_rule_new, env, axis2_phase_rule_get_after(phase_rule, env)); + + axis2_phase_rule_set_name(phase_rule_new, env, axis2_phase_rule_get_name(phase_rule, env)); + + axis2_phase_rule_set_first(phase_rule_new, env, axis2_phase_rule_is_first(phase_rule, env)); + + axis2_phase_rule_set_last(phase_rule_new, env, axis2_phase_rule_is_last(phase_rule, env)); + + return phase_rule_new; +} + diff --git a/src/core/description/policy_include.c b/src/core/description/policy_include.c new file mode 100644 index 0000000..5ce93f8 --- /dev/null +++ b/src/core/description/policy_include.c @@ -0,0 +1,612 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_policy_include.h> +#include <neethi_policy.h> +#include <neethi_engine.h> + +struct axis2_policy_include +{ + neethi_policy_t *policy; + + neethi_policy_t *effective_policy; + + neethi_registry_t *registry; + + axis2_desc_t *desc; + + axutil_hash_t *wrapper_elements; +}; + +typedef struct axis2_policy_wrapper +{ + int type; + void *value; +} axis2_policy_wrapper_t; + +AXIS2_EXTERN axis2_policy_include_t *AXIS2_CALL +axis2_policy_include_create( + const axutil_env_t * env) +{ + axis2_policy_include_t *policy_include = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + policy_include = (axis2_policy_include_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_policy_include_t)); + + if(!policy_include) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + policy_include->policy = NULL; + policy_include->effective_policy = NULL; + policy_include->registry = NULL; + policy_include->desc = NULL; + policy_include->wrapper_elements = NULL; + + policy_include->registry = neethi_registry_create(env); + if(!policy_include->registry) + { + axis2_policy_include_free(policy_include, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + policy_include->wrapper_elements = axutil_hash_make(env); + if(!policy_include->wrapper_elements) + { + axis2_policy_include_free(policy_include, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + return policy_include; +} + +AXIS2_EXTERN axis2_policy_include_t *AXIS2_CALL +axis2_policy_include_create_with_desc( + const axutil_env_t * env, + axis2_desc_t * desc) +{ + axis2_policy_include_t *policy_include = NULL; + axis2_desc_t *parent_desc = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + policy_include = (axis2_policy_include_t *)axis2_policy_include_create(env); + + parent_desc = axis2_desc_get_parent(desc, env); + + if(policy_include->registry) + { + neethi_registry_free(policy_include->registry, env); + policy_include->registry = NULL; + } + + if(parent_desc) + { + axis2_policy_include_t *preant_policy_include = axis2_desc_get_policy_include(parent_desc, + env); + if(preant_policy_include) + { + policy_include->registry = neethi_registry_create_with_parent(env, + axis2_policy_include_get_registry(preant_policy_include, env)); + } + else + { + policy_include->registry = neethi_registry_create(env); + } + } + else + { + policy_include->registry = neethi_registry_create(env); + } + + policy_include->desc = desc; + + return policy_include; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_policy_include_free( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(policy_include->registry) + { + neethi_registry_free(policy_include->registry, env); + } + + if(policy_include->wrapper_elements) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + for(hi = axutil_hash_first(policy_include->wrapper_elements, env); hi; hi + = axutil_hash_next(env, hi)) + { + axis2_policy_wrapper_t *wrapper = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + wrapper = (axis2_policy_wrapper_t *)val; + if(wrapper) + AXIS2_FREE(env->allocator, wrapper); + val = NULL; + wrapper = NULL; + } + axutil_hash_free(policy_include->wrapper_elements, env); + } + + if(policy_include) + { + AXIS2_FREE(env->allocator, policy_include); + } + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_set_registry( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + neethi_registry_t * registry) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(policy_include->registry) + { + neethi_registry_free(policy_include->registry, env); + } + + policy_include->registry = registry; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN neethi_registry_t *AXIS2_CALL +axis2_policy_include_get_registry( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + return policy_include->registry; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_set_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + neethi_policy_t * policy) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(policy_include->wrapper_elements) + { + axutil_hash_free(policy_include->wrapper_elements, env); + policy_include->wrapper_elements = NULL; + } + + policy_include->wrapper_elements = axutil_hash_make(env); + + if(!neethi_policy_get_name(policy, env) && !neethi_policy_get_id(policy, env)) + { + neethi_policy_set_id(policy, env, axutil_uuid_gen(env)); + } + + if(policy_include->wrapper_elements) + { + axis2_policy_wrapper_t *wrapper = NULL; + + wrapper = (axis2_policy_wrapper_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_policy_wrapper_t)); + if(wrapper) + { + axis2_char_t *policy_name = NULL; + wrapper->type = AXIS2_ANON_POLICY; + wrapper->value = policy; + + policy_name = neethi_policy_get_name(policy, env); + + if(policy_name) + { + axutil_hash_set(policy_include->wrapper_elements, policy_name, + AXIS2_HASH_KEY_STRING, wrapper); + } + else + { + axutil_hash_set(policy_include->wrapper_elements, + neethi_policy_get_id(policy, env), AXIS2_HASH_KEY_STRING, wrapper); + } + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_update_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + neethi_policy_t * policy) +{ + axis2_char_t *key; + axis2_policy_wrapper_t *wrapper = NULL; + + key = neethi_policy_get_name(policy, env); + if(!key) + key = neethi_policy_get_id(policy, env); + + if(!key) + { + return AXIS2_FAILURE; + } + + wrapper = axutil_hash_get(policy_include->wrapper_elements, key, AXIS2_HASH_KEY_STRING); + if(wrapper) + { + wrapper->value = policy; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_set_effective_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + neethi_policy_t * effective_policy) +{ + policy_include->effective_policy = effective_policy; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_set_desc( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + axis2_desc_t * desc) +{ + policy_include->desc = desc; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_policy_include_get_desc( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + return policy_include->desc; +} + +AXIS2_EXTERN axis2_policy_include_t *AXIS2_CALL +axis2_policy_include_get_parent( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + if(policy_include->desc) + { + axis2_desc_t *parent = NULL; + parent = axis2_desc_get_parent(policy_include->desc, env); + if(parent) + { + return axis2_desc_get_policy_include(parent, env); + } + } + + return NULL; +} + +static axis2_status_t +axis2_policy_include_calculate_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + neethi_policy_t *result = NULL; + axutil_hash_index_t *hi = NULL; + void *val = NULL; + + for(hi = axutil_hash_first(policy_include->wrapper_elements, env); hi; hi = axutil_hash_next( + env, hi)) + { + axis2_policy_wrapper_t *wrapper = NULL; + + axutil_hash_this(hi, NULL, NULL, &val); + wrapper = (axis2_policy_wrapper_t *)val; + + if(wrapper) + { + neethi_policy_t *policy = NULL; + if(wrapper->type == AXIS2_POLICY_REF) + { + neethi_reference_t *reference = (neethi_reference_t *)wrapper->value; + if(reference) + { + /* TOOD add neethi_reference_normalize + policy = (neethi_policy_t*) neethi_reference_normalize( + reference, env, policy_include->registry, AXIS2_FALSE); + */ + } + } + else + { + policy = (neethi_policy_t *)wrapper->value; + } + + result = (result == NULL) ? (neethi_policy_t *)policy + : (neethi_policy_t *)neethi_engine_merge(env, result, policy); + } + } + + policy_include->policy = result; + return AXIS2_SUCCESS; +} + +static neethi_policy_t * +axis2_policy_include_calculate_effective_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + neethi_policy_t *result; + axis2_policy_include_t *parent = NULL; + + parent = axis2_policy_include_get_parent(policy_include, env); + + if(parent) + { + neethi_policy_t *parent_policy = axis2_policy_include_get_effective_policy(parent, env); + + if(!parent_policy) + { + result = axis2_policy_include_get_policy(policy_include, env); + + } + else + { + if(axis2_policy_include_get_policy(policy_include, env)) + { + neethi_policy_t *temp_policy = NULL; + parent_policy = (neethi_policy_t *)neethi_engine_get_normalize(env, AXIS2_FALSE, + parent_policy); + temp_policy = axis2_policy_include_get_policy(policy_include, env); + temp_policy = (neethi_policy_t *)neethi_engine_get_normalize(env, AXIS2_FALSE, + temp_policy); + /* result = (neethi_policy_t*) neethi_engine_merge(env, parent_policy, + axis2_policy_include_get_policy(policy_include, env)); */ + result = (neethi_policy_t *)neethi_engine_merge(env, parent_policy, temp_policy); + + } + else + { + result = parent_policy; + } + } + } + else + { + result = axis2_policy_include_get_policy(policy_include, env); + } + + return result; + /*policy_include->effective_policy = result; + return AXIS2_SUCCESS; */ +} + +AXIS2_EXTERN neethi_policy_t *AXIS2_CALL +axis2_policy_include_get_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + axis2_policy_include_calculate_policy(policy_include, env); + return policy_include->policy; +} + +AXIS2_EXTERN neethi_policy_t *AXIS2_CALL +axis2_policy_include_get_effective_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + /*if (policy_include->effective_policy) + return policy_include->effective_policy; + */ + return axis2_policy_include_calculate_effective_policy(policy_include, env); + /*return policy_include->effective_policy; */ +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_policy_include_get_policy_elements( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + axutil_array_list_t *policy_elements_list = NULL; + axutil_hash_index_t *hi = NULL; + void *val = NULL; + + policy_elements_list = axutil_array_list_create(env, 10); + + for(hi = axutil_hash_first(policy_include->wrapper_elements, env); hi; hi = axutil_hash_next( + env, hi)) + { + axis2_policy_wrapper_t *wrapper = NULL; + + axutil_hash_this(hi, NULL, NULL, &val); + wrapper = (axis2_policy_wrapper_t *)val; + + if(wrapper) + { + axutil_array_list_add(policy_elements_list, env, wrapper->value); + } + } + return policy_elements_list; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_policy_include_get_policy_elements_with_type( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + int type) +{ + axutil_array_list_t *policy_elements_list = NULL; + axutil_hash_index_t *hi = NULL; + void *val = NULL; + + policy_elements_list = axutil_array_list_create(env, 10); + + for(hi = axutil_hash_first(policy_include->wrapper_elements, env); hi; hi = axutil_hash_next( + env, hi)) + { + axis2_policy_wrapper_t *wrapper = NULL; + + axutil_hash_this(hi, NULL, NULL, &val); + wrapper = (axis2_policy_wrapper_t *)val; + + if(wrapper && wrapper->type == type) + { + axutil_array_list_add(policy_elements_list, env, wrapper->value); + } + } + return policy_elements_list; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_register_policy( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + axis2_char_t * key, + neethi_policy_t * policy) +{ + if(policy_include->registry) + { + return neethi_registry_register(policy_include->registry, env, key, policy); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN neethi_policy_t *AXIS2_CALL +axis2_policy_include_get_policy_with_key( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + axis2_char_t * key) +{ + if(policy_include->registry) + { + return neethi_registry_lookup(policy_include->registry, env, key); + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_add_policy_element( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + int type, + neethi_policy_t * policy) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(!neethi_policy_get_name(policy, env) && !neethi_policy_get_id(policy, env)) + { + axis2_char_t *uuid = axutil_uuid_gen(env); + neethi_policy_set_id(policy, env, uuid); + if(uuid) + { + AXIS2_FREE(env->allocator, uuid); + uuid = NULL; + } + } + + if(policy_include->wrapper_elements) + { + axis2_policy_wrapper_t *wrapper = NULL; + + wrapper = (axis2_policy_wrapper_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_policy_wrapper_t)); + if(wrapper) + { + axis2_char_t *policy_name = NULL; + wrapper->type = type; + wrapper->value = policy; + + policy_name = neethi_policy_get_name(policy, env); + if(!policy_name) + policy_name = neethi_policy_get_id(policy, env); + + if(policy_name) + { + axutil_hash_set(policy_include->wrapper_elements, policy_name, + AXIS2_HASH_KEY_STRING, wrapper); + if(policy_include->registry) + { + neethi_registry_register(policy_include->registry, env, policy_name, policy); + } + return AXIS2_SUCCESS; + } + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_add_policy_reference_element( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + int type, + neethi_reference_t * reference) +{ + axis2_policy_wrapper_t *wrapper = NULL; + + wrapper + = (axis2_policy_wrapper_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_policy_wrapper_t)); + if(wrapper) + { + wrapper->type = type; + wrapper->value = reference; + axutil_hash_set(policy_include->wrapper_elements, neethi_reference_get_uri(reference, env), + AXIS2_HASH_KEY_STRING, wrapper); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_remove_policy_element( + axis2_policy_include_t * policy_include, + const axutil_env_t * env, + axis2_char_t * policy_uri) +{ + if(policy_include->wrapper_elements) + { + axutil_hash_set(policy_include->wrapper_elements, policy_uri, AXIS2_HASH_KEY_STRING, NULL); + } + if(policy_include->registry) + { + neethi_registry_register(policy_include->registry, env, policy_uri, NULL); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_policy_include_remove_all_policy_element( + axis2_policy_include_t * policy_include, + const axutil_env_t * env) +{ + if(policy_include->wrapper_elements) + { + axutil_hash_free(policy_include->wrapper_elements, env); + } + return AXIS2_SUCCESS; +} diff --git a/src/core/description/svc.c b/src/core/description/svc.c new file mode 100644 index 0000000..72f4597 --- /dev/null +++ b/src/core/description/svc.c @@ -0,0 +1,1543 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_svc.h> +#include <axis2_addr.h> +#include <axutil_property.h> +#include <axis2_module.h> +#include "../deployment/axis2_desc_builder.h" +#include <axis2_svc_skeleton.h> +#include <axutil_thread.h> +#include <axis2_core_utils.h> + +struct axis2_svc +{ + axis2_svc_grp_t *parent; + axis2_char_t *axis_svc_name; + + /** To keep last update time of the service */ + long last_update; + axis2_char_t *filename; + + /** To store module descriptions at deploy time parsing */ + axutil_array_list_t *module_list; + + /** Service description */ + axis2_char_t *svc_desc; + + /** wsdl file path */ + axis2_char_t *wsdl_path; + + /** service folder path */ + axis2_char_t *folder_path; + + /** + * WSDL related stuff + */ + axutil_hash_t *ns_map; + /* Count of the entries in the namespace map */ + int ns_count; + /* To keep the XML scheama either from WSDL or + * C2WSDL(in the future) + */ + axutil_array_list_t *schema_list; + + /** + * A table that keeps a mapping of unique XSD names (Strings) + * against the schema objects. This is populated in the first + * instance the schemas are asked for and then used to serve + * the subsequent requests + */ + axutil_hash_t *schema_mapping_table; + + /** + * This is where operations are kept + */ + axutil_hash_t *op_alias_map; + + /** + * This is where action mappings are kept + */ + axutil_hash_t *op_action_map; + + /** + * This is where REST mappings are kept + */ + axutil_hash_t *op_rest_map; + + /** + * Keeps track whether the schema locations are adjusted + */ + axis2_bool_t schema_loc_adjusted; + + /** + * A custom schema name prefix. if set this will be used to + * modify the schema names + */ + axis2_char_t *custom_schema_name_prefix; + + /** + * A custom schema name suffix. will be attached to the + * schema file name when the files are uniquely named. + * A good place to add a file extension if needed + */ + axis2_char_t *custom_schema_name_suffix; + /* To store the target namespace for the schema */ + axis2_char_t *schema_target_ns; + axis2_char_t *schema_target_ns_prefix; + /* To keep the service target name space */ + axis2_char_t *target_ns; + axis2_char_t *target_ns_prefix; + /* Used for schema name calculations */ + int sc_calc_count; + + void *impl_class; + axutil_qname_t *qname; + axis2_char_t *style; + axutil_array_list_t *engaged_module_list; + + /** Parameter container to hold service related parameters */ + struct axutil_param_container *param_container; + + /** Flow container that encapsulates the flow related data */ + struct axis2_flow_container *flow_container; + + /** Base description struct */ + axis2_desc_t *base; + + /* Mutex to avoid loading the same service dll twice */ + axutil_thread_mutex_t *mutex; +}; + +AXIS2_EXTERN axis2_svc_t *AXIS2_CALL +axis2_svc_create( + const axutil_env_t * env) +{ + axis2_svc_t *svc = NULL; + + svc = (axis2_svc_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_t)); + if(!svc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return NULL; + } + + svc->parent = NULL; + svc->axis_svc_name = NULL; + svc->filename = NULL; + svc->svc_desc = NULL; + svc->wsdl_path = NULL; + svc->folder_path = NULL; + svc->last_update = 0; + svc->param_container = NULL; + svc->flow_container = NULL; + svc->op_alias_map = NULL; + svc->op_action_map = NULL; + svc->op_rest_map = NULL; + svc->module_list = NULL; + svc->ns_map = NULL; + svc->ns_count = 0; + svc->schema_list = NULL; + svc->schema_mapping_table = NULL; + svc->schema_loc_adjusted = AXIS2_FALSE; + svc->custom_schema_name_prefix = NULL; + svc->custom_schema_name_suffix = NULL; + svc->schema_target_ns = NULL; + svc->schema_target_ns_prefix = NULL; + svc->target_ns = NULL; + svc->target_ns_prefix = NULL; + svc->sc_calc_count = 0; + svc->impl_class = NULL; + svc->qname = NULL; + svc->style = NULL; + svc->base = NULL; + + svc->param_container = axutil_param_container_create(env); + if(!svc->param_container) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service param container creation failed"); + return NULL; + } + + svc->flow_container = axis2_flow_container_create(env); + if(!svc->flow_container) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service flow container creation failed"); + return NULL; + } + + svc->op_alias_map = axutil_hash_make(env); + if(!svc->op_alias_map) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation alias map creation failed"); + return NULL; + } + + svc->op_action_map = axutil_hash_make(env); + if(!svc->op_action_map) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation action map creation failed"); + return NULL; + } + + svc->op_rest_map = axutil_hash_make(env); + if(!svc->op_rest_map) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation rest map creation failed"); + return NULL; + } + + /** Create module list of default size */ + svc->module_list = axutil_array_list_create(env, 0); + if(!svc->module_list) + { + axis2_svc_free(svc, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service module list creation failed"); + return NULL; + } + + svc->schema_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY); + if(!svc->schema_list) + { + axis2_svc_free(svc, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service schema list creation failed"); + return NULL; + } + + svc->engaged_module_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY); + if(!svc->engaged_module_list) + { + axis2_svc_free(svc, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service engaged modules list creation failed"); + return NULL; + } + + svc->schema_loc_adjusted = AXIS2_FALSE; + if(svc->schema_target_ns_prefix) + { + AXIS2_FREE(env->allocator, svc->schema_target_ns_prefix); + svc->schema_target_ns_prefix = NULL; + } + svc->schema_target_ns_prefix = axutil_strdup(env, "ns"); + + if(svc->target_ns) + { + AXIS2_FREE(env->allocator, svc->target_ns); + svc->target_ns = NULL; + } + svc->target_ns = axutil_strdup(env, "http://ws.apache.org/axis2"); + + if(svc->target_ns_prefix) + { + AXIS2_FREE(env->allocator, svc->target_ns_prefix); + svc->target_ns_prefix = NULL; + } + svc->target_ns_prefix = axutil_strdup(env, "tns"); + svc->sc_calc_count = 0; + + svc->base = axis2_desc_create(env); + if(!svc->base) + { + axis2_svc_free(svc, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service base creation failed"); + return NULL; + } + svc->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT); + if(!svc->mutex) + { + axis2_svc_free(svc, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service mutex creation failed"); + return NULL; + } + return svc; +} + +AXIS2_EXTERN axis2_svc_t *AXIS2_CALL +axis2_svc_create_with_qname( + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + axis2_svc_t *svc = NULL; + axis2_status_t status = AXIS2_FAILURE; + + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + svc = axis2_svc_create(env); + if(!svc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service creation failed for name %s", + axutil_qname_get_localpart(qname, env)); + return NULL; + } + + status = axis2_svc_set_qname(svc, env, qname); + if(AXIS2_FAILURE == status) + { + axis2_svc_free(svc, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting name %s to service failed", + axutil_qname_get_localpart(qname, env)); + return NULL; + } + + return svc; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_svc_free( + axis2_svc_t * svc, + const axutil_env_t * env) +{ + if(svc->impl_class) + { + AXIS2_SVC_SKELETON_FREE((axis2_svc_skeleton_t *)svc->impl_class, env); + } + if(svc->param_container) + { + axutil_param_container_free(svc->param_container, env); + } + + if(svc->flow_container) + { + axis2_flow_container_free(svc->flow_container, env); + } + + if(svc->filename) + { + AXIS2_FREE(env->allocator, svc->filename); + svc->filename = NULL; + } + + if(svc->svc_desc) + { + AXIS2_FREE(env->allocator, svc->svc_desc); + svc->svc_desc = NULL; + } + + svc->parent = NULL; + + if(svc->module_list) + { + int i = 0; + int size = 0; + + size = axutil_array_list_size(svc->module_list, env); + for(i = 0; i < size; i++) + { + axutil_qname_t *qname = NULL; + qname = axutil_array_list_get(svc->module_list, env, i); + if(qname) + { + axutil_qname_free(qname, env); + } + } + axutil_array_list_free(svc->module_list, env); + } + + if(svc->schema_list) + { + axutil_array_list_free(svc->schema_list, env); + } + + if(svc->engaged_module_list) + { + axutil_array_list_free(svc->engaged_module_list, env); + } + + if(svc->axis_svc_name) + { + AXIS2_FREE(env->allocator, svc->axis_svc_name); + svc->axis_svc_name = NULL; + } + + if(svc->op_alias_map) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + + for(hi = axutil_hash_first(svc->op_alias_map, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + if(axis2_op_is_from_module((axis2_op_t *)val, env) == AXIS2_FALSE) + { + axis2_op_free((axis2_op_t *)val, env); + } + val = NULL; + } + } + + axutil_hash_free(svc->op_alias_map, env); + } + + if(svc->op_action_map) + { + axutil_hash_index_t *hi = NULL; + const void *key = NULL; + + for(hi = axutil_hash_first(svc->op_action_map, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, &key, NULL, NULL); + + if(key) + { + AXIS2_FREE(env->allocator, (axis2_char_t *)key); + key = NULL; + } + } + axutil_hash_free(svc->op_action_map, env); + } + + if(svc->op_rest_map) + { + axis2_core_utils_free_rest_map(env, svc->op_rest_map); + } + + if(svc->schema_target_ns_prefix) + { + AXIS2_FREE(env->allocator, svc->schema_target_ns_prefix); + svc->schema_target_ns_prefix = NULL; + } + + if(svc->target_ns) + { + AXIS2_FREE(env->allocator, svc->target_ns); + svc->target_ns = NULL; + } + + if(svc->wsdl_path) + { + AXIS2_FREE(env->allocator, svc->wsdl_path); + svc->wsdl_path = NULL; + } + + if(svc->folder_path) + { + AXIS2_FREE(env->allocator, svc->folder_path); + svc->folder_path = NULL; + } + + if(svc->target_ns_prefix) + { + AXIS2_FREE(env->allocator, svc->target_ns_prefix); + svc->target_ns_prefix = NULL; + } + + if(svc->qname) + { + axutil_qname_free(svc->qname, env); + } + + if(svc->style) + { + AXIS2_FREE(env->allocator, svc->style); + } + + if(svc->base) + { + axis2_desc_free(svc->base, env); + } + if(svc->mutex) + { + axutil_thread_mutex_destroy(svc->mutex); + } + if(svc) + { + AXIS2_FREE(env->allocator, svc); + svc = NULL; + } + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_op( + axis2_svc_t * svc, + const axutil_env_t * env, + axis2_op_t * op) +{ + axis2_status_t status = AXIS2_FAILURE; + axis2_msg_recv_t *msg_recv = NULL; + const axutil_qname_t *qname = NULL; + axis2_char_t *key = NULL; + const axis2_char_t *svcname = NULL; + axutil_array_list_t *mappings_list = NULL; + int size = 0; + int j = 0; + + AXIS2_PARAM_CHECK(env->error, op, AXIS2_FAILURE); + svcname = axis2_svc_get_name(svc, env); + qname = axis2_op_get_qname(op, env); + if(qname) + key = axutil_qname_get_localpart(qname, env); + mappings_list = axis2_op_get_wsamapping_list(op, env); + /* Adding action mappings into service */ + if(mappings_list) + size = axutil_array_list_size(mappings_list, env); + for(j = 0; j < size; j++) + { + axis2_char_t *mapping = NULL; + + mapping = (axis2_char_t *)axutil_array_list_get(mappings_list, env, j); + status = axis2_svc_add_mapping(svc, env, mapping, op); + if(AXIS2_SUCCESS != status) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Adding operation %s to service %s mapping list failed", svcname, key); + return status; + } + } + + status = axis2_op_set_parent(op, env, svc); + if(AXIS2_SUCCESS != status) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting service %s as operation %s parent failed", + svcname, key); + return status; + } + msg_recv = axis2_op_get_msg_recv(op, env); + if(msg_recv == NULL) + { + msg_recv = axis2_desc_builder_load_default_msg_recv(env); + axis2_op_set_msg_recv(op, env, msg_recv); + } + if(key) + { + /* If service defines the operation, then we should not override with module level + * operation. Module operations are global. If any setting to be modified, those operations + * can be defined in service */ + if(!axutil_hash_get(svc->op_alias_map, key, AXIS2_HASH_KEY_STRING)) + { + axutil_hash_set(svc->op_alias_map, key, AXIS2_HASH_KEY_STRING, op); + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_svc_get_op_with_qname( + const axis2_svc_t * svc, + const axutil_env_t * env, + const axutil_qname_t * op_qname) +{ + axis2_op_t *op = NULL; + axis2_char_t *nc_name = NULL; + + axis2_char_t *nc_tmp = NULL; + /* This is just for the sake of comparison, + * and must not be used to change the passed value + */ + axis2_bool_t is_matched = AXIS2_FALSE; + + AXIS2_PARAM_CHECK(env->error, op_qname, NULL); + + nc_name = axutil_qname_get_localpart(op_qname, env); + nc_tmp = nc_name; + + op = axutil_hash_get(svc->op_alias_map, nc_tmp, AXIS2_HASH_KEY_STRING); + if(op) + { + return op; + } + op = axutil_hash_get(svc->op_action_map, nc_tmp, AXIS2_HASH_KEY_STRING); + if(op) + { + return op; + } + + if(*nc_tmp && svc->op_action_map) + { + axutil_hash_index_t *hi = NULL; + const void *key = NULL; + + for(hi = axutil_hash_first(svc->op_action_map, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, &key, NULL, NULL); + + nc_tmp = nc_name; + + if(key) + { + axis2_char_t *search = NULL; + axis2_bool_t match_start = AXIS2_TRUE; + axis2_char_t *search_tmp = NULL; + + search = (axis2_char_t *)key; + + if(!axutil_strchr(search, '*')) + { + if(axutil_strstr(nc_tmp, search)) + { + axis2_char_t *comp_tmp = NULL; + + comp_tmp = axutil_strstr(nc_tmp, search); + if(strlen(comp_tmp) == strlen(search)) + { + nc_tmp = (axis2_char_t *)key; + is_matched = AXIS2_TRUE; + break; + } + } + continue; + } + + if(search[0] == '*') + { + search++; + if(!*search) + { + nc_tmp = (axis2_char_t *)key; + is_matched = AXIS2_TRUE; + break; + } + else if(axutil_strchr(search, '*')) + { + continue; + } + match_start = AXIS2_FALSE; + } + while(search && *search) + { + int length = 0; + axis2_char_t *loc_tmp = NULL; + + if(search_tmp) + { + AXIS2_FREE(env->allocator, search_tmp); + search_tmp = NULL; + } + loc_tmp = axutil_strchr(search, '*'); + if(loc_tmp && *loc_tmp) + { + if(!loc_tmp[1]) + { + is_matched = AXIS2_TRUE; + break; + } + length = (int)(loc_tmp - search); + /* We are sure that the difference lies within the int range */ + search_tmp = (axis2_char_t *)(AXIS2_MALLOC(env->allocator, + sizeof(axis2_char_t) * (length + 1))); + strncpy(search_tmp, search, length); + search_tmp[length] = '\0'; + } + else if(axutil_strstr(nc_tmp, search)) + { + axis2_char_t *comp_tmp = NULL; + + comp_tmp = axutil_strstr(nc_tmp, search); + if(strlen(comp_tmp) == strlen(search)) + { + nc_tmp = (axis2_char_t *)key; + is_matched = AXIS2_TRUE; + break; + } + break; + } + else + { + break; + } + if(search_tmp && axutil_strstr(nc_tmp, search_tmp)) + { + if(match_start && !(axutil_strncmp(nc_tmp, search, length) == 0)) + { + break; + } + else if(!match_start) + { + match_start = AXIS2_TRUE; + } + } + else + { + break; + } + search += axutil_strlen(search_tmp) + 1; + nc_tmp = axutil_strstr(nc_tmp, search_tmp) + axutil_strlen(search_tmp); + } + if(search_tmp) + { + AXIS2_FREE(env->allocator, search_tmp); + search_tmp = NULL; + } + if(is_matched || !*search) + { + nc_tmp = (axis2_char_t *)key; + is_matched = AXIS2_TRUE; + break; + } + } + } + } + if(!is_matched) + { + nc_tmp = nc_name; + } + + op = axutil_hash_get(svc->op_alias_map, nc_tmp, AXIS2_HASH_KEY_STRING); + if(op) + { + return op; + } + return (axis2_op_t *)axutil_hash_get(svc->op_action_map, nc_tmp, AXIS2_HASH_KEY_STRING); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_get_rest_op_list_with_method_and_location( + const axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * method, + const axis2_char_t * location) +{ + axutil_array_list_t *op_list = NULL; + axis2_char_t *key = NULL; + axis2_char_t *loc_str = NULL; + axis2_char_t *loc_str_tmp = NULL; + axis2_char_t *rindex = NULL; + int plen; + + AXIS2_PARAM_CHECK(env->error, method, NULL); + AXIS2_PARAM_CHECK(env->error, location, NULL); + + loc_str_tmp = (axis2_char_t *)location; /* Casted to facilitate loop */ + if(loc_str_tmp[1] == '/') + { + loc_str_tmp++; + } /* ignore any '/' at the beginning */ + if(strchr(loc_str_tmp, '?')) + { + axis2_char_t *temp = NULL; + + temp = strchr(loc_str_tmp, '?'); + temp[0] = '\0'; + } /* ignore block after '?' */ + do + { + axis2_char_t *temp = NULL; + temp = strchr(loc_str_tmp, '{'); + if(temp) + { + loc_str_tmp = temp; + } + else + { + loc_str_tmp += strlen(loc_str_tmp); + break; + } + } + while(loc_str_tmp[1] && loc_str_tmp[1] == '{'); + + loc_str = (axis2_char_t *)axutil_strmemdup(location, (loc_str_tmp - location), env); + + rindex = axutil_rindex(loc_str, '/'); + if(rindex && *rindex) + { + loc_str_tmp = axutil_string_substring_ending_at(loc_str, (int)(rindex - loc_str)); + /* We are sure that the difference lies within the int range */ + } + else + { + loc_str_tmp = loc_str; + } + + plen = axutil_strlen(method) + axutil_strlen(loc_str_tmp) + 2; + key = (axis2_char_t *)(AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * plen)); + sprintf(key, "%s:%s", method, loc_str_tmp); + AXIS2_FREE(env->allocator, loc_str); + op_list = (axutil_array_list_t *)axutil_hash_get(svc->op_rest_map, key, AXIS2_HASH_KEY_STRING); + AXIS2_FREE(env->allocator, key); + return op_list; +} + +AXIS2_EXTERN axis2_op_t *AXIS2_CALL +axis2_svc_get_op_with_name( + const axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * nc_name) +{ + AXIS2_PARAM_CHECK(env->error, nc_name, NULL); + + return (axis2_op_t *)axutil_hash_get(svc->op_alias_map, nc_name, AXIS2_HASH_KEY_STRING); +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_svc_get_all_ops( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->op_alias_map; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_parent( + axis2_svc_t * svc, + const axutil_env_t * env, + axis2_svc_grp_t * svc_grp) +{ + AXIS2_PARAM_CHECK(env->error, svc_grp, AXIS2_FAILURE); + + svc->parent = svc_grp; + if(svc_grp) + { + axis2_desc_set_parent(svc->base, env, axis2_svc_grp_get_base(svc_grp, env)); + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL +axis2_svc_get_parent( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_qname( + axis2_svc_t * svc, + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + AXIS2_PARAM_CHECK(env->error, qname, AXIS2_FAILURE); + if(svc->qname) + { + axutil_qname_free(svc->qname, env); + } + + if(qname) + { + svc->qname = axutil_qname_clone((axutil_qname_t *)qname, env); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axutil_qname_t *AXIS2_CALL +axis2_svc_get_qname( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->qname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_param( + axis2_svc_t * svc, + const axutil_env_t * env, + axutil_param_t * param) +{ + axis2_char_t *paramname = NULL; + const axis2_char_t *svcname = axis2_svc_get_name(svc, env); + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE); + paramname = axutil_param_get_name(param, env); + + if(axis2_svc_is_param_locked(svc, env, axutil_param_get_name(param, env))) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked for service %s", paramname, + svcname); + return AXIS2_FAILURE; + } + return axutil_param_container_add_param(svc->param_container, env, param); +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_svc_get_param( + const axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * name) +{ + axutil_param_t *param = NULL; + AXIS2_PARAM_CHECK(env->error, name, NULL); + + param = axutil_param_container_get_param(svc->param_container, env, name); + if(!param && svc->parent) + { + param = axis2_svc_grp_get_param(svc->parent, env, name); + } + return param; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_remove_param( + const axis2_svc_t *svc, + const axutil_env_t *env, + const axis2_char_t *param_name) +{ + axis2_status_t status = AXIS2_FAILURE; + status = axutil_param_container_delete_param(svc->param_container, env, param_name); + return status; +} + + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_get_all_params( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return axutil_param_container_get_params(svc->param_container, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_svc_is_param_locked( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axis2_bool_t locked = AXIS2_FALSE; + axutil_param_t *param = NULL; + axis2_svc_grp_t *parent = NULL; + axis2_bool_t ret = AXIS2_FALSE; + + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE); + + /* Checking the locked value of parent */ + + parent = axis2_svc_get_parent(svc, env); + if(parent) + locked = axis2_svc_grp_is_param_locked(parent, env, param_name); + if(parent && locked) + { + return AXIS2_TRUE; + } + param = axis2_svc_get_param(svc, env, param_name); + if(param) + { + ret = axutil_param_is_locked(param, env); + } + return ret; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_engage_module( + axis2_svc_t * svc, + const axutil_env_t * env, + axis2_module_desc_t * module_desc, + axis2_conf_t * conf) +{ + axis2_phase_resolver_t *phase_resolver = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axis2_char_t *svcname = NULL; + + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_engage_module"); + + AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE); + + svcname = axis2_svc_get_name(svc, env); + phase_resolver = axis2_phase_resolver_create_with_config(env, conf); + if(!phase_resolver) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s", + svcname); + + return AXIS2_FAILURE; + } + + status = axis2_phase_resolver_engage_module_to_svc(phase_resolver, env, svc, module_desc); + if(status) + { + const axutil_qname_t *qname = NULL; + status = axutil_array_list_add(svc->engaged_module_list, env, module_desc); + qname = axis2_module_desc_get_qname(module_desc, env); + axis2_svc_add_module_qname(svc, env, qname); + } + + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_engage_module"); + + return status; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_svc_is_module_engaged( + axis2_svc_t * svc, + const axutil_env_t * env, + axutil_qname_t * module_qname) +{ + int i = 0, size = 0; + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_is_module_engaged"); + size = axutil_array_list_size(svc->engaged_module_list, env); + for(i = 0; i < size; i++) + { + const axutil_qname_t *module_qname_l = NULL; + axis2_module_desc_t *module_desc_l = NULL; + + module_desc_l = (axis2_module_desc_t *)axutil_array_list_get(svc->engaged_module_list, env, + i); + module_qname_l = axis2_module_desc_get_qname(module_desc_l, env); + + if(axutil_qname_equals(module_qname, env, module_qname_l)) + { + return AXIS2_TRUE; + } + } + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_is_module_engaged"); + return AXIS2_FALSE; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_get_engaged_module_list( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->engaged_module_list; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_disengage_module( + axis2_svc_t * svc, + const axutil_env_t * env, + axis2_module_desc_t * module_desc, + axis2_conf_t * conf) +{ + axis2_phase_resolver_t *phase_resolver = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axis2_char_t *svcname = NULL; + + AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE); + svcname = axis2_svc_get_name(svc, env); + + phase_resolver = axis2_phase_resolver_create_with_config(env, conf); + if(!phase_resolver) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s", + svcname); + return AXIS2_FAILURE; + } + status = axis2_phase_resolver_disengage_module_from_svc(phase_resolver, env, svc, module_desc); + + axis2_phase_resolver_free(phase_resolver, env); + + return status; +} + +/** + * Here we extract all operations defined in module.xml and built execution + * chains for them by calling axis2_phase_resolver_build_execution_chains_for_module_op() + * function. Within that function handlers of the modules defined for that + * operation are added to module operation chains appropriately. + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_module_ops( + axis2_svc_t * svc, + const axutil_env_t * env, + axis2_module_desc_t * module_desc, + axis2_conf_t * conf) +{ + axutil_hash_t *map = NULL; + axutil_hash_index_t *index = NULL; + axis2_phase_resolver_t *phase_resolver = NULL; + axis2_op_t *op_desc = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axis2_char_t *svcname = NULL; + axis2_char_t *modname = NULL; + axis2_char_t *opname = NULL; + + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_add_module_ops"); + AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE); + svcname = axis2_svc_get_name(svc, env); + modname = axutil_qname_get_localpart(axis2_module_desc_get_qname(module_desc, env), env); + map = axis2_module_desc_get_all_ops(module_desc, env); + phase_resolver = axis2_phase_resolver_create_with_config_and_svc(env, conf, svc); + if(!phase_resolver) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s", + svcname); + return AXIS2_FAILURE; + } + for(index = axutil_hash_first(map, env); index; index = axutil_hash_next(env, index)) + { + void *v = NULL; + axutil_hash_this(index, NULL, NULL, &v); + op_desc = (axis2_op_t *)v; + opname = axutil_qname_get_localpart(axis2_op_get_qname(op_desc, env), env); + status = axis2_phase_resolver_build_execution_chains_for_module_op(phase_resolver, env, + op_desc); + + if(AXIS2_SUCCESS != status) + { + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Builidng module operation %s failed for module %s", opname, modname); + return status; + } + + status = axis2_svc_add_op(svc, env, op_desc); + if(AXIS2_SUCCESS != status) + { + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Adding operation %s to service %s failed", + opname, svcname); + return status; + } + + } + + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_add_module_ops"); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_name( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + if(svc->qname) + { + return axutil_qname_get_localpart(svc->qname, env); + } + + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_name( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * axis_svc_name) +{ + AXIS2_PARAM_CHECK(env->error, axis_svc_name, AXIS2_FAILURE); + + if(svc->axis_svc_name) + { + AXIS2_FREE(env->allocator, svc->axis_svc_name); + svc->axis_svc_name = NULL; + } + svc->axis_svc_name = axutil_strdup(env, axis_svc_name); + if(!svc->axis_svc_name) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_last_update( + axis2_svc_t * svc, + const axutil_env_t * env) +{ + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN long AXIS2_CALL +axis2_svc_get_last_update( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->last_update; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_file_name( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->filename; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_file_name( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * filename) +{ + AXIS2_PARAM_CHECK(env->error, filename, AXIS2_FAILURE); + + if(svc->filename) + { + AXIS2_FREE(env->allocator, svc->filename); + svc->filename = NULL; + } + svc->filename = (axis2_char_t *)axutil_strdup(env, filename); + if(!svc->filename) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_svc_desc( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->svc_desc; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_svc_desc( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * svc_desc) +{ + AXIS2_PARAM_CHECK(env->error, svc_desc, AXIS2_FAILURE); + + if(svc->svc_desc) + { + AXIS2_FREE(env->allocator, svc->svc_desc); + svc->svc_desc = NULL; + } + svc->svc_desc = (axis2_char_t *)axutil_strdup(env, svc_desc); + if(!svc->svc_desc) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_mapping( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * mapping_key, + axis2_op_t * op_desc) +{ + AXIS2_PARAM_CHECK(env->error, mapping_key, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, op_desc, AXIS2_FAILURE); + + axutil_hash_set(svc->op_action_map, axutil_strdup(env, mapping_key), AXIS2_HASH_KEY_STRING, + op_desc); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_rest_mapping( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * method, + const axis2_char_t * location, + axis2_op_t * op_desc) +{ + + axis2_char_t *mapping_url = NULL; + int key_len = 0; + axis2_char_t* question_char = NULL; + axis2_char_t* local_location_str = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + local_location_str = (axis2_char_t *)location; /* Casted to facilitate loop */ + + /* skip the beginning '/' */ + if(*local_location_str == '/') + { + local_location_str++; + } + question_char = axutil_strchr(local_location_str, '?'); + if(question_char) + { + *question_char = '\0'; + } + + key_len = axutil_strlen(method) + axutil_strlen(local_location_str) + 2; + + mapping_url = (axis2_char_t *)(AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * key_len)); + if(!mapping_url) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create the rest mapping url"); + return AXIS2_FAILURE; + } + + sprintf(mapping_url, "%s:%s", method, local_location_str); + + status = axis2_core_utils_prepare_rest_mapping(env, mapping_url, svc->op_rest_map, op_desc); + + if(mapping_url) + { + AXIS2_FREE(env->allocator, mapping_url); + } + + /* restore the question character */ + if(question_char) + { + *question_char = '?'; + } + + return status; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_add_module_qname( + axis2_svc_t * svc, + const axutil_env_t * env, + const axutil_qname_t * module_qname) +{ + axutil_qname_t *qmodule_qname_l = NULL; + + AXIS2_PARAM_CHECK(env->error, module_qname, AXIS2_FAILURE); + + qmodule_qname_l = axutil_qname_clone((axutil_qname_t *)module_qname, env); + return axutil_array_list_add(svc->module_list, env, qmodule_qname_l); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_get_all_module_qnames( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->module_list; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_target_ns( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->target_ns; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_target_ns( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * ns) +{ + AXIS2_PARAM_CHECK(env->error, ns, AXIS2_FAILURE); + + if(svc->target_ns) + { + AXIS2_FREE(env->allocator, svc->target_ns); + svc->target_ns = NULL; + } + svc->target_ns = axutil_strdup(env, ns); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_target_ns_prefix( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->target_ns_prefix; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_target_ns_prefix( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * prefix) +{ + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + + if(svc->target_ns_prefix) + { + AXIS2_FREE(env->allocator, svc->target_ns_prefix); + svc->target_ns_prefix = NULL; + } + svc->target_ns_prefix = axutil_strdup(env, prefix); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_svc_get_ns_map( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->ns_map; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_ns_map( + axis2_svc_t * svc, + const axutil_env_t * env, + axutil_hash_t * ns_map) +{ + axutil_hash_index_t *hi = NULL; + + AXIS2_PARAM_CHECK(env->error, ns_map, AXIS2_FAILURE); + + if(svc->ns_map) + { + for(hi = axutil_hash_first(svc->ns_map, env); hi; hi = axutil_hash_next(env, hi)) + { + void *value = NULL; + void *key = NULL; + axutil_hash_this(hi, (const void **)&key, NULL, (void **)&value); + if(key) + { + AXIS2_FREE(env->allocator, key); + key = NULL; + } + if(value) + { + AXIS2_FREE(env->allocator, value); + value = NULL; + } + } + axutil_hash_free(svc->ns_map, env); + } + svc->ns_map = ns_map; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_svc_swap_mapping_table( + axis2_svc_t * svc, + const axutil_env_t * env, + axutil_hash_t * orig_table) +{ + axutil_hash_t *new_table = NULL; + axutil_hash_index_t *hi = NULL; + + AXIS2_PARAM_CHECK(env->error, orig_table, NULL); + + new_table = axutil_hash_make(env); + + for(hi = axutil_hash_first(orig_table, env); env; hi = axutil_hash_next(env, hi)) + { + void *value = NULL; + void *key = NULL; + + axutil_hash_this(hi, (const void **)&key, NULL, (void **)&value); + axutil_hash_set(new_table, value, AXIS2_HASH_KEY_STRING, key); + } + return new_table; +} + +AXIS2_EXTERN void *AXIS2_CALL +axis2_svc_get_impl_class( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->impl_class; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_impl_class( + axis2_svc_t * svc, + const axutil_env_t * env, + void *impl_class) +{ + svc->impl_class = impl_class; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_svc_get_param_container( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->param_container; +} + +AXIS2_EXTERN axis2_flow_container_t *AXIS2_CALL +axis2_svc_get_flow_container( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->flow_container; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_svc_wsdl_path( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->wsdl_path; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_svc_wsdl_path( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * wsdl_path) +{ + AXIS2_PARAM_CHECK(env->error, wsdl_path, AXIS2_FAILURE); + svc->wsdl_path = (axis2_char_t *)axutil_strdup(env, wsdl_path); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_get_svc_folder_path( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->folder_path; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_set_svc_folder_path( + axis2_svc_t * svc, + const axutil_env_t * env, + const axis2_char_t * folder_path) +{ + AXIS2_PARAM_CHECK(env->error, folder_path, AXIS2_FAILURE); + svc->folder_path = (axis2_char_t *)axutil_strdup(env, folder_path); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_svc_get_base( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->base; +} + +AXIS2_EXTERN axutil_thread_mutex_t * AXIS2_CALL +axis2_svc_get_mutex( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->mutex; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_svc_get_rest_map( + const axis2_svc_t * svc, + const axutil_env_t * env) +{ + return svc->op_rest_map; +} + diff --git a/src/core/description/svc_grp.c b/src/core/description/svc_grp.c new file mode 100644 index 0000000..157b77a --- /dev/null +++ b/src/core/description/svc_grp.c @@ -0,0 +1,600 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_svc_grp.h> +#include <axis2_conf_ctx.h> + +struct axis2_svc_grp +{ + + /** service group name */ + axis2_char_t *svc_grp_name; + + /** map of services */ + axutil_hash_t *svcs; + + /** to store service group modules QNames */ + axutil_array_list_t *module_qname_list; + + /** to store module ref at deploy time parsing */ + axis2_conf_t *parent; + + /** list of module references */ + axutil_array_list_t *module_list; + + /** parameter container to hold service related parameters */ + axutil_param_container_t *param_container; + + /** base description struct */ + axis2_desc_t *base; +}; + +AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL +axis2_svc_grp_create( + const axutil_env_t * env) +{ + axis2_svc_grp_t *svc_grp = NULL; + svc_grp = (axis2_svc_grp_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_grp_t)); + + if(!svc_grp) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); + return NULL; + } + + svc_grp->param_container = NULL; + svc_grp->module_qname_list = NULL; + svc_grp->svcs = NULL; + svc_grp->parent = NULL; + svc_grp->svc_grp_name = NULL; + svc_grp->module_list = NULL; + svc_grp->base = NULL; + + svc_grp->param_container = axutil_param_container_create(env); + if(!svc_grp->param_container) + { + axis2_svc_grp_free(svc_grp, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating parameter container failed"); + return NULL; + } + + svc_grp->module_qname_list = axutil_array_list_create(env, 20); + if(!svc_grp->module_qname_list) + { + axis2_svc_grp_free(svc_grp, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating module qnames list failed"); + return NULL; + } + + svc_grp->module_list = axutil_array_list_create(env, 0); + if(!svc_grp->module_list) + { + axis2_svc_grp_free(svc_grp, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating modules list failed"); + return NULL; + } + + svc_grp->svcs = axutil_hash_make(env); + if(!svc_grp->svcs) + { + axis2_svc_grp_free(svc_grp, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating services map failed"); + return NULL; + } + + svc_grp->base = axis2_desc_create(env); + if(!svc_grp->base) + { + axis2_svc_grp_free(svc_grp, env); + return NULL; + } + + return svc_grp; +} + +AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL +axis2_svc_grp_create_with_conf( + const axutil_env_t * env, + axis2_conf_t * conf) +{ + axis2_svc_grp_t *svc_grp = NULL; + + AXIS2_PARAM_CHECK(env->error, conf, NULL); + + svc_grp = (axis2_svc_grp_t *)axis2_svc_grp_create(env); + if(svc_grp) + svc_grp->parent = conf; + if(conf) + { + axis2_desc_set_parent(svc_grp->base, env, axis2_conf_get_base(conf, env)); + } + + return svc_grp; + +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_svc_grp_free( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + if(svc_grp->param_container) + { + axutil_param_container_free(svc_grp->param_container, env); + } + + if(svc_grp->svc_grp_name) + { + AXIS2_FREE(env->allocator, svc_grp->svc_grp_name); + } + + if(svc_grp->svcs) + { + /* services are freed by arch_file_data */ + axutil_hash_free(svc_grp->svcs, env); + } + + if(svc_grp->module_qname_list) + { + axutil_array_list_free(svc_grp->module_qname_list, env); + } + + if(svc_grp->module_list) + { + axutil_array_list_free(svc_grp->module_list, env); + } + + if(svc_grp->base) + { + axis2_desc_free(svc_grp->base, env); + } + + if(svc_grp) + { + AXIS2_FREE(env->allocator, svc_grp); + } + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_set_name( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axis2_char_t * name) +{ + if(svc_grp->svc_grp_name) + AXIS2_FREE(env->allocator, svc_grp->svc_grp_name); + svc_grp->svc_grp_name = axutil_strdup(env, name); + if(!svc_grp->svc_grp_name) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No Memory"); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axis2_svc_grp_get_name( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->svc_grp_name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_add_svc( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + axis2_svc_t * svc) +{ + axis2_status_t status = AXIS2_FAILURE; + const axutil_qname_t *svc_qname = NULL; + axis2_char_t *svc_name = NULL; + + AXIS2_PARAM_CHECK(env->error, svc, AXIS2_FAILURE); + + if(!svc_grp->svcs) + { + svc_grp->svcs = axutil_hash_make(env); + if(!svc_grp->svcs) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating services list failed"); + return AXIS2_FAILURE; + } + } + + svc_qname = axis2_svc_get_qname(svc, env); + svc_name = axutil_qname_to_string((axutil_qname_t *)svc_qname, env); + axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, svc); + + status = axis2_svc_set_last_update(svc, env); + + if(AXIS2_SUCCESS != status) + { + /* remove the previously added service */ + axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting last update failed for service %s", + svc_name); + + return status; + } + + status = axis2_svc_set_parent(svc, env, svc_grp); + if(AXIS2_SUCCESS != status) + { + /* remove the previously added service */ + axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting parent failed for service %s", svc_name); + + return status; + } + + return status; +} + +AXIS2_EXTERN axis2_svc_t *AXIS2_CALL +axis2_svc_grp_get_svc( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * qname) +{ + axis2_char_t *name = NULL; + + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + name = axutil_qname_to_string((axutil_qname_t *)qname, env); + return (axis2_svc_t *)axutil_hash_get(svc_grp->svcs, name, AXIS2_HASH_KEY_STRING); +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axis2_svc_grp_get_all_svcs( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->svcs; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_remove_svc( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * svc_qname) +{ + axis2_svc_t *svc = NULL; + axis2_char_t *svc_name = NULL; + + AXIS2_PARAM_CHECK(env->error, svc_name, AXIS2_FAILURE); + + svc = axis2_svc_grp_get_svc(svc_grp, env, svc_qname); + + svc_name = axutil_qname_to_string((axutil_qname_t *)svc_qname, env); + axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_add_param( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + axutil_param_t * param) +{ + const axis2_char_t *svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); + axis2_char_t *param_name = axutil_param_get_name(param, env); + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE); + if(axis2_svc_grp_is_param_locked(svc_grp, env, param_name)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked for service group %s", + param_name, svc_grp_name); + return AXIS2_FAILURE; + } + return axutil_param_container_add_param(svc_grp->param_container, env, param); +} + +AXIS2_EXTERN axutil_param_t *AXIS2_CALL +axis2_svc_grp_get_param( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axis2_char_t * name) +{ + axutil_param_t *param = NULL; + AXIS2_PARAM_CHECK(env->error, name, NULL); + + param = axutil_param_container_get_param(svc_grp->param_container, env, name); + if(!param && svc_grp->parent) + { + param = axis2_conf_get_param(svc_grp->parent, env, name); + } + return param; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_remove_param( + const axis2_svc_grp_t *svc_grp, + const axutil_env_t *env, + const axis2_char_t *param_name) +{ + axis2_status_t status = AXIS2_FAILURE; + status = axutil_param_container_delete_param(svc_grp->param_container, env, param_name); + return status; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_grp_get_all_params( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return axutil_param_container_get_params(svc_grp->param_container, env); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_svc_grp_is_param_locked( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + axis2_bool_t locked = AXIS2_FALSE; + axis2_conf_t *parent = NULL; + axutil_param_t *param = NULL; + axis2_bool_t ret = AXIS2_FALSE; + + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE); + + parent = axis2_svc_grp_get_parent(svc_grp, env); + /* Checking the locked value of parent */ + if(parent) + { + locked = axis2_conf_is_param_locked(parent, env, param_name); + } + if(locked) + { + ret = AXIS2_TRUE; + } + param = axis2_svc_grp_get_param(svc_grp, env, param_name); + if(param && axutil_param_is_locked(param, env)) + { + ret = AXIS2_TRUE; + } + else + { + ret = AXIS2_FALSE; + } + return ret; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_add_module_qname( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * module_qname) +{ + return axutil_array_list_add(svc_grp->module_qname_list, env, module_qname); +} + +AXIS2_EXTERN axis2_conf_t *AXIS2_CALL +axis2_svc_grp_get_parent( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->parent; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_set_parent( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + axis2_conf_t * parent) +{ + AXIS2_PARAM_CHECK(env->error, parent, AXIS2_FAILURE); + + if(svc_grp->parent) + axis2_conf_free(svc_grp->parent, env); + svc_grp->parent = parent; + if(parent) + { + axis2_desc_set_parent(svc_grp->base, env, axis2_conf_get_base(parent, env)); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_engage_module( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * module_name) +{ + int i = 0; + axis2_status_t status = AXIS2_FAILURE; + axutil_qname_t *modu = NULL; + axis2_char_t *modu_local = NULL; + axis2_char_t *module_name_local = NULL; + axutil_hash_t *svc_map = NULL; + axis2_phase_resolver_t *phase_resolver = NULL; + axis2_module_desc_t *module = NULL; + const axis2_char_t *svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); + + int size = 0; + + AXIS2_PARAM_CHECK(env->error, module_name, AXIS2_FAILURE); + + size = axutil_array_list_size(svc_grp->module_qname_list, env); + for(i = 0; size; i++) + { + modu = axutil_array_list_get(svc_grp->module_qname_list, env, i); + modu_local = axutil_qname_get_localpart(modu, env); + module_name_local = axutil_qname_get_localpart(module_name, env); + if(!axutil_strcmp(modu_local, module_name_local)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC_GRP, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Module %s is already engaged to service group %s", module_name_local, svc_grp_name); + + return AXIS2_FAILURE; + } + } + + svc_map = axis2_svc_grp_get_all_svcs(svc_grp, env); + if(!svc_map) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service map not found for service group %s", + svc_grp_name); + + return AXIS2_FAILURE; + } + + phase_resolver = axis2_phase_resolver_create_with_config(env, svc_grp->parent); + + if(!phase_resolver) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Creating phase resolver failed for service group %s", svc_grp_name); + + return AXIS2_FAILURE; + } + + module = axis2_conf_get_module(svc_grp->parent, env, module_name); + if(module) + { + axis2_svc_t *axis_svc = NULL; + axutil_hash_index_t *index = NULL; + + index = axutil_hash_first(svc_map, env); + while(index) + { + const axis2_char_t *svc_name = NULL; + void *v = NULL; + /* engage in per each service */ + axutil_hash_this(index, NULL, NULL, &v); + axis_svc = (axis2_svc_t *)v; + svc_name = axis2_svc_get_name(axis_svc, env); + status = axis2_phase_resolver_engage_module_to_svc(phase_resolver, env, axis_svc, + module); + + if(!status) + { + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Engaging module %s to service %s failed", + module_name_local, svc_name); + + return status; + } + + index = axutil_hash_next(env, index); + } + } + + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + + return axis2_svc_grp_add_module_qname(svc_grp, env, module_name); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_grp_get_all_module_qnames( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->module_qname_list; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_svc_grp_add_module_ref( + axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * moduleref) +{ + const axis2_char_t *svc_grp_name = NULL; + + AXIS2_PARAM_CHECK(env->error, moduleref, AXIS2_FAILURE); + svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); + + if(!svc_grp->module_list) + { + svc_grp->module_list = axutil_array_list_create(env, 0); + if(!svc_grp->module_list) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Creating module list failed for service group %s", svc_grp_name); + return AXIS2_FAILURE; + } + } + + return axutil_array_list_add(svc_grp->module_list, env, moduleref); +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axis2_svc_grp_get_all_module_refs( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->module_list; +} + +AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL +axis2_svc_grp_get_svc_grp_ctx( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + axis2_conf_ctx_t * parent) +{ + axis2_svc_grp_ctx_t *svc_grp_ctx = NULL; + const axis2_char_t *svc_grp_name = NULL; + + AXIS2_PARAM_CHECK(env->error, parent, NULL); + svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); + + svc_grp_ctx = axis2_svc_grp_ctx_create(env, (axis2_svc_grp_t *)svc_grp, parent); + if(!svc_grp_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Creating service group context failed for service group %s", svc_grp_name); + return NULL; + } + + return svc_grp_ctx; +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_svc_grp_get_param_container( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->param_container; +} + +AXIS2_EXTERN axis2_desc_t *AXIS2_CALL +axis2_svc_grp_get_base( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env) +{ + return svc_grp->base; +} + diff --git a/src/core/description/transport_in_desc.c b/src/core/description/transport_in_desc.c new file mode 100644 index 0000000..85885b6 --- /dev/null +++ b/src/core/description/transport_in_desc.c @@ -0,0 +1,305 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_transport_in_desc.h> +#include <axis2_transport_receiver.h> + +struct axis2_transport_in_desc +{ + axis2_flow_t *in_flow; + axis2_flow_t *fault_in_flow; + AXIS2_TRANSPORT_ENUMS trans_enum; + + /** + * transport receiver will have a shallow copy, but will be freed by + * free function. + */ + axis2_transport_receiver_t *recv; + axis2_phase_t *in_phase; + axis2_phase_t *fault_phase; + + /** parameter container to hold transport in related parameters */ + axutil_param_container_t *param_container; +}; + +AXIS2_EXTERN axis2_transport_in_desc_t *AXIS2_CALL +axis2_transport_in_desc_create( + const axutil_env_t * env, + const AXIS2_TRANSPORT_ENUMS trans_enum) +{ + axis2_transport_in_desc_t *transport_in = NULL; + + transport_in = (axis2_transport_in_desc_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_transport_in_desc_t)); + + if(!transport_in) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + transport_in->trans_enum = trans_enum; + transport_in->in_phase = NULL; + transport_in->fault_phase = NULL; + transport_in->in_flow = NULL; + transport_in->fault_in_flow = NULL; + transport_in->recv = NULL; + transport_in->param_container = NULL; + + transport_in->param_container = axutil_param_container_create(env); + if(!transport_in->param_container) + { + axis2_transport_in_desc_free(transport_in, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + return transport_in; +} + +void AXIS2_CALL +axis2_transport_in_desc_free( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + if(transport_in->recv) + { + axis2_transport_receiver_free(transport_in->recv, env); + } + + if(transport_in->param_container) + { + axutil_param_container_free(transport_in->param_container, env); + } + + if(transport_in->in_flow) + { + axis2_flow_free(transport_in->in_flow, env); + } + + if(transport_in->fault_in_flow) + { + axis2_flow_free(transport_in->fault_in_flow, env); + } + + if(transport_in->in_phase) + { + axis2_phase_free(transport_in->in_phase, env); + } + + if(transport_in->fault_phase) + { + axis2_phase_free(transport_in->fault_phase, env); + } + + AXIS2_FREE(env->allocator, transport_in); + + return; +} + +void AXIS2_CALL +axis2_transport_in_desc_free_void_arg( + void *transport_in, + const axutil_env_t * env) +{ + axis2_transport_in_desc_t *transport_in_l = NULL; + + transport_in_l = (axis2_transport_in_desc_t *)transport_in; + axis2_transport_in_desc_free(transport_in_l, env); + return; +} + +AXIS2_TRANSPORT_ENUMS AXIS2_CALL +axis2_transport_in_desc_get_enum( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->trans_enum; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_enum( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + const AXIS2_TRANSPORT_ENUMS trans_enum) +{ + transport_in->trans_enum = trans_enum; + return AXIS2_SUCCESS; +} + +axis2_flow_t *AXIS2_CALL +axis2_transport_in_desc_get_in_flow( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->in_flow; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_in_flow( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + axis2_flow_t * in_flow) +{ + AXIS2_PARAM_CHECK(env->error, in_flow, AXIS2_FAILURE); + + if(transport_in->in_flow) + { + axis2_flow_free(transport_in->in_flow, env); + } + transport_in->in_flow = in_flow; + return AXIS2_SUCCESS; +} + +axis2_flow_t *AXIS2_CALL +axis2_transport_in_desc_get_fault_in_flow( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->fault_in_flow; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_fault_in_flow( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + axis2_flow_t * fault_in_flow) +{ + AXIS2_PARAM_CHECK(env->error, fault_in_flow, AXIS2_FAILURE); + + if(transport_in->fault_in_flow) + { + axis2_flow_free(transport_in->fault_in_flow, env); + } + transport_in->fault_in_flow = fault_in_flow; + return AXIS2_SUCCESS; +} + +axis2_transport_receiver_t *AXIS2_CALL +axis2_transport_in_desc_get_recv( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->recv; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_recv( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + axis2_transport_receiver_t * recv) +{ + AXIS2_PARAM_CHECK(env->error, recv, AXIS2_FAILURE); + + if(transport_in->recv) + { + axis2_transport_receiver_free(transport_in->recv, env); + } + + transport_in->recv = recv; + return AXIS2_SUCCESS; +} + +axis2_phase_t *AXIS2_CALL +axis2_transport_in_desc_get_in_phase( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->in_phase; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_in_phase( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + axis2_phase_t * in_phase) +{ + AXIS2_PARAM_CHECK(env->error, in_phase, AXIS2_FAILURE); + + if(transport_in->in_phase) + { + axis2_phase_free(transport_in->in_phase, env); + } + transport_in->in_phase = in_phase; + return AXIS2_SUCCESS; +} + +axis2_phase_t *AXIS2_CALL +axis2_transport_in_desc_get_fault_phase( + const axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env) +{ + return transport_in->fault_phase; +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_set_fault_phase( + axis2_transport_in_desc_t * transport_in, + const axutil_env_t * env, + axis2_phase_t * fault_phase) +{ + AXIS2_PARAM_CHECK(env->error, fault_phase, AXIS2_FAILURE); + + if(transport_in->fault_phase) + { + axis2_phase_free(transport_in->fault_phase, env); + } + transport_in->fault_phase = fault_phase; + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +axis2_transport_in_desc_add_param( + axis2_transport_in_desc_t * transport_in_desc, + const axutil_env_t * env, + axutil_param_t * param) +{ + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE); + + return axutil_param_container_add_param(transport_in_desc-> param_container, env, param); +} + +axutil_param_t *AXIS2_CALL +axis2_transport_in_desc_get_param( + const axis2_transport_in_desc_t * transport_in_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + return axutil_param_container_get_param(transport_in_desc->param_container, env, param_name); +} + +axis2_bool_t AXIS2_CALL +axis2_transport_in_desc_is_param_locked( + axis2_transport_in_desc_t * transport_in_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FAILURE); + + return axutil_param_container_is_param_locked(transport_in_desc-> param_container, env, + param_name); +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_transport_in_desc_param_container( + const axis2_transport_in_desc_t * transport_in_desc, + const axutil_env_t * env) +{ + return transport_in_desc->param_container; +} + diff --git a/src/core/description/transport_out_desc.c b/src/core/description/transport_out_desc.c new file mode 100644 index 0000000..ec69f56 --- /dev/null +++ b/src/core/description/transport_out_desc.c @@ -0,0 +1,299 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_transport_out_desc.h> + +struct axis2_transport_out_desc +{ + axis2_flow_t *out_flow; + axis2_flow_t *fault_out_flow; + AXIS2_TRANSPORT_ENUMS trans_enum; + axis2_transport_sender_t *sender; + axis2_phase_t *out_phase; + axis2_phase_t *fault_phase; + + /** parameter container that holds parameter */ + axutil_param_container_t *param_container; +}; + +AXIS2_EXTERN axis2_transport_out_desc_t *AXIS2_CALL +axis2_transport_out_desc_create( + const axutil_env_t * env, + const AXIS2_TRANSPORT_ENUMS trans_enum) +{ + axis2_transport_out_desc_t *transport_out = NULL; + + transport_out = (axis2_transport_out_desc_t *)AXIS2_MALLOC(env-> allocator, + sizeof(axis2_transport_out_desc_t)); + + if(!transport_out) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + transport_out->trans_enum = trans_enum; + transport_out->out_phase = NULL; + transport_out->fault_phase = NULL; + transport_out->out_flow = NULL; + transport_out->fault_out_flow = NULL; + transport_out->sender = NULL; + transport_out->param_container = NULL; + + transport_out->param_container = axutil_param_container_create(env); + if(!transport_out->param_container) + { + axis2_transport_out_desc_free(transport_out, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + return transport_out; +} + +void AXIS2_CALL +axis2_transport_out_desc_free( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + if(transport_out->sender) + { + AXIS2_TRANSPORT_SENDER_FREE(transport_out->sender, env); + } + + if(transport_out->param_container) + { + axutil_param_container_free(transport_out->param_container, env); + } + + if(transport_out->out_flow) + { + axis2_flow_free(transport_out->out_flow, env); + } + + if(transport_out->fault_out_flow) + { + axis2_flow_free(transport_out->fault_out_flow, env); + } + + if(transport_out->out_phase) + { + axis2_phase_free(transport_out->out_phase, env); + } + + if(transport_out->fault_phase) + { + axis2_phase_free(transport_out->fault_phase, env); + } + + AXIS2_FREE(env->allocator, transport_out); + + return; +} + +void AXIS2_CALL +axis2_transport_out_desc_free_void_arg( + void *transport_out, + const axutil_env_t * env) +{ + axis2_transport_out_desc_t *transport_out_l = NULL; + + transport_out_l = (axis2_transport_out_desc_t *)transport_out; + axis2_transport_out_desc_free(transport_out_l, env); + return; +} + +AXIS2_TRANSPORT_ENUMS AXIS2_CALL +axis2_transport_out_desc_get_enum( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->trans_enum; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_enum( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + const AXIS2_TRANSPORT_ENUMS trans_enum) +{ + transport_out->trans_enum = trans_enum; + return AXIS2_SUCCESS; +} + +axis2_flow_t *AXIS2_CALL +axis2_transport_out_desc_get_out_flow( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->out_flow; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_out_flow( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + axis2_flow_t * out_flow) +{ + AXIS2_PARAM_CHECK(env->error, out_flow, AXIS2_FAILURE); + + if(transport_out->out_flow) + { + axis2_flow_free(transport_out->out_flow, env); + } + transport_out->out_flow = out_flow; + return AXIS2_SUCCESS; +} + +axis2_flow_t *AXIS2_CALL +axis2_transport_out_desc_get_fault_out_flow( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->fault_out_flow; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_fault_out_flow( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + axis2_flow_t * fault_out_flow) +{ + AXIS2_PARAM_CHECK(env->error, fault_out_flow, AXIS2_FAILURE); + + if(transport_out->fault_out_flow) + { + axis2_flow_free(transport_out->fault_out_flow, env); + } + transport_out->fault_out_flow = fault_out_flow; + return AXIS2_SUCCESS; +} + +axis2_transport_sender_t *AXIS2_CALL +axis2_transport_out_desc_get_sender( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->sender; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_sender( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + axis2_transport_sender_t * sender) +{ + AXIS2_PARAM_CHECK(env->error, sender, AXIS2_FAILURE); + + if(transport_out->sender) + { + AXIS2_TRANSPORT_SENDER_FREE(transport_out->sender, env); + } + + transport_out->sender = sender; + return AXIS2_SUCCESS; +} + +axis2_phase_t *AXIS2_CALL +axis2_transport_out_desc_get_out_phase( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->out_phase; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_out_phase( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + axis2_phase_t * out_phase) +{ + AXIS2_PARAM_CHECK(env->error, out_phase, AXIS2_FAILURE); + + if(transport_out->out_phase) + { + axis2_phase_free(transport_out->out_phase, env); + } + transport_out->out_phase = out_phase; + return AXIS2_SUCCESS; +} + +axis2_phase_t *AXIS2_CALL +axis2_transport_out_desc_get_fault_phase( + const axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env) +{ + return transport_out->fault_phase; +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_set_fault_phase( + axis2_transport_out_desc_t * transport_out, + const axutil_env_t * env, + axis2_phase_t * fault_phase) +{ + AXIS2_PARAM_CHECK(env->error, fault_phase, AXIS2_FAILURE); + + if(transport_out->fault_phase) + { + axis2_phase_free(transport_out->fault_phase, env); + } + transport_out->fault_phase = fault_phase; + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +axis2_transport_out_desc_add_param( + axis2_transport_out_desc_t * transport_out_desc, + const axutil_env_t * env, + axutil_param_t * param) +{ + AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE); + + return axutil_param_container_add_param(transport_out_desc-> param_container, env, param); +} + +axutil_param_t *AXIS2_CALL +axis2_transport_out_desc_get_param( + const axis2_transport_out_desc_t * transport_out_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + return axutil_param_container_get_param(transport_out_desc->param_container, env, param_name); +} + +axis2_bool_t AXIS2_CALL +axis2_transport_out_desc_is_param_locked( + axis2_transport_out_desc_t * transport_out_desc, + const axutil_env_t * env, + const axis2_char_t * param_name) +{ + AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FAILURE); + + return axutil_param_container_is_param_locked(transport_out_desc-> param_container, env, + param_name); +} + +AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL +axis2_transport_out_desc_param_container( + const axis2_transport_out_desc_t * transport_out_desc, + const axutil_env_t * env) +{ + return transport_out_desc->param_container; +} + |