| 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 "ServiceGroupTestService_skeleton.h" | |
| 19 | #include "ServiceGroupTestService_internal_skeleton.h" | |
| 20 | #include "wssg_MembershipContentRuleType.h" | |
| 21 | #include "wssg_MembershipContentRule.h" | |
| 22 | #include "globus_wsrf_resource.h" | |
| 23 | #include "globus_wsrf_core_tools.h" | |
| 24 | ||
| 25 | #define WSSG_SERVICE_GROUP_PROVIDER \ | |
| 26 | "globus_wssg_ServiceGroup_provider" | |
| 27 | #define WSSG_SERVICE_GROUP_REGISTRATION_PROVIDER \ | |
| 28 | "globus_wssg_ServiceGroupRegistration_provider" | |
| 29 | ||
| 30 | #define SERVICE_GROUP_TEST_NS "http://www.globus.org/namespaces/2005/09/ServiceGroupTest" | |
| 31 | ||
| 32 | static | |
| 33 | xsd_QName | |
| 34 | wssg_l_ServiceGroup_qname = | |
| 35 | { | |
| 36 | "http://docs.oasis-open.org/wsrf/sgw-2/providers", | |
| 37 | "ServiceGroup" | |
| 38 | }; | |
| 39 | ||
| 40 | static | |
| 41 | xsd_QName | |
| 42 | wssg_l_Add_qname = | |
| 43 | { | |
| 44 | "http://docs.oasis-open.org/wsrf/sgw-2/providers", | |
| 45 | "Add" | |
| 46 | }; | |
| 47 | ||
| 48 | globus_result_t | |
| 49 | ServiceGroupTestService_init( | |
| 50 | globus_service_descriptor_t * service_desc) | |
| 51 | 50 | { |
| 52 | globus_result_t result; | |
| 53 | ||
| 54 | GlobusFuncName(ServiceGroupTestService_init); | |
| 55 | 50 | ServiceGroupTestServiceDebugEnter(); |
| 56 | ||
| 57 | /* do any service specific init stuff here, such | |
| 58 | * as loading other operation providers and setting them | |
| 59 | * in the operation table of the service descriptor. This | |
| 60 | * function is called at the end of service activation. | |
| 61 | */ | |
| 62 | /* Load the wssg:ServiceGroup provider */ | |
| 63 | 50 | result = globus_extension_activate(WSSG_SERVICE_GROUP_PROVIDER); |
| 64 | 50 | if (result != GLOBUS_SUCCESS) |
| 65 | { | |
| 66 | 0 | goto out; |
| 67 | } | |
| 68 | 50 | result = globus_extension_activate( |
| 69 | WSSG_SERVICE_GROUP_REGISTRATION_PROVIDER); | |
| 70 | 50 | if (result != GLOBUS_SUCCESS) |
| 71 | { | |
| 72 | 0 | goto deactivate_service_group_provider; |
| 73 | } | |
| 74 | ||
| 75 | /* Add the wssg:ServiceGroup provider to our service implementation */ | |
| 76 | 50 | result = globus_operation_table_add_provider( |
| 77 | ServiceGroupTestService_descriptor.operations, | |
| 78 | &wssg_l_ServiceGroup_qname); | |
| 79 | ||
| 80 | 50 | if (result != GLOBUS_SUCCESS) |
| 81 | { | |
| 82 | 0 | goto deactivate_service_group_registration_provider; |
| 83 | } | |
| 84 | ||
| 85 | /* Add the wssg:ServiceGroupRegistration provider to our service | |
| 86 | * implementation | |
| 87 | */ | |
| 88 | 50 | result = globus_operation_table_add_provider( |
| 89 | ServiceGroupTestService_descriptor.operations, | |
| 90 | &wssg_l_Add_qname); | |
| 91 | ||
| 92 | 50 | deactivate_service_group_registration_provider: |
| 93 | 50 | if (result != GLOBUS_SUCCESS) |
| 94 | { | |
| 95 | 0 | globus_extension_deactivate(WSSG_SERVICE_GROUP_REGISTRATION_PROVIDER); |
| 96 | 0 | deactivate_service_group_provider: |
| 97 | 0 | globus_extension_deactivate(WSSG_SERVICE_GROUP_PROVIDER); |
| 98 | } | |
| 99 | 50 | out: |
| 100 | 50 | ServiceGroupTestServiceDebugExit(); |
| 101 | 50 | return result; |
| 102 | } | |
| 103 | ||
| 104 | globus_result_t | |
| 105 | ServiceGroupTestService_finalize( | |
| 106 | globus_service_descriptor_t * service_desc) | |
| 107 | 42 | { |
| 108 | GlobusFuncName(ServiceGroupTestService_finalize); | |
| 109 | 42 | ServiceGroupTestServiceDebugEnter(); |
| 110 | ||
| 111 | 42 | globus_extension_deactivate(WSSG_SERVICE_GROUP_REGISTRATION_PROVIDER); |
| 112 | 42 | globus_extension_deactivate(WSSG_SERVICE_GROUP_PROVIDER); |
| 113 | ||
| 114 | 42 | ServiceGroupTestServiceDebugExit(); |
| 115 | 42 | return GLOBUS_SUCCESS; |
| 116 | } | |
| 117 | ||
| 118 | ||
| 119 | ||
| 120 | globus_result_t | |
| 121 | ServiceGroupTestPortType_Add_impl( | |
| 122 | globus_service_engine_t engine, | |
| 123 | globus_soap_message_handle_t message, | |
| 124 | globus_service_descriptor_t * descriptor, | |
| 125 | wssg_AddType * Add, | |
| 126 | wssg_AddResponseType * AddResponse, | |
| 127 | xsd_any * fault) | |
| 128 | 0 | { |
| 129 | /* add function local variable declarations here */ | |
| 130 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 131 | ||
| 132 | /* initialize trace debugging info */ | |
| 133 | GlobusFuncName(ServiceGroupTestPortType_Add_impl); | |
| 134 | 0 | ServiceGroupTestServiceDebugEnter(); |
| 135 | ||
| 136 | /* This is where it all happens. Service implementer must | |
| 137 | * implmenent this function. Asume that Add has | |
| 138 | * been initialized and filled with request values. | |
| 139 | * AddResponse must be set by the implementer. | |
| 140 | */ | |
| 141 | ||
| 142 | /* do not use GLOBUS_FAILURE, you the error object construction api */ | |
| 143 | 0 | result = ServiceGroupTestServiceErrorNotImplemented("ServiceGroupTestPortType_Add"); |
| 144 | ||
| 145 | 0 | ServiceGroupTestServiceDebugExit(); |
| 146 | 0 | return result; |
| 147 | } | |
| 148 | ||
| 149 | ||
| 150 | ||
| 151 | globus_result_t | |
| 152 | ServiceGroupTestPortType_GetCurrentMessage_impl( | |
| 153 | globus_service_engine_t engine, | |
| 154 | globus_soap_message_handle_t message, | |
| 155 | globus_service_descriptor_t * descriptor, | |
| 156 | wsnt_GetCurrentMessageType * GetCurrentMessage, | |
| 157 | wsnt_GetCurrentMessageResponseType * GetCurrentMessageResponse, | |
| 158 | xsd_any * fault) | |
| 159 | 0 | { |
| 160 | /* add function local variable declarations here */ | |
| 161 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 162 | ||
| 163 | /* initialize trace debugging info */ | |
| 164 | GlobusFuncName(ServiceGroupTestPortType_GetCurrentMessage_impl); | |
| 165 | 0 | ServiceGroupTestServiceDebugEnter(); |
| 166 | ||
| 167 | /* This is where it all happens. Service implementer must | |
| 168 | * implmenent this function. Asume that GetCurrentMessage has | |
| 169 | * been initialized and filled with request values. | |
| 170 | * GetCurrentMessageResponse must be set by the implementer. | |
| 171 | */ | |
| 172 | ||
| 173 | /* do not use GLOBUS_FAILURE, you the error object construction api */ | |
| 174 | 0 | result = ServiceGroupTestServiceErrorNotImplemented("ServiceGroupTestPortType_GetCurrentMessage"); |
| 175 | ||
| 176 | 0 | ServiceGroupTestServiceDebugExit(); |
| 177 | 0 | return result; |
| 178 | } | |
| 179 | ||
| 180 | ||
| 181 | ||
| 182 | globus_result_t | |
| 183 | ServiceGroupTestPortType_Subscribe_impl( | |
| 184 | globus_service_engine_t engine, | |
| 185 | globus_soap_message_handle_t message, | |
| 186 | globus_service_descriptor_t * descriptor, | |
| 187 | wsnt_SubscribeType * Subscribe, | |
| 188 | wsnt_SubscribeResponseType * SubscribeResponse, | |
| 189 | xsd_any * fault) | |
| 190 | 0 | { |
| 191 | /* add function local variable declarations here */ | |
| 192 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 193 | ||
| 194 | /* initialize trace debugging info */ | |
| 195 | GlobusFuncName(ServiceGroupTestPortType_Subscribe_impl); | |
| 196 | 0 | ServiceGroupTestServiceDebugEnter(); |
| 197 | ||
| 198 | /* This is where it all happens. Service implementer must | |
| 199 | * implmenent this function. Asume that Subscribe has | |
| 200 | * been initialized and filled with request values. | |
| 201 | * SubscribeResponse must be set by the implementer. | |
| 202 | */ | |
| 203 | ||
| 204 | /* do not use GLOBUS_FAILURE, you the error object construction api */ | |
| 205 | 0 | result = ServiceGroupTestServiceErrorNotImplemented("ServiceGroupTestPortType_Subscribe"); |
| 206 | ||
| 207 | 0 | ServiceGroupTestServiceDebugExit(); |
| 208 | 0 | return result; |
| 209 | } | |
| 210 | ||
| 211 | ||
| 212 | ||
| 213 | globus_result_t | |
| 214 | ServiceGroupTestPortType_GetResourceProperty_impl( | |
| 215 | globus_service_engine_t engine, | |
| 216 | globus_soap_message_handle_t message, | |
| 217 | globus_service_descriptor_t * descriptor, | |
| 218 | xsd_QName * GetResourceProperty, | |
| 219 | wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse, | |
| 220 | xsd_any * fault) | |
| 221 | 0 | { |
| 222 | /* add function local variable declarations here */ | |
| 223 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 224 | ||
| 225 | /* initialize trace debugging info */ | |
| 226 | GlobusFuncName(ServiceGroupTestPortType_GetResourceProperty_impl); | |
| 227 | 0 | ServiceGroupTestServiceDebugEnter(); |
| 228 | ||
| 229 | /* This is where it all happens. Service implementer must | |
| 230 | * implmenent this function. Asume that GetResourceProperty has | |
| 231 | * been initialized and filled with request values. | |
| 232 | * GetResourcePropertyResponse must be set by the implementer. | |
| 233 | */ | |
| 234 | ||
| 235 | /* do not use GLOBUS_FAILURE, you the error object construction api */ | |
| 236 | 0 | result = ServiceGroupTestServiceErrorNotImplemented("ServiceGroupTestPortType_GetResourceProperty"); |
| 237 | ||
| 238 | 0 | ServiceGroupTestServiceDebugExit(); |
| 239 | 0 | return result; |
| 240 | } | |
| 241 | ||
| 242 | ||
| 243 | ||
| 244 | ||
| 245 | globus_result_t | |
| 246 | ServiceGroupTestPortType_CreateServiceGroup_impl( | |
| 247 | globus_service_engine_t engine, | |
| 248 | globus_soap_message_handle_t message, | |
| 249 | globus_service_descriptor_t * descriptor, | |
| 250 | sgtest_CreateServiceGroupType * CreateServiceGroup, | |
| 251 | sgtest_CreateServiceGroupResponseType * CreateServiceGroupResponse, | |
| 252 | xsd_any * fault) | |
| 253 | 8 | { |
| 254 | wssg_MembershipContentRuleType * membership_content_rule; | |
| 255 | 8 | globus_result_t result = GLOBUS_SUCCESS; |
| 256 | int rc; | |
| 257 | globus_uuid_t resource_id; | |
| 258 | 8 | globus_resource_t resource = NULL; |
| 259 | xsd_any * reference_properties; | |
| 260 | ||
| 261 | /* initialize trace debugging info */ | |
| 262 | GlobusFuncName(ServiceGroupTestPortType_CreateServiceGroup_impl); | |
| 263 | 8 | ServiceGroupTestServiceDebugEnter(); |
| 264 | ||
| 265 | 8 | rc = globus_uuid_create(&resource_id); |
| 266 | 8 | if (rc != GLOBUS_SUCCESS) |
| 267 | { | |
| 268 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 269 | ||
| 270 | 0 | goto out; |
| 271 | } | |
| 272 | ||
| 273 | 8 | result = globus_resource_create( |
| 274 | resource_id.text, | |
| 275 | &resource); | |
| 276 | ||
| 277 | 8 | if (result != GLOBUS_SUCCESS) |
| 278 | { | |
| 279 | 0 | goto out; |
| 280 | } | |
| 281 | 8 | result = xsd_any_init(&reference_properties); |
| 282 | 8 | if (result != GLOBUS_SUCCESS) |
| 283 | { | |
| 284 | 0 | goto destroy_resource_out; |
| 285 | } | |
| 286 | 8 | reference_properties->any_info = &xsd_string_info; |
| 287 | 8 | result = xsd_QName_init(&reference_properties->element); |
| 288 | 8 | if (result != GLOBUS_SUCCESS) |
| 289 | { | |
| 290 | 0 | goto free_reference_properties_out; |
| 291 | } | |
| 292 | 8 | reference_properties->element->Namespace = |
| 293 | globus_libc_strdup(SERVICE_GROUP_TEST_NS); | |
| 294 | 8 | if (reference_properties->element->Namespace == NULL) |
| 295 | { | |
| 296 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 297 | ||
| 298 | 0 | goto free_reference_properties_out; |
| 299 | } | |
| 300 | 8 | reference_properties->element->local = |
| 301 | globus_libc_strdup("ResourceID"); | |
| 302 | 8 | if (reference_properties->element->local == NULL) |
| 303 | { | |
| 304 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 305 | ||
| 306 | 0 | goto free_reference_properties_out; |
| 307 | } | |
| 308 | 8 | result = xsd_string_init_cstr( |
| 309 | (xsd_string **) &reference_properties->value, | |
| 310 | globus_libc_strdup(resource_id.text)); | |
| 311 | 8 | if (reference_properties->value == NULL || |
| 312 | *(xsd_string *) reference_properties->value == NULL) | |
| 313 | { | |
| 314 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 315 | ||
| 316 | 0 | goto free_reference_properties_out; |
| 317 | } | |
| 318 | ||
| 319 | ||
| 320 | 8 | result = globus_wsrf_core_create_endpoint_reference( |
| 321 | engine, | |
| 322 | SERVICEGROUPTESTSERVICE_BASE_PATH, | |
| 323 | &reference_properties, | |
| 324 | &CreateServiceGroupResponse->EndpointReference); | |
| 325 | ||
| 326 | 8 | if (result != GLOBUS_SUCCESS) |
| 327 | { | |
| 328 | 0 | goto destroy_resource_out; |
| 329 | } | |
| 330 | ||
| 331 | /* Prepare Service Group-related RPs so the ServiceGroup and | |
| 332 | * ServiceGroupRegistration providers can do their things | |
| 333 | */ | |
| 334 | 8 | result = wssg_MembershipContentRuleType_copy( |
| 335 | &membership_content_rule, | |
| 336 | &CreateServiceGroup->MembershipContentRule); | |
| 337 | 8 | if (result != GLOBUS_SUCCESS) |
| 338 | { | |
| 339 | 0 | goto destroy_epr_out; |
| 340 | } | |
| 341 | ||
| 342 | 8 | result = globus_resource_create_property( |
| 343 | resource, | |
| 344 | &wssg_MembershipContentRule_qname, | |
| 345 | &wssg_MembershipContentRuleType_info, | |
| 346 | membership_content_rule); | |
| 347 | ||
| 348 | 8 | if (result != GLOBUS_SUCCESS) |
| 349 | { | |
| 350 | 0 | goto free_membership_content_out; |
| 351 | } | |
| 352 | 8 | membership_content_rule = NULL; |
| 353 | ||
| 354 | 8 | result = ServiceGroupTestServiceInitResource( |
| 355 | &CreateServiceGroupResponse->EndpointReference); | |
| 356 | if (result != GLOBUS_SUCCESS) | |
| 357 | { | |
| 358 | 8 | goto free_membership_content_out; |
| 359 | } | |
| 360 | ||
| 361 | 8 | free_membership_content_out: |
| 362 | 8 | if (membership_content_rule != NULL) |
| 363 | { | |
| 364 | 0 | wssg_MembershipContentRuleType_destroy(membership_content_rule); |
| 365 | } | |
| 366 | ||
| 367 | 8 | if (result != GLOBUS_SUCCESS) |
| 368 | { | |
| 369 | 0 | destroy_epr_out: |
| 370 | 0 | wsa_EndpointReferenceType_destroy_contents( |
| 371 | &CreateServiceGroupResponse->EndpointReference); | |
| 372 | 0 | free_reference_properties_out: |
| 373 | 0 | if (reference_properties != NULL) |
| 374 | { | |
| 375 | 0 | xsd_any_destroy(reference_properties); |
| 376 | } | |
| 377 | 0 | destroy_resource_out: |
| 378 | 0 | globus_resource_destroy(resource); |
| 379 | } | |
| 380 | else | |
| 381 | { | |
| 382 | 8 | globus_resource_finish(resource); |
| 383 | } | |
| 384 | 8 | out: |
| 385 | 8 | ServiceGroupTestServiceDebugExit(); |
| 386 | 8 | return result; |
| 387 | } |