diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-05-07 12:36:00 +0000 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-05-07 12:36:00 +0000 |
| commit | 81bc017436149a18efe93fed2adb324639c753c7 (patch) | |
| tree | 1dd60b4771ecbd18fb8bc887fb2ebd23120f7338 | |
| parent | a4e03e7626c281410cc396fb1202132e216ed358 (diff) | |
Do not respect default semantic of dst:Query
* lasso/id-wsf-2.0/data_service.c:
the specification for data service template indicat that the query
must fail at the first failing query, we think this is a stupid
behaviour so I set the default to keep running query until the last
one and returning a partial result if at least one failed and a
failed result if absolutely no query matched.
* lasso/id-wsf-2.0/private.h:
declare the lasso_flag_follow_id_wsf_supid_semantic flag.
* lasso.c:
declare the lasso_flag_follow_id_wsf_supid_semantic flag, it's
conditionned by the LASSO_WSF_ENABLED preprocessor symbol.
| -rw-r--r-- | lasso/id-wsf-2.0/data_service.c | 80 | ||||
| -rw-r--r-- | lasso/id-wsf-2.0/private.h | 38 | ||||
| -rw-r--r-- | lasso/lasso.c | 10 |
3 files changed, 87 insertions, 41 deletions
diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c index 2cdaf4bc..88beb793 100644 --- a/lasso/id-wsf-2.0/data_service.c +++ b/lasso/id-wsf-2.0/data_service.c @@ -49,6 +49,7 @@ #include <lasso/xml/soap_fault.h> #include "../utils.h" +#include "./private.h" struct _LassoIdWsf2DataServicePrivate { @@ -240,34 +241,27 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service) LassoIdWsf2DstRefQueryItem *item; LassoIdWsf2DstRefResultQuery *item_result_query; LassoIdWsf2DstResultQueryBase *item_result_query_base; - LassoIdWsf2DstRefData *data; - LassoIdWsf2DstRefItemData *data_item; xmlNode *node; GList *iter; int i; - /* Default is Failed, will be OK or Partial when some items are successfully parsed */ - char *status_code = LASSO_DST_STATUS_CODE_FAILED; + /* How much query did we execute */ + int executed = 0; + /* How much query did succeed */ + int successful = 0; + int rc = 0; - g_return_val_if_fail(LASSO_IS_IDWSF2_DATA_SERVICE(service), - LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); - - if (! LASSO_IS_IDWSF2_DSTREF_QUERY(LASSO_PROFILE(profile)->request)) { - return LASSO_PROFILE_ERROR_MISSING_REQUEST; - } - request = LASSO_IDWSF2_DSTREF_QUERY(LASSO_PROFILE(profile)->request); + lasso_bad_param(IDWSF2_DATA_SERVICE, service); + lasso_extract_node_or_fail(request, LASSO_PROFILE(profile)->request, IDWSF2_DSTREF_QUERY, LASSO_PROFILE_ERROR_MISSING_REQUEST); if (service->data == NULL) { return LASSO_DST_ERROR_MISSING_SERVICE_DATA; } /* Response envelope and body */ - envelope = profile->soap_envelope_response; - if (envelope == NULL) { - return LASSO_SOAP_ERROR_MISSING_ENVELOPE; - } + lasso_extract_node_or_fail(envelope, profile->soap_envelope_response, SOAP_ENVELOPE, LASSO_SOAP_ERROR_MISSING_ENVELOPE); response = lasso_idwsf2_dstref_query_response_new(); - response->prefixServiceType = g_strdup(request->prefixServiceType); - response->hrefServiceType = g_strdup(request->hrefServiceType); + lasso_assign_string(response->prefixServiceType, request->prefixServiceType); + lasso_assign_string(response->hrefServiceType, request->hrefServiceType); lasso_assign_new_gobject(LASSO_PROFILE(profile)->response, LASSO_NODE(response)); lasso_list_add_gobject(envelope->Body->any, response); @@ -280,6 +274,10 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service) /* Parse request QueryItems and fill response Data accordingly */ /* XXX: needs another level, since there may be more than one <dst:Query> */ for (iter = g_list_first(request->QueryItem); iter != NULL; iter = g_list_next(iter)) { + LassoIdWsf2DstRefData *data; + LassoIdWsf2DstRefItemData *data_item; + + executed++; item = iter->data; item_result_query = LASSO_IDWSF2_DSTREF_RESULT_QUERY(item); item_result_query_base = LASSO_IDWSF2_DST_RESULT_QUERY_BASE(item); @@ -299,50 +297,50 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service) LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any, xmlCopyNode(node, 1)); } } + lasso_release_xpath_object(xpathObj); } else if (xpathObj && xpathObj->type == XPATH_STRING) { data = lasso_idwsf2_dstref_data_new(); data_item = LASSO_IDWSF2_DSTREF_ITEM_DATA(data); LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any = g_list_append( LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any, xmlNewText(xpathObj->stringval)); + lasso_release_xpath_object(xpathObj); } else { - /* If status was OK, change it to Partial, else keep it Failed */ - if (strcmp(status_code, LASSO_DST_STATUS_CODE_OK) == 0) { - status_code = LASSO_DST_STATUS_CODE_PARTIAL; - } - if (xpathObj != NULL) { - xmlXPathFreeObject(xpathObj); - xpathObj = NULL; - } - /* Stop processing at first error, according to the specifications */ - break; + lasso_release_xpath_object(xpathObj); + /* Stop processing at first error, according to the specifications, or not + * ;) */ + if (lasso_flag_follow_id_wsf_stupid_semantic) + break; + else + continue; } /* Finish handling of a successful item parsing */ - status_code = LASSO_DST_STATUS_CODE_OK; - if (item_result_query_base->itemID != NULL) { - data_item->itemIDRef = g_strdup(item_result_query_base->itemID); - } - response->Data = g_list_append(response->Data, data); - - xmlXPathFreeObject(xpathObj); - xpathObj = NULL; + successful++; + lasso_assign_string(data_item->itemIDRef, item_result_query_base->itemID); + lasso_list_add_new_gobject(response->Data, data); } /* Free XML parsing objects */ xmlUnlinkNode(service->data); - xmlXPathFreeContext(xpathCtx); - lasso_release_doc(doc); + lasso_release_xpath_job(xpathObj, xpathCtx, doc); + xmlSetTreeDoc(service->data, NULL); response2 = LASSO_IDWSF2_UTIL_RESPONSE(response); lasso_assign_new_gobject(response2->Status, lasso_idwsf2_util_status_new()); - response2->Status->code = g_strdup(status_code); - if (strcmp(status_code, LASSO_DST_STATUS_CODE_FAILED) == 0) { - return LASSO_DST_ERROR_QUERY_FAILED; + if (executed == successful) { + lasso_assign_string(response2->Status->code, LASSO_DST_STATUS_CODE_OK); + } else if (successful == 0) { + lasso_assign_string(response2->Status->code, LASSO_DST_STATUS_CODE_FAILED); + rc = LASSO_DST_ERROR_QUERY_FAILED; + } else { + lasso_assign_string(response2->Status->code, LASSO_DST_STATUS_CODE_PARTIAL); + rc = LASSO_DST_ERROR_QUERY_PARTIALLY_FAILED; } +cleanup: - return 0; + return rc; } static gint diff --git a/lasso/id-wsf-2.0/private.h b/lasso/id-wsf-2.0/private.h new file mode 100644 index 00000000..7a6de634 --- /dev/null +++ b/lasso/id-wsf-2.0/private.h @@ -0,0 +1,38 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004-2007 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: See AUTHORS file in top-level directory. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LASSO_ID_WSF_20_PRIVATE_H__ +#define __LASSO_ID_WSF_20_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern gboolean lasso_flag_follow_id_wsf_stupid_semantic; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_ID_WSF_20_PRIVATE_H__ */ diff --git a/lasso/lasso.c b/lasso/lasso.c index 327133db..27c63288 100644 --- a/lasso/lasso.c +++ b/lasso/lasso.c @@ -49,6 +49,10 @@ gboolean lasso_flag_memory_debug = FALSE; gboolean lasso_flag_strict_checking = FALSE; /* set to false, it do not sign messages */ gboolean lasso_flag_add_signature = TRUE; +#ifdef LASSO_WSF_ENABLED +/* set to false, it do not follow stupid id-wsf semantic */ +gboolean lasso_flag_follow_id_wsf_stupid_semantic = FALSE; +#endif static void lasso_flag_parse_environment_variable(); /* do not sign messages */ gboolean lasso_flag_sign_messages = TRUE; @@ -275,6 +279,12 @@ void lasso_set_flag(char *flag) { lasso_flag_sign_messages = value; continue; } +#ifdef LASSO_WSF_ENABLED + if (g_strcmp0(flag, "follow-stupid-id-wsf-semantic") == 0) { + lasso_flag_follow_id_wsf_stupid_semantic = value; + continue; + } +#endif } while (FALSE); } |
