| 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 "wsrl_DestroyType.h" | |
| 26 | #include "wsrl_DestroyResponseType.h" | |
| 27 | ||
| 28 | #define WSRL_IMMEDIATE_RESOURCE_TERMINATION 1 | |
| 29 | ||
| 30 | #include "wsrl_i_faults.h" | |
| 31 | ||
| 32 | /** | |
| 33 | * @page wsrl_ImmediateResourceTermination_provider ImmediateResourceTermination Provider | |
| 34 | * | |
| 35 | * <h2>Provider Usage Overview</h2> | |
| 36 | * This operation provider implements the ImmediateResourceTermination portType | |
| 37 | * defined in | |
| 38 | * http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl . | |
| 39 | * This portType consists of the @a Destroy operation and | |
| 40 | * related faults. | |
| 41 | * | |
| 42 | * The WSRF service engine will automatically register this provider to handle | |
| 43 | * the Destroy operation for services which use the port type. | |
| 44 | */ | |
| 45 | ||
| 46 | /* Prototypes */ | |
| 47 | static | |
| 48 | globus_result_t | |
| 49 | wsrl_Destroy_provider( | |
| 50 | globus_service_engine_t engine, | |
| 51 | globus_soap_message_handle_t handle, | |
| 52 | globus_service_descriptor_t * service, | |
| 53 | wsrl_DestroyType * input, | |
| 54 | wsrl_DestroyResponseType * output, | |
| 55 | char ** fault_name, | |
| 56 | void ** fault); | |
| 57 | ||
| 58 | static | |
| 59 | int | |
| 60 | wsrl_ImmediateResourceTermination_activate(void); | |
| 61 | ||
| 62 | static | |
| 63 | int | |
| 64 | wsrl_ImmediateResourceTermination_deactivate(void); | |
| 65 | ||
| 66 | /* Local Variables */ | |
| 67 | static xsd_QName wsrl_Destroy_qname = | |
| 68 | { | |
| 69 | "http://www.globus.org/docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl", | |
| 70 | "Destroy" | |
| 71 | }; | |
| 72 | ||
| 73 | static | |
| 74 | globus_operation_provider_descriptor_t | |
| 75 | wsrl_Destroy_descriptor = | |
| 76 | { | |
| 77 | &wsrl_Destroy_qname, | |
| 78 | "Destroy", | |
| 79 | (void *)wsrl_Destroy_provider, | |
| 80 | }; | |
| 81 | ||
| 82 | GlobusExtensionDefineModule(globus_wsrl_ImmediateResourceTermination_provider) = | |
| 83 | { | |
| 84 | "globus_wsrl_ImmediateResourceTermination_provider", | |
| 85 | wsrl_ImmediateResourceTermination_activate, | |
| 86 | wsrl_ImmediateResourceTermination_deactivate, | |
| 87 | NULL, | |
| 88 | NULL, | |
| 89 | &local_version | |
| 90 | }; | |
| 91 | ||
| 92 | /* Implementation */ | |
| 93 | ||
| 94 | static | |
| 95 | globus_result_t | |
| 96 | wsrl_Destroy_provider( | |
| 97 | globus_service_engine_t engine, | |
| 98 | globus_soap_message_handle_t handle, | |
| 99 | globus_service_descriptor_t * service, | |
| 100 | wsrl_DestroyType * input, | |
| 101 | wsrl_DestroyResponseType * output, | |
| 102 | char ** fault_name, | |
| 103 | void ** fault) | |
| 104 | 61 | { |
| 105 | 61 | globus_result_t result; |
| 106 | 61 | globus_resource_t resource; |
| 107 | 61 | globus_object_t * error; |
| 108 | ||
| 109 | 61 | result = globus_wsrf_core_get_resource(handle, service, &resource); |
| 110 | ||
| 111 | 61 | if (result != GLOBUS_SUCCESS || resource == NULL) |
| 112 | { | |
| 113 | 0 | result = wsrl_l_ResourceUnknownFaultType_create( |
| 114 | fault_name, | |
| 115 | (wsrl_ResourceUnknownFaultType **) fault); | |
| 116 | ||
| 117 | 0 | goto out; |
| 118 | } | |
| 119 | ||
| 120 | 61 | result = globus_resource_destroy(resource); |
| 121 | ||
| 122 | 61 | if (result != GLOBUS_SUCCESS) |
| 123 | { | |
| 124 | 0 | error = globus_error_get(result); |
| 125 | ||
| 126 | 0 | if (globus_error_match(error, |
| 127 | GLOBUS_WSRF_RESOURCE_MODULE, | |
| 128 | GLOBUS_WSRF_RESOURCE_ERROR_TYPE_ALREADY_DESTROYED)) | |
| 129 | { | |
| 130 | 0 | result = wsrl_l_ResourceNotDestroyedFaultType_create( |
| 131 | fault_name, | |
| 132 | (wsrl_ResourceNotDestroyedFaultType **) fault); | |
| 133 | } | |
| 134 | else | |
| 135 | { | |
| 136 | 0 | result = wsrl_l_ResourceUnknownFaultType_create( |
| 137 | fault_name, | |
| 138 | (wsrl_ResourceUnknownFaultType **) fault); | |
| 139 | } | |
| 140 | 0 | globus_object_free(error); |
| 141 | ||
| 142 | 0 | goto out; |
| 143 | } | |
| 144 | ||
| 145 | 61 | return GLOBUS_SUCCESS; |
| 146 | ||
| 147 | out: | |
| 148 | 0 | return result; |
| 149 | } | |
| 150 | /* wsrl_Destroy_provider() */ | |
| 151 | ||
| 152 | ||
| 153 | static | |
| 154 | int | |
| 155 | wsrl_ImmediateResourceTermination_activate(void) | |
| 156 | 93 | { |
| 157 | 93 | int res = 0; |
| 158 | 93 | GlobusFuncName(wsrl_ImmediateResourceTermination_activate); |
| 159 | ||
| 160 | 93 | res = globus_extension_registry_add( |
| 161 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 162 | &wsrl_Destroy_qname, | |
| 163 | GlobusExtensionMyModule(globus_wsrl_ImmediateResourceTermination_provider), | |
| 164 | &wsrl_Destroy_descriptor); | |
| 165 | ||
| 166 | 93 | return res; |
| 167 | } | |
| 168 | /* wsrl_ImmediateResourceTermination_activate() */ | |
| 169 | ||
| 170 | static | |
| 171 | int | |
| 172 | wsrl_ImmediateResourceTermination_deactivate(void) | |
| 173 | 21 | { |
| 174 | 21 | GlobusFuncName(wsrl_ImmediateResourceTermination_deactivate); |
| 175 | ||
| 176 | 21 | globus_extension_registry_remove( |
| 177 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 178 | &wsrl_Destroy_qname); | |
| 179 | ||
| 180 | 21 | return 0; |
| 181 | } |