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 /**
22 * @defgroup globus_service_registry Service Registry
23 * The service registry is used by the service engine to map SOAP Actions and
24 * body elements to services and operations within those services. This module
25 * includes definitions of data types which describe what operations are
26 * provided by a service and which operation providers implement those
27 * operations.
28 */
29
30 /**
31 * Default reference properties to resource_id mapping function
32 * @ingroup globus_service_registry
33 * If the @a reference_properties array contains a single element, a string
34 * containing that element's content is copied and a pointer is returned via
35 * @a id.
36 *
37 * @param reference_properties
38 * The any array containing the reference properties associated with
39 * an EndpointReference. To be successfully processed, this array must
40 * have a single element containing string content.
41 * @param id
42 * Pointer to a string. If the function is successful, this value will
43 * be updated to point to a newly allocated string which contains the
44 * resource id string. The caller is responsible for freeing this string.
45 *
46 * @retval GLOBUS_SUCCESS
47 * Resource id extracted successfully.
48 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
49 * The @a id parameter is NULL.
50 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NO_REFERENCE_PROPERTIES
51 * The @a reference_properties parameter is NULL, or contains no elements.
52 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_TOO_MANY_REFERENCE_PROPERTIES
53 * The @a reference_properties array contains more than one element.
54 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_FAILED_RESOURCE_GET
55 * Unable to parse the content of the @a reference_properties element.
56 */
57 globus_result_t
58 globus_resource_id_get_as_string(
59 xsd_any_array * reference_properties,
60 char ** id)
61 10732 {
62 10732 globus_result_t result = GLOBUS_SUCCESS;
63 globus_soap_message_handle_t memory_message;
64 globus_xml_buffer * buffer_handle;
65 GlobusFuncName(globus_resource_id_get_as_string);
66 10732 GlobusSoapMessageDebugEnter();
67
68 10732 if (id == NULL)
69 {
70 0 result = GlobusSoapMessageErrorNullParam;
71
72 0 goto exit;
73 }
74 10732 if(!reference_properties || reference_properties->length < 1)
75 {
76 0 result = GlobusSoapMessageErrorNoReferenceProperties();
77 0 goto exit;
78 }
79 10732 else if(reference_properties->length > 1)
80 {
81 0 result = GlobusSoapMessageErrorTooManyReferenceProperties(
82 reference_properties->length);
83 0 goto exit;
84 }
85
86 10732 if(reference_properties->elements[0].any_info ==
87 (&globus_xml_buffer_contents_info))
88 {
89 9700 buffer_handle =
90 (globus_xml_buffer *)reference_properties->elements[0].value;
91
92 9700 result = globus_soap_message_handle_init_from_memory(
93 &memory_message, buffer_handle->buffer, buffer_handle->length);
94 9700 if(result != GLOBUS_SUCCESS)
95 {
96 0 result = GlobusSoapMessageErrorFailedResourceGet(
97 result, "Failed to initalize memory message");
98 0 goto exit;
99 }
100
101 9700 result = xsd_string_deserialize(
102 NULL,
103 id,
104 memory_message,
105 0);
106 9700 if(result != GLOBUS_SUCCESS)
107 {
108 0 result = GlobusSoapMessageErrorFailedResourceGet(
109 result, "Failed deserialize reference properties");
110 0 goto exit;
111 }
112
113 9700 globus_soap_message_handle_destroy(memory_message);
114 9700 memory_message = NULL;
115 }
116 1032 else if(reference_properties->elements[0].any_info ==
117 (&xsd_string_info))
118 {
119 1032 *id = globus_libc_strdup(
120 *(char **)reference_properties->elements[0].value);
121 }
122 else
123 {
124 0 result = GlobusSoapMessageErrorFailedResourceGet(
125 result, "Failed deserialize reference properties");
126 0 goto exit;
127 }
128
129 10732 exit:
130
131 10732 GlobusSoapMessageDebugExit();
132 10732 return result;
133 }