AXIS2_EXTERN axiom_node_t* AXIS2_CALL load_sample_xml(const axutil_env_t *env, axiom_node_t* tmpl, axis2_char_t* filename ) { axiom_document_t *doc = NULL; axiom_stax_builder_t *builder = NULL; axiom_xml_reader_t *reader = NULL; /*axiom_xml_writer_t *writer = NULL;*/ reader = axiom_xml_reader_create_for_file(env, filename, NULL); if (!reader) printf("\n Reader is NULL"); builder = axiom_stax_builder_create(env, reader); if (!builder) printf("\n builder is NULL"); doc = axiom_document_create(env, NULL, builder); if (!doc) printf("\n doc is NULL"); tmpl = axiom_document_build_all(doc, env); axiom_stax_builder_free_self(builder, env); builder = NULL; /* tmpl = axiom_document_get_root_element(doc, env);*/ if (!tmpl) printf("\n tmpl is NULL"); return tmpl; }
axiom_node_t * wsf_wsdl_util_deserialize_file( const axutil_env_t* env, axis2_char_t* file_name) { axiom_node_t* payload = NULL; axiom_document_t* document = NULL; axiom_xml_reader_t* reader = NULL; axiom_stax_builder_t* builder = NULL; reader = axiom_xml_reader_create_for_file (env, file_name, WSF_WSDL_ENCODING_UTF_8); if (reader) { builder = axiom_stax_builder_create (env, reader); } if (builder) { document = axiom_stax_builder_get_document (builder, env); } if (document) { payload = axiom_document_build_all (document, env); } if (builder) { axiom_stax_builder_free_self (builder, env); } if (!payload) { AXIS2_LOG_ERROR_MSG(env->log, "Deserialization failed.."); } return payload; }
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsdl_util_create_type_map( const axutil_env_t* env, axis2_char_t* type_map_xml_file, axiom_node_t** type_map) { axiom_xml_reader_t* typemap_xml_reader = NULL; axiom_document_t* typemap_document = NULL; axiom_stax_builder_t* typemap_om_builder = NULL; typemap_xml_reader = axiom_xml_reader_create_for_file(env, type_map_xml_file, NULL); /* encoding ?? */ if (!typemap_xml_reader) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create xml reader for typemap"); return AXIS2_FAILURE; } typemap_om_builder = axiom_stax_builder_create(env, typemap_xml_reader); if (!typemap_om_builder) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create om builder for typemap"); axiom_xml_reader_free(typemap_xml_reader, env); return AXIS2_FAILURE; } typemap_document = axiom_stax_builder_get_document(typemap_om_builder, env); if (!typemap_document) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create document for typemap"); axiom_stax_builder_free(typemap_om_builder, env); return AXIS2_FAILURE; } *type_map = axiom_document_build_all(typemap_document, env); axiom_stax_builder_free_self(typemap_om_builder, env); return AXIS2_SUCCESS; }
axiom_node_t * return_policy_element( axis2_char_t * name, const axutil_env_t * env, axis2_char_t * wsdl_name) { axiom_element_t *ele1 = NULL, *ele2 = NULL; axiom_document_t *document = NULL; axiom_node_t *node1 = NULL, *node2 = NULL, *policy_node = NULL; axiom_namespace_t *ns = NULL; axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; char *buffer = NULL; axiom_attribute_t *attr = NULL; axis2_char_t *value = NULL; axis2_char_t *val = NULL; axutil_hash_t *attr_hash = NULL; axis2_char_t *xml_output = NULL; axutil_hash_index_t *hi; /* f = fopen(wsdl_name, "r"); if (!f) return NULL; reader = axiom_xml_reader_create_for_io(env, read_input, NULL , NULL, NULL); */ reader = axiom_xml_reader_create_for_file(env, wsdl_name, NULL); if (!reader) { printf("ERROR CREATING PULLPARSER"); return NULL; } builder = axiom_stax_builder_create(env, reader); if (!builder) { printf("ERROR CREATING PULL PARSER"); return NULL; } document = axiom_stax_builder_get_document(builder, env); if (!document) return NULL; node1 = axiom_document_get_root_element(document, env); if (!node1) { printf(" root element null "); axiom_stax_builder_free(builder, env); return NULL; } do { node2 = axiom_document_build_next(document, env); if (!node2) break; if (axiom_node_get_node_type(node2, env) == AXIOM_ELEMENT) { ele2 = (axiom_element_t *) axiom_node_get_data_element(node2, env); attr_hash = axiom_element_get_all_attributes(ele2, env); if (attr_hash) { hi = axutil_hash_first(attr_hash, env); axutil_hash_this(hi, NULL, NULL, &attr); if (axutil_strcmp(axiom_attribute_get_value(attr, env), name) == 0) { policy_node = node2; } } } } while (node2); return policy_node; }
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; }