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 "CounterService_skeleton.h"
19 #include "CounterService_internal_skeleton.h"
20 #include "counter_Value.h"
21
22 #include "globus_wsrf_resource.h"
23 #include "globus_wsrf_core_tools.h"
24 #include "globus_soap_message_handle.h"
25
26 extern globus_service_descriptor_t CounterService_descriptor;
27
28
29 globus_result_t
30 CounterService_init(
31 globus_service_descriptor_t * service_desc)
32 11 {
33 int rc;
34
35 GlobusFuncName(CounterService_init);
36 11 CounterServiceDebugEnter();
37
38 11 rc = globus_module_activate(GLOBUS_WSRF_RESOURCE_MODULE);
39
40 11 CounterServiceDebugExit();
41
42 11 return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE;
43 }
44
45 globus_result_t
46 CounterService_finalize(
47 globus_service_descriptor_t * service_desc)
48 0 {
49 int rc;
50 GlobusFuncName(CounterService_finalize);
51
52 0 CounterServiceDebugEnter();
53
54 /* do any service specific finalize stuff here,
55 * opposite of CounterService_init
56 */
57
58 0 rc = globus_module_deactivate(GLOBUS_WSRF_RESOURCE_MODULE);
59
60 0 CounterServiceDebugExit();
61
62 0 return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE;
63 }
64
65 /* these functions are the service implementation and
66 * must be implemented by the service implementer
67 */
68
69 globus_result_t
70 CounterPortType_GetCurrentMessage_impl(
71 globus_service_engine_t engine,
72 globus_soap_message_handle_t message,
73 globus_service_descriptor_t * service,
74 wsnt_GetCurrentMessageType * GetCurrentMessage,
75 wsnt_GetCurrentMessageResponseType * GetCurrentMessageResponse,
76 xsd_any * fault)
77 0 {
78 /* add function local variable declarations here */
79 0 globus_result_t result = GLOBUS_SUCCESS;
80
81 /* initialize trace debugging info */
82 GlobusFuncName(CounterPortType_GetCurrentMessage_impl);
83 0 CounterServiceDebugEnter();
84
85 /* This is where it all happens. Service implementer must
86 * implmenent this function. Asume that GetCurrentMessage has
87 * been initialized and filled with request values.
88 * GetCurrentMessageResponse must be set by the implementer.
89 */
90
91 0 result = CounterServiceErrorNotImplemented(
92 "CounterPorType_GetCurrentMessage_impl");
93
94 0 CounterServiceDebugExit();
95 0 return result;
96 }
97
98
99
100 /* these functions are the service implementation and
101 * must be implemented by the service implementer
102 */
103
104
105 globus_result_t
106 CounterPortType_Subscribe_impl(
107 globus_service_engine_t engine,
108 globus_soap_message_handle_t message,
109 globus_service_descriptor_t * service,
110 wsnt_SubscribeType * Subscribe,
111 wsnt_SubscribeResponseType * SubscribeResponse,
112 xsd_any * fault)
113 0 {
114 /* add function local variable declarations here */
115 0 globus_result_t result = GLOBUS_SUCCESS;
116
117 /* initialize trace debugging info */
118 GlobusFuncName(CounterPortType_Subscribe_impl);
119 0 CounterServiceDebugEnter();
120
121 /* This is where it all happens. Service implementer must
122 * implmenent this function. Asume that Subscribe has
123 * been initialized and filled with request values.
124 * SubscribeResponse must be set by the implementer.
125 */
126
127 0 result = CounterServiceErrorNotImplemented(
128 "CounterPortType_Subscribe_impl");
129
130 0 CounterServiceDebugExit();
131 0 return result;
132 }
133
134 /* these functions are the service implementation and
135 * must be implemented by the service implementer
136 */
137
138
139 globus_result_t
140 CounterPortType_GetMultipleResourceProperties_impl(
141 globus_service_engine_t engine,
142 globus_soap_message_handle_t message,
143 globus_service_descriptor_t * service,
144 wsrp_GetMultipleResourcePropertiesType * GetResourceProperty,
145 wsrp_GetMultipleResourcePropertiesResponseType * GetMultipleResourcePropertiesResponse,
146 xsd_any * fault)
147 0 {
148 /* add function local variable declarations here */
149 0 globus_result_t result = GLOBUS_SUCCESS;
150
151 /* initialize trace debugging info */
152 GlobusFuncName(CounterPortType_GetMultipleResourceProperties_impl);
153 0 CounterServiceDebugEnter();
154
155 /* This is where it all happens. Service implementer must
156 * implmenent this function. Asume that GetResourceProperty has
157 * been initialized and filled with request values.
158 * GetResourcePropertyResponse must be set by the implementer.
159 */
160
161 0 result = CounterServiceErrorNotImplemented(
162 "CounterPortType_GetMultipleResourceProperties_impl");
163
164 0 CounterServiceDebugExit();
165 0 return result;
166 }
167
168
169
170 /* these functions are the service implementation and
171 * must be implemented by the service implementer
172 */
173
174
175 globus_result_t
176 CounterPortType_GetResourceProperty_impl(
177 globus_service_engine_t engine,
178 globus_soap_message_handle_t message,
179 globus_service_descriptor_t * service,
180 xsd_QName * GetResourceProperty,
181 wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse,
182 xsd_any * fault)
183 0 {
184 /* add function local variable declarations here */
185 0 globus_result_t result = GLOBUS_SUCCESS;
186
187 /* initialize trace debugging info */
188 GlobusFuncName(CounterPortType_GetResourceProperty_impl);
189 0 CounterServiceDebugEnter();
190
191 /* This is where it all happens. Service implementer must
192 * implmenent this function. Asume that GetResourceProperty has
193 * been initialized and filled with request values.
194 * GetResourcePropertyResponse must be set by the implementer.
195 */
196
197 0 result = CounterServiceErrorNotImplemented(
198 "CounterPortType_GetResourceProperty_impl");
199
200 0 CounterServiceDebugExit();
201 0 return result;
202 }
203
204 /* these functions are the service implementation and
205 * must be implemented by the service implementer
206 */
207
208
209 globus_result_t
210 CounterPortType_QueryResourceProperties_impl(
211 globus_service_engine_t engine,
212 globus_soap_message_handle_t message,
213 globus_service_descriptor_t * descriptor,
214 wsrp_QueryResourcePropertiesType * QueryResourceProperties,
215 wsrp_QueryResourcePropertiesResponseType * QueryResourcePropertiesResponse,
216 xsd_any * fault)
217 0 {
218 /* add function local variable declarations here */
219 0 globus_result_t result = GLOBUS_SUCCESS;
220
221 /* initialize trace debugging info */
222 GlobusFuncName(CounterPortType_QueryResourceProperties_impl);
223 0 CounterServiceDebugEnter();
224
225 /* This is where it all happens. Service implementer must
226 * implmenent this function. Asume that QueryResourceProperties has
227 * been initialized and filled with request values.
228 * QueryResourcePropertiesResponse must be set by the implementer.
229 */
230
231 0 result = CounterServiceErrorNotImplemented(
232 "CounterPortType_QueryResourceProperties_impl");
233
234 0 CounterServiceDebugExit();
235 0 return result;
236 }
237
238
239
240 /* these functions are the service implementation and
241 * must be implemented by the service implementer
242 */
243
244
245 globus_result_t
246 CounterPortType_Destroy_impl(
247 globus_service_engine_t engine,
248 globus_soap_message_handle_t message,
249 globus_service_descriptor_t * service,
250 wsrl_DestroyType * Destroy,
251 wsrl_DestroyResponseType * DestroyResponse,
252 xsd_any * fault)
253 0 {
254 /* add function local variable declarations here */
255 0 globus_result_t result = GLOBUS_SUCCESS;
256
257 /* initialize trace debugging info */
258 GlobusFuncName(CounterPortType_Destroy_impl);
259 0 CounterServiceDebugEnter();
260
261 /* This is where it all happens. Service implementer must
262 * implmenent this function. Asume that Destroy has
263 * been initialized and filled with request values.
264 * DestroyResponse must be set by the implementer.
265 */
266
267 0 result = CounterServiceErrorNotImplemented(
268 "CounterPortType_Destroy_impl");
269
270 0 CounterServiceDebugExit();
271 0 return result;
272 }
273
274
275
276 /* these functions are the service implementation and
277 * must be implemented by the service implementer
278 */
279
280
281 globus_result_t
282 CounterPortType_SetTerminationTime_impl(
283 globus_service_engine_t engine,
284 globus_soap_message_handle_t message,
285 globus_service_descriptor_t * service,
286 wsrl_SetTerminationTimeType * SetTerminationTime,
287 wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse,
288 xsd_any * fault)
289 0 {
290 /* add function local variable declarations here */
291 0 globus_result_t result = GLOBUS_SUCCESS;
292
293 /* initialize trace debugging info */
294 GlobusFuncName(CounterPortType_SetTerminationTime_impl);
295 0 CounterServiceDebugEnter();
296
297 /* This is where it all happens. Service implementer must
298 * implmenent this function. Asume that SetTerminationTime has
299 * been initialized and filled with request values.
300 * SetTerminationTimeResponse must be set by the implementer.
301 */
302
303 0 result = CounterServiceErrorNotImplemented(
304 "CounterPortType_SetTerminationTime_impl");
305
306 0 CounterServiceDebugExit();
307 0 return result;
308 }
309
310
311
312 /* these functions are the service implementation and
313 * must be implemented by the service implementer
314 */
315
316
317 globus_result_t
318 CounterPortType_add_impl(
319 globus_service_engine_t engine,
320 globus_soap_message_handle_t message,
321 globus_service_descriptor_t * service,
322 xsd_int * add,
323 xsd_int * addResponse,
324 xsd_any * fault)
325 87 {
326 /* add function local variable declarations here */
327 87 xsd_int * counter_value = NULL;
328 87 globus_soap_message_handle_t memory_message = NULL;
329 87 globus_resource_t resource = NULL;
330 87 globus_result_t result = GLOBUS_SUCCESS;
331
332 /* initialize trace debugging info */
333 GlobusFuncName(CounterPortType_add_impl);
334 87 CounterServiceDebugEnter();
335
336 87 result = globus_wsrf_core_get_resource(
337 message,
338 service,
339 &resource);
340 87 if(result != GLOBUS_SUCCESS)
341 {
342 3 result = CounterPortType_add_chain_error(
343 result,
344 "Failed to get resource from EPR");
345 3 goto exit;
346 }
347
348 84 result = globus_resource_get_property(resource,
349 &counter_Value_qname, (void **)&counter_value, NULL);
350 84 if(result != GLOBUS_SUCCESS)
351 {
352 0 result = CounterPortType_add_chain_error(
353 result,
354 "Failed to get CounterRP resource property from resource");
355 0 goto finish_exit;
356 }
357
358 84 *counter_value += *add;
359 84 *addResponse = *counter_value;
360
361 84 globus_resource_property_changed(resource, &counter_Value_qname);
362
363 84 finish_exit:
364 84 globus_resource_finish(resource);
365 87 exit:
366
367 87 if(memory_message)
368 {
369 0 globus_soap_message_handle_destroy(memory_message);
370 }
371
372 87 CounterServiceDebugExit();
373 87 return result;
374 }
375
376
377
378 /* these functions are the service implementation and
379 * must be implemented by the service implementer
380 */
381
382 globus_result_t
383 CounterPortType_createCounter_impl(
384 globus_service_engine_t engine,
385 globus_soap_message_handle_t message,
386 globus_service_descriptor_t * service,
387 counter_createCounterType * createCounter,
388 counter_createCounterResponseType * createCounterResponse,
389 xsd_any * fault)
390 12 {
391 /* add function local variable declarations here */
392 xsd_any * counter_key;
393 char * resource_id;
394 xsd_int * counter_value;
395 globus_resource_t resource;
396 char * endpoint;
397 12 globus_result_t result = GLOBUS_SUCCESS;
398
399 /* initialize trace debugging info */
400 GlobusFuncName(CounterPortType_createCounter_init);
401 12 CounterServiceDebugEnter();
402
403 12 resource_id = globus_common_create_string("%d", rand());
404
405 12 memset(createCounterResponse, 0, sizeof(counter_createCounterResponseType));
406
407 12 wsa_ReferenceParametersType_init(
408 &createCounterResponse->EndpointReference.ReferenceParameters);
409
410 12 counter_key = xsd_any_array_push(
411 &createCounterResponse->EndpointReference.ReferenceParameters->any);
412
413 12 counter_key->any_info = &xsd_string_info;
414 12 xsd_QName_init(&counter_key->element);
415 12 counter_key->element->local = globus_libc_strdup("CounterKey");
416 12 counter_key->element->Namespace = globus_libc_strdup(
417 CounterService_service_qname.Namespace);
418 12 xsd_string_init_cstr((xsd_string **)&counter_key->value, resource_id);
419
420 12 globus_service_engine_get_contact(engine, &endpoint);
421
422 12 createCounterResponse->EndpointReference.Address.base_value =
423 globus_common_create_string("%s/%s", endpoint, COUNTERSERVICE_BASE_PATH);
424
425 12 free(endpoint);
426
427 12 globus_resource_create(
428 resource_id, &resource);
429
430 12 result = CounterServiceInitResource(
431 &createCounterResponse->EndpointReference);
432 12 if(result != GLOBUS_SUCCESS)
433 {
434 0 result = CounterPortType_add_chain_error(
435 result, "Failed to initialize resource with service");
436 0 goto exit;
437 }
438
439 12 xsd_int_init(&counter_value);
440 12 *counter_value = 0;
441
442 12 result = globus_resource_create_property(
443 resource,
444 &counter_Value_qname,
445 &xsd_int_info, counter_value);
446 12 if(result != GLOBUS_SUCCESS)
447 {
448 0 result = CounterPortType_add_chain_error(
449 result, "Failed to create resource property for CounterRP");
450 0 goto exit;
451 }
452
453 12 globus_resource_finish(resource);
454 12 exit:
455
456 12 CounterServiceDebugExit();
457 12 return result;