1 /*
2  * Copyright 1999-2006 University of Chicago
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include "globus_xml_buffer.h"
19 #include "globus_service_registry.h"
20
21 globus_result_t
22 globus_resource_id_get_as_string(
23     xsd_any_array *                     reference_properties,
24     char **                             id)
25 3226 {
26 3226     globus_result_t                     result = GLOBUS_SUCCESS;
27 3226     globus_soap_message_handle_t        memory_message;
28 3226     globus_xml_buffer *                 buffer_handle;
29 3226     GlobusFuncName(globus_resource_id_get_as_string);
30 3226     GlobusSoapMessageDebugEnter();
31
32 3226     if(!reference_properties || reference_properties->length < 1)
33     {
34 0         result = GlobusSoapMessageErrorNoReferenceProperties();
35 0         goto exit;
36     }
37 3226     else if(reference_properties->length > 1)
38     {
39 0         result = GlobusSoapMessageErrorTooManyReferenceProperties(
40             reference_properties->length);
41 0         goto exit;
42     }
43
44 3226     if(reference_properties->elements[0].any_info == 
45        (&globus_xml_buffer_contents_info))
46     {
47 2242         buffer_handle = 
48         (globus_xml_buffer *)reference_properties->elements[0].value;
49
50 2242         result = globus_soap_message_handle_init_from_memory(
51             &memory_message, buffer_handle->buffer, buffer_handle->length);
52 2242         if(result != GLOBUS_SUCCESS)
53         {
54 0             result = GlobusSoapMessageErrorFailedResourceGet(
55                 result, "Failed to initalize memory message");
56 0             goto exit;
57         }
58
59 2242         result = xsd_string_deserialize(
60             NULL,
61             id,
62             memory_message,
63             0);
64 2242         if(result != GLOBUS_SUCCESS)
65         {
66 0             result = GlobusSoapMessageErrorFailedResourceGet(
67                 result, "Failed deserialize of CounterKey");
68 0             goto exit;
69         }
70
71 2242         globus_soap_message_handle_destroy(memory_message);
72 2242         memory_message = NULL;
73     }
74
75 3226     if(reference_properties->elements[0].any_info ==
76        (&xsd_string_info))
77     {
78 984         *id = globus_libc_strdup(
79             *(char **)reference_properties->elements[0].value);
80     }
81
82  exit:
83
84 3226     GlobusSoapMessageDebugExit();
85 3226     return result;