Exemple #1
0
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
remote_registry_util_get_tags_from_feed(
    const axutil_env_t *env,
    axis2_char_t *feed)
{
	axiom_node_t *entry_node = NULL;
	
    axiom_children_iterator_t *entry_it = NULL;
    axiom_element_t *entry_ele = NULL;

	axutil_array_list_t *tags = NULL;


	entry_node = axiom_node_create_from_buffer(env, feed);
	if(!entry_node) {
		return NULL;
	}

	entry_ele = axiom_node_get_data_element(entry_node, env);
    entry_it = axiom_element_get_children(entry_ele, env, entry_node);

    while(axiom_children_iterator_has_next(entry_it, env))
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(entry_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);
		if(!axutil_strcmp(local_name, "entry"))
		{
			axiom_children_iterator_t *entry_child_it = NULL;
			axis2_char_t *is_tagging = NULL;

			entry_child_it = axiom_element_get_children(entry_ele, env, entry_node);

			while(axiom_children_iterator_has_next(entry_child_it, env))
			{
				axiom_element_t *entry_child_ele = NULL;
				axiom_node_t *entry_child = NULL;

				entry_child = axiom_children_iterator_next(entry_child_it, env);
				if(axiom_node_get_node_type(entry_child, env) != AXIOM_ELEMENT)
				{
					continue;
				}

				entry_child_ele = (axiom_element_t*)axiom_node_get_data_element(entry_child, env);

				local_name = axiom_element_get_localname(entry_child_ele, env);

				if(!axutil_strcmp(local_name, "taggings"))
				{
					is_tagging = axiom_element_get_text(entry_child_ele, env, entry_child);
				}
			}

			if(!axutil_strcmp("1", is_tagging))
			{
				axiom_children_iterator_reset(entry_child_it, env);
				while(axiom_children_iterator_has_next(entry_child_it, env))
				{
					axiom_element_t *entry_child_ele = NULL;
					axiom_node_t *entry_child = NULL;

					entry_child = axiom_children_iterator_next(entry_child_it, env);
					if(axiom_node_get_node_type(entry_child, env) != AXIOM_ELEMENT)
					{
						continue;
					}

					entry_child_ele = (axiom_element_t*)axiom_node_get_data_element(entry_child, env);

					local_name = axiom_element_get_localname(entry_child_ele, env);

					if(!axutil_strcmp(local_name, "title"))
					{
						axis2_char_t *tag_name = NULL;
						tag_name = axiom_element_get_text(entry_child_ele, env, entry_child);

						axutil_array_list_add(tags, env, tag_name);
					}
				}
			}
		}
	}
	return tags;
}
AXIS2_EXTERN neethi_assertion_t *AXIS2_CALL
axis2_rm_assertion_builder_build(
    const axutil_env_t *env,
    axiom_node_t *rm_assertion_node,
    axiom_element_t *rm_assertion_ele)
{
    axis2_rm_assertion_t *rm_assertion = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axiom_children_iterator_t *children_iter = NULL;
    neethi_assertion_t *assertion = NULL;
    axis2_char_t *ns = NULL;
    axutil_qname_t *node_qname = NULL;

    node_qname = axiom_element_get_qname(rm_assertion_ele, env, rm_assertion_node);
    if(!node_qname)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get qname from element");
        return NULL;
    }

    ns = axutil_qname_get_uri(node_qname, env);
    if(!ns)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get namespace from element.");
        return NULL;
    }

    rm_assertion = axis2_rm_assertion_create(env);
    if(!rm_assertion)
    {
        return NULL;
    }

    /* First we check whether this is in 1.0 or 1.1 
     * namespace. Then we called the appropriate builder */

    children_iter = axiom_element_get_children(rm_assertion_ele, env, rm_assertion_node);

    if(!axutil_strcmp(ns, AXIS2_RM_POLICY_10_NS))
    {
        status = axis2_rm_assertion_builder_populate_for_10(env, rm_assertion, rm_assertion_node,
            rm_assertion_ele);

        axiom_children_iterator_reset(children_iter, env);

    }
    else if(!axutil_strcmp(ns, AXIS2_RM_POLICY_11_NS))
    {
        status = axis2_rm_assertion_builder_populate_for_11(env, rm_assertion, rm_assertion_node,
            rm_assertion_ele);
    }

    if(status == AXIS2_FAILURE)
    {
        axis2_rm_assertion_free(rm_assertion, env);
        rm_assertion = NULL;
        return NULL;
    }

    /*children_iter = axiom_element_get_children(rm_assertion_ele, env, rm_assertion_node);*/
    if(children_iter)
    {
        while(axiom_children_iterator_has_next(children_iter, env))
        {
            axiom_node_t *node = NULL;
            axiom_element_t *ele = NULL;
            axis2_char_t *local_name = NULL;
            axutil_qname_t *node_qn = NULL;

            node = axiom_children_iterator_next(children_iter, env);
            if(node)
            {
                if(axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
                {
                    ele = (axiom_element_t *)axiom_node_get_data_element(node, env);
                    node_qn = axiom_element_get_qname(ele, env, node);
                    if(!node_qn)
                    {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[neethi] Cannot get qname from element %s.", local_name);
                        return NULL;
                    }
                    ns = axutil_qname_get_uri(node_qn, env);
                    if(!ns)
                    {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[neethi] Cannot get namespace from element %s.", local_name);
                        return NULL;
                    }
                    if(!axutil_strcmp(ns, AXIS2_SANDESHA2_NS))
                    {
                        status = axis2_rm_assertion_builder_process_sandesha2_assertions(env,
                            rm_assertion, node, ele);
                        if(status == AXIS2_FAILURE)
                        {
                            axis2_rm_assertion_free(rm_assertion, env);
                            rm_assertion = NULL;
                            return NULL;
                        }
                    }
                }
            }
        }
    }
    assertion = neethi_assertion_create_with_args(env,
        (AXIS2_FREE_VOID_ARG)axis2_rm_assertion_free, rm_assertion, ASSERTION_TYPE_RM_ASSERTION);
    return assertion;
}