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 #include "globus_soap_message.h"
18 #include "globus_wsrf_resource.h"
19 #include "globus_service_engine.h"
20 #include "globus_operation_provider.h"
21 #include "globus_service_registry.h"
22 #include "globus_wsrf_core_tools.h"
23 #include "version.h"
24
25 #include "wsrp_GetMultipleResourcePropertiesType.h"
26 #include "wsrp_GetMultipleResourcePropertiesResponseType.h"
27
28 #include "wsr_ResourceUnknownFault.h"
29 #include "wsrp_InvalidResourcePropertyQNameFault.h"
30
31 /**
32 * @page wsrp_GetMultipleResourceProperties_provider GetMultipleResourceProperties Provider
33 *
34 * <h2>Provider Usage Overview</h2>
35 * This operation provider implements the GetMultipleResourceProperties
36 * portType defined in http://docs.oasis-open.org/wsrf/rpw-2 .
37 * This portType consists of the @a GetMultipleResourceProperties operation and
38 * related faults.
39 *
40 * The WSRF service engine will automatically register this provider to handle
41 * the GetMultipleResourceProperties operation for services which use the port
42 * type.
43 */
44
45 /* Prototypes */
46 static
47 globus_result_t
48 wsrp_GetMultipleResourceProperties_provider(
49 globus_service_engine_t engine,
50 globus_soap_message_handle_t handle,
51 globus_service_descriptor_t * service,
52 wsrp_GetMultipleResourcePropertiesType *
53 input,
54 wsrp_GetMultipleResourcePropertiesResponseType *
55 output,
56 xsd_any * fault);
57
58 static
59 int
60 wsrp_GetMultipleResourceProperties_activate(void);
61
62 static
63 int
64 wsrp_GetMultipleResourceProperties_deactivate(void);
65
66 /* Local Variables */
67 static xsd_QName wsrp_GetMultipleResourceProperties_qname =
68 {
69 "http://docs.oasis-open.org/wsrf/rpw-2/providers",
70 "GetMultipleResourceProperties"
71 };
72
73 static
74 globus_operation_provider_descriptor_t
75 wsrp_GetMultipleResourceProperties_descriptor =
76 {
77 &wsrp_GetMultipleResourceProperties_qname,
78 "GetMultipleResourceProperties",
79 (void *)wsrp_GetMultipleResourceProperties_provider
80 };
81
82 GlobusExtensionDefineModule(globus_wsrp_GetMultipleResourceProperties_provider) =
83 {
84 "globus_wsrp_GetMultipleResourceProperties_provider",
85 wsrp_GetMultipleResourceProperties_activate,
86 wsrp_GetMultipleResourceProperties_deactivate,
87 NULL,
88 NULL,
89 &local_version
90 };
91
92 /* Implementation */
93
94 static
95 globus_result_t
96 wsrp_GetMultipleResourceProperties_provider(
97 globus_service_engine_t engine,
98 globus_soap_message_handle_t handle,
99 globus_service_descriptor_t * service,
100 wsrp_GetMultipleResourcePropertiesType *
101 input,
102 wsrp_GetMultipleResourcePropertiesResponseType *
103 output,
104 xsd_any * fault)
105 8992 {
106 globus_resource_t resource;
107 void * property;
108 xsd_any * value;
109 globus_xsd_type_info_t info;
110 globus_result_t result;
111 int i, j;
112 8992 xsd_any * prop_any = NULL;
113
114 8992 result = globus_wsrf_core_get_resource(
115 handle,
116 service,
117 &resource);
118
119 8992 if (result != GLOBUS_SUCCESS || resource == NULL)
120 {
121 0 result = globus_wsrf_core_create_fault(
122 fault,
123 &wsr_ResourceUnknownFault_qname);
124
125 0 goto out;
126 }
127
128 2499908 for (i = 0; i < input->ResourceProperty.length; i++)
129 {
130 globus_object_t * error;
131
132 2490916 result = globus_resource_get_property(
133 resource,
134 &input->ResourceProperty.elements[i],
135 &property,
136 &info);
137
138 2490916 if (result != GLOBUS_SUCCESS)
139 {
140 0 error = globus_error_get(result);
141
142 0 if (globus_error_match(error,
143 GLOBUS_WSRF_RESOURCE_MODULE,
144 GLOBUS_WSRF_RESOURCE_ERROR_TYPE_UNKNOWN_PROPERTY))
145 {
146 0 result = globus_wsrf_core_create_fault(
147 fault,
148 &wsrp_InvalidResourcePropertyQNameFault_qname);
149 0 if (result != GLOBUS_SUCCESS)
150 {
151 0 goto out;
152 }
153 }
154 else
155 {
156 0 result = globus_wsrf_core_create_fault(
157 fault,
158 &wsr_ResourceUnknownFault_qname);
159
160 0 if (result != GLOBUS_SUCCESS)
161 {
162 0 goto out;
163 }
164
165 }
166 0 globus_object_free(error);
167
168 0 goto free_array_out;
169 }
170
171 2490916 if (info == &xsd_any_info)
172 {
173 30 prop_any = property;
174 }
175
176 2490916 if ((prop_any != NULL &&
177 prop_any->any_info != NULL &&
178 prop_any->value != NULL) ||
179 (prop_any == NULL && property != NULL))
180 {
181 2490892 value = xsd_any_array_push(&output->any);
182 2490892 if (value == NULL)
183 {
184 0 result = globus_error_put(GLOBUS_ERROR_NO_INFO);
185
186 0 goto free_array_out;
187 }
188 2490892 value->any_info = info;
189 2490892 result = xsd_QName_copy(&value->element,
190 &input->ResourceProperty.elements[i]);
191 2490892 if (result != GLOBUS_SUCCESS)
192 {
193 0 goto free_array_out;
194 }
195
196 2490892 result = info->copy(&value->value, property);
197 2490892 if (result != GLOBUS_SUCCESS)
198 {
199 0 goto free_array_out;
200 }
201 }
202 }
203 8992 globus_resource_finish(resource);
204
205 8992 return GLOBUS_SUCCESS;
206
207 0 free_array_out:
208 0 if (output->any.length > 0)
209 {
210 0 for (j = i-1; j >=0; j--)
211 {
212 0 info = output->any.elements[j].any_info;
213 0 info->destroy(output->any.elements[j].value);
214 }
215 0 free(output->any.elements);
216 }
217 0 output->any.length = 0;
218 0 output->any.elements = NULL;
219
220 0 globus_resource_finish(resource);
221 0 out:
222 0 return result;
223 }
224 /* wsrp_GetMultipleResourceProperties_provider() */
225
226 static
227 int
228 wsrp_GetMultipleResourceProperties_activate(void)
229 334 {
230 334 int res = 0;
231 GlobusFuncName(wsrp_GetMultipleResourceProperties_activate);
232
233 334 res = globus_extension_registry_add(
234 GLOBUS_OPERATION_PROVIDER_REGISTRY,
235 &wsrp_GetMultipleResourceProperties_qname,
236 GlobusExtensionMyModule(globus_wsrp_GetMultipleResourceProperties_provider),
237 &wsrp_GetMultipleResourceProperties_descriptor);
238
239
240 334 return res;
241 }
242 /* wsrp_GetMultipleResourceProperties_activate() */
243
244 static
245 int
246 wsrp_GetMultipleResourceProperties_deactivate(void)
247 63 {
248 GlobusFuncName(wsrp_GetMultipleResourceProperties_deactivate);
249
250 63 globus_extension_registry_remove(
251 GLOBUS_OPERATION_PROVIDER_REGISTRY,
252 &wsrp_GetMultipleResourceProperties_qname);
253
254 63 return 0;
255 }