예제 #1
0
/**
 * Deserialises given buffer and creates the axiom node 
 * @param env Environment. Must not be NULL
 * @param buffer representation of serialised node
 * @return deserialised node if success. NULL otherwise.
 */
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
oxs_axiom_deserialize_node(
    const axutil_env_t *env,  
    axis2_char_t* buffer)
{
    return axiom_node_create_from_buffer(env, buffer);
}
예제 #2
0
파일: comment.c 프로젝트: AdrianRys/wsf
axutil_array_list_t* AXIS2_CALL
remote_registry_comment_load_from_feed(
    const axutil_env_t *env,
    axis2_char_t *buffer)
{
    axiom_children_iterator_t *node_it = NULL;
    axiom_node_t *feed_node = NULL;
    axiom_element_t *feed_ele = NULL;
    axutil_array_list_t *comment_list = NULL;
    

    feed_node = axiom_node_create_from_buffer(env, buffer);
    if(!feed_node)
    {
        return NULL;
    }

    comment_list = axutil_array_list_create(env, 10);
    if(!comment_list)
    {
        return 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, "entry")) 
        {
            remote_registry_comment_t *comment = NULL;
            comment = remote_registry_comment_create_from_entry_node(env, child);

            axutil_array_list_add(comment_list, env, comment);
        }
    }

    return comment_list;
}
예제 #3
0
파일: util.c 프로젝트: AdrianRys/wsf
AXIS2_EXTERN int AXIS2_CALL
remote_registry_util_get_ratings_from_feed(
    const axutil_env_t *env,
    axis2_char_t *feed)
{
	axiom_node_t *entry_node;
	
    axiom_children_iterator_t *entry_it = NULL;
    axiom_element_t *entry_ele = NULL;

	int rating = -1;


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

	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, "AverageRating"))
		{
			axis2_char_t *rating_str = NULL;

			rating_str = axiom_element_get_text(child_ele, env, child);

			rating = atoi(rating_str);
			break;
		}
	}
	return rating;
}
예제 #4
0
파일: resource.c 프로젝트: AdrianRys/wsf
AXIS2_EXTERN remote_registry_resource_t *AXIS2_CALL
remote_registry_resource_create_from_feed(
                const axutil_env_t *env,
                axis2_char_t *buffer,
				axis2_char_t *content_type)
{
    axiom_node_t *root = NULL;
    axiom_element_t *root_ele = NULL;
    remote_registry_resource_t *resource = NULL;

    if(!buffer) {
        return NULL;
    }

    root = axiom_node_create_from_buffer(env, buffer);
    if(!root) 
    {
        return NULL;
    }

    resource = remote_registry_resource_create(env);
    if(!resource)
	{
        axiom_node_free_tree(root, env);
        return NULL;
	}
	/* distinguising whether it s a collection or entry */
	if(!axutil_strcmp(content_type, REMOTE_REGISTRY_FEED_ENTRY_CONTENT_TYPE)) {
		resource->is_collection = 0;
	}
	else {
		resource->is_collection = 1;
	}

    remote_registry_resource_load_metadata_from_feed_node(env,
                            resource,
                            root);

    return resource;
}
예제 #5
0
파일: util.c 프로젝트: AdrianRys/wsf
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;
}
예제 #6
0
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);
}