| 1 | /* | |
| 2 | * Portions of this file Copyright 1999-2005 University of Chicago | |
| 3 | * Portions of this file Copyright 1999-2005 The University of Southern California. | |
| 4 | * | |
| 5 | * This file or a portion of this file is licensed under the | |
| 6 | * terms of the Globus Toolkit Public License, found at | |
| 7 | * http://www.globus.org/toolkit/download/license.html. | |
| 8 | * If you redistribute this file, with or without | |
| 9 | * modifications, you must include this notice in the file. | |
| 10 | */ | |
| 11 | ||
| 12 | ||
| 13 | #include "xsd_anyType.h" | |
| 14 | #include "globus_soap_message.h" | |
| 15 | #include "globus_soap_message_utils.h" | |
| 16 | #include "globus_i_soap_message.h" | |
| 17 | #include "globus_i_soap_message_wildcards.h" | |
| 18 | #include "globus_xml_buffer.h" | |
| 19 | #include "globus_i_xsd.h" | |
| 20 | ||
| 21 | GLOBUS_I_XSD_DEFINE_QNAME(xsd, anyType); | |
| 22 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_INIT_ARRAY(xsd_anyType); |
| 23 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY_ARRAY(xsd_anyType); |
| 24 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_COPY_ARRAY(xsd_anyType); |
| 25 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_SERIALIZE_ARRAY(xsd_anyType); |
| 26 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_DESERIALIZE_ARRAY(xsd_anyType); |
| 27 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_ARRAY_PUSH(xsd_anyType); |
| 28 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_INIT(xsd_anyType); |
| 29 | 6 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY(xsd_anyType); |
| 30 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_COPY(xsd_anyType); |
| 31 | 0 | GLOBUS_I_XSD_DEFINE_INIT_CONTENTS_GENERIC(xsd_anyType); |
| 32 | ||
| 33 | globus_result_t | |
| 34 | xsd_anyType_serialize_wrapper( | |
| 35 | xsd_QName * element_qname, | |
| 36 | void * instance, | |
| 37 | globus_soap_message_handle_t message_handle, | |
| 38 | globus_xsd_element_options_t options) | |
| 39 | 0 | { |
| 40 | 0 | return xsd_anyType_serialize( |
| 41 | element_qname, | |
| 42 | (xsd_anyType *) instance, | |
| 43 | message_handle, options); | |
| 44 | } | |
| 45 | ||
| 46 | globus_result_t | |
| 47 | xsd_anyType_deserialize_pointer_wrapper( | |
| 48 | xsd_QName * element_qname, | |
| 49 | void ** ip, | |
| 50 | globus_soap_message_handle_t message_handle, | |
| 51 | globus_xsd_element_options_t options) | |
| 52 | 0 | { |
| 53 | 0 | return xsd_anyType_deserialize_pointer( |
| 54 | element_qname, | |
| 55 | (xsd_anyType **) ip, | |
| 56 | message_handle, options); | |
| 57 | } | |
| 58 | ||
| 59 | struct globus_xsd_type_info_s xsd_anyType_info = | |
| 60 | { | |
| 61 | &xsd_anyType_qname, | |
| 62 | xsd_anyType_serialize_wrapper, | |
| 63 | xsd_anyType_deserialize_pointer_wrapper, | |
| 64 | xsd_anyType_init_wrapper, | |
| 65 | xsd_anyType_destroy_wrapper, | |
| 66 | xsd_anyType_copy_wrapper, | |
| 67 | xsd_anyType_init_contents_wrapper, | |
| 68 | xsd_anyType_destroy_contents_wrapper, | |
| 69 | xsd_anyType_copy_contents_wrapper, | |
| 70 | sizeof(xsd_anyType), | |
| 71 | NULL, | |
| 72 | NULL, | |
| 73 | NULL | |
| 74 | }; | |
| 75 | ||
| 76 | struct globus_xsd_type_info_s xsd_anyType_array_info = | |
| 77 | { | |
| 78 | &xsd_anyType_qname, | |
| 79 | xsd_anyType_array_serialize_wrapper, | |
| 80 | xsd_anyType_array_deserialize_wrapper, | |
| 81 | xsd_anyType_array_init_wrapper, | |
| 82 | xsd_anyType_array_destroy_wrapper, | |
| 83 | xsd_anyType_array_copy_wrapper, | |
| 84 | xsd_anyType_array_init_contents_wrapper, | |
| 85 | xsd_anyType_array_destroy_contents_wrapper, | |
| 86 | xsd_anyType_array_copy_contents_wrapper, | |
| 87 | sizeof(xsd_anyType), | |
| 88 | xsd_anyType_array_push_wrapper, | |
| 89 | NULL, | |
| 90 | NULL | |
| 91 | }; | |
| 92 | ||
| 93 | struct globus_xsd_type_info_s xsd_anyType_contents_info = | |
| 94 | { | |
| 95 | &xsd_anyType_qname, | |
| 96 | xsd_anyType_serialize_wrapper, | |
| 97 | xsd_anyType_deserialize_pointer_wrapper, | |
| 98 | xsd_anyType_init_wrapper, | |
| 99 | xsd_anyType_destroy_wrapper, | |
| 100 | xsd_anyType_copy_wrapper, | |
| 101 | xsd_anyType_init_contents_wrapper, | |
| 102 | xsd_anyType_destroy_contents_wrapper, | |
| 103 | xsd_anyType_copy_contents_wrapper, | |
| 104 | sizeof(xsd_anyType), | |
| 105 | NULL, | |
| 106 | NULL, | |
| 107 | NULL | |
| 108 | }; | |
| 109 | ||
| 110 | void | |
| 111 | xsd_anyType_destroy_contents( | |
| 112 | xsd_anyType * instance) | |
| 113 | 20 | { |
| 114 | GlobusFuncName(xsd_anyType_destroy_contents); | |
| 115 | 20 | GlobusSoapMessageDebugEnter(); |
| 116 | ||
| 117 | 20 | if(instance && instance->value && instance->any_info) |
| 118 | { | |
| 119 | 20 | instance->any_info->destroy(instance->value); |
| 120 | 20 | instance->value = NULL; |
| 121 | } | |
| 122 | ||
| 123 | 20 | GlobusSoapMessageDebugExit(); |
| 124 | } | |
| 125 | ||
| 126 | globus_result_t | |
| 127 | xsd_anyType_copy_contents( | |
| 128 | xsd_anyType * dest, | |
| 129 | const xsd_anyType * src) | |
| 130 | 10 | { |
| 131 | 10 | globus_result_t result = GLOBUS_SUCCESS; |
| 132 | GlobusFuncName(xsd_anyType_copy_contents); | |
| 133 | 10 | GlobusSoapMessageDebugEnter(); |
| 134 | ||
| 135 | 10 | if(dest && src) |
| 136 | { | |
| 137 | 10 | *dest = *src; |
| 138 | 10 | if(src->value && src->any_info) |
| 139 | { | |
| 140 | 10 | result = src->any_info->copy(&dest->value, src->value); |
| 141 | } | |
| 142 | } | |
| 143 | ||
| 144 | 10 | GlobusSoapMessageDebugExit(); |
| 145 | 10 | return result; |
| 146 | } | |
| 147 | ||
| 148 | globus_result_t | |
| 149 | xsd_anyType_serialize( | |
| 150 | xsd_QName * element_qname, | |
| 151 | xsd_anyType * anyinst, | |
| 152 | globus_soap_message_handle_t message_handle, | |
| 153 | globus_xsd_element_options_t options) | |
| 154 | 0 | { |
| 155 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 156 | GlobusFuncName(xsd_anyType_serialize); | |
| 157 | 0 | GlobusSoapMessageDebugEnter(); |
| 158 | ||
| 159 | /* serialize contents of type */ | |
| 160 | 0 | result = anyinst->any_info->serialize( |
| 161 | element_qname, | |
| 162 | anyinst->value, | |
| 163 | message_handle, | |
| 164 | options | GLOBUS_XSD_ELEMENT_TYPE_ATTR); | |
| 165 | 0 | if(result != GLOBUS_SUCCESS) |
| 166 | { | |
| 167 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 168 | result, | |
| 169 | "Serialization of xsd:any failed", | |
| 170 | element_qname); | |
| 171 | goto exit; | |
| 172 | } | |
| 173 | ||
| 174 | 0 | exit: |
| 175 | ||
| 176 | 0 | GlobusSoapMessageDebugExit(); |
| 177 | 0 | return result; |
| 178 | } | |
| 179 | ||
| 180 | globus_result_t | |
| 181 | xsd_anyType_deserialize( | |
| 182 | xsd_QName * element_qname, | |
| 183 | xsd_anyType * instance, | |
| 184 | globus_soap_message_handle_t message_handle, | |
| 185 | globus_xsd_element_options_t options) | |
| 186 | 10 | { |
| 187 | 10 | globus_result_t result = GLOBUS_SUCCESS; |
| 188 | GlobusFuncName(xsd_anyType_deserialize); | |
| 189 | 10 | GlobusSoapMessageDebugEnter(); |
| 190 | ||
| 191 | 10 | result = globus_soap_message_deserialize_element( |
| 192 | message_handle, element_qname); | |
| 193 | 10 | if(result != GLOBUS_SUCCESS) |
| 194 | { | |
| 195 | 0 | if(GlobusSoapMessageStatusFailedWithTextCheck(result)) |
| 196 | { | |
| 197 | 0 | result = GLOBUS_SUCCESS; |
| 198 | } | |
| 199 | 0 | else if(!GlobusSoapMessageStatusCheck(result)) |
| 200 | { | |
| 201 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 202 | result, element_qname); | |
| 203 | 0 | goto exit; |
| 204 | } | |
| 205 | else | |
| 206 | { | |
| 207 | goto exit; | |
| 208 | } | |
| 209 | } | |
| 210 | ||
| 211 | 10 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 212 | { | |
| 213 | 10 | globus_soap_message_deserialize_push_element(message_handle); |
| 214 | } | |
| 215 | ||
| 216 | 10 | GlobusSoapMessageDebugPrintf( |
| 217 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 218 | ("\n\nDeserializing xsd:anyType\n")); | |
| 219 | ||
| 220 | 10 | result = globus_i_xsd_deserialize_from_xsi_type( |
| 221 | &instance->any_info, | |
| 222 | instance->registry, | |
| 223 | message_handle); | |
| 224 | 10 | if(result != GLOBUS_SUCCESS) |
| 225 | { | |
| 226 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 227 | result, element_qname); | |
| 228 | 0 | goto exit; |
| 229 | } | |
| 230 | ||
| 231 | 10 | if(!instance->any_info) |
| 232 | { | |
| 233 | 0 | instance->any_info = (&globus_xml_buffer_contents_info); |
| 234 | } | |
| 235 | ||
| 236 | 10 | GlobusSoapMessageDebugPrintf( |
| 237 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 238 | ("Using any info: {%s}%s\n", | |
| 239 | instance->any_info->type->Namespace, | |
| 240 | instance->any_info->type->local)); | |
| 241 | ||
| 242 | 10 | result = instance->any_info->deserialize( |
| 243 | element_qname, | |
| 244 | &instance->value, | |
| 245 | message_handle, | |
| 246 | options); | |
| 247 | 10 | if(result != GLOBUS_SUCCESS) |
| 248 | { | |
| 249 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 250 | result, instance->any_info->type); | |
| 251 | goto exit; | |
| 252 | } | |
| 253 | ||
| 254 | /* if(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY) */ | |
| 255 | /* { */ | |
| 256 | /* globus_soap_message_deserialize_push_element(message_handle); */ | |
| 257 | /* } */ | |
| 258 | ||
| 259 | 10 | exit: |
| 260 | ||
| 261 | 10 | if(result != GLOBUS_SUCCESS) |
| 262 | { | |
| 263 | 0 | xsd_anyType_destroy_contents(instance); |
| 264 | } | |
| 265 | ||
| 266 | 10 | GlobusSoapMessageDebugExit(); |
| 267 | 10 | return result; |
| 268 | } | |
| 269 | ||
| 270 | globus_result_t | |
| 271 | xsd_anyType_deserialize_pointer( | |
| 272 | xsd_QName * element_qname, | |
| 273 | xsd_anyType ** ip, | |
| 274 | globus_soap_message_handle_t message_handle, | |
| 275 | globus_xsd_element_options_t options) | |
| 276 | 1 | { |
| 277 | 1 | xsd_anyType * instance = NULL; |
| 278 | 1 | globus_result_t result = GLOBUS_SUCCESS; |
| 279 | GlobusFuncName(xsd_any_deserialize_pointer); | |
| 280 | 1 | GlobusSoapMessageDebugEnter(); |
| 281 | ||
| 282 | 1 | result = globus_soap_message_deserialize_element( |
| 283 | message_handle, element_qname); | |
| 284 | 1 | if(result != GLOBUS_SUCCESS) |
| 285 | { | |
| 286 | 1 | if(GlobusSoapMessageStatusElementNotFoundCheck(result) || |
| 287 | GlobusSoapMessageStatusFailedElementCheck(result)) | |
| 288 | { | |
| 289 | 1 | *ip = NULL; |
| 290 | 1 | result = GLOBUS_SUCCESS; |
| 291 | 1 | goto exit; |
| 292 | } | |
| 293 | ||
| 294 | 0 | if(!GlobusSoapMessageStatusCheck(result)) |
| 295 | { | |
| 296 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 297 | result, element_qname); | |
| 298 | 0 | goto exit; |
| 299 | } | |
| 300 | goto exit; | |
| 301 | } | |
| 302 | ||
| 303 | ||
| 304 | 0 | GlobusSoapMessageDebugPrintf( |
| 305 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 306 | ("\n\nDeserializing xsd:anyType\n")); | |
| 307 | ||
| 308 | 0 | result = xsd_anyType_init(&instance); |
| 309 | 0 | if(result != GLOBUS_SUCCESS) |
| 310 | { | |
| 311 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 312 | result, &xsd_anyType_qname); | |
| 313 | 0 | goto exit; |
| 314 | } | |
| 315 | ||
| 316 | 0 | result = globus_i_xsd_deserialize_from_xsi_type( |
| 317 | &instance->any_info, | |
| 318 | instance->registry, | |
| 319 | message_handle); | |
| 320 | 0 | if(result != GLOBUS_SUCCESS) |
| 321 | { | |
| 322 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 323 | result, element_qname); | |
| 324 | 0 | goto exit; |
| 325 | } | |
| 326 | ||
| 327 | 0 | if(!instance->any_info) |
| 328 | { | |
| 329 | 0 | result = GlobusSoapMessageErrorNoXSITypeAttr(); |
| 330 | 0 | goto exit; |
| 331 | } | |
| 332 | ||
| 333 | 0 | globus_soap_message_deserialize_push_element(message_handle); |
| 334 | ||
| 335 | 0 | GlobusSoapMessageDebugPrintf( |
| 336 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 337 | ("Using any info: {%s}%s\n", | |
| 338 | instance->any_info->type->Namespace, | |
| 339 | instance->any_info->type->local)); | |
| 340 | ||
| 341 | 0 | result = instance->any_info->deserialize( |
| 342 | element_qname, | |
| 343 | &instance->value, | |
| 344 | message_handle, | |
| 345 | options); | |
| 346 | 0 | if(result != GLOBUS_SUCCESS) |
| 347 | { | |
| 348 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 349 | result, instance->any_info->type); | |
| 350 | 0 | goto exit; |
| 351 | } | |
| 352 | ||
| 353 | 0 | *ip = instance; |
| 354 | ||
| 355 | 1 | exit: |
| 356 | ||
| 357 | 1 | if(result != GLOBUS_SUCCESS && instance) |
| 358 | { | |
| 359 | 0 | xsd_anyType_destroy(instance); |
| 360 | } | |
| 361 | ||
| 362 | 1 | GlobusSoapMessageDebugExit(); |
| 363 | 1 | return result; |