You are viewing a plain text version of this content. The canonical link for it is here.
Posted to savan-dev@ws.apache.org by da...@apache.org on 2009/03/06 12:47:38 UTC
svn commit: r750859 - in /webservices/savan/trunk/c: ./ include/
samples/client/subscriber/ src/client/ src/core/ src/filters/common/
src/filters/xpath/ src/subscribers/ src/util/
Author: damitha
Date: Fri Mar 6 11:47:37 2009
New Revision: 750859
URL: http://svn.apache.org/viewvc?rev=750859&view=rev
Log:
Working on xpath filter module
Modified:
webservices/savan/trunk/c/configure.ac
webservices/savan/trunk/c/include/savan_error.h
webservices/savan/trunk/c/include/savan_filter_mod.h
webservices/savan/trunk/c/samples/client/subscriber/subscriber.c
webservices/savan/trunk/c/src/client/Makefile.am
webservices/savan/trunk/c/src/client/savan_publishing_client.c
webservices/savan/trunk/c/src/core/savan_sub_processor.c
webservices/savan/trunk/c/src/filters/common/Makefile.am
webservices/savan/trunk/c/src/filters/common/filter_mod.c
webservices/savan/trunk/c/src/filters/xpath/Makefile.am
webservices/savan/trunk/c/src/filters/xpath/filter_mod.c
webservices/savan/trunk/c/src/subscribers/Makefile.am
webservices/savan/trunk/c/src/subscribers/savan_subscriber.c
webservices/savan/trunk/c/src/util/Makefile.am
webservices/savan/trunk/c/src/util/error.c
webservices/savan/trunk/c/src/util/savan_util.c
Modified: webservices/savan/trunk/c/configure.ac
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/configure.ac?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/configure.ac (original)
+++ webservices/savan/trunk/c/configure.ac Fri Mar 6 11:47:37 2009
@@ -69,24 +69,6 @@
AC_MSG_RESULT(no)
)
-AC_MSG_CHECKING(whether to enable savan filtering)
-AC_ARG_ENABLE(filtering, [ --enable-filtering
- enable savan filtering(default=no)],
-[ case "${enableval}" in
- no)
- AC_MSG_RESULT(no)
- ;;
- *)
- AC_MSG_RESULT(yes)
- PKG_CHECK_MODULES(XSLT, libxslt)
- CFLAGS="$CFLAGS -DSAVAN_FILTERING $XSLT_CFLAGS"
- LDFLAGS="$LDFLAGS -lxslt"
-
- ;;
- esac ],
- AC_MSG_RESULT(no)
-)
-
AC_MSG_CHECKING(whether to build sqlite based storage)
AC_ARG_ENABLE(sqlite, [ --enable-sqlite
build Sqlite based storage (default=yes)],
Modified: webservices/savan/trunk/c/include/savan_error.h
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/include/savan_error.h?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/include/savan_error.h (original)
+++ webservices/savan/trunk/c/include/savan_error.h Fri Mar 6 11:47:37 2009
@@ -101,6 +101,8 @@
SAVAN_ERROR_DATABASE_CREATION_ERROR,
/* Could create the filter */
SAVAN_ERROR_FILTER_CREATION_FAILED,
+ /* Could not create the filter module */
+ SAVAN_ERROR_FILTER_MODULE_COULD_NOT_BE_RETRIEVED,
SAVAN_ERROR_LAST
Modified: webservices/savan/trunk/c/include/savan_filter_mod.h
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/include/savan_filter_mod.h?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/include/savan_filter_mod.h (original)
+++ webservices/savan/trunk/c/include/savan_filter_mod.h Fri Mar 6 11:47:37 2009
@@ -18,7 +18,7 @@
#define SAVAN_FILTER_H
/**
- * @file savan_filter.h
+ * @file savan_filter_mod.h
* @brief
*/
#include <platforms/axutil_platform_auto_sense.h>
@@ -34,27 +34,27 @@
#endif
/**
- * @ingroup savan_filter
+ * @ingroup savan_filter_mod
* @{
*/
-typedef struct savan_filter savan_filter_t;
-typedef struct savan_filter_ops savan_filter_ops_t;
+typedef struct savan_filter_mod savan_filter_mod_t;
+typedef struct savan_filter_mod_ops savan_filter_mod_ops_t;
/**
* @brief Filter ops struct
- * Encapsulator struct for ops of savan_filter
+ * Encapsulator struct for ops of savan_filter_mod
*/
-AXIS2_DECLARE_DATA struct savan_filter_ops
+AXIS2_DECLARE_DATA struct savan_filter_mod_ops
{
void (AXIS2_CALL *
free)(
- savan_filter_t *filter,
+ savan_filter_mod_t *filter,
const axutil_env_t *env);
axiom_node_t *(AXIS2_CALL *
apply)(
- savan_filter_t *filter,
+ savan_filter_mod_t *filter,
const axutil_env_t *env,
savan_subscriber_t *subscriber,
axiom_node_t *payload);
@@ -62,9 +62,9 @@
};
-AXIS2_DECLARE_DATA struct savan_filter
+AXIS2_DECLARE_DATA struct savan_filter_mod
{
- const savan_filter_ops_t *ops;
+ const savan_filter_mod_ops_t *ops;
};
@@ -74,8 +74,8 @@
* @param conf axis2 configuration
* @return status of the operation
*/
-AXIS2_EXTERN savan_filter_t * AXIS2_CALL
-savan_filter_create(
+AXIS2_EXTERN savan_filter_mod_t * AXIS2_CALL
+savan_filter_mod_create(
const axutil_env_t *env,
axis2_conf_t *conf);
@@ -85,8 +85,8 @@
* @param env environment object
*/
void AXIS2_CALL
-savan_filter_free(
- savan_filter_t *filter,
+savan_filter_mod_free(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *envv);
/**
@@ -98,8 +98,8 @@
* @return filtered payload
*/
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-savan_filter_apply(
- savan_filter_t *filter,
+savan_filter_mod_apply(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env,
savan_subscriber_t *subscriber,
axiom_node_t *payload);
Modified: webservices/savan/trunk/c/samples/client/subscriber/subscriber.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/client/subscriber/subscriber.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/client/subscriber/subscriber.c (original)
+++ webservices/savan/trunk/c/samples/client/subscriber/subscriber.c Fri Mar 6 11:47:37 2009
@@ -101,15 +101,17 @@
* built and running with filtering enabled.
*/
/*axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING,
- "//test3[@data='5']");
+ "//test3[@data='5']");*/
+ 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,
- DEFAULT_FILTER_DIALECT);*/
+ XPATH_FILTER_DIALECT);
- axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING, "weather/4");
+ /*axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING, "weather/4");
axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER_DIALECT, AXIS2_HASH_KEY_STRING,
- DEFAULT_FILTER_DIALECT);
+ DEFAULT_FILTER_DIALECT);*/
/* Create a savan client */
savan_client = savan_client_create(env);
Modified: webservices/savan/trunk/c/src/client/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/client/Makefile.am?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/client/Makefile.am (original)
+++ webservices/savan/trunk/c/src/client/Makefile.am Fri Mar 6 11:47:37 2009
@@ -4,7 +4,8 @@
libsavan_client_la_SOURCES = savan_client.c savan_publishing_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
+ ../storage/@SAVAN_STORAGE@/libsavan_storage.la \
+ ../filters/@SAVAN_FILTER@/libsavan_filter_mod.la
INCLUDES = -I$(top_builddir)/include \
@AXIS2INC@ \
Modified: webservices/savan/trunk/c/src/client/savan_publishing_client.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/client/savan_publishing_client.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/client/savan_publishing_client.c (original)
+++ webservices/savan/trunk/c/src/client/savan_publishing_client.c Fri Mar 6 11:47:37 2009
@@ -81,6 +81,7 @@
axis2_conf_t *conf = NULL;
int i = 0, size = 0;
savan_storage_mgr_t *storage_mgr = NULL;
+ savan_filter_mod_t *filtermod = NULL;
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_publishing_client_publish");
@@ -106,14 +107,11 @@
sub = (savan_subscriber_t *)axutil_array_list_get(subs_store, env, i);
if (sub)
{
- axis2_char_t *filter_template_path = NULL;
axis2_char_t *id = savan_subscriber_get_id(sub, env);
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", id);
- filter_template_path = savan_util_get_module_param(env, conf,
- SAVAN_FILTER_TEMPLATE_PATH);
- savan_subscriber_set_filter_template_path(sub, env, filter_template_path);
- if(!savan_subscriber_publish(sub, env, payload))
+ filtermod = savan_util_get_filter_module(env, client->conf);
+ if(!savan_subscriber_publish(sub, env, filtermod, payload))
{
axis2_endpoint_ref_t *notifyto = savan_subscriber_get_notify_to(sub, env);
const axis2_char_t *address = NULL;
Modified: webservices/savan/trunk/c/src/core/savan_sub_processor.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/core/savan_sub_processor.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/core/savan_sub_processor.c (original)
+++ webservices/savan/trunk/c/src/core/savan_sub_processor.c Fri Mar 6 11:47:37 2009
@@ -453,7 +453,7 @@
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Filter is Null");
return AXIS2_SUCCESS;
}
- else if(!axutil_strcmp(filter_dialect, DEFAULT_FILTER_DIALECT))
+ else if(!axutil_strcmp(filter_dialect, XPATH_FILTER_DIALECT))
{
axis2_char_t *reason = NULL;
@@ -472,6 +472,10 @@
return AXIS2_FAILURE;
#endif
}
+ else if(!axutil_strcmp(filter_dialect, SYNAPSE_FILTER_DIALECT))
+ {
+ return AXIS2_SUCCESS;
+ }
else
{
axis2_char_t *reason = NULL;
@@ -505,11 +509,11 @@
return AXIS2_FAILURE;
}
/* Hold this until filter abstration is properly designed and implemented */
- /*if(savan_sub_processor_validate_filter(subscriber,
+ if(savan_sub_processor_validate_filter(subscriber,
env, msg_ctx) == AXIS2_FAILURE)
{
return AXIS2_FAILURE;
- }*/
+ }
return AXIS2_SUCCESS;
}
Modified: webservices/savan/trunk/c/src/filters/common/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/filters/common/Makefile.am?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/filters/common/Makefile.am (original)
+++ webservices/savan/trunk/c/src/filters/common/Makefile.am Fri Mar 6 11:47:37 2009
@@ -1,6 +1,6 @@
-noinst_LTLIBRARIES = libsavan_common_filter.la
+noinst_LTLIBRARIES = libsavan_common_filter_mod.la
-libsavan_common_filter_la_SOURCES = filter.c
+libsavan_common_filter_mod_la_SOURCES = filter_mod.c
INCLUDES = -I$(top_builddir)/include \
@AXIS2INC@ \
Modified: webservices/savan/trunk/c/src/filters/common/filter_mod.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/filters/common/filter_mod.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/filters/common/filter_mod.c (original)
+++ webservices/savan/trunk/c/src/filters/common/filter_mod.c Fri Mar 6 11:47:37 2009
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <savan_filter.h>
+#include <savan_filter_mod.h>
#include <savan_constants.h>
#include <savan_error.h>
#include <savan_util.h>
@@ -25,20 +25,20 @@
#include <axis2_conf_ctx.h>
AXIS2_EXTERN void AXIS2_CALL
-savan_filter_free(
- savan_filter_t *filter,
+savan_filter_mod_free(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env)
{
- return filter->ops->free(filter, env);
+ return filtermod->ops->free(filtermod, env);
}
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-savan_filter_apply(
- savan_filter_t *filter,
+savan_filter_mod_apply(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env,
savan_subscriber_t *subscriber,
axiom_node_t *payload)
{
- return filter->ops->apply(filter, env, subscriber, payload);
+ return filtermod->ops->apply(filtermod, env, subscriber, payload);
}
Modified: webservices/savan/trunk/c/src/filters/xpath/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/filters/xpath/Makefile.am?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/filters/xpath/Makefile.am (original)
+++ webservices/savan/trunk/c/src/filters/xpath/Makefile.am Fri Mar 6 11:47:37 2009
@@ -1,8 +1,7 @@
-noinst_LTLIBRARIES = libsavan_filter.la
+noinst_LTLIBRARIES = libsavan_filter_mod.la
-libsavan_filter_la_SOURCES = filter.c
-libsavan_filter_la_LIBADD = ../common/libsavan_common_filter.la \
- -lxml2
+libsavan_filter_mod_la_SOURCES = filter_mod.c
+libsavan_filter_mod_la_LIBADD = ../common/libsavan_common_filter_mod.la -lxml2
data_DATA=template.xsl
Modified: webservices/savan/trunk/c/src/filters/xpath/filter_mod.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/filters/xpath/filter_mod.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/filters/xpath/filter_mod.c (original)
+++ webservices/savan/trunk/c/src/filters/xpath/filter_mod.c Fri Mar 6 11:47:37 2009
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <savan_filter.h>
+#include <savan_filter_mod.h>
#include <axutil_log.h>
#include <axutil_hash.h>
#include <axutil_property.h>
@@ -38,109 +38,109 @@
* @brief Savan XPath Filter Struct Impl
* Savan XPath Filter
*/
-typedef struct savan_xpath_filter
+typedef struct savan_xpath_filter_mod
{
- savan_filter_t filter;
+ savan_filter_mod_t filtermod;
axis2_char_t *dialect;
axis2_char_t *filter_template_path;
axis2_conf_t *conf;
-} savan_xpath_filter_t;
+} savan_xpath_filter_mod_t;
-#define SAVAN_INTF_TO_IMPL(filter) ((savan_xpath_filter_t *) filter)
+#define SAVAN_INTF_TO_IMPL(filtermod) ((savan_xpath_filter_mod_t *) filtermod)
static xsltStylesheetPtr
-savan_xpath_filter_get_filter_template(
+savan_xpath_filter_mod_get_filter_template(
const axutil_env_t *env,
axis2_char_t *filter_template_path,
xmlChar *filter);
static axis2_status_t
-savan_xpath_filter_update_filter_template(
+savan_xpath_filter_mod_update_filter_template(
xmlNodeSetPtr nodes,
const xmlChar* value);
AXIS2_EXTERN void AXIS2_CALL
-savan_xpath_filter_free(
- savan_filter_t *filter,
+savan_xpath_filter_mod_free(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env);
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-savan_xpath_filter_apply(
- savan_filter_t *filter,
+savan_xpath_filter_mod_apply(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env,
savan_subscriber_t *subscriber,
axiom_node_t *payload);
-static const savan_filter_ops_t savan_filter_ops =
+static const savan_filter_mod_ops_t savan_filter_mod_ops =
{
- savan_xpath_filter_free,
- savan_xpath_filter_apply
+ savan_xpath_filter_mod_free,
+ savan_xpath_filter_mod_apply
};
-AXIS2_EXTERN savan_filter_t * AXIS2_CALL
-savan_xpath_filter_create(
+AXIS2_EXTERN savan_filter_mod_t * AXIS2_CALL
+savan_filter_mod_create(
const axutil_env_t *env,
axis2_conf_t *conf)
{
- savan_xpath_filter_t *filterimpl = NULL;
+ savan_xpath_filter_mod_t *filtermodimpl = NULL;
axis2_char_t *filter_template_path = NULL;
- filterimpl = AXIS2_MALLOC(env->allocator, sizeof(savan_xpath_filter_t));
- if (!filterimpl)
+ filtermodimpl = AXIS2_MALLOC(env->allocator, sizeof(savan_xpath_filter_mod_t));
+ if (!filtermodimpl)
{
AXIS2_HANDLE_ERROR(env, SAVAN_ERROR_FILTER_CREATION_FAILED, AXIS2_FAILURE);
return NULL;
}
- memset ((void *) filterimpl, 0, sizeof(savan_xpath_filter_t));
+ memset ((void *) filtermodimpl, 0, sizeof(savan_xpath_filter_mod_t));
filter_template_path = savan_util_get_module_param(env, conf, SAVAN_FILTER_TEMPLATE_PATH);
if(!filter_template_path)
{
- savan_xpath_filter_free((savan_filter_t *) filterimpl, env);
+ savan_xpath_filter_mod_free((savan_filter_mod_t *) filtermodimpl, env);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Filter template path not set");
return NULL;
}
- filterimpl->filter_template_path = filter_template_path;
+ filtermodimpl->filter_template_path = filter_template_path;
- filterimpl->dialect = NULL;
- filterimpl->conf = conf;
- filterimpl->filter.ops = &savan_filter_ops;
+ filtermodimpl->dialect = NULL;
+ filtermodimpl->conf = conf;
+ filtermodimpl->filtermod.ops = &savan_filter_mod_ops;
- return (savan_filter_t *) filterimpl;
+ return (savan_filter_mod_t *) filtermodimpl;
}
AXIS2_EXTERN void AXIS2_CALL
-savan_xpath_filter_free(
- savan_filter_t *filter,
+savan_xpath_filter_mod_free(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env)
{
- savan_xpath_filter_t *filterimpl = NULL;
- filterimpl = SAVAN_INTF_TO_IMPL(filter);
+ savan_xpath_filter_mod_t *filtermodimpl = NULL;
+ filtermodimpl = SAVAN_INTF_TO_IMPL(filtermod);
- AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_xpath_filter_free");
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_xpath_filter_mod_free");
- if(filterimpl->dialect)
+ if(filtermodimpl->dialect)
{
- AXIS2_FREE(env->allocator, filterimpl->dialect);
- filterimpl->dialect = NULL;
+ AXIS2_FREE(env->allocator, filtermodimpl->dialect);
+ filtermodimpl->dialect = NULL;
}
- filterimpl->conf = NULL;
+ filtermodimpl->conf = NULL;
- if(filterimpl)
+ if(filtermodimpl)
{
- AXIS2_FREE(env->allocator, filterimpl);
- filterimpl = NULL;
+ AXIS2_FREE(env->allocator, filtermodimpl);
+ filtermodimpl = NULL;
}
- AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_xpath_filter_free");
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_xpath_filter_mod_free");
}
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-savan_xpath_filter_apply(
- savan_filter_t *filter,
+savan_xpath_filter_mod_apply(
+ savan_filter_mod_t *filtermod,
const axutil_env_t *env,
savan_subscriber_t *subscriber,
axiom_node_t *payload)
@@ -155,12 +155,12 @@
axiom_document_t *document = NULL;
axiom_node_t *node = NULL;
xmlChar *xfilter = NULL;
- savan_xpath_filter_t *filterimpl = NULL;
+ savan_xpath_filter_mod_t *filtermodimpl = NULL;
- filterimpl = SAVAN_INTF_TO_IMPL(filter);
+ filtermodimpl = SAVAN_INTF_TO_IMPL(filtermod);
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
- "[savan] Entry:savan_xpath_filter_insert_subscriber");
+ "[savan] Entry:savan_xpath_filter_mod_insert_subscriber");
xfilter = (xmlChar *) savan_subscriber_get_filter(subscriber, env);
if(!xfilter)
@@ -174,8 +174,8 @@
payload_doc = (xmlDocPtr)xmlParseDoc((xmlChar*)payload_string);
- xslt_template_filter = (xsltStylesheetPtr) savan_xpath_filter_get_filter_template(env,
- filterimpl->filter_template_path, xfilter);
+ xslt_template_filter = (xsltStylesheetPtr) savan_xpath_filter_mod_get_filter_template(env,
+ filtermodimpl->filter_template_path, xfilter);
xmlDocPtr result_doc = (xmlDocPtr)xsltApplyStylesheet(xslt_template_filter, payload_doc, NULL);
@@ -235,7 +235,7 @@
}
static xsltStylesheetPtr
-savan_xpath_filter_get_filter_template(
+savan_xpath_filter_mod_get_filter_template(
const axutil_env_t *env,
axis2_char_t *filter_template_path,
xmlChar *filter)
@@ -252,7 +252,7 @@
xpathExpr = (xmlChar*)"//@select";
xpathCtx = xmlXPathNewContext(xslt_template_xml);
xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
- savan_xpath_filter_update_filter_template(xpathObj->nodesetval, filter);
+ savan_xpath_filter_mod_update_filter_template(xpathObj->nodesetval, filter);
xslt_template_xslt = xsltParseStylesheetDoc(xslt_template_xml);
@@ -263,7 +263,7 @@
}
static axis2_status_t
-savan_xpath_filter_update_filter_template(
+savan_xpath_filter_mod_update_filter_template(
xmlNodeSetPtr nodes,
const xmlChar* value)
{
Modified: webservices/savan/trunk/c/src/subscribers/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/subscribers/Makefile.am?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/subscribers/Makefile.am (original)
+++ webservices/savan/trunk/c/src/subscribers/Makefile.am Fri Mar 6 11:47:37 2009
@@ -8,7 +8,4 @@
@NEETHIINC@ \
@AXIS2INC@
-libsavan_subscribers_la_LIBADD = \
- -lxml2
-
Modified: webservices/savan/trunk/c/src/subscribers/savan_subscriber.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/subscribers/savan_subscriber.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/subscribers/savan_subscriber.c (original)
+++ webservices/savan/trunk/c/src/subscribers/savan_subscriber.c Fri Mar 6 11:47:37 2009
@@ -22,10 +22,7 @@
#include <savan_subscriber.h>
#include <savan_util.h>
-
-#ifdef SAVAN_FILTERING
-#include <libxslt/xsltutils.h>
-#endif
+#include <savan_error.h>
struct savan_subscriber_t
{
@@ -39,11 +36,6 @@
axis2_char_t *topic_url;*/
axis2_bool_t renewed;
axis2_char_t *filter_dialect;
-
- #ifdef SAVAN_FILTERING
- xsltStylesheetPtr xslt_filter;
- axis2_char_t *filter_template_path;
- #endif
};
AXIS2_EXTERN savan_subscriber_t * AXIS2_CALL
@@ -70,10 +62,6 @@
/*subscriber->topic_name = NULL;
subscriber->topic_url = NULL;*/
subscriber->renewed = AXIS2_FALSE;
- #ifdef SAVAN_FILTERING
- subscriber->xslt_filter = NULL;
- subscriber->filter_template_path = NULL;
- #endif
return subscriber;
}
@@ -122,19 +110,6 @@
AXIS2_FREE(env->allocator, subscriber->topic_url);
}*/
- #ifdef SAVAN_FILTERING
- if(subscriber->xslt_filter)
- {
- AXIS2_FREE(env->allocator, subscriber->xslt_filter);
- }
-
- if(subscriber->filter_template_path)
- {
- AXIS2_FREE(env->allocator, subscriber->filter_template_path);
- }
-
- #endif
-
if(subscriber->filter_dialect)
{
AXIS2_FREE(env->allocator, subscriber->filter_dialect);
@@ -143,71 +118,6 @@
AXIS2_FREE(env->allocator, subscriber);
}
-void* AXIS2_CALL
-savan_subscriber_get_filter_template(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env)
-{
- #ifdef SAVAN_FILTERING
- return subscriber->xslt_filter;
- #else
- return NULL;
- #endif
-}
-
-axis2_status_t AXIS2_CALL
-savan_subscriber_set_filter_template(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env,
- void *xslt_filter_template)
-{
- if (!subscriber->filter)
- {
- return AXIS2_SUCCESS;
- }
-
- #ifdef SAVAN_FILTERING
- if (subscriber->xslt_filter)
- {
- AXIS2_FREE(env->allocator, subscriber->filter);
- subscriber->xslt_filter = NULL;
- }
- subscriber->xslt_filter = (xsltStylesheetPtr)xslt_filter_template;
- #endif
- return AXIS2_SUCCESS;
-}
-
-axis2_status_t AXIS2_CALL
-savan_subscriber_set_filter_template_path(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env,
- axis2_char_t *path)
-{
- #ifdef SAVAN_FILTERING
- if (subscriber->filter_template_path)
- {
- AXIS2_FREE(env->allocator, subscriber->filter_template_path);
- subscriber->filter_template_path = NULL;
- }
- subscriber->filter_template_path = axutil_strdup(env, path);
- #endif
- return AXIS2_SUCCESS;
-}
-
-axis2_char_t *AXIS2_CALL
-savan_subscriber_get_filter_template_path(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env)
-{
- axis2_char_t *filter_template_path = NULL;
-
- #ifdef SAVAN_FILTERING
- filter_template_path = subscriber->filter_template_path;
- #endif
-
- return filter_template_path;
-}
-
AXIS2_EXTERN axis2_char_t * AXIS2_CALL
savan_subscriber_get_id(
savan_subscriber_t *subscriber,
@@ -382,6 +292,7 @@
savan_subscriber_publish(
savan_subscriber_t *subscriber,
const axutil_env_t *env,
+ savan_filter_mod_t *filtermod,
axiom_node_t *payload)
{
axis2_svc_client_t *svc_client = NULL;
@@ -421,18 +332,25 @@
/* Apply the filter, and check whether it evaluates to success */
- #ifdef SAVAN_FILTERING
- filtered_payload = savan_util_apply_filter(subscriber, env, payload);
- if(!filtered_payload)
+ if(savan_subscriber_get_filter(subscriber, env) && !filtermod)
{
- status = axutil_error_get_status_code(env->error);
- if(AXIS2_SUCCESS != status)
+ AXIS2_HANDLE_ERROR(env, SAVAN_ERROR_FILTER_MODULE_COULD_NOT_BE_RETRIEVED, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+
+ if(filtermod)
+ {
+ filtered_payload = savan_filter_mod_apply(filtermod ,env, subscriber, payload);
+ if(!filtered_payload)
{
- return status;
+ status = axutil_error_get_status_code(env->error);
+ if(AXIS2_SUCCESS != status)
+ {
+ return status;
+ }
}
}
- #endif
-
+
/* Set service client options */
axis2_svc_client_set_options(svc_client, env, options);
if(filtered_payload)
Modified: webservices/savan/trunk/c/src/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/util/Makefile.am?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/util/Makefile.am (original)
+++ webservices/savan/trunk/c/src/util/Makefile.am Fri Mar 6 11:47:37 2009
@@ -3,14 +3,9 @@
libsavan_util_la_SOURCES = savan_util.c error.c
-data_DATA=template.xsl
INCLUDES = -I$(top_builddir)/include \
@AXIOMINC@ \
@AXIS2INC@ \
@UTILINC@ \
@NEETHIINC@
-libsavan_util_la_LIBADD = \
- -lxml2
-
-EXTRA_DIST=template.xsl
Modified: webservices/savan/trunk/c/src/util/error.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/util/error.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/util/error.c (original)
+++ webservices/savan/trunk/c/src/util/error.c Fri Mar 6 11:47:37 2009
@@ -85,6 +85,9 @@
axutil_error_messages[SAVAN_ERROR_FILTER_CREATION_FAILED] =
"Could not create the filter";
+
+ axutil_error_messages[SAVAN_ERROR_FILTER_MODULE_COULD_NOT_BE_RETRIEVED] =
+ "Could not create the filter module";
return AXIS2_SUCCESS;
}
Modified: webservices/savan/trunk/c/src/util/savan_util.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/src/util/savan_util.c?rev=750859&r1=750858&r2=750859&view=diff
==============================================================================
--- webservices/savan/trunk/c/src/util/savan_util.c (original)
+++ webservices/savan/trunk/c/src/util/savan_util.c Fri Mar 6 11:47:37 2009
@@ -32,16 +32,6 @@
#include <savan_msg_recv.h>
#include <savan_error.h>
#include <savan_storage_mgr.h>
-#ifdef SAVAN_FILTERING
-#include <libxslt/xsltutils.h>
-#endif
-
-#ifdef SAVAN_FILTERING
-axis2_status_t
-savan_util_update_filter_template(
- xmlNodeSetPtr nodes,
- const xmlChar* value);
-#endif
axis2_status_t AXIS2_CALL
savan_util_create_fault_envelope(
@@ -84,155 +74,6 @@
return AXIS2_SUCCESS;
}
-#ifdef SAVAN_FILTERING
-axis2_status_t AXIS2_CALL
-savan_util_set_filter_template_for_subscriber(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env)
-{
- xsltStylesheetPtr xslt_template_xslt = NULL;
- xmlDocPtr xslt_template_xml = NULL;
- axis2_char_t *filter_template_path = NULL;
-
- if(!savan_subscriber_get_filter(subscriber, env))
- {
- return AXIS2_SUCCESS;
- }
-
- filter_template_path = savan_subscriber_get_filter_template_path(subscriber, env);
- if(!filter_template_path)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Filter template path not set");
- return AXIS2_FAILURE;
- }
-
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] filter_template_path:%s", filter_template_path);
-
- xslt_template_xml = xmlParseFile(filter_template_path);
- xmlChar* xpathExpr = (xmlChar*)"//@select";
- xmlChar* value = (xmlChar*)savan_subscriber_get_filter(subscriber,env);
- xmlXPathContextPtr xpathCtx = xmlXPathNewContext(xslt_template_xml);
- xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
- savan_util_update_filter_template(xpathObj->nodesetval, value);
-
- xslt_template_xslt = xsltParseStylesheetDoc(xslt_template_xml);
- savan_subscriber_set_filter_template(subscriber, env, xslt_template_xslt);
-
- xmlXPathFreeObject(xpathObj);
- xmlXPathFreeContext(xpathCtx);
-
- return AXIS2_SUCCESS;
-}
-#endif
-
-#ifdef SAVAN_FILTERING
-axiom_node_t *AXIS2_CALL
-savan_util_apply_filter(
- savan_subscriber_t *subscriber,
- const axutil_env_t *env,
- axiom_node_t *payload)
-{
- xmlChar *buffer = NULL;
- int size = 0;
- axis2_char_t *payload_string = NULL;
- xmlDocPtr payload_doc = NULL;
- xsltStylesheetPtr xslt_template_filter = NULL;
- axiom_xml_reader_t *reader = NULL;
- axiom_stax_builder_t *om_builder = NULL;
- axiom_document_t *document = NULL;
- axiom_node_t *node = NULL;
- axis2_char_t *filter = NULL;
-
- filter = savan_subscriber_get_filter(subscriber, env);
- if(!filter)
- {
- return payload;
- }
-
- payload_string = axiom_node_to_string(payload, env);
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
- "[savan] payload_string before applying filter %s:%s", filter, payload_string);
-
- payload_doc = (xmlDocPtr)xmlParseDoc((xmlChar*)payload_string);
-
- savan_util_set_filter_template_for_subscriber(subscriber, env);
-
- xslt_template_filter = (xsltStylesheetPtr)savan_subscriber_get_filter_template(subscriber,
- env);
-
- xmlDocPtr result_doc = (xmlDocPtr)xsltApplyStylesheet(xslt_template_filter, payload_doc, NULL);
-
- if(result_doc)
- {
- xmlDocDumpMemory(result_doc, &buffer, &size);
- }
-
- if(buffer)
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
- "[savan] payload_string after applying filter:%s", buffer);
- reader = axiom_xml_reader_create_for_memory(env,
- (char*)buffer,axutil_strlen((char*)buffer), NULL, AXIS2_XML_PARSER_TYPE_BUFFER);
- }
-
- if(reader)
- {
- om_builder = axiom_stax_builder_create(env, reader);
- }
-
- if(om_builder)
- {
- document = axiom_stax_builder_get_document(om_builder, env);
- }
-
- if(document)
- {
- node = axiom_document_build_all(document, env);
- }
-
- if(om_builder)
- {
- axiom_stax_builder_free_self(om_builder, env);
- }
-
- /*free(payload_string);*/ /* In apache freeing this give seg fault:damitha */
- if(result_doc)
- {
- xmlFreeDoc(result_doc);
- }
-
- if(!node)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Applying filter for payload failed");
- AXIS2_ERROR_SET(env->error, SAVAN_ERROR_APPLYING_FILTER_FAILED, AXIS2_FAILURE);
- return NULL;
- }
- else
- {
- return node;
- }
-}
-#endif
-
-#ifdef SAVAN_FILTERING
-axis2_status_t
-savan_util_update_filter_template(
- xmlNodeSetPtr nodes,
- const xmlChar* value)
-{
- int size;
- int i;
- size = (nodes) ? nodes->nodeNr : 0;
- for(i = size - 1; i >= 0; i--)
- {
- xmlNodeSetContent(nodes->nodeTab[i], value);
- if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
- nodes->nodeTab[i] = NULL;
- }
- return AXIS2_SUCCESS;
-}
-#endif
-
axiom_node_t * AXIS2_CALL
savan_util_build_fault_msg(
const axutil_env_t *env,
@@ -1093,6 +934,39 @@
return storage_mgr;
}
+AXIS2_EXTERN savan_filter_mod_t * AXIS2_CALL
+savan_util_get_filter_module(
+ const axutil_env_t *env,
+ axis2_conf_t *conf)
+{
+ axutil_param_t *filter_param = NULL;
+ savan_filter_mod_t *filtermod = NULL;
+
+ if(conf)
+ {
+ filter_param = axis2_conf_get_param(conf, env, SAVAN_FILTER);
+ if(filter_param)
+ {
+ filtermod = (savan_filter_mod_t *) axutil_param_get_value(filter_param, env);
+ }
+ }
+
+ if(!filtermod)
+ {
+#ifdef SAVAN_FILTERING
+ filtermod = savan_filter_mod_create(env, conf);
+#endif
+
+ if(filtermod)
+ {
+ filter_param = axutil_param_create(env, SAVAN_FILTER, filtermod);
+ axis2_conf_add_param(conf, env, filter_param);
+ }
+ }
+
+ return filtermod;
+}
+
axis2_bool_t AXIS2_CALL
savan_util_is_valid_duration(
const axutil_env_t *env,