diff options
| author | Nicolas Clapies <nclapies@entrouvert.com> | 2005-09-05 10:00:07 +0000 |
|---|---|---|
| committer | Nicolas Clapies <nclapies@entrouvert.com> | 2005-09-05 10:00:07 +0000 |
| commit | 4b75a46a39859d3548b1e30eec62c8be28961b2b (patch) | |
| tree | d0e092edfbef3e7d8253c289af76e8a5df109551 | |
| parent | ea4fea07caa8c194faebcadca48d88a02312b0db (diff) | |
Updated lasso_discovery_build_modify_response_msg() : now it sets status code to OK only if every remove entry are possible.
| -rw-r--r-- | lasso/id-ff/identity.c | 18 | ||||
| -rw-r--r-- | lasso/id-wsf/discovery.c | 37 | ||||
| -rw-r--r-- | lasso/id-wsf/identity.h | 2 |
3 files changed, 46 insertions, 11 deletions
diff --git a/lasso/id-ff/identity.c b/lasso/id-ff/identity.c index b120461c..3338d2c9 100644 --- a/lasso/id-ff/identity.c +++ b/lasso/id-ff/identity.c @@ -192,6 +192,24 @@ lasso_identity_get_offerings(LassoIdentity *identity, const char *service_type) return result; } +LassoDiscoResourceOffering* lasso_identity_get_resource_offering( + LassoIdentity *identity, const char *entryID) +{ + GList *iter; + LassoDiscoResourceOffering *t; + + iter = identity->private_data->resource_offerings; + while (iter) { + t = iter->data; + iter = g_list_next(iter); + if (strcmp(t->entryID, entryID) == 0) { + return t; + } + } + + return NULL; +} + #endif diff --git a/lasso/id-wsf/discovery.c b/lasso/id-wsf/discovery.c index 56fe1222..4fd73f8d 100644 --- a/lasso/id-wsf/discovery.c +++ b/lasso/id-wsf/discovery.c @@ -474,10 +474,32 @@ lasso_discovery_build_modify_response_msg(LassoDiscovery *discovery) LassoDiscoModify *request = LASSO_DISCO_MODIFY(LASSO_WSF_PROFILE(discovery)->request); LassoDiscoModifyResponse *response; LassoSoapEnvelope *envelope; + LassoUtilityStatus *status; GList *iter; gboolean failure = FALSE; char *new_entry_ids = NULL, *t_new_entry_ids = NULL; - + + /* build response */ + status = lasso_utility_status_new(LASSO_DISCO_STATUS_CODE_FAILED); + response = lasso_disco_modify_response_new(status); + LASSO_WSF_PROFILE(discovery)->response = LASSO_NODE(response); + envelope = LASSO_WSF_PROFILE(discovery)->soap_envelope_response; + envelope->Body->any = g_list_append(envelope->Body->any, response); + + /* First verify remove entries are all ok */ + iter = request->RemoveEntry; + while (iter) { + LassoDiscoRemoveEntry *entry = iter->data; + iter = g_list_next(iter); + + if (lasso_identity_get_resource_offering( + LASSO_WSF_PROFILE(discovery)->identity, + entry->entryID) == NULL) { + /* FIXME: Return a better code error. */ + return -1; + } + } + if (request->InsertEntry) { new_entry_ids = g_malloc(10*g_list_length(request->InsertEntry)); t_new_entry_ids = new_entry_ids; @@ -510,20 +532,13 @@ lasso_discovery_build_modify_response_msg(LassoDiscovery *discovery) } } - if (failure) { - /* XXX: should restore previous content */ - } - - /* build response */ - response = lasso_disco_modify_response_new( - lasso_utility_status_new(LASSO_DST_STATUS_CODE_OK)); if (new_entry_ids) { response->newEntryIDs = g_strdup(new_entry_ids); g_free(new_entry_ids); } - LASSO_WSF_PROFILE(discovery)->response = LASSO_NODE(response); - envelope = LASSO_WSF_PROFILE(discovery)->soap_envelope_response; - envelope->Body->any = g_list_append(envelope->Body->any, response); + + g_free(status->code); + status->code = g_strdup(LASSO_DISCO_STATUS_CODE_OK); return lasso_wsf_profile_build_soap_response_msg(LASSO_WSF_PROFILE(discovery)); } diff --git a/lasso/id-wsf/identity.h b/lasso/id-wsf/identity.h index d0c5d044..29536b4f 100644 --- a/lasso/id-wsf/identity.h +++ b/lasso/id-wsf/identity.h @@ -37,6 +37,8 @@ LASSO_EXPORT gboolean lasso_identity_remove_resource_offering(LassoIdentity *ide const char *entryID); LASSO_EXPORT GList* lasso_identity_get_offerings(LassoIdentity *identity, const char *service_type); +LASSO_EXPORT LassoDiscoResourceOffering* lasso_identity_get_resource_offering( + LassoIdentity *identity, const char *entryID); #ifdef __cplusplus |
