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