| 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_wsrf_core_tools.h" | |
| 22 | #include "globus_wsrf_service_group.h" | |
| 23 | #include "globus_ws_addressing.h" | |
| 24 | ||
| 25 | #include "wssg_AddType.h" | |
| 26 | #include "wsa_EndpointReferenceType.h" | |
| 27 | #include "wssg_i_faults.h" | |
| 28 | ||
| 29 | #include "version.h" | |
| 30 | ||
| 31 | /** | |
| 32 | * @defgroup wssg_ServiceGroupRegistration_provider ServiceGroupRegistration Provider | |
| 33 | * | |
| 34 | * <h2>Provider Usage Overview</h2> | |
| 35 | * This operation provider implements the ServiceGroupRegistry portType | |
| 36 | * defined in | |
| 37 | * http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-02.pdf | |
| 38 | * This portType consists of the wssg:Add operation and related faults. | |
| 39 | * | |
| 40 | * This provider is located in the | |
| 41 | * @b globus_wssg_ServiceGroupRegistration_provider extension. After this | |
| 42 | * extension is activated, the provider may be associated with a service by | |
| 43 | * adding the provider for | |
| 44 | {http://www.globus.org/docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl}Add to the service. | |
| 45 | */ | |
| 46 | ||
| 47 | static | |
| 48 | globus_result_t | |
| 49 | wssg_Add_provider( | |
| 50 | globus_service_engine_t engine, | |
| 51 | globus_soap_message_handle_t message, | |
| 52 | globus_service_descriptor_t * descriptor, | |
| 53 | wssg_AddType * add, | |
| 54 | wsa_EndpointReferenceType * add_response, | |
| 55 | const char ** fault_name, | |
| 56 | void ** fault); | |
| 57 | ||
| 58 | static | |
| 59 | int | |
| 60 | wssg_l_ServiceGroupRegistration_activate(void); | |
| 61 | ||
| 62 | static | |
| 63 | int | |
| 64 | wssg_l_ServiceGroupRegistration_deactivate(void); | |
| 65 | ||
| 66 | /* Local Variables */ | |
| 67 | static xsd_QName wssg_Add_qname = | |
| 68 | { | |
| 69 | "http://www.globus.org/docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl", | |
| 70 | "Add" | |
| 71 | }; | |
| 72 | ||
| 73 | static | |
| 74 | globus_operation_provider_descriptor_t | |
| 75 | wssg_ServiceGroup_descriptor = | |
| 76 | { | |
| 77 | &wssg_Add_qname, | |
| 78 | "Add", | |
| 79 | wssg_Add_provider, | |
| 80 | NULL | |
| 81 | }; | |
| 82 | ||
| 83 | GlobusExtensionDefineModule(globus_wssg_ServiceGroupRegistration_provider) = | |
| 84 | { | |
| 85 | "globus_wssg_ServiceGroupRegistration_provider", | |
| 86 | wssg_l_ServiceGroupRegistration_activate, | |
| 87 | wssg_l_ServiceGroupRegistration_deactivate, | |
| 88 | NULL, | |
| 89 | NULL, | |
| 90 | &local_version | |
| 91 | }; | |
| 92 | ||
| 93 | ||
| 94 | static | |
| 95 | globus_result_t | |
| 96 | wssg_Add_provider( | |
| 97 | globus_service_engine_t engine, | |
| 98 | globus_soap_message_handle_t message, | |
| 99 | globus_service_descriptor_t * descriptor, | |
| 100 | wssg_AddType * add, | |
| 101 | wsa_EndpointReferenceType * add_response, | |
| 102 | const char ** fault_name, | |
| 103 | void ** fault) | |
| 104 | 3 | { |
| 105 | 3 | globus_result_t result; |
| 106 | 3 | wsa_EndpointReferenceType * entry_epr = NULL; |
| 107 | 3 | wsa_EndpointReferenceType * service_group_epr; |
| 108 | ||
| 109 | 3 | service_group_epr = globus_soap_message_handle_get_attr( |
| 110 | message, | |
| 111 | WSADDR_EPR_KEY); | |
| 112 | ||
| 113 | 3 | if (service_group_epr == NULL) |
| 114 | { | |
| 115 | 0 | result = globus_error_put(GLOBUS_ERROR_NO_INFO); |
| 116 | ||
| 117 | 0 | goto out; |
| 118 | } | |
| 119 | ||
| 120 | 3 | result = wsa_EndpointReferenceType_init_contents(add_response); |
| 121 | ||
| 122 | 3 | if (result != GLOBUS_SUCCESS) |
| 123 | { | |
| 124 | ||
| 125 | 0 | goto out; |
| 126 | } | |
| 127 | ||
| 128 | 3 | result = globus_service_group_add( |
| 129 | service_group_epr, | |
| 130 | &add->MemberEPR, | |
| 131 | &add->Content, | |
| 132 | add->InitialTerminationTime, | |
| 133 | &entry_epr); | |
| 134 | ||
| 135 | 3 | if (result != GLOBUS_SUCCESS) |
| 136 | { | |
| 137 | 0 | result = wssg_l_AddRefusedFaultType_create( |
| 138 | fault_name, | |
| 139 | (wssg_AddRefusedFaultType **) fault); | |
| 140 | ||
| 141 | 0 | goto out; |
| 142 | } | |
| 143 | 3 | result = wsa_EndpointReferenceType_copy_contents( |
| 144 | add_response, entry_epr); | |
| 145 | ||
| 146 | 3 | if (result != GLOBUS_SUCCESS) |
| 147 | { | |
| 148 | 0 | wsa_EndpointReferenceType_destroy(entry_epr); |
| 149 | } | |
| 150 | ||
| 151 | out: | |
| 152 | 3 | return result; |
| 153 | } | |
| 154 | /* wssg_Add_provider() */ | |
| 155 | ||
| 156 | static | |
| 157 | int | |
| 158 | wssg_l_ServiceGroupRegistration_activate(void) | |
| 159 | 25 | { |
| 160 | 25 | int res = 0; |
| 161 | 25 | GlobusFuncName(wssg_l_ServiceGroup_activate); |
| 162 | ||
| 163 | 25 | res = globus_module_activate(GLOBUS_WSRF_SERVICE_GROUP_MODULE); |
| 164 | 25 | if (res != GLOBUS_SUCCESS) |
| 165 | { | |
| 166 | 0 | goto out; |
| 167 | } | |
| 168 | ||
| 169 | 25 | res = globus_extension_registry_add( |
| 170 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 171 | &wssg_Add_qname, | |
| 172 | GlobusExtensionMyModule(globus_wssg_ServiceGroupRegistration_provider), | |
| 173 | &wssg_ServiceGroup_descriptor); | |
| 174 | ||
| 175 | 25 | if (res != GLOBUS_SUCCESS) |
| 176 | { | |
| 177 | 0 | globus_module_deactivate(GLOBUS_WSRF_SERVICE_GROUP_MODULE); |
| 178 | } | |
| 179 | out: | |
| 180 | 25 | return res; |
| 181 | } | |
| 182 | /* wssg_ServiceGroupRegistration_activate() */ | |
| 183 | ||
| 184 | static | |
| 185 | int | |
| 186 | wssg_l_ServiceGroupRegistration_deactivate(void) | |
| 187 | 21 | { |
| 188 | 21 | GlobusFuncName(wssg_ServiceGroup_deactivate); |
| 189 | ||
| 190 | 21 | globus_extension_registry_remove( |
| 191 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 192 | &wssg_Add_qname); | |
| 193 | ||
| 194 | 21 | globus_module_deactivate(GLOBUS_WSRF_SERVICE_GROUP_MODULE); |
| 195 | ||
| 196 | 21 | return 0; |
| 197 | } |