Makding the publisher pluggable. Added deafult publisher
diff --git a/configure.ac b/configure.ac
index eb5184b..36259d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@
CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
if test "$GCC" = "yes"; then
- CFLAGS="$CFLAGS -ansi -Wall -Wno-implicit-function-declaration"
+ CFLAGS="$CFLAGS -ansi -Wall -Wno-implicit-function-declaration -Werror"
#CFLAGS="$CFLAGS -ansi -Wall -Wno-implicit-function-declaration"
fi
LDFLAGS="-lpthread"
@@ -166,6 +166,41 @@
AC_MSG_RESULT(no)
)
+#Default for savan publisher
+SAVAN_PUBLISHER="default"
+SAVAN_PUBLISHER_LIB="default/libsavan_publisher_mod.la"
+
+AC_MSG_CHECKING(To Use esb based publisher . This is an optional module to build Savan C)
+AC_ARG_WITH(esbpub,
+[ --with-esbpub[=PATH] Find the esbc header files in 'PATH'.
+ 'PATH' should point to esbc include files location.
+ If you omit the '=PATH' part completely, the configure script will assume
+ esbc is installed in default paths.],
+[ case "$withval" in
+ no)
+ AC_MSG_RESULT(no)
+ SAVAN_PUBLISHER=""
+ SAVAN_PUBLISHER_LIB=""
+ ;;
+ *)
+ AC_MSG_RESULT(yes)
+ SAVAN_PUBLISHER="esb"
+ SAVAN_PUBLISHER_LIB=esb/libsavan_publisher_mod.la
+ dnl Find esbc include dir in the path
+ if test -d $withval; then
+ esbpubinc="-I$withval"
+ dnl else find the esbc include dir in /usr/local/include
+ elif test -d '/usr/local/include'; then
+ esbpubinc="-I/usr/local/include"
+ else
+ AC_MSG_ERROR(could not find esbc. stop)
+ fi
+ CFLAGS="$CFLAGS"
+ LDFLAGS="$LDFLAGS"
+ ;;
+ esac ],
+ AC_MSG_RESULT(no)
+)
AC_MSG_CHECKING(To Use Xml Schema.)
AXIOMINC="-I$abs_top_builddir/../axis2c/axiom/include"
@@ -175,9 +210,11 @@
REGISTRYINC=$registryinc
XPATHINC=$xpathinc
+ESBPUBINC=$esbpubinc
AC_SUBST(REGISTRYINC)
AC_SUBST(XPATHINC)
+AC_SUBST(ESBPUBINC)
AC_SUBST(AXIS2INC)
AC_SUBST(AXIOMINC)
AC_SUBST(UTILINC)
@@ -186,11 +223,15 @@
AC_SUBST(SAVAN_STORAGE)
AC_SUBST(SAVAN_FILTER)
AC_SUBST(SAVAN_FILTER_LIB)
+AC_SUBST(SAVAN_PUBLISHER)
+AC_SUBST(SAVAN_PUBLISHER_LIB)
AC_SUBST(SVC_DIR)
export SAVAN_STORAGE
export SAVAN_FILTER
export SAVAN_FILTER_LIB
+export SAVAN_PUBLISHER
+export SAVAN_PUBLISHER_LIB
export SVC_DIR
AC_CONFIG_FILES([Makefile \
@@ -209,6 +250,10 @@
src/filters/Makefile\
src/filters/common/Makefile\
src/filters/xpath/Makefile\
+ src/publisher/Makefile\
+ src/publisher/common/Makefile\
+ src/publisher/esb/Makefile\
+ src/publisher/default/Makefile\
src/subs_mgr/Makefile\
src/data/Makefile\
src/util/Makefile
diff --git a/include/savan_constants.h b/include/savan_constants.h
index e6364b7..3dc94f7 100644
--- a/include/savan_constants.h
+++ b/include/savan_constants.h
@@ -136,6 +136,7 @@
#define SAVAN_FILTER_DIALECT "Dialect"
#define SAVAN_SUBSCRIPTION_MANAGER "subscription"
#define SAVAN_STORAGE_MANAGER "storage_mgr"
+#define SAVAN_PUBLISHER "publisher"
#define SAVAN_FILTER "filter"
#define SAVAN_SQLITE "sqlite"
#define SAVAN_INMEMORY_STORAGE "inmemory"
diff --git a/include/savan_util.h b/include/savan_util.h
index e4dfbc1..e9801b1 100644
--- a/include/savan_util.h
+++ b/include/savan_util.h
@@ -30,6 +30,7 @@
#include <savan_subscriber.h>
#include <savan_sub_processor.h>
#include <savan_storage_mgr.h>
+#include <savan_publisher_mod.h>
#include <savan_filter_mod.h>
#include <axiom_node.h>
#include <axiom_element.h>
diff --git a/samples/client/subscriber/subscriber.c b/samples/client/subscriber/subscriber.c
index ce14a84..9a3f961 100644
--- a/samples/client/subscriber/subscriber.c
+++ b/samples/client/subscriber/subscriber.c
@@ -25,14 +25,14 @@
#include <savan_client.h>
#include <savan_constants.h>
-static void event_source_handle_lifecycle(
+static void event_source_send_event(
axutil_env_t* env,
axis2_svc_client_t *svc_client,
axis2_char_t *address,
axis2_char_t *action);
axiom_node_t *
-build_om_payload_for_weather_svc(
+build_om_payload_for_weather_event(
const axutil_env_t *env,
axis2_char_t *node_name);
@@ -100,11 +100,11 @@
* Following commented lines show how to use filtering when savan server side is
* built and running with filtering enabled.
*/
- /*axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING,
+ axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING,
"//weather_report");
axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER_DIALECT, AXIS2_HASH_KEY_STRING,
- XPATH_FILTER_DIALECT);*/
+ XPATH_FILTER_DIALECT);
/*axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING, "weather/4");
@@ -121,10 +121,14 @@
"2 renew\n"\
"3 get status\n"\
"4 unsubscribe\n"\
- "5 Generate event from weather event source\n"\
+ "5 Generate weather event\n"\
"6 quit\n\n");
- scanf("%d", &action);
+ if(1 != scanf("%d", &action))
+ {
+ printf("Give correct input\n");
+ continue;
+ }
if(1 == action) /* Send subscribe message */
{
@@ -194,7 +198,7 @@
endpoint_ref = axis2_options_get_to(options, env);
axis2_endpoint_ref_set_address(endpoint_ref, env, address);
axis2_svc_client_remove_all_headers(svc_client, env);
- event_source_handle_lifecycle((axutil_env_t*)env, svc_client, address, "send");
+ event_source_send_event((axutil_env_t*)env, svc_client, address, "send");
}
else if(7 == action)
{
@@ -216,7 +220,7 @@
}
-static void event_source_handle_lifecycle(
+static void event_source_send_event(
axutil_env_t* env,
axis2_svc_client_t *svc_client,
axis2_char_t *address,
@@ -227,7 +231,7 @@
AXIS2_LOG_INFO(env->log, "[savan] event_source_handle_lifecycle");
- payload = build_om_payload_for_weather_svc(env, action);
+ payload = build_om_payload_for_weather_event(env, action);
/* Send request */
ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
@@ -251,17 +255,23 @@
}
axiom_node_t *
-build_om_payload_for_weather_svc(
+build_om_payload_for_weather_event(
const axutil_env_t *env,
axis2_char_t *node_name)
{
- axiom_node_t *om_node = NULL;
- axiom_element_t* om_ele = NULL;
- axiom_namespace_t *ns = NULL;
+ axiom_namespace_t *test_ns = NULL;
+ axiom_element_t* test_elem = NULL;
+ axiom_node_t *test_node = NULL;
+ axiom_element_t* test_elem1 = NULL;
+ axiom_node_t *test_node1 = NULL;
+
+ /* Build a payload and pass it to the savan publisher module */
+ test_ns = axiom_namespace_create(env, "http://ws.apache.org/savan/samples/weather", "weather");
+ test_elem = axiom_element_create(env, NULL, node_name, test_ns, &test_node);
+ test_elem1 = axiom_element_create(env, test_node, "weather_report", NULL, &test_node1);
- ns = axiom_namespace_create(env, "http://ws.apache.org/axis2/c/savan/samples/weather", "ns");
- om_ele = axiom_element_create(env, NULL, node_name, ns, &om_node);
-
- return om_node;
+ axiom_element_set_text(test_elem1, env, "sunny day", test_node1);
+
+ return test_node;
}
-
+
diff --git a/samples/server/listener/listener_skeleton.c b/samples/server/listener/listener_skeleton.c
index 2e56fc9..a12d29e 100644
--- a/samples/server/listener/listener_skeleton.c
+++ b/samples/server/listener/listener_skeleton.c
@@ -82,7 +82,6 @@
* the array list of functions
*/
axutil_array_list_add(svc_skeleton->func_array, env, "weather");
- axutil_array_list_add(svc_skeleton->func_array, env, "weather_report");
/* Any initialization stuff of service should go here */
diff --git a/samples/server/listener/services.xml b/samples/server/listener/services.xml
index c716bcb..7075beb 100644
--- a/samples/server/listener/services.xml
+++ b/samples/server/listener/services.xml
@@ -1,9 +1,6 @@
<service name="listener">
<parameter name="ServiceClass" locked="xsd:false">listener</parameter>
- <operation name="weather" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <parameter name="wsamapping">http://ws.apache.org/axis2/c/samples/weather</parameter>
- </operation>
- <operation name="weather_report" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <parameter name="wsamapping">http://ws.apache.org/axis2/c/samples/weather</parameter>
+ <operation name="send" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <parameter name="wsamapping" >http://ws.apache.org/savan/samples/weather/send</parameter>
</operation>
</service>
diff --git a/samples/server/weather/Makefile.am b/samples/server/weather/Makefile.am
index 3bee760..0504727 100644
--- a/samples/server/weather/Makefile.am
+++ b/samples/server/weather/Makefile.am
@@ -9,8 +9,6 @@
libweather_la_LIBADD = -L$(AXIS2C_HOME)/lib -lsavan_client
-INCLUDES = -I@AXIS2INC@ \
- @AXIS2INC@ \
- @SAVANINC@
+INCLUDES = @AXIS2INC@ @SAVANINC@
EXTRA_DIST=services.xml
diff --git a/samples/server/weather/services.xml b/samples/server/weather/services.xml
index 23a6ba2..972dc97 100644
--- a/samples/server/weather/services.xml
+++ b/samples/server/weather/services.xml
@@ -8,6 +8,7 @@
<parameter name="TopicURL" locked="xsd:false">http://localhost:9090/axis2/services/weather</parameter>
<operation name="send">
- <parameter name="wsamapping" >http://ws.apache.org/axis2/c/savan/samples/weather/send</parameter>
+ <messageReceiver class="savan_msgreceivers" />
+ <parameter name="wsamapping" >http://ws.apache.org/savan/samples/weather/send</parameter>
</operation>
</service>
diff --git a/samples/server/weather/weather.c b/samples/server/weather/weather.c
index d6ebd69..7669986 100644
--- a/samples/server/weather/weather.c
+++ b/samples/server/weather/weather.c
@@ -20,43 +20,3 @@
#include "weather.h"
-axiom_node_t *
-build_om_programatically(
- const axutil_env_t *env,
- axis2_char_t *text);
-
-axiom_node_t *
-axis2_weather_send(
- const axutil_env_t *env,
- axiom_node_t *node)
-{
- axiom_node_t *ret_node = NULL;
-
- ret_node = build_om_programatically(env, "Weather event source generated event successfully");
-
- return ret_node;
-}
-
-/* Builds the response content */
-axiom_node_t *
-build_om_programatically(
- const axutil_env_t *env,
- axis2_char_t *text)
-{
- axiom_node_t *om_node = NULL;
- axiom_element_t* om_ele = NULL;
- axiom_node_t* text_om_node = NULL;
- axiom_element_t * text_om_ele = NULL;
- axiom_namespace_t *ns = NULL;
-
- ns = axiom_namespace_create (env, "http://ws.apache.org/axis2/c/savan/samples/weather", "ns");
-
- om_ele = axiom_element_create(env, NULL, "weather", ns, &om_node);
-
- text_om_ele = axiom_element_create(env, om_node, "text", NULL, &text_om_node);
-
- axiom_element_set_text(text_om_ele, env, text, text_om_node);
-
- return om_node;
-}
-
diff --git a/samples/server/weather/weather.h b/samples/server/weather/weather.h
index 6102965..6f395e1 100644
--- a/samples/server/weather/weather.h
+++ b/samples/server/weather/weather.h
@@ -19,9 +19,4 @@
#include <axiom_node.h>
-axiom_node_t *
-axis2_weather_send(
- const axutil_env_t *env,
- axiom_node_t *node);
-
#endif /* PUBLISHER_H*/
diff --git a/samples/server/weather/weather_skeleton.c b/samples/server/weather/weather_skeleton.c
index 081d6cd..f54c56c 100644
--- a/samples/server/weather/weather_skeleton.c
+++ b/samples/server/weather/weather_skeleton.c
@@ -16,7 +16,7 @@
#include <axis2_util.h>
#include <axis2_svc_skeleton.h>
#include <axiom_element.h>
-#include <savan_publishing_client.h>
+#include <savan_publisher_mod.h>
#include "weather.h"
@@ -49,13 +49,9 @@
int AXIS2_CALL
-weather_init(axis2_svc_skeleton_t *svc_skeleton,
- const axutil_env_t *env);
-
-static void
-send_weather_event(
- const axutil_env_t *env,
- axis2_conf_t *conf);
+weather_init(
+ axis2_svc_skeleton_t *svc_skeleton,
+ const axutil_env_t *env);
int AXIS2_CALL
weather_init_with_conf(
@@ -120,7 +116,6 @@
axis2_conf_t *conf)
{
weather_init(svc_skeleton, env);
- /*send_weather_event(env, conf); */
return AXIS2_SUCCESS;
}
@@ -134,42 +129,6 @@
axiom_node_t *node,
axis2_msg_ctx_t *msg_ctx)
{
- axis2_conf_t *conf = NULL;
- axis2_conf_ctx_t *conf_ctx = NULL;
-
- conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
- conf = axis2_conf_ctx_get_conf(conf_ctx, env);
- /* Depending on the function name invoke the
- * corresponding function
- */
- if (node)
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "node:%s", axiom_node_to_string(node, env));
- if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
- {
- axiom_element_t *element = NULL;
- element =
- (axiom_element_t *) axiom_node_get_data_element(node, env);
- if (element)
- {
- axis2_char_t *op_name =
- axiom_element_get_localname(element, env);
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "op_name:%s", op_name);
- if (op_name)
- {
- if (axutil_strcmp(op_name, "send") == 0)
- {
- send_weather_event(env, conf);
- return axis2_weather_send(env, node);
- }
- }
- }
- }
- }
-
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "[savan] Weather service ERROR: invalid OM parameters in request");
-
return NULL;
}
@@ -211,35 +170,6 @@
return AXIS2_SUCCESS;
}
-static void
-send_weather_event(
- const axutil_env_t *env,
- axis2_conf_t *conf)
-{
- axiom_namespace_t *test_ns = NULL;
- axiom_element_t* test_elem = NULL;
- axiom_node_t *test_node = NULL;
- axiom_element_t* test_elem1 = NULL;
- axiom_node_t *test_node1 = NULL;
- axis2_svc_t *svc = NULL;
- savan_publishing_client_t *pub_client = NULL;
-
- svc = axis2_conf_get_svc(conf, env, WEATHER);
-
- pub_client = savan_publishing_client_create(env, conf, svc);
- /* Build a payload and pass it to the savan publishing client */
- test_ns = axiom_namespace_create (env, "http://www.wso2.com/savan/c/weather", "weather");
- test_elem = axiom_element_create(env, NULL, "weather", test_ns, &test_node);
- test_elem1 = axiom_element_create(env, test_node, "weather_report", NULL, &test_node1);
-
- axiom_element_set_text(test_elem1, env, "sunny day", test_node1);
-
- savan_publishing_client_publish(pub_client, env, test_node, NULL);
- savan_publishing_client_free(pub_client, env);
-
- return;
-}
-
/**
* Following block distinguish the exposed part of the dll.
*/
diff --git a/src/Makefile.am b/src/Makefile.am
index 15cb836..598c56d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = handlers msgreceivers util subscribers filters storage client core $(SVC_DIR)
+SUBDIRS = handlers util subscribers filters storage publisher msgreceivers client core $(SVC_DIR)
EXTRA_DIST=data
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 717fcf0..91f0459 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -1,11 +1,11 @@
prglibdir=$(prefix)/lib
prglib_LTLIBRARIES = libsavan_client.la
-libsavan_client_la_SOURCES = savan_client.c savan_publishing_client.c
+libsavan_client_la_SOURCES = savan_client.c
libsavan_client_la_LIBADD = $(top_builddir)/src/subscribers/libsavan_subscribers.la \
$(top_builddir)/src/util/libsavan_util.la \
../storage/@SAVAN_STORAGE@/libsavan_storage.la \
- ../filters/@SAVAN_FILTER_LIB@
+ ../filters/@SAVAN_FILTER_LIB@
INCLUDES = -I$(top_builddir)/include \
@AXIS2INC@ \
diff --git a/src/data/axis2.xml b/src/data/axis2.xml
index 714a824..225be66 100644
--- a/src/data/axis2.xml
+++ b/src/data/axis2.xml
@@ -20,6 +20,9 @@
<!-- ================================================= -->
<!-- This is the Deafult Message Receiver for the Request Response style Operations -->
<!--messageReceiver mep="INOUT" class="axis2_receivers"/-->
+
+ <!-- Savan message receiver -->
+ <messageReceiver mep="INOUT" class="savan_msgreceivers"/>
<!-- ================================================= -->
<!-- Transport Ins -->
diff --git a/src/filters/xpath/Makefile.am b/src/filters/xpath/Makefile.am
index 73b1794..9ab518e 100644
--- a/src/filters/xpath/Makefile.am
+++ b/src/filters/xpath/Makefile.am
@@ -1,3 +1,4 @@
+datadir=$(prefix)/modules/savan
noinst_LTLIBRARIES = libsavan_filter_mod.la
libsavan_filter_mod_la_SOURCES = filter_mod.c
diff --git a/src/msgreceivers/Makefile.am b/src/msgreceivers/Makefile.am
index 69b02f1..f06df34 100644
--- a/src/msgreceivers/Makefile.am
+++ b/src/msgreceivers/Makefile.am
@@ -1,7 +1,9 @@
-noinst_LTLIBRARIES = libsavan_msgreceivers.la
+lib_LTLIBRARIES = libsavan_msgreceivers.la
libsavan_msgreceivers_la_SOURCES = savan_msg_recv.c
+libsavan_msgreceivers_la_LIBADD = ../publisher/@SAVAN_PUBLISHER_LIB@
+
INCLUDES = -I$(top_builddir)/include \
@AXIS2INC@ \
@AXIOMINC@ \
diff --git a/src/msgreceivers/savan_msg_recv.c b/src/msgreceivers/savan_msg_recv.c
index 8348bc7..2d6157e 100644
--- a/src/msgreceivers/savan_msg_recv.c
+++ b/src/msgreceivers/savan_msg_recv.c
@@ -29,6 +29,7 @@
#include <savan_error.h>
#include <savan_subscriber.h>
#include <savan_storage_mgr.h>
+#include <savan_publisher_mod.h>
#include <savan_msg_recv.h>
axis2_status_t AXIS2_CALL
@@ -131,9 +132,9 @@
}
else
{
- status = AXIS2_FAILURE;
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Unhandled message type");
- AXIS2_ERROR_SET(env->error, SAVAN_ERROR_UNHANDLED_MSG_TYPE, AXIS2_FAILURE);
+ /* Treat this as an event */
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Event received");
+ status = savan_msg_recv_handle_event(env, msg_ctx, new_msg_ctx);
}
if(AXIS2_SUCCESS != status)
@@ -516,6 +517,30 @@
return AXIS2_SUCCESS;
}
+axis2_status_t AXIS2_CALL
+savan_msg_recv_handle_event(
+ const axutil_env_t *env,
+ axis2_msg_ctx_t *msg_ctx,
+ axis2_msg_ctx_t *new_msg_ctx)
+{
+ axis2_conf_t *conf = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ savan_publisher_mod_t *pub_mod = NULL;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_msg_recv_handle_event");
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+
+ pub_mod = savan_publisher_mod_create(env, conf);
+
+ savan_publisher_mod_publish(pub_mod, env, msg_ctx);
+ savan_publisher_mod_free(pub_mod, env);
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_msg_recv_handle_event");
+ return AXIS2_SUCCESS;
+}
+
axiom_soap_envelope_t *AXIS2_CALL
savan_msg_recv_build_soap_envelope(
const axutil_env_t *env,
@@ -560,3 +585,29 @@
return default_envelope;
}
+AXIS2_EXPORT int
+axis2_get_instance(
+ struct axis2_msg_recv **inst,
+ const axutil_env_t * env)
+{
+ *inst = savan_msg_recv_create(env);
+ if (!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(
+ struct axis2_msg_recv *inst,
+ const axutil_env_t * env)
+{
+ if (inst)
+ {
+ axis2_msg_recv_free(inst, env);
+ }
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/storage/sqlite/sqlite3.c b/src/storage/sqlite/sqlite3.c
index bb7cc37..908ba99 100644
--- a/src/storage/sqlite/sqlite3.c
+++ b/src/storage/sqlite/sqlite3.c
@@ -17117,8 +17117,13 @@
pid = getpid();
memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
}else{
- read(fd, zBuf, nBuf);
+ int ret = 0;
+
+ ret = read(fd, zBuf, nBuf);
close(fd);
+ if(-1 == ret){
+ return SQLITE_IOERR_READ;
+ }
}
}
#endif
@@ -50407,6 +50412,7 @@
#endif
sContext.pParse = 0;
+ sContext.zAuthContext = 0;
db = pParse->db;
if( pParse->nErr || db->mallocFailed ){
goto delete_from_cleanup;
@@ -61503,6 +61509,7 @@
int oldIdx = -1; /* index of trigger "old" temp table */
sContext.pParse = 0;
+ sContext.zAuthContext = 0;
db = pParse->db;
if( pParse->nErr || db->mallocFailed ){
goto update_cleanup;
diff --git a/src/storage/sqlite/storage_mgr.c b/src/storage/sqlite/storage_mgr.c
index 16e9102..e6fd558 100644
--- a/src/storage/sqlite/storage_mgr.c
+++ b/src/storage/sqlite/storage_mgr.c
@@ -406,6 +406,7 @@
if(subscriber)
{
int i = 0;
+ axis2_char_t *temp = NULL;
id = savan_subscriber_get_id(subscriber, env);
endto_epr = savan_subscriber_get_end_to(subscriber, env);
@@ -414,7 +415,9 @@
endto = (axis2_char_t *) axis2_endpoint_ref_get_address(endto_epr, env);
if(endto)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",end_to");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",end_to");
+ AXIS2_FREE(env->allocator, temp);
counter++;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_insert:%s", sql_insert);
}
@@ -426,7 +429,9 @@
notifyto = (axis2_char_t *) axis2_endpoint_ref_get_address(notifyto_epr, env);
if(notifyto)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",notify_to");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",notify_to");
+ AXIS2_FREE(env->allocator, temp);
counter++;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_insert:%s", sql_insert);
}
@@ -435,29 +440,43 @@
delivery_mode = savan_subscriber_get_delivery_mode(subscriber, env);
if(delivery_mode)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",delivery_mode");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",delivery_mode");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
expires = savan_subscriber_get_expires(subscriber, env);
if(expires)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",expires");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",expires");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
filter = savan_subscriber_get_filter(subscriber, env);
if(filter)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",filter");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",filter");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
renewed = (int) savan_subscriber_get_renew_status(subscriber, env);
- sprintf(sql_insert, "%s%s", sql_insert, ",renewed");
- sprintf(sql_insert, "%s%s", sql_insert, ") values(?");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",renewed");
+ AXIS2_FREE(env->allocator, temp);
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ") values(?");
+ AXIS2_FREE(env->allocator, temp);
for(i = 0; i < counter; i++)
{
- sprintf(sql_insert, "%s%s", sql_insert, ",?");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ",?");
+ AXIS2_FREE(env->allocator, temp);
}
- sprintf(sql_insert, "%s%s", sql_insert, ");");
+ temp = axutil_strdup(env, sql_insert);
+ sprintf(sql_insert, "%s%s", temp, ");");
+ AXIS2_FREE(env->allocator, temp);
}
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_insert:%s", sql_insert);
@@ -472,11 +491,13 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
if (sqlite3_bind_text(insertqry, counter, id, strlen(id), SQLITE_STATIC))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] id:%s", id);
@@ -488,6 +509,7 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
}
if(notifyto)
@@ -498,6 +520,7 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
}
if(delivery_mode)
@@ -508,6 +531,7 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
}
if(expires)
@@ -518,6 +542,7 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
}
if(filter)
@@ -527,20 +552,24 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
}
counter++;
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] renewed:%d", renewed);
if (sqlite3_bind_int(insertqry, counter, renewed))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"[savan] Sql insert error: %s", sqlite3_errmsg(dbconn));
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
}
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] renewed:%d", renewed);
if (sqlite3_step(insertqry) == SQLITE_DONE)
{
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Subscriber is added to the database");
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] sql:%s", sql_insert);
sqlite3_reset(insertqry);
}
else
@@ -599,6 +628,8 @@
if(subscriber)
{
+ axis2_char_t *temp = NULL;
+
id = savan_subscriber_get_id(subscriber, env);
endto_epr = savan_subscriber_get_end_to(subscriber, env);
if(endto_epr)
@@ -606,7 +637,9 @@
endto = (axis2_char_t *) axis2_endpoint_ref_get_address(endto_epr, env);
if(endto)
{
- sprintf(sql_update, "%s%s", sql_update, "end_to=?, ");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "end_to=?, ");
+ AXIS2_FREE(env->allocator, temp);
counter++;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_update:%s", sql_update);
}
@@ -618,7 +651,9 @@
notifyto = (axis2_char_t *) axis2_endpoint_ref_get_address(notifyto_epr, env);
if(notifyto)
{
- sprintf(sql_update, "%s%s", sql_update, "notify_to=?, ");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "notify_to=?, ");
+ AXIS2_FREE(env->allocator, temp);
counter++;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_update:%s", sql_update);
}
@@ -627,26 +662,34 @@
delivery_mode = savan_subscriber_get_delivery_mode(subscriber, env);
if(delivery_mode)
{
- sprintf(sql_update, "%s%s", sql_update, "delivery_mode=?, ");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "delivery_mode=?, ");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
expires = savan_subscriber_get_expires(subscriber, env);
if(expires)
{
- sprintf(sql_update, "%s%s", sql_update, "expires=?, ");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "expires=?, ");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
filter = savan_subscriber_get_filter(subscriber, env);
if(filter)
{
- sprintf(sql_update, "%s%s", sql_update, "filter=?, ");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "filter=?, ");
+ AXIS2_FREE(env->allocator, temp);
counter++;
}
renewed = (int) savan_subscriber_get_renew_status(subscriber, env);
- sprintf(sql_update, "%s%s", sql_update, "renewed=? where id=?;");
+ temp = axutil_strdup(env, sql_update);
+ sprintf(sql_update, "%s%s", temp, "renewed=? where id=?;");
+ AXIS2_FREE(env->allocator, temp);
}
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "sql_update:%s", sql_update);
@@ -1131,7 +1174,10 @@
{
axis2_char_t permission_str[256];
sprintf(permission_str, "chmod 777 %s", dbname);
- system(permission_str);
+ if(-1 == system(permission_str))
+ {
+ return AXIS2_FAILURE;
+ }
}
#endif