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 #include "WidgetService_skeleton.h"
13 #include "WidgetService_internal_skeleton.h"
14
15 #include "globus_wsrf_resource.h"
16 #include "globus_soap_message_handle.h"
17 #include "globus_libc.h"
18 #include "globus_uuid.h"
19 #include "globus_wsrf_core_tools.h"
20
21 #define WIDGET_NS "http://widgets.com"
22
23 static xsd_QName WidgetService_foo_qname =
24 {
25 "http://widgets.com",
26 "foo"
27 };
28
29 globus_result_t
30 WidgetService_init(
31 globus_service_descriptor_t * service_desc)
32 3 {
33 int rc;
34 GlobusFuncName(WidgetService_init);
35
36 3 WidgetServiceDebugEnter();
37
38 3 rc = globus_module_activate(GLOBUS_WSRF_RESOURCE_MODULE);
39
40 3 WidgetServiceDebugExit();
41
42 3 return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE;
43 }
44 /* WidgetService_init() */
45
46 globus_result_t
47 WidgetService_finalize(
48 globus_service_descriptor_t * service_desc)
49 0 {
50 int rc;
51 GlobusFuncName(WidgetService_finalize);
52
53 0 WidgetServiceDebugEnter();
54
55 /* do any service specific finalize stuff here,
56 * opposite of WidgetService_init
57 */
58 0 rc = globus_module_deactivate(GLOBUS_WSRF_RESOURCE_MODULE);
59
60 0 WidgetServiceDebugExit();
61
62 0 return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE;
63 }
64 /* WidgetService_finalize() */
65
66 /* Dummy implementations of functions defined by providers */
67 globus_result_t
68 WidgetPortType_GetResourceProperty_init(
69 globus_service_engine_t engine,
70 globus_soap_message_handle_t message,
71 xsd_QName * GetResourceProperty)
72 0 {
73 0 return GLOBUS_FAILURE;
74 }
75 /* WidgetPortType_GetResourceProperty_init() */
76
77 globus_result_t
78 WidgetPortType_GetResourceProperty_impl(
79 globus_service_engine_t engine,
80 globus_soap_message_handle_t message,
81 globus_service_descriptor_t * descriptor,
82 xsd_QName * GetResourceProperty,
83 wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse,
84 const char ** fault_name,
85 void ** fault)
86 0 {
87 0 return GLOBUS_FAILURE;
88 }
89 /* WidgetPortType_GetResourceProperty_impl() */
90
91 globus_result_t
92 WidgetPortType_GetMultipleResourceProperties_init(
93 globus_service_engine_t engine,
94 globus_soap_message_handle_t message,
95 wsrp_GetMultipleResourcePropertiesType * GetMultipleResourceProperties)
96 0 {
97 0 return GLOBUS_FAILURE;
98 }
99 /* WidgetPortType_GetMultipleResourceProperties_init() */
100
101 globus_result_t
102 WidgetPortType_GetMultipleResourceProperties_impl(
103 globus_service_engine_t engine,
104 globus_soap_message_handle_t message,
105 globus_service_descriptor_t * descriptor,
106 wsrp_GetMultipleResourcePropertiesType * GetMultipleResourceProperties,
107 wsrp_GetMultipleResourcePropertiesResponseType * GetMultipleResourcePropertiesResponse,
108 const char ** fault_name,
109 void ** fault)
110 0 {
111 0 return GLOBUS_FAILURE;
112 }
113 /* WidgetPortType_GetMultipleResourceProperties_impl() */
114
115 globus_result_t
116 WidgetPortType_SetResourceProperties_init(
117 globus_service_engine_t engine,
118 globus_soap_message_handle_t message,
119 wsrp_SetResourcePropertiesType * SetResourceProperties)
120 0 {
121 0 return GLOBUS_FAILURE;
122 }
123 /* WidgetPortType_SetResourceProperties_init() */
124
125 globus_result_t
126 WidgetPortType_SetResourceProperties_impl(
127 globus_service_engine_t engine,
128 globus_soap_message_handle_t message,
129 globus_service_descriptor_t * descriptor,
130 wsrp_SetResourcePropertiesType * SetResourceProperties,
131 wsrp_SetResourcePropertiesResponseType * SetResourcePropertiesResponse,
132 const char ** fault_name,
133 void ** fault)
134 0 {
135 0 return GLOBUS_FAILURE;
136 }
137 /* WidgetPortType_SetResourceProperties_impl() */
138
139 globus_result_t
140 WidgetPortType_QueryResourceProperties_init(
141 globus_service_engine_t engine,
142 globus_soap_message_handle_t message,
143 wsrp_QueryResourcePropertiesType * QueryResourceProperties)
144 0 {
145 0 return GLOBUS_FAILURE;
146 }
147 /* WidgetPortType_QueryResourceProperties_init() */
148
149 globus_result_t
150 WidgetPortType_QueryResourceProperties_impl(
151 globus_service_engine_t engine,
152 globus_soap_message_handle_t message,
153 globus_service_descriptor_t * descriptor,
154 wsrp_QueryResourcePropertiesType * QueryResourceProperties,
155 wsrp_QueryResourcePropertiesResponseType * QueryResourcePropertiesResponse,
156 const char ** fault_name,
157 void ** fault)
158 0 {
159 0 return GLOBUS_FAILURE;
160 }
161 /* WidgetPortType_QueryResourceProperties_impl() */
162
163 globus_result_t
164 WidgetPortType_Destroy_init(
165 globus_service_engine_t engine,
166 globus_soap_message_handle_t message,
167 wsrl_DestroyType * Destroy)
168 0 {
169 0 return GLOBUS_FAILURE;
170 }
171 /* WidgetPortType_Destroy_init() */
172
173 globus_result_t
174 WidgetPortType_Destroy_impl(
175 globus_service_engine_t engine,
176 globus_soap_message_handle_t message,
177 globus_service_descriptor_t * descriptor,
178 wsrl_DestroyType * Destroy,
179 wsrl_DestroyResponseType * DestroyResponse,
180 const char ** fault_name,
181 void ** fault)
182 0 {
183 0 return GLOBUS_FAILURE;
184 }
185 /* WidgetPortType_Destroy_impl() */
186
187 globus_result_t
188 WidgetPortType_SetTerminationTime_init(
189 globus_service_engine_t engine,
190 globus_soap_message_handle_t message,
191 wsrl_SetTerminationTimeType * SetTerminationTime)
192 0 {
193 0 return GLOBUS_FAILURE;
194 }
195 /* WidgetPortType_SetTerminationTime_init() */
196
197 globus_result_t
198 WidgetPortType_SetTerminationTime_impl(
199 globus_service_engine_t engine,
200 globus_soap_message_handle_t message,
201 globus_service_descriptor_t * descriptor,
202 wsrl_SetTerminationTimeType * SetTerminationTime,
203 wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse,
204 const char ** fault_name,
205 void ** fault)
206 0 {
207 0 return GLOBUS_FAILURE;
208 }
209 /* WidgetPortType_SetTerminationTime_impl() */
210
211
212 globus_result_t
213 WidgetPortType_createWidget_init(
214 globus_service_engine_t engine,
215 globus_soap_message_handle_t message,
216 createWidgetType * createWidget)
217 21 {
218 21 return GLOBUS_SUCCESS;
219 }
220 /* WidgetPortType_createWidget_init() */
221
222 globus_result_t
223 WidgetPortType_createWidget_impl(
224 globus_service_engine_t engine,
225 globus_soap_message_handle_t message,
226 globus_service_descriptor_t * descriptor,
227 createWidgetType * createWidget,
228 createWidgetResponseType * createWidgetResponse,
229 const char ** fault_name,
230 void ** fault)
231 21 {
232 globus_result_t result;
233 globus_uuid_t uuid;
234 xsd_any * reference_property;
235 xsd_string_array * foo_value;
236 globus_resource_t resource;
237 int rc;
238
239 21 *fault_name = NULL;
240 21 *fault = NULL;
241
242 21 rc = globus_uuid_create(&uuid);
243 21 if (rc != GLOBUS_SUCCESS)
244 {
245 21 goto out;
246 }
247
248 21 result = globus_resource_create(uuid.text, &resource);
249 21 if (result != GLOBUS_SUCCESS)
250 {
251 21 goto out;
252 }
253 21 xsd_string_array_init(&foo_value);
254
255 21 result = globus_resource_create_property(
256 resource,
257 &WidgetService_foo_qname,
258 &xsd_string_array_info,
259 foo_value);
260 21 if (result != GLOBUS_SUCCESS)
261 {
262 21 goto destroy_out;
263 }
264
265 21 result = WidgetServiceInitResource(uuid.text);
266 21 if (result != GLOBUS_SUCCESS)
267 {
268 21 goto destroy_out;
269 }
270
271 21 xsd_any_init(&reference_property);
272 21 if (reference_property == NULL)
273 {
274 0 result = GLOBUS_FAILURE;
275 0 goto destroy_out;
276 }
277
278 21 reference_property->any_info = &xsd_string_info;
279 21 xsd_QName_init(&reference_property->element);
280 21 if (reference_property->element == NULL)
281 {
282 0 result = GLOBUS_FAILURE;
283 0 goto destroy_ref_property;
284 }
285 21 reference_property->element->Namespace = globus_libc_strdup(WIDGET_NS);
286 21 if (reference_property->element->Namespace == NULL)
287 {
288 0 result = GLOBUS_FAILURE;
289 0 goto destroy_ref_element;
290 }
291 21 reference_property->element->local = globus_libc_strdup("ResourceID");
292 21 if (reference_property->element->local == NULL)
293 {
294 0 result = GLOBUS_FAILURE;
295 0 goto destroy_ref_element_Namespace;
296 }
297 21 xsd_string_init((xsd_string **) &reference_property->value);
298 21 (*(xsd_string*)reference_property->value) = globus_libc_strdup(uuid.text);
299 21 if (reference_property->value == NULL)
300 {
301 0 result = GLOBUS_FAILURE;
302 0 goto destroy_ref_element_local;
303 }
304 21 result = globus_wsrf_core_create_endpoint_reference(
305 engine,
306 WIDGETSERVICE_BASE_PATH,
307 &reference_property,
308 &createWidgetResponse->EndpointReference);
309 21 if (result != GLOBUS_SUCCESS)
310 {
311 0 result = GLOBUS_FAILURE;
312 0 goto destroy_ref_value;
313 }
314
315 21 return GLOBUS_SUCCESS;
316
317 0 destroy_ref_value:
318 0 if (reference_property->value != NULL)
319 {
320 0 free(reference_property->value);
321 }
322 0 reference_property->value = NULL;
323 0 destroy_ref_element_local:
324 0 free(reference_property->element->local);
325 0 reference_property->element->local = NULL;
326 0 destroy_ref_element_Namespace:
327 0 free(reference_property->element->Namespace);
328 0 reference_property->element->Namespace = NULL;
329 0 destroy_ref_element:
330 0 xsd_QName_destroy(reference_property->element);
331 0 destroy_ref_property:
332 0 xsd_any_destroy(reference_property);
333 0 destroy_out:
334 0 globus_resource_destroy(resource);
335 0 out:
336 0 return result;
337 }