static rp_header_t *AXIS2_CALL rp_signed_encrypted_parts_builder_build_header( axiom_element_t *element, const axutil_env_t *env) { rp_header_t *header = NULL; axis2_char_t *name = NULL; axis2_char_t *nspace = NULL; name = axiom_element_get_attribute_value_by_name(element, env, RP_NAME); nspace = axiom_element_get_attribute_value_by_name(element, env, RP_NAMESPACE); if (!nspace) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Header assertion should have namespace associated with it."); return NULL; } header = rp_header_create(env); if (!header) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot create rp_header structure. Insufficient memory."); return NULL; } if (name) { rp_header_set_name(header, env, name); } rp_header_set_namespace(header, env, nspace); return header; }
AXIS2_EXTERN neethi_assertion_t *AXIS2_CALL rp_https_token_builder_build( const axutil_env_t *env, axiom_node_t *node, axiom_element_t *element) { rp_https_token_t *https_token = NULL; neethi_assertion_t *assertion = NULL; axis2_char_t *value = NULL; https_token = rp_https_token_create(env); value = axiom_element_get_attribute_value_by_name(element, env, RP_REQUIRE_CLIENT_CERTIFICATE); if(value) { if(axutil_strcmp(value, "true") == 0) { rp_https_token_set_require_client_certificate(https_token, env, AXIS2_TRUE); } else if(axutil_strcmp(value, "false") == 0) { rp_https_token_set_require_client_certificate(https_token, env, AXIS2_FALSE); } else return NULL; } assertion = neethi_assertion_create_with_args(env, (AXIS2_FREE_VOID_ARG)rp_https_token_free, https_token, ASSERTION_TYPE_HTTPS_TOKEN); return assertion; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL oxs_token_get_c14n_method( const axutil_env_t *env, axiom_node_t *c14n_mtd_node) { axis2_char_t *c14n_mtd = NULL; axiom_element_t *c14n_mtd_ele = NULL; if(!c14n_mtd_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]CanonicalizationMethod node is not valid."); return NULL; } c14n_mtd_ele = axiom_node_get_data_element(c14n_mtd_node, env); if (!c14n_mtd_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error retrieving c14n method element."); return NULL; } c14n_mtd = axiom_element_get_attribute_value_by_name(c14n_mtd_ele, env, OXS_ATTR_ALGORITHM); if((!c14n_mtd) ||(!axutil_strcmp("", c14n_mtd))) { return NULL; } return c14n_mtd; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL oxs_token_get_transform( const axutil_env_t *env, axiom_node_t *transform_node) { axis2_char_t *transform = NULL; axiom_element_t *transform_ele = NULL; if(!transform_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error retrieving digest method node."); return NULL; } transform_ele = axiom_node_get_data_element(transform_node, env); if (!transform_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error retrieving digest method element."); return NULL; } transform = axiom_element_get_attribute_value_by_name(transform_ele, env, OXS_ATTR_ALGORITHM); if((!transform) ||(!axutil_strcmp("", transform))) { return NULL; } return transform; }
axis2_status_t AXIS2_CALL adb_data_type0_deserialize_obj( adb_data_type0_t* _data_type0, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; status = AXIS2_FAILURE; if(parent) { axis2_char_t *attrib_text = NULL; attrib_text = axiom_element_get_attribute_value_by_name(axiom_node_get_data_element(parent, env), env, "nil"); if (attrib_text != NULL && !axutil_strcasecmp(attrib_text, "true")) { /* but the wsdl says that, this is non nillable */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element data_type0"); status = AXIS2_FAILURE; } else { axiom_node_t *text_node = NULL; axiom_text_t *text_element = NULL; text_node = axiom_node_get_first_child(parent, env); if (text_node && axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) text_element = (axiom_text_t*)axiom_node_get_data_element(text_node, env); text_value = ""; if(text_element && axiom_text_get_value(text_element, env)) { text_value = (axis2_char_t*)axiom_text_get_value(text_element, env); } status = adb_data_type0_deserialize_from_string(_data_type0, env, text_value, parent); } } return status; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL oxs_token_get_embedded_id( const axutil_env_t *env, axiom_node_t *embedded_node) { axis2_char_t *embedded = NULL; axiom_element_t *embedded_ele = NULL; embedded_ele = axiom_node_get_data_element(embedded_node, env); if(!embedded_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error retrieving embedded element."); return NULL; } embedded = axiom_element_get_attribute_value_by_name(embedded_ele, env, OXS_ATTR_ID); return embedded; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL oxs_token_get_reference_value_type( const axutil_env_t *env, axiom_node_t *ref_node) { axis2_char_t *val_type = NULL; axiom_element_t *reference_ele = NULL; reference_ele = axiom_node_get_data_element(ref_node, env); if (!reference_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"[rampart]Error retrieving data reference element."); return NULL; } val_type = axiom_element_get_attribute_value_by_name(reference_ele, env, OXS_ATTR_VALUE_TYPE); return val_type; }
/** Get the href reference string from node's xlink:href attribute. * @param env * @param node * @return the href string */ axis2_char_t *rp_get_ref_href( const axutil_env_t *env, axiom_node_t *node) { axis2_char_t *a_val = NULL; if (NULL != node && axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { axiom_element_t *el2 = (axiom_element_t *) axiom_node_get_data_element (node, env); a_val = axiom_element_get_attribute_value_by_name(el2, env, "xlink:href"); } return a_val; }
axis2_status_t AXIS2_CALL adb_lang_type0_deserialize_from_string( adb_lang_type0_t* _lang_type0, const axutil_env_t *env, const axis2_char_t *node_value, axiom_node_t *parent) { axis2_status_t status = AXIS2_SUCCESS; /* * axis2_qname_t *qname = NULL; * axiom_attribute_t *the_attri = NULL; * * qname = axutil_qname_create(env, "type", "http://www.w3.org/2001/XMLSchema-instance", "xsi"); * the_attri = axiom_element_get_attribute(current_element, env, qname); */ /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */ axiom_attribute_t *the_attri = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; void *element = NULL; axiom_element_t *current_element = NULL; current_element = (axiom_element_t*)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(current_element, env); attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(strstr((axis2_char_t*)key, "lang|http://www.w3.org/XML/1998/namespace")) { the_attri = (axiom_attribute_t*)val; break; } } } if(the_attri) { attrib_text = axiom_attribute_get_value(the_attri, env); } else { /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "type"); } if(attrib_text) { /* skipping the namespace prefix */ axis2_char_t *temp_attrib = NULL; temp_attrib = strchr(attrib_text, ':'); if(temp_attrib) { /* take the string after the ':' character */ attrib_text = temp_attrib + 1; } } if(!attrib_text) { /* nothing is here, reset things */ status = adb_lang_type0_reset_members(_lang_type0, env); } else { status = adb_lang_type0_set_language(_lang_type0, env, attrib_text); } return status; }
axis2_status_t AXIS2_CALL adb_SnakeException_deserialize( adb_SnakeException_t* _SnakeException, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _SnakeException, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for SnakeException : " "NULL elemenet can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building message element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "message", NULL, NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("message", axiom_element_get_localname(current_element, env))))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("message", axiom_element_get_localname(current_element, env)))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_SnakeException_set_message(_SnakeException, env, text_value); } else { /* * axis2_qname_t *qname = NULL; * axiom_attribute_t *the_attri = NULL; * * qname = axutil_qname_create(env, "nil", "http://www.w3.org/2001/XMLSchema-instance", "xsi"); * the_attri = axiom_element_get_attribute(current_element, env, qname); */ /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */ axiom_attribute_t *the_attri = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; attribute_hash = axiom_element_get_all_attributes(current_element, env); attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(strstr((axis2_char_t*)key, "nil|http://www.w3.org/2001/XMLSchema-instance")) { the_attri = (axiom_attribute_t*)val; break; } } } if(the_attri) { attrib_text = axiom_attribute_get_value(the_attri, env); } else { /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "nil"); } if(attrib_text && 0 == axutil_strcmp(attrib_text, "1")) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element message"); status = AXIS2_FAILURE; } else { /* after all, we found this is a empty string */ status = adb_SnakeException_set_message(_SnakeException, env, ""); } } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for message "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL adb_service_type0_deserialize_obj( adb_service_type0_t* _service_type0, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axiom_attribute_t *parent_attri = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _service_type0, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for service_type0 : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(parent_element, env); /* * building label element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "label", "http://www.daisy.org/ns/daisy-online/", NULL); if (adb_label_type0_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_label_type0"); status = adb_label_type0_deserialize((adb_label_type0_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element label"); } else { status = adb_service_type0_set_label(_service_type0, env, (adb_label_type0_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for label "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "id")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "id", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "id"); } if(attrib_text != NULL) { adb_service_type0_set_id(_service_type0, env, attrib_text); } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute id missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL adb_audio_type0_deserialize_obj( adb_audio_type0_t* _audio_type0, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axiom_attribute_t *parent_attri = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _audio_type0, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for audio_type0 : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(parent_element, env); parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "uri")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "uri", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "uri"); } if(attrib_text != NULL) { adb_audio_type0_set_uri(_audio_type0, env, axutil_uri_parse_string(env, attrib_text)); } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute uri missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "rangeBegin")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "rangeBegin", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "rangeBegin"); } if(attrib_text != NULL) { adb_audio_type0_set_rangeBegin(_audio_type0, env, axutil_strtol(attrib_text, (char**)NULL, 0)); } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "rangeEnd")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "rangeEnd", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "rangeEnd"); } if(attrib_text != NULL) { adb_audio_type0_set_rangeEnd(_audio_type0, env, axutil_strtol(attrib_text, (char**)NULL, 0)); } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "size")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "size", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "size"); } if(attrib_text != NULL) { adb_audio_type0_set_size(_audio_type0, env, axutil_strtol(attrib_text, (char**)NULL, 0)); } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t wsclient_set_attachment (const axutil_env_t *env, axiom_node_t *node, axis2_char_t *base_dir, int is_mtom_enabled) { axiom_node_t *child_node = NULL; axiom_element_t *element; if (!node || !env) return AXIS2_FAILURE; if (axiom_node_get_node_type (node, env) == AXIOM_ELEMENT) { axis2_char_t *local_name; axiom_namespace_t *ns; axis2_char_t *ns_uri; element = (axiom_element_t *) axiom_node_get_data_element (node, env); local_name = axiom_element_get_localname (element, env); if (local_name) { if (!strcmp (local_name, "Include")) { ns = axiom_element_get_namespace(element, env, node); if (ns && (ns_uri = axiom_namespace_get_uri (ns, env)) && (!strcmp (ns_uri, "http://www.w3.org/2004/08/xop/include"))) { axis2_char_t *file_path; axiom_data_handler_t *data_handler; axiom_text_t *data_text; axiom_node_t *data_node; axiom_node_t *parent; axutil_uri_t *file_uri = NULL; axutil_uri_t *base_uri = NULL; axutil_uri_t *real_uri = NULL; axis2_char_t *real_path = NULL; parent = axiom_node_get_parent (node, env); axiom_node_detach (node, env); file_path = axiom_element_get_attribute_value_by_name (element, env, "href"); file_uri = axutil_uri_parse_string (env, file_path); if (base_dir) base_uri = axutil_uri_parse_string (env, base_dir); else return AXIS2_FAILURE; if (base_uri) real_uri = axutil_uri_parse_relative (env, base_uri, file_path); else return AXIS2_FAILURE; if (real_uri) real_path = axutil_uri_to_string (real_uri, env, 1); else return AXIS2_FAILURE; if (real_path) data_handler = axiom_data_handler_create (env, real_path, "image/jpeg"); else return AXIS2_FAILURE; if (data_handler) data_text = axiom_text_create_with_data_handler (env, parent, data_handler, &data_node); else return AXIS2_FAILURE; if (data_text) { if (!is_mtom_enabled) axiom_text_set_optimize (data_text, env, AXIS2_FALSE); } } } } child_node = axiom_node_get_first_element (node, env); while (child_node) { wsclient_set_attachment (env, child_node, base_dir, is_mtom_enabled); child_node = axiom_node_get_next_sibling (child_node, env); } } else return AXIS2_FAILURE; return AXIS2_SUCCESS; }
void wsf_util_pack_attachments ( axutil_env_t *env, axiom_node_t *node, VALUE attach_ht, int enable_mtom, char *default_cnt_type) { axiom_element_t *node_element = NULL; axiom_element_t *child_element = NULL; axiom_child_element_iterator_t *child_element_ite = NULL; axiom_node_t *child_node = NULL; int attachment_done = 0; axis2_char_t *element_localname = NULL; axiom_namespace_t *element_namespace = NULL; axis2_char_t *namespace_uri = NULL; if (!node) return; if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { node_element = axiom_node_get_data_element(node, env); if (node_element) { child_element_ite = axiom_element_get_child_elements(node_element, env, node); if (child_element_ite) { child_node = axiom_child_element_iterator_next(child_element_ite, env); attachment_done = 0; while (child_node && !attachment_done) { child_element = axiom_node_get_data_element(child_node, env); element_localname = axiom_element_get_localname(child_element, env); if (element_localname && (axutil_strcmp(element_localname, AXIS2_ELEMENT_LN_INCLUDE) == 0)) { element_namespace = axiom_element_get_namespace(child_element, env, child_node); if (element_namespace) { namespace_uri = axiom_namespace_get_uri(element_namespace, env); if (namespace_uri && (axutil_strcmp(namespace_uri, AXIS2_NAMESPACE_URI_INCLUDE) == 0)) { axis2_char_t *cnt_type = NULL; axis2_char_t *content_type = NULL; axis2_char_t *href = NULL; axis2_char_t* pos = NULL; cnt_type = axiom_element_get_attribute_value_by_name(node_element, env, AXIS2_ELEMENT_ATTR_NAME_CONTENT_TYPE); content_type = !cnt_type ? default_cnt_type : cnt_type; href = axiom_element_get_attribute_value_by_name(child_element, env, AXIS2_ELEMENT_ATTR_NAME_HREF); if ((axutil_strlen(href) > 4) && (pos = axutil_strstr (href, "cid:"))) { axis2_char_t* cid = NULL; VALUE content_tmp; void* content = NULL; unsigned int content_length = 0; cid = href + 4; content_tmp = rb_hash_aref(attach_ht, rb_str_new2(cid)); content_length = RSTRING(content_tmp)->len; content = malloc(sizeof (char) * content_length); memcpy (content, (const void*)STR2CSTR(content_tmp), content_length); if (content) { void *data_buffer = NULL; axiom_data_handler_t *data_handler = NULL; axiom_node_t *text_node = NULL; axiom_text_t *text = NULL; data_buffer = AXIS2_MALLOC (env->allocator, sizeof (char) * content_length); if (data_buffer) { memcpy (data_buffer, content, content_length); data_handler = axiom_data_handler_create (env, NULL, content_type); if (data_handler) { axiom_data_handler_set_binary_data (data_handler, env, (axis2_byte_t *)content, content_length); text = axiom_text_create_with_data_handler (env, node, data_handler, &text_node); if (enable_mtom == AXIS2_FALSE) axiom_text_set_optimize (text, env, AXIS2_FALSE); axiom_node_detach (child_node, env); } } attachment_done = 1; } } } } } child_node = axiom_child_element_iterator_next(child_element_ite, env); } } } } // Process child nodes child_node = axiom_node_get_first_child(node, env); while (child_node) { wsf_util_pack_attachments(env, child_node, attach_ht, enable_mtom, default_cnt_type); child_node = axiom_node_get_next_sibling(child_node, env); } }
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL security_admin_load_scenarios( const axutil_env_t* env, axis2_msg_ctx_t* msg_ctx) { /* Read senarios from config file*/ axis2_conf_ctx_t* conf_ctx = NULL; axis2_char_t* repo_path = NULL; axis2_char_t* scenario_config_file_path = NULL; axiom_xml_reader_t* xml_reader = NULL; axiom_document_t* document = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_node_t* scenario_config_root_node = NULL; axiom_element_t* scenario_config_root_element = NULL; axiom_children_iterator_t* children_ite = NULL; axutil_array_list_t* scenarios = NULL; /* Form absolute path to config file*/ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); repo_path = axis2_conf_ctx_get_root_dir(conf_ctx, env); scenario_config_file_path = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", AXIS2_PATH_SEP_STR, "SecurityAdminService", AXIS2_PATH_SEP_STR, "scenario-config.xml", NULL); xml_reader = axiom_xml_reader_create_for_file(env, scenario_config_file_path, NULL); AXIS2_FREE(env->allocator, scenario_config_file_path); if (!xml_reader) return NULL; stax_builder = axiom_stax_builder_create(env, xml_reader); if (!stax_builder) return NULL; document = axiom_stax_builder_get_document(stax_builder, env); if (!document) return NULL; /* Build XML document*/ axiom_document_build_all(document, env); scenario_config_root_node = axiom_document_get_root_element(document, env); scenario_config_root_element = axiom_node_get_data_element(scenario_config_root_node, env); axiom_stax_builder_free_self(stax_builder, env); children_ite = axiom_element_get_children(scenario_config_root_element, env, scenario_config_root_node); if (children_ite) { /* Get Scenario nodes and build hash*/ while (axiom_children_iterator_has_next(children_ite, env)) { axiom_node_t* node = NULL; node = axiom_children_iterator_next(children_ite, env); if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { axis2_char_t* localname = NULL; axiom_element_t* scenario_ele = NULL; axiom_children_iterator_t* ite = NULL; scenario_ele = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(scenario_ele, env); if (0 == axutil_strcmp(localname, "Scenario")) /* Scenario */ { axis2_char_t* id = NULL; security_admin_scenario_data_t* data = NULL; /* Create scenarios hash*/ if (!scenarios) scenarios = axutil_array_list_create(env, SEC_ADMIN_SCENARIO_COUNT); data = security_admin_scenario_data_create(env); /* Current scenario*/ security_admin_scenario_data_set_current_scenario(data, AXIS2_TRUE); /* id*/ id = axiom_element_get_attribute_value_by_name(scenario_ele, env, "id"); security_admin_scenario_data_set_id(data, axutil_strdup(env, id)); ite = axiom_element_get_children(scenario_ele, env, node); while (axiom_children_iterator_has_next(ite, env)) { axiom_node_t* node = NULL; node = axiom_children_iterator_next(ite, env); if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { axiom_element_t* node_ele = NULL; axis2_char_t* localname = NULL; axis2_char_t* text = NULL; node_ele = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(node_ele, env); text = axiom_element_get_text(node_ele, env, node); if (0 == axutil_strcmp(localname, "Summary")) /* Summary */ { security_admin_scenario_data_set_summary(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Description")) /* Description */ { security_admin_scenario_data_set_description(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Category")) /* Category */ { security_admin_scenario_data_set_category(data, axutil_strdup(env, text)); } /*else if (0 == axutil_strcmp(localname, "WsuId")*/ /* WsuId */ /*{ }*/ else if (0 == axutil_strcmp(localname, "Type")) /* Type */ { security_admin_scenario_data_set_type(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Modules")) /* Modules */ { } } } /* Add scenario data into the hash map*/ axutil_array_list_add(scenarios, env, data); } } } } return scenarios; }
void test_endpoint_deserialize(char *content) { axutil_qname_t *qname = NULL; axiom_node_t *subs_node = NULL; axiom_element_t *subs_element = NULL; axiom_node_t *endpoint_node = NULL; axiom_element_t *endpoint_element = NULL; axiom_node_t *address_node = NULL; axiom_element_t *address_element = NULL; axis2_char_t *address = NULL; const axutil_env_t *env = NULL; axis2_char_t *nsurl = "http://ws.apache.org/ns/synapse"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); subs_node = axiom_node_create_from_buffer(env, content); subs_element = axiom_node_get_data_element(subs_node, env); if(!subs_element) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_OM_ELEMENT_EXPECTED, AXIS2_FAILURE); return; } qname = axutil_qname_create(env, "endpoint", nsurl, NULL); if(!qname) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return; } endpoint_element = axiom_element_get_first_child_with_qname(subs_element, env, qname, subs_node, &endpoint_node); if(qname) { axutil_qname_free(qname, env); } qname = axutil_qname_create(env, "address", nsurl, NULL); if(!qname) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return; } address_element = axiom_element_get_first_child_with_qname(endpoint_element, env, qname, endpoint_node, &address_node); if(qname) { axutil_qname_free(qname, env); } address = axiom_element_get_attribute_value_by_name(address_element, env, "url"); if(!address) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE); return; } printf("\naddress:%s\n\n", address); }
axis2_status_t AXIS2_CALL adb_UAKType_deserialize_obj( adb_UAKType_t* _UAKType, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axiom_attribute_t *parent_attri = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; status = AXIS2_FAILURE; if(parent) { axis2_char_t *attrib_text = NULL; attrib_text = axiom_element_get_attribute_value_by_name(axiom_node_get_data_element(parent, env), env, "nil"); if (attrib_text != NULL && !axutil_strcasecmp(attrib_text, "true")) { /* but the wsdl says that, this is non nillable */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element UAKType"); status = AXIS2_FAILURE; } else { axiom_node_t *text_node = NULL; axiom_text_t *text_element = NULL; text_node = axiom_node_get_first_child(parent, env); if (text_node && axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) text_element = (axiom_text_t*)axiom_node_get_data_element(text_node, env); text_value = ""; if(text_element && axiom_text_get_value(text_element, env)) { text_value = (axis2_char_t*)axiom_text_get_value(text_element, env); } status = adb_UAKType_deserialize_from_string(_UAKType, env, text_value, parent); } } parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(parent_element, env); parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "issuerID")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "issuerID", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "issuerID"); } if(attrib_text != NULL) { adb_UAKType_set_issuerID(_UAKType, env, attrib_text); } else if(!dont_care_minoccurs) { /* if(element_qname) { axutil_qname_free(element_qname, env); } */ /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute issuerID missing"); return AXIS2_FAILURE; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "collectionID")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "collectionID", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "collectionID"); } if(attrib_text != NULL) { adb_UAKType_set_collectionID(_UAKType, env, attrib_text); } else if(!dont_care_minoccurs) { /* if(element_qname) { axutil_qname_free(element_qname, env); } */ /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute collectionID missing"); return AXIS2_FAILURE; } return status; }
axis2_status_t AXIS2_CALL adb_CanonicalizationMethodType_deserialize_obj( adb_CanonicalizationMethodType_t* _CanonicalizationMethodType, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axiom_attribute_t *parent_attri = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; int i = 0; axutil_array_list_t *arr_list = NULL; int sequence_broken = 0; axiom_node_t *tmp_node = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for CanonicalizationMethodType : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(parent_element, env); /* * building extraElement array */ arr_list = axutil_array_list_create(env, 10); /* * building extraElement element */ /* 'any' arrays are not handling correctly when there are other elements mixed with the 'any' element. */ for (i = 0, sequence_broken = 0, current_node = first_node; !sequence_broken && current_node != NULL;) { if(axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node =axiom_node_get_next_sibling(current_node, env); is_early_node_valid = AXIS2_FALSE; continue; } if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("extraElement", axiom_element_get_localname(current_element, env)))) { is_early_node_valid = AXIS2_TRUE; } text_value = NULL; /* just to avoid warning */ { axiom_node_t *current_property_node = current_node; current_node = axiom_node_get_next_sibling(current_node, env); axiom_node_detach(current_property_node, env); axutil_array_list_add_at(arr_list, env, i, (void*)current_property_node); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for extraElement "); if(element_qname) { axutil_qname_free(element_qname, env); } if(arr_list) { axutil_array_list_free(arr_list, env); } return AXIS2_FAILURE; } i ++; } if(0 == axutil_array_list_size(arr_list,env)) { axutil_array_list_free(arr_list, env); } else { status = adb_CanonicalizationMethodType_set_extraElement(_CanonicalizationMethodType, env, arr_list); } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "Algorithm")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "Algorithm", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "Algorithm"); } if(attrib_text != NULL) { adb_CanonicalizationMethodType_set_Algorithm(_CanonicalizationMethodType, env, axutil_uri_parse_string(env, attrib_text)); } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute Algorithm missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
AXIS2_EXTERN void AXIS2_CALL remote_registry_resource_load_metadata_from_feed_node(const axutil_env_t *env, remote_registry_resource_t *resource, axiom_node_t *feed_node) { axiom_children_iterator_t *node_it = NULL; axiom_element_t *feed_ele = NULL; feed_ele = axiom_node_get_data_element(feed_node, env); node_it = axiom_element_get_children(feed_ele, env, feed_node); /* iterate all the children */ while(axiom_children_iterator_has_next(node_it, env)) { axiom_node_t *child = NULL; axiom_element_t *child_ele = NULL; axis2_char_t *local_name = NULL; child = axiom_children_iterator_next(node_it, env); if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) { continue; } child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env); local_name = axiom_element_get_localname(child_ele, env); /* retriving the attribute one by one */ if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_ID)) { axis2_char_t *id_text = NULL; id_text = axiom_element_get_text(child_ele, env, child); resource->id = id_text; } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_MEDIA_TYPE)) { axis2_char_t *media_type = NULL; media_type = axiom_element_get_text(child_ele, env, child); /* for the root feed the feed xml is NULL */ if(media_type != NULL) { if(!axutil_strcmp(media_type, REMOTE_REGISTRY_FEED_KEY_DIR)) { resource->is_collection = 1; } resource->media_type = media_type; } } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_ENTRY)) { /* now iterate through the entries */ axutil_array_list_t *entry_arr = NULL; remote_registry_resource_t *entry_resource = NULL; axis2_char_t *child_path = NULL; entry_arr = resource->entries; if(!entry_arr) { entry_arr = axutil_array_list_create(env, 5); resource->entries = entry_arr; } entry_resource = remote_registry_resource_create_from_entry_node(env, child); axutil_array_list_add(entry_arr, env, entry_resource); /* adding child as a path */ child_path = entry_resource->link_path; if(!resource->child_paths) { resource->child_paths = axutil_array_list_create(env, 10); } axutil_array_list_add(resource->child_paths, env, child_path); } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_LINK)) { /* loading all the links */ axis2_char_t *href = NULL; axis2_char_t *rel = NULL; href = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_HREF); rel = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_REL); if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_SELF)) { resource->link_self = axutil_strdup(env, href); } else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_ALTERNATE)) { resource->link_alternate = axutil_strdup(env, href); } else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_PATH)) { remote_registry_resource_set_link_path(resource, env, href); } else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_EDIT)) { resource->link_edit = axutil_strdup(env, href); } else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_EDIT_MEDIA)) { resource->link_edit_media = axutil_strdup(env, href); } } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_CONTENT)) { axis2_char_t *content_src_url = NULL; content_src_url = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_SRC); remote_registry_resource_set_content_src_url(resource, env, content_src_url); if(content_src_url != NULL) { resource->is_collection = 0; } } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_AUTHOR)) { axiom_node_t *name_node = NULL; axiom_element_t *name_element = NULL; name_node = axiom_node_get_first_child(child, env); /* get the first child (with type AXIOM_ELEMENT) where we can find the name */ if(name_node && axiom_node_get_node_type(name_node, env) != AXIOM_ELEMENT) { name_node = axiom_node_get_next_sibling(name_node, env); } if(name_node) { axis2_char_t *name = NULL; name_element = axiom_node_get_data_element(name_node, env); name = axiom_element_get_text(name_element, env, name_node); remote_registry_resource_set_author_name(resource, env, name); } } else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_PROPERTIES)) { axiom_children_iterator_t *properties_it = NULL; axiom_element_t *properties_ele = NULL; if(!resource->properties) { resource->properties = axutil_hash_make(env); } properties_ele = axiom_node_get_data_element(child, env); properties_it = axiom_element_get_children(properties_ele, env, child); /* iterate all the properties */ while(axiom_children_iterator_has_next(properties_it, env)) { axiom_node_t *property_node = NULL; axiom_node_t *name_node = NULL; axiom_node_t *value_node = NULL; axiom_element_t *name_element = NULL; axiom_element_t *value_element = NULL; axis2_char_t *name = NULL; axis2_char_t *value = NULL; property_node = axiom_children_iterator_next(properties_it, env); if(axiom_node_get_node_type(property_node, env) != AXIOM_ELEMENT) { continue; } name_node = axiom_node_get_first_child(property_node, env); while(name_node && axiom_node_get_node_type(name_node, env) != AXIOM_ELEMENT) { name_node = axiom_node_get_next_sibling(name_node, env); } if(!name_node) { continue; } value_node = axiom_node_get_next_sibling(name_node, env); while(value_node && axiom_node_get_node_type(value_node, env) != AXIOM_ELEMENT) { value_node = axiom_node_get_next_sibling(value_node, env); } if(!value_node) { continue; } name_element = axiom_node_get_data_element(name_node, env); value_element = axiom_node_get_data_element(value_node, env); name = axiom_element_get_text(name_element, env, name_node); value = axiom_element_get_text(value_element, env, value_node); axutil_hash_set(resource->properties, name, AXIS2_HASH_KEY_STRING, value); } } } }
axis2_status_t AXIS2_CALL adb_TransformTypeChoice_deserialize_obj( adb_TransformTypeChoice_t* _TransformTypeChoice, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _TransformTypeChoice, AXIS2_FAILURE); first_node = parent; /* * building extraElement element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; if ( (current_node )) { if( current_node ) { is_early_node_valid = AXIS2_TRUE; } text_value = NULL; /* just to avoid warning */ { axiom_node_t *current_property_node = current_node; current_node = axiom_node_get_next_sibling(current_node, env); axiom_node_detach(current_property_node, env); status = adb_TransformTypeChoice_set_extraElement(_TransformTypeChoice, env, current_property_node); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for extraElement "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } /* * building XPath element */ /* * because elements are ordered this works fine */ if(current_node != NULL && is_early_node_valid) { current_node = axiom_node_get_next_sibling(current_node, env); while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } } is_early_node_valid = AXIS2_FALSE; element_qname = axutil_qname_create(env, "XPath", "http://www.w3.org/2000/09/xmldsig#", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_TransformTypeChoice_set_XPath(_TransformTypeChoice, env, text_value); } else { /* * axis2_qname_t *qname = NULL; * axiom_attribute_t *the_attri = NULL; * * qname = axutil_qname_create(env, "nil", "http://www.w3.org/2001/XMLSchema-instance", "xsi"); * the_attri = axiom_element_get_attribute(current_element, env, qname); */ /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */ axiom_attribute_t *the_attri = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; attribute_hash = axiom_element_get_all_attributes(current_element, env); attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(strstr((axis2_char_t*)key, "nil|http://www.w3.org/2001/XMLSchema-instance")) { the_attri = (axiom_attribute_t*)val; break; } } } if(the_attri) { attrib_text = axiom_attribute_get_value(the_attri, env); } else { /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "nil"); } if(attrib_text && 0 == axutil_strcmp(attrib_text, "1")) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element XPath"); status = AXIS2_FAILURE; } else { /* after all, we found this is a empty string */ status = adb_TransformTypeChoice_set_XPath(_TransformTypeChoice, env, ""); } } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for XPath "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } *dp_parent = current_node; *dp_is_early_node_valid = is_early_node_valid; return status; }
axis2_status_t AXIS2_CALL adb_supportedContentFormats_type0_deserialize_obj( adb_supportedContentFormats_type0_t* _supportedContentFormats_type0, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; int i = 0; axutil_array_list_t *arr_list = NULL; int sequence_broken = 0; axiom_node_t *tmp_node = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _supportedContentFormats_type0, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for supportedContentFormats_type0 : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building contentFormat array */ arr_list = axutil_array_list_create(env, 10); /* * building contentFormat element */ element_qname = axutil_qname_create(env, "contentFormat", "http://www.daisy.org/ns/daisy-online/", NULL); for (i = 0, sequence_broken = 0, current_node = first_node; !sequence_broken && current_node != NULL;) { if(axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node =axiom_node_get_next_sibling(current_node, env); is_early_node_valid = AXIS2_FALSE; continue; } current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { axutil_array_list_add_at(arr_list, env, i, axutil_strdup(env, text_value)); } else { /* * axis2_qname_t *qname = NULL; * axiom_attribute_t *the_attri = NULL; * * qname = axutil_qname_create(env, "nil", "http://www.w3.org/2001/XMLSchema-instance", "xsi"); * the_attri = axiom_element_get_attribute(current_element, env, qname); */ /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */ axiom_attribute_t *the_attri = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; attribute_hash = axiom_element_get_all_attributes(current_element, env); attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(strstr((axis2_char_t*)key, "nil|http://www.w3.org/2001/XMLSchema-instance")) { the_attri = (axiom_attribute_t*)val; break; } } } if(the_attri) { attrib_text = axiom_attribute_get_value(the_attri, env); } else { /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "nil"); } if(attrib_text && 0 == axutil_strcmp(attrib_text, "1")) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element contentFormat"); status = AXIS2_FAILURE; } else { /* after all, we found this is a empty string */ axutil_array_list_add_at(arr_list, env, i, axutil_strdup(env, "")); } } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for contentFormat "); if(element_qname) { axutil_qname_free(element_qname, env); } if(arr_list) { axutil_array_list_free(arr_list, env); } return AXIS2_FAILURE; } i ++; current_node = axiom_node_get_next_sibling(current_node, env); } else { is_early_node_valid = AXIS2_FALSE; sequence_broken = 1; } } if (i < 0) { /* found element out of order */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "contentFormat (@minOccurs = '0') only have %d elements", i); if(element_qname) { axutil_qname_free(element_qname, env); } if(arr_list) { axutil_array_list_free(arr_list, env); } return AXIS2_FAILURE; } if(0 == axutil_array_list_size(arr_list,env)) { axutil_array_list_free(arr_list, env); } else { status = adb_supportedContentFormats_type0_set_contentFormat(_supportedContentFormats_type0, env, arr_list); } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
/** * Traverse thru the node and its children. Check if the element has the * given qname and has a id attribute equal to the given value. * @param env Environment. MUST NOT be NULL, * @param node the node to be searched * @param e_name element name * @param e_ns element namespace. If NULL doesn't consider the namespaces * @param attr_name the attribute name of the node * @param attr_val the attribute value of the node * @param attr_ns the attribute namespace. If NULL doesn't consider namespaces. * @return the node if found, else NULL */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_axiom_get_first_node_by_name_and_attr_val( const axutil_env_t *env, axiom_node_t *node, axis2_char_t *e_name, axis2_char_t *e_ns, axis2_char_t *attr_name, axis2_char_t *attr_val, axis2_char_t *attr_ns) { axis2_char_t *attribute_value = NULL; axis2_char_t *localname = NULL; axiom_namespace_t *nmsp = NULL; axiom_element_t *element = NULL; axis2_bool_t element_match = AXIS2_FALSE; axiom_node_t *temp_node = NULL; if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) { return NULL; } element = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(element, env); if(localname && !axutil_strcmp(localname, e_name)) { element_match = AXIS2_TRUE; if(e_ns) { nmsp = axiom_element_get_namespace(element, env, node); if(nmsp) { axis2_char_t *namespacea = NULL; namespacea = axiom_namespace_get_uri(nmsp, env); if(axutil_strcmp(e_ns, namespacea)) { element_match = AXIS2_FALSE; } } } /* element is ok. So, we have to check the attribute value */ if(element_match) { if(attr_ns) { axiom_attribute_t *attr = NULL; axutil_qname_t *qname = axutil_qname_create(env, attr_name, attr_ns, NULL); attr = axiom_element_get_attribute(element, env, qname); if(attr) { attribute_value = axiom_attribute_get_value(attr, env); } axutil_qname_free(qname, env); } else { attribute_value = axiom_element_get_attribute_value_by_name( element, env, attr_name); } } if (attribute_value && !axutil_strcmp(attribute_value, attr_val)) { return node; } } /* Doesn't match? Get the children and search */ temp_node = axiom_node_get_first_element(node, env); while (temp_node) { axiom_node_t *res_node = NULL; res_node = oxs_axiom_get_first_node_by_name_and_attr_val( env, temp_node, e_name, e_ns, attr_name, attr_val, attr_ns); if (res_node) { return res_node; } temp_node = axiom_node_get_next_sibling(temp_node, env); } return NULL; }
/** f_add_PostEncodingSOAP * Add the element * <ns:Value>SOAP</ns:Value> * at all nodes * Constraint[@name="PostEncoding"]/AllowedValues * (See OGC 09-148r1 and OGC 09-149r1). * * This function may be invoked via sp_func_at_nodes() if needed. * */ static int f_add_PostEncodingSOAP( const axutil_env_t * env, axiom_node_t *target_node, void *arg3 ) { // // Find the path // Constraint[@name="PostEncoding"]/AllowedValues // and add // <ns:Value>SOAP</ns:Value> // where ns is the namespace of the enclosing AllowedValues element. // const axis2_char_t *constrIdStr = "Constraint"; axiom_node_t *constraint_node = rp_find_named_child(env, target_node, constrIdStr, 1); if (NULL == constraint_node) { axiom_element_t *el = NULL; axis2_char_t *el_name = NULL; axis2_char_t *op_name = NULL; if (axiom_node_get_node_type(target_node, env) == AXIOM_ELEMENT) { el = (axiom_element_t *) axiom_node_get_data_element (target_node, env); el_name = el ? axiom_element_get_localname( el, env) : NULL; op_name = el ? axiom_element_get_attribute_value_by_name(el, env, "name"): NULL; } rp_log_error(env, "*** S2P(%s:%d): %s node not found under %s/name='%s'.\n", __FILE__, __LINE__, constrIdStr, el_name ? el_name : "<UNKNOWN>", op_name ? op_name : "<UNKNOWN>"); return 1; } // check that constr_node is "PostEncoding", otherwise try to find it axiom_element_t *el = axiom_node_get_data_element(constraint_node, env); const axis2_char_t *nameAttr = axiom_element_get_attribute_value_by_name (el, env, "name"); while (nameAttr == NULL || axutil_strncmp(nameAttr, "PostEncoding", 12) ) { // loop through siblings trying find the "PostEncoding" constraint constraint_node = axiom_node_get_next_sibling (constraint_node, env); el = axiom_node_get_data_element(constraint_node, env); if (axiom_node_get_node_type(constraint_node, env) == AXIOM_ELEMENT) { nameAttr = axiom_element_get_attribute_value_by_name(el, env, "name"); } } if (nameAttr == NULL || axutil_strncmp(nameAttr, "PostEncoding", 12) ) { // Did not find a "PostEncoding" constraint, bail out. // TODO: Future enhancement: could add a "PostEncoding" constraint // element. rp_log_error(env, "*** S2P(%s:%d): 'PostEncoding' constraint not found.\n", __FILE__, __LINE__, constrIdStr); return 1; } axiom_node_t *allowedValues_node = rp_find_named_child(env, constraint_node, "AllowedValues", 1); if (NULL == allowedValues_node) { // TODO: Future enhancement: insert an "AllowedValues" node. rp_log_error(env, "*** S2P(%s:%d): 'AllowedValues' node not found.\n", __FILE__, __LINE__, constrIdStr); return 1; } // Insert <ns:Value>SOAP</ns:Value> Name_value value_nv_n; value_nv_n.name = "Value"; value_nv_n.value = "SOAP"; rp_add_child (env, allowedValues_node, &value_nv_n, NULL, NULL); return 0; }