diff options
Diffstat (limited to 'lasso')
-rw-r--r-- | lasso/id-wsf-2.0/data_service.c | 135 | ||||
-rw-r--r-- | lasso/id-wsf-2.0/data_service.h | 9 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/dstref_app_data.h | 2 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/dstref_modify.c | 2 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/dstref_modify_item.c | 17 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/dstref_modify_item.h | 4 |
6 files changed, 164 insertions, 5 deletions
diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c index 1969c76f..e1b157b9 100644 --- a/lasso/id-wsf-2.0/data_service.c +++ b/lasso/id-wsf-2.0/data_service.c @@ -34,6 +34,9 @@ #include <lasso/xml/id-wsf-2.0/dstref_data.h> #include <lasso/xml/id-wsf-2.0/util_status.h> #include <lasso/xml/id-wsf-2.0/sb2_redirect_request.h> +#include <lasso/xml/id-wsf-2.0/dstref_modify.h> +#include <lasso/xml/id-wsf-2.0/dstref_modify_item.h> +#include <lasso/xml/id-wsf-2.0/dstref_modify_response.h> #include <lasso/xml/soap_fault.h> @@ -456,6 +459,138 @@ lasso_idwsf2_data_service_init_redirect_user_for_consent(LassoIdWsf2DataService return 0; } +gint +lasso_idwsf2_data_service_init_modify(LassoIdWsf2DataService *service) +{ + LassoIdWsf2Profile *profile = LASSO_IDWSF2_PROFILE(service); + LassoIdWsf2DstRefModify *modify; + LassoWsAddrEndpointReference *epr; + GList *metadata_item; + GList *i; + gchar *service_type = NULL; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DATA_SERVICE(service), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + modify = lasso_idwsf2_dstref_modify_new(); + + if (LASSO_PROFILE(profile)->request) { + lasso_node_destroy(LASSO_NODE(LASSO_PROFILE(profile)->request)); + } + LASSO_PROFILE(profile)->request = LASSO_NODE(modify); + + if (service == NULL || service->private_data == NULL + || service->private_data->epr == NULL + || service->private_data->epr->Metadata == NULL) { + return LASSO_PROFILE_ERROR_MISSING_ENDPOINT_REFERENCE; + } + + epr = service->private_data->epr; + + /* Get the service type from the EPR */ + metadata_item = epr->Metadata->any; + for (i = g_list_first(metadata_item); i != NULL; i = g_list_next(i)) { + if (LASSO_IS_IDWSF2_DISCO_SERVICE_TYPE(i->data)) { + service_type = LASSO_IDWSF2_DISCO_SERVICE_TYPE(i->data)->content; + break; + } + } + + /* Set hrefServiceType and prefixServiceType in query in order to set the profile */ + /* namespace in the request */ + if (service_type != NULL) { + modify->hrefServiceType = g_strdup(service_type); + modify->prefixServiceType = lasso_get_prefix_for_idwsf2_dst_service_href( + modify->hrefServiceType); + } + if (modify->prefixServiceType == NULL) { + return LASSO_PROFILE_ERROR_MISSING_SERVICE_TYPE; + } + + lasso_idwsf2_profile_init_soap_request(profile, LASSO_NODE(modify), service_type); + + /* Set msg_url as epr address, which is the SoapEndpoint */ + if (epr->Address != NULL) { + LASSO_PROFILE(profile)->msg_url = g_strdup(epr->Address->content); + } else { + return LASSO_PROFILE_ERROR_MISSING_ENDPOINT_REFERENCE_ADDRESS; + } + + return 0; +} + +static void set_xml_string(xmlNode **xmlnode, const char* string) +{ + xmlDoc *doc; + xmlNode *node; + + doc = xmlReadDoc((xmlChar*)string, NULL, NULL, XML_PARSE_NONET); + node = xmlDocGetRootElement(doc); + if (node != NULL) { + node = xmlCopyNode(node, 1); + } + xmlFreeDoc(doc); + + if (*xmlnode) { + xmlFreeNode(*xmlnode); + } + + *xmlnode = node; +} + +gint +lasso_idwsf2_data_service_add_modify_item(LassoIdWsf2DataService *service, const gchar *item_xpath, + const gchar *item_id, const gchar *new_data, const gboolean overrideAllowed) +{ + LassoIdWsf2Profile *profile = LASSO_IDWSF2_PROFILE(service); + LassoIdWsf2DstRefModify *modify; + LassoIdWsf2DstRefModifyItem *item; + xmlNode *new_data_node = NULL; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DATA_SERVICE(service), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(item_xpath != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(item_id != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + if (! LASSO_IS_IDWSF2_DSTREF_MODIFY(LASSO_PROFILE(profile)->request)) { + return LASSO_PROFILE_ERROR_MISSING_REQUEST; + } + + modify = LASSO_IDWSF2_DSTREF_MODIFY(LASSO_PROFILE(profile)->request); + + set_xml_string(&new_data_node, new_data); + item = lasso_idwsf2_dstref_modify_item_new_full( + item_xpath, item_id, new_data_node, overrideAllowed); + modify->ModifyItem = g_list_append(modify->ModifyItem, item); + + return 0; +} + +gint +lasso_idwsf2_data_service_process_modify_msg(LassoIdWsf2DataService *service, const gchar *message) +{ + LassoIdWsf2Profile *profile = LASSO_IDWSF2_PROFILE(service); + LassoIdWsf2DstRefModify *request = NULL; + LassoIdWsf2DstRefModifyItem *item = NULL; + GList *i; + int res = 0; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DATA_SERVICE(service), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(message != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + + res = lasso_idwsf2_profile_process_soap_request_msg(profile, message); + + if (! LASSO_IS_IDWSF2_DSTREF_MODIFY(LASSO_PROFILE(profile)->request)) { + res = LASSO_PROFILE_ERROR_INVALID_SOAP_MSG; + } else { + request = LASSO_IDWSF2_DSTREF_MODIFY(LASSO_PROFILE(profile)->request); + service->type = g_strdup(request->hrefServiceType); + } + + return res; +} + /*****************************************************************************/ /* private methods */ /*****************************************************************************/ diff --git a/lasso/id-wsf-2.0/data_service.h b/lasso/id-wsf-2.0/data_service.h index 71cf9e78..eb3dd511 100644 --- a/lasso/id-wsf-2.0/data_service.h +++ b/lasso/id-wsf-2.0/data_service.h @@ -98,6 +98,15 @@ LASSO_EXPORT gchar* lasso_idwsf2_data_service_get_attribute_string(LassoIdWsf2Da LASSO_EXPORT gint lasso_idwsf2_data_service_init_redirect_user_for_consent( LassoIdWsf2DataService *service, const gchar *redirect_url); +LASSO_EXPORT gint lasso_idwsf2_data_service_init_modify(LassoIdWsf2DataService *service); + +LASSO_EXPORT gint lasso_idwsf2_data_service_add_modify_item( + LassoIdWsf2DataService *service, const gchar *item_xpath, const gchar *item_id, + const gchar *new_data, const gboolean overrideAllowed); + +LASSO_EXPORT gint lasso_idwsf2_data_service_process_modify_msg(LassoIdWsf2DataService *service, + const gchar *message); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/xml/id-wsf-2.0/dstref_app_data.h b/lasso/xml/id-wsf-2.0/dstref_app_data.h index e0201d95..5c664c26 100644 --- a/lasso/xml/id-wsf-2.0/dstref_app_data.h +++ b/lasso/xml/id-wsf-2.0/dstref_app_data.h @@ -72,8 +72,6 @@ struct _LassoIdWsf2DstRefAppDataClass { LASSO_EXPORT GType lasso_idwsf2_dstref_app_data_get_type(void); LASSO_EXPORT LassoIdWsf2DstRefAppData* lasso_idwsf2_dstref_app_data_new(void); - - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/xml/id-wsf-2.0/dstref_modify.c b/lasso/xml/id-wsf-2.0/dstref_modify.c index 4b57b3b0..273d9416 100644 --- a/lasso/xml/id-wsf-2.0/dstref_modify.c +++ b/lasso/xml/id-wsf-2.0/dstref_modify.c @@ -56,7 +56,6 @@ static struct XmlSnippet schema_snippets[] = { static LassoNodeClass *parent_class = NULL; - static xmlNode* get_xmlNode(LassoNode *node, gboolean lasso_dump) { @@ -91,7 +90,6 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode) return 0; } - /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ diff --git a/lasso/xml/id-wsf-2.0/dstref_modify_item.c b/lasso/xml/id-wsf-2.0/dstref_modify_item.c index bc872417..eddf30d2 100644 --- a/lasso/xml/id-wsf-2.0/dstref_modify_item.c +++ b/lasso/xml/id-wsf-2.0/dstref_modify_item.c @@ -124,3 +124,20 @@ lasso_idwsf2_dstref_modify_item_new() { return g_object_new(LASSO_TYPE_IDWSF2_DSTREF_MODIFY_ITEM, NULL); } + +LassoIdWsf2DstRefModifyItem* +lasso_idwsf2_dstref_modify_item_new_full(const gchar *item_xpath, const gchar *item_id, + xmlNode *new_data, const gboolean overrideAllowed) +{ + LassoIdWsf2DstRefModifyItem *item; + + item = g_object_new(LASSO_TYPE_IDWSF2_DSTREF_MODIFY_ITEM, NULL); + item->Select = g_strdup(item_xpath); + item->id = g_strdup(item_id); + item->NewData = lasso_idwsf2_dstref_app_data_new(); + item->NewData->any = g_list_append(item->NewData->any, new_data); + item->overrideAllowed = overrideAllowed; + + return item; +} + diff --git a/lasso/xml/id-wsf-2.0/dstref_modify_item.h b/lasso/xml/id-wsf-2.0/dstref_modify_item.h index 1b99ef63..86159c63 100644 --- a/lasso/xml/id-wsf-2.0/dstref_modify_item.h +++ b/lasso/xml/id-wsf-2.0/dstref_modify_item.h @@ -79,7 +79,9 @@ struct _LassoIdWsf2DstRefModifyItemClass { LASSO_EXPORT GType lasso_idwsf2_dstref_modify_item_get_type(void); LASSO_EXPORT LassoIdWsf2DstRefModifyItem* lasso_idwsf2_dstref_modify_item_new(void); - +LASSO_EXPORT LassoIdWsf2DstRefModifyItem* lasso_idwsf2_dstref_modify_item_new_full( + const gchar *item_xpath, const gchar *item_id, xmlNode *new_data, + const gboolean overrideAllowed); #ifdef __cplusplus } |