static void topic_index_init() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *id = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { res = remote_registry_resource_create(env); id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); remote_registry_resource_set_properties(res, env, axutil_hash_make(env)); /*remote_registry_resource_set_author_name(res, env, "admin"); */ remote_registry_resource_set_description(res, env, ""); /*remote_registry_resource_set_last_modified_time(res, env, axutil_date_time_create(env));*/ remote_registry_put(remote_registry, env, TOPIC_INDEX, res); return; } }
AXIS2_EXTERN remote_registry_resource_t* AXIS2_CALL remote_registry_resource_create_collection( const axutil_env_t *env) { remote_registry_resource_t *resource = NULL; resource = remote_registry_resource_create(env); /* mark it as a collection */ if(resource) { resource->is_collection = 1; } return resource; }
AXIS2_EXTERN remote_registry_resource_t *AXIS2_CALL remote_registry_resource_create_from_entry_node( const axutil_env_t *env, axiom_node_t *entry_node) { remote_registry_resource_t *resource = NULL; resource = remote_registry_resource_create(env); if(!resource) { return NULL; } remote_registry_resource_load_metadata_from_feed_node(env, resource, entry_node); return resource; }
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; }
int add_subscriber() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *subscription_id = NULL; axis2_char_t *id = NULL; axis2_char_t *path = NULL; axis2_char_t *index_path = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; char *content = (char *) strdup("<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); axis2_char_t *epr_type = "application/vnd.epr"; axis2_char_t *filter = "/weather/4/"; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); subscription_id = axutil_strcat(env, "urn:uuid:", axutil_uuid_gen(env), NULL); path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); id = axutil_strcat(env, reg_url, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); topic_index_init(); res = remote_registry_resource_create(env); remote_registry_resource_set_content(res, env, content); remote_registry_resource_set_content_len(res, env, axutil_strlen(content)); remote_registry_resource_set_media_type(res, env, epr_type); remote_registry_resource_set_description(res, env, ""); properties = axutil_hash_make(env); if(properties) { axutil_hash_set(properties, axutil_strdup(env, "expires"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "*")); axutil_hash_set(properties, axutil_strdup(env, "staticFlag"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "false")); axutil_hash_set(properties, axutil_strdup(env, "filterValue"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, filter)); axutil_hash_set(properties, axutil_strdup(env, "subManagerURI"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://10.100.1.44:8280/services/SampleEventSource")); axutil_hash_set(properties, axutil_strdup(env, "filterDialect"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://synapse.apache.org/eventing/dialect/topicFilter")); remote_registry_resource_set_properties(res, env, properties); } remote_registry_put(remote_registry, env, path, res); if(id) { AXIS2_FREE(env->allocator, id); } if(path) { AXIS2_FREE(env->allocator, path); path = NULL; } if(res) { remote_registry_resource_free(res, env); res = NULL; } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return 0; } id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); properties = remote_registry_resource_get_properties(res, env); if(properties) { path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, NULL); axutil_hash_set(properties, subscription_id, AXIS2_HASH_KEY_STRING, path); remote_registry_resource_set_properties(res, env, properties); } remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, TOPIC_INDEX, res); if(id) { AXIS2_FREE(env->allocator, id); } if(res) { remote_registry_resource_free(res, env); res = NULL; } printf("\n"); return 0; }