| 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 "SubscriptionManagerService_skeleton.h" | |
| 18 | #include "globus_i_notification_producer.h" | |
| 19 | #include "globus_ws_addressing.h" | |
| 20 | ||
| 21 | ||
| 22 | static | |
| 23 | globus_result_t | |
| 24 | wsnt_l_ResourceUnknownFaultType_create( | |
| 25 | const char ** fault_name, | |
| 26 | wsnt_ResourceUnknownFaultType ** fault); | |
| 27 | ||
| 28 | static | |
| 29 | globus_result_t | |
| 30 | wsnt_l_ResumeFailedFaultType_create( | |
| 31 | const char ** fault_name, | |
| 32 | wsnt_ResumeFailedFaultType ** fault); | |
| 33 | ||
| 34 | static | |
| 35 | globus_result_t | |
| 36 | wsnt_l_PauseFailedFaultType_create( | |
| 37 | const char ** fault_name, | |
| 38 | wsnt_PauseFailedFaultType ** fault); | |
| 39 | ||
| 40 | globus_result_t | |
| 41 | SubscriptionManagerService_init( | |
| 42 | globus_service_descriptor_t * service_desc) | |
| 43 | 7 | { |
| 44 | 7 | GlobusFuncName(SubscriptionManagerService_init); |
| 45 | ||
| 46 | 7 | return globus_module_activate(GLOBUS_NOTIFICATION_PRODUCER_MODULE); |
| 47 | } | |
| 48 | /* SubscriptionManagerService_init() */ | |
| 49 | ||
| 50 | globus_result_t | |
| 51 | SubscriptionManagerService_finalize( | |
| 52 | globus_service_descriptor_t * service_desc) | |
| 53 | 0 | { |
| 54 | 0 | GlobusFuncName(SubscriptionManagerService_finalize); |
| 55 | ||
| 56 | 0 | return globus_module_deactivate(GLOBUS_NOTIFICATION_PRODUCER_MODULE); |
| 57 | } | |
| 58 | /* SubscriptionManagerService_finalize() */ | |
| 59 | ||
| 60 | ||
| 61 | globus_result_t | |
| 62 | SubscriptionManager_ResumeSubscription_impl( | |
| 63 | globus_service_engine_t engine, | |
| 64 | globus_soap_message_handle_t message, | |
| 65 | globus_service_descriptor_t * descriptor, | |
| 66 | wsnt_ResumeSubscriptionType * ResumeSubscription, | |
| 67 | wsnt_ResumeSubscriptionResponseType * ResumeSubscriptionResponse, | |
| 68 | const char ** fault_name, | |
| 69 | void ** fault) | |
| 70 | 0 | { |
| 71 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 72 | 0 | globus_object_t * error; |
| 73 | 0 | wsa_EndpointReferenceType * epr; |
| 74 | ||
| 75 | 0 | epr = globus_soap_message_handle_get_attr( |
| 76 | message, | |
| 77 | WSADDR_EPR_KEY); | |
| 78 | ||
| 79 | 0 | if(epr == NULL) |
| 80 | { | |
| 81 | 0 | result = wsnt_l_ResumeFailedFaultType_create(fault_name, (wsnt_ResumeFailedFaultType **) fault); |
| 82 | ||
| 83 | 0 | goto out; |
| 84 | } | |
| 85 | ||
| 86 | 0 | result = globus_notification_subscription_resume(epr); |
| 87 | ||
| 88 | 0 | if (result != GLOBUS_SUCCESS) |
| 89 | { | |
| 90 | 0 | error = globus_error_get(result); |
| 91 | 0 | if (globus_error_match(error, |
| 92 | GLOBUS_NOTIFICATION_PRODUCER_MODULE, | |
| 93 | GLOBUS_NOTIFICATION_PRODUCER_ERROR_TYPE_UNKNOWN_RESOURCE)) | |
| 94 | { | |
| 95 | 0 | result = wsnt_l_ResourceUnknownFaultType_create( |
| 96 | fault_name, | |
| 97 | (wsnt_ResourceUnknownFaultType **)fault); | |
| 98 | } | |
| 99 | else | |
| 100 | { | |
| 101 | 0 | result = wsnt_l_ResumeFailedFaultType_create( |
| 102 | fault_name, | |
| 103 | (wsnt_ResumeFailedFaultType **)fault); | |
| 104 | } | |
| 105 | 0 | globus_object_free(error); |
| 106 | } | |
| 107 | ||
| 108 | out: | |
| 109 | 0 | return result; |
| 110 | } | |
| 111 | /* SubscriptionManager_ResumeSubscription_impl() */ | |
| 112 | ||
| 113 | globus_result_t | |
| 114 | SubscriptionManager_PauseSubscription_impl( | |
| 115 | globus_service_engine_t engine, | |
| 116 | globus_soap_message_handle_t message, | |
| 117 | globus_service_descriptor_t * descriptor, | |
| 118 | wsnt_PauseSubscriptionType * PauseSubscription, | |
| 119 | wsnt_PauseSubscriptionResponseType * PauseSubscriptionResponse, | |
| 120 | const char ** fault_name, | |
| 121 | void ** fault) | |
| 122 | 0 | { |
| 123 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 124 | 0 | globus_object_t * error; |
| 125 | 0 | wsa_EndpointReferenceType * epr; |
| 126 | ||
| 127 | 0 | epr = globus_soap_message_handle_get_attr( |
| 128 | message, | |
| 129 | WSADDR_EPR_KEY); | |
| 130 | ||
| 131 | 0 | if(epr == NULL) |
| 132 | { | |
| 133 | 0 | result = wsnt_l_PauseFailedFaultType_create(fault_name, (wsnt_PauseFailedFaultType **) fault); |
| 134 | ||
| 135 | 0 | goto out; |
| 136 | } | |
| 137 | ||
| 138 | 0 | result = globus_notification_subscription_pause( |
| 139 | epr); | |
| 140 | ||
| 141 | 0 | if (result != GLOBUS_SUCCESS) |
| 142 | { | |
| 143 | 0 | error = globus_error_get(result); |
| 144 | ||
| 145 | 0 | if (globus_error_match(error, |
| 146 | GLOBUS_NOTIFICATION_PRODUCER_MODULE, | |
| 147 | GLOBUS_NOTIFICATION_PRODUCER_ERROR_TYPE_UNKNOWN_RESOURCE)) | |
| 148 | { | |
| 149 | 0 | result = wsnt_l_ResourceUnknownFaultType_create( |
| 150 | fault_name, | |
| 151 | (wsnt_ResourceUnknownFaultType **) fault); | |
| 152 | } | |
| 153 | else | |
| 154 | { | |
| 155 | 0 | result = wsnt_l_PauseFailedFaultType_create( |
| 156 | fault_name, | |
| 157 | (wsnt_PauseFailedFaultType **) fault); | |
| 158 | } | |
| 159 | ||
| 160 | 0 | globus_object_free(error); |
| 161 | } | |
| 162 | ||
| 163 | out: | |
| 164 | 0 | return result; |
| 165 | } | |
| 166 | /* SubscriptionManager_PauseSubscription_impl() */ | |
| 167 | ||
| 168 | ||
| 169 | globus_result_t | |
| 170 | SubscriptionManager_SetTerminationTime_init( | |
| 171 | globus_service_engine_t engine, | |
| 172 | globus_soap_message_handle_t message, | |
| 173 | wsrl_SetTerminationTimeType * SetTerminationTime) | |
| 174 | 0 | { |
| 175 | 0 | return GLOBUS_FAILURE; |
| 176 | } | |
| 177 | /* SubscriptionManager_SetTerminationTime_init() */ | |
| 178 | ||
| 179 | globus_result_t | |
| 180 | SubscriptionManager_SetTerminationTime_impl( | |
| 181 | globus_service_engine_t engine, | |
| 182 | globus_soap_message_handle_t message, | |
| 183 | globus_service_descriptor_t * descriptor, | |
| 184 | wsrl_SetTerminationTimeType * SetTerminationTime, | |
| 185 | wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse, | |
| 186 | const char ** fault_name, | |
| 187 | void ** fault) | |
| 188 | 0 | { |
| 189 | 0 | return GLOBUS_FAILURE; |
| 190 | } | |
| 191 | /* SubscriptionManager_SetTerminationTime_impl() */ | |
| 192 | ||
| 193 | globus_result_t | |
| 194 | SubscriptionManager_Destroy_init( | |
| 195 | globus_service_engine_t engine, | |
| 196 | globus_soap_message_handle_t message, | |
| 197 | wsrl_DestroyType * Destroy) | |
| 198 | 0 | { |
| 199 | 0 | return GLOBUS_FAILURE; |
| 200 | } | |
| 201 | /* SubscriptionManager_Destroy_init() */ | |
| 202 | ||
| 203 | globus_result_t | |
| 204 | SubscriptionManager_Destroy_impl( | |
| 205 | globus_service_engine_t engine, | |
| 206 | globus_soap_message_handle_t message, | |
| 207 | globus_service_descriptor_t * descriptor, | |
| 208 | wsrl_DestroyType * Destroy, | |
| 209 | wsrl_DestroyResponseType * DestroyResponse, | |
| 210 | const char ** fault_name, | |
| 211 | void ** fault) | |
| 212 | 0 | { |
| 213 | 0 | return GLOBUS_FAILURE; |
| 214 | } | |
| 215 | /* SubscriptionManager_Destroy_impl() */ | |
| 216 | ||
| 217 | globus_result_t | |
| 218 | SubscriptionManager_GetResourceProperty_init( | |
| 219 | globus_service_engine_t engine, | |
| 220 | globus_soap_message_handle_t message, | |
| 221 | xsd_QName * GetResourceProperty) | |
| 222 | 0 | { |
| 223 | 0 | return GLOBUS_FAILURE; |
| 224 | } | |
| 225 | /* SubscriptionManager_GetResourceProperty_init() */ | |
| 226 | ||
| 227 | globus_result_t | |
| 228 | SubscriptionManager_GetResourceProperty_impl( | |
| 229 | globus_service_engine_t engine, | |
| 230 | globus_soap_message_handle_t message, | |
| 231 | globus_service_descriptor_t * descriptor, | |
| 232 | xsd_QName * GetResourceProperty, | |
| 233 | wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse, | |
| 234 | const char ** fault_name, | |
| 235 | void ** fault) | |
| 236 | 0 | { |
| 237 | 0 | return GLOBUS_FAILURE; |
| 238 | } | |
| 239 | /* SubscriptionManager_GetResourceProperty_impl() */ | |
| 240 | ||
| 241 | static | |
| 242 | globus_result_t | |
| 243 | wsnt_l_ResourceUnknownFaultType_create( | |
| 244 | const char ** fault_name, | |
| 245 | wsnt_ResourceUnknownFaultType ** fault) | |
| 246 | 0 | { |
| 247 | 0 | globus_result_t result; |
| 248 | 0 | time_t timestamp = time(NULL); |
| 249 | 0 | struct tm * tp; |
| 250 | ||
| 251 | 0 | result = wsnt_ResourceUnknownFaultType_init(fault); |
| 252 | ||
| 253 | 0 | if (result != GLOBUS_SUCCESS) |
| 254 | { | |
| 255 | 0 | return result; |
| 256 | } | |
| 257 | ||
| 258 | 0 | tp = globus_libc_gmtime_r( |
| 259 | ×tamp, | |
| 260 | &(*fault)->Timestamp); | |
| 261 | ||
| 262 | 0 | globus_assert(tp != NULL); |
| 263 | ||
| 264 | 0 | *fault_name = "ResourceUnknownFault"; |
| 265 | ||
| 266 | 0 | return result; |
| 267 | } | |
| 268 | /* wsnt_l_ResourceUnknownFaultType_create() */ | |
| 269 | ||
| 270 | static | |
| 271 | globus_result_t | |
| 272 | wsnt_l_ResumeFailedFaultType_create( | |
| 273 | const char ** fault_name, | |
| 274 | wsnt_ResumeFailedFaultType ** fault) | |
| 275 | 0 | { |
| 276 | 0 | globus_result_t result; |
| 277 | 0 | time_t timestamp = time(NULL); |
| 278 | 0 | struct tm * tp; |
| 279 | ||
| 280 | 0 | result = wsnt_ResumeFailedFaultType_init(fault); |
| 281 | ||
| 282 | 0 | if (result != GLOBUS_SUCCESS) |
| 283 | { | |
| 284 | 0 | return result; |
| 285 | } | |
| 286 | ||
| 287 | 0 | tp = globus_libc_gmtime_r( |
| 288 | ×tamp, | |
| 289 | &(*fault)->Timestamp); | |
| 290 | ||
| 291 | 0 | globus_assert(tp != NULL); |
| 292 | ||
| 293 | 0 | *fault_name = "ResumeFailedFault"; |
| 294 | ||
| 295 | 0 | return result; |
| 296 | } | |
| 297 | /* wsnt_l_ResumeFailedFaultType_create() */ | |
| 298 | ||
| 299 | static | |
| 300 | globus_result_t | |
| 301 | wsnt_l_PauseFailedFaultType_create( | |
| 302 | const char ** fault_name, | |
| 303 | wsnt_PauseFailedFaultType ** fault) | |
| 304 | 0 | { |
| 305 | 0 | globus_result_t result; |
| 306 | 0 | time_t timestamp = time(NULL); |
| 307 | 0 | struct tm * tp; |
| 308 | ||
| 309 | 0 | result = wsnt_PauseFailedFaultType_init(fault); |
| 310 | ||
| 311 | 0 | if (result != GLOBUS_SUCCESS) |
| 312 | { | |
| 313 | 0 | return result; |
| 314 | } | |
| 315 | ||
| 316 | 0 | tp = globus_libc_gmtime_r( |
| 317 | ×tamp, | |
| 318 | &(*fault)->Timestamp); | |
| 319 | ||
| 320 | 0 | globus_assert(tp != NULL); |
| 321 | ||
| 322 | 0 | *fault_name = "PauseFailedFault"; |
| 323 | ||
| 324 | 0 | return result; |
| 325 | } |