void remove_subscriber(axis2_char_t *id) { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *val; axis2_char_t *index_path = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_char_t *path = 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) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); val = remote_registry_resource_get_property(res, env, id); if(val) { path = axutil_strcat(env, val, "/", id, NULL); printf("path:%s\n", path); status = remote_registry_delete(remote_registry, env, path); } if(AXIS2_SUCCESS != status) { printf("\nSubscription deletion failed\n"); } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); /*remote_registry_resource_remove_property(res, env, id); remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); remote_registry_resource_set_parent_path(res, env, "/eventing/index"); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, index_path, res);*/ remote_registry_resource_free(res, env); }
void get_all_subscribers() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; axis2_char_t *path = 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) { return; } properties = remote_registry_resource_get_properties(res, env); if(properties) { axutil_hash_index_t *hi; void *val; void *key; for (hi = axutil_hash_first(properties, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, (const void**)&key, NULL, &val); path = axutil_strcat(env, val, "/", key, NULL); res = remote_registry_get(remote_registry, env, path, NULL); if(res) { if(res) { printf("\n\nresource id:%s\n\n",remote_registry_resource_get_id(res, env)); } } remove_subscriber((axis2_char_t *) key); } } remote_registry_resource_free(res, env); }
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; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL remote_registry_resource_free( remote_registry_resource_t *resource, const axutil_env_t *env) { if(resource->author_name != NULL) { AXIS2_FREE(env->allocator, resource->author_name); resource->author_name = NULL; } if(resource->created_time != NULL) { axutil_date_time_free(resource->created_time, env); resource->created_time = NULL; } if(resource->last_updated_username != NULL) { AXIS2_FREE(env->allocator, resource->last_updated_username); resource->last_updated_username = NULL; } if(resource->description != NULL) { AXIS2_FREE(env->allocator, resource->description); resource->description = NULL; } if(resource->path != NULL) { AXIS2_FREE(env->allocator, resource->path); resource->path = NULL; } if(resource->media_type != NULL) { AXIS2_FREE(env->allocator, resource->media_type); resource->media_type = NULL; } if(resource->parent_path != NULL) { AXIS2_FREE(env->allocator, resource->parent_path); resource->parent_path = NULL; } if(resource->properties != NULL) { axutil_hash_index_t *hi; void *val; void *key; int sum = 0; for (hi = axutil_hash_first(resource->properties, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, (const void**)&key, NULL, &val); AXIS2_FREE(env->allocator, key); AXIS2_FREE(env->allocator, val); } axutil_hash_free(resource->properties, env); resource->properties = NULL; } if(resource->depends_on != NULL) { axutil_array_list_free(resource->depends_on, env); resource->depends_on = NULL; } if(resource->depended_on_by != NULL) { AXIS2_FREE(env->allocator, resource->depended_on_by); resource->depended_on_by = NULL; } if(resource->content != NULL) { AXIS2_FREE(env->allocator, resource->content); resource->content = NULL; } if(resource->subtitle != NULL) { AXIS2_FREE(env->allocator, resource->subtitle); resource->subtitle = NULL; } if(resource->title != NULL) { AXIS2_FREE(env->allocator, resource->title); resource->title = NULL; } if(resource->collection != NULL) { AXIS2_FREE(env->allocator, resource->collection); resource->collection = NULL; } if(resource->entries != NULL) { int i = 0; /* needed to free all the resouces recursively */ for(i = 0; i < axutil_array_list_size(resource->entries, env); i ++ ) { remote_registry_resource_t *res = NULL; res = axutil_array_list_get(resource->entries, env, i); remote_registry_resource_free(res, env); } axutil_array_list_free(resource->entries, env); resource->entries = NULL; } if(resource->child_paths != NULL) { axutil_array_list_free(resource->child_paths, env); resource->child_paths = NULL; } if(resource->link_self != NULL) { AXIS2_FREE(env->allocator, resource->link_self); } if(resource->link_alternate != NULL) { AXIS2_FREE(env->allocator, resource->link_alternate); } if(resource->link_path != NULL) { AXIS2_FREE(env->allocator, resource->link_path); } if(resource->link_edit != NULL) { AXIS2_FREE(env->allocator, resource->link_edit); } if(resource->link_edit_media != NULL) { AXIS2_FREE(env->allocator, resource->link_edit_media); } if(resource->content_src_url != NULL) { AXIS2_FREE(env->allocator, resource->content_src_url); } AXIS2_FREE(env->allocator, resource); return AXIS2_SUCCESS; }