| 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 "ResourcePropertiesTestService_skeleton.h" | |
| 18 | #include "ResourcePropertiesTestService_internal_skeleton.h" | |
| 19 | #include "rptest_ResourcePropertyDefinitionType.h" | |
| 20 | ||
| 21 | #include "globus_wsrf_resource.h" | |
| 22 | #include "globus_soap_message_handle.h" | |
| 23 | #include "globus_wsrf_core_tools.h" | |
| 24 | ||
| 25 | #define ResourcePropertiesTestService_NS \ | |
| 26 | "http://www.globus.org/namespaces/2004/10/ResourcePropertiesTest" | |
| 27 | ||
| 28 | extern globus_service_descriptor_t ResourcePropertiesTestService_descriptor; | |
| 29 | ||
| 30 | globus_result_t | |
| 31 | ResourcePropertiesTestService_init( | |
| 32 | globus_service_descriptor_t * service_desc) | |
| 33 | 180 | { |
| 34 | int rc; | |
| 35 | GlobusFuncName(ResourcePropertiesTestService_init); | |
| 36 | ||
| 37 | 180 | rc = globus_module_activate(GLOBUS_WSRF_RESOURCE_MODULE); |
| 38 | ||
| 39 | 180 | return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE; |
| 40 | } | |
| 41 | /* ResourcePropertiesTestService_init() */ | |
| 42 | ||
| 43 | globus_result_t | |
| 44 | ResourcePropertiesTestService_finalize( | |
| 45 | globus_service_descriptor_t * service_desc) | |
| 46 | 0 | { |
| 47 | int rc; | |
| 48 | GlobusFuncName(ResourcePropertiesService_finalize); | |
| 49 | ||
| 50 | 0 | rc = globus_module_deactivate(GLOBUS_WSRF_RESOURCE_MODULE); |
| 51 | ||
| 52 | 0 | return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE; |
| 53 | } | |
| 54 | /* ResourcePropertiesTestService_finalize() */ | |
| 55 | ||
| 56 | globus_result_t | |
| 57 | ResourcePropertiesTestPortType_SetTerminationTime_impl( | |
| 58 | globus_service_engine_t engine, | |
| 59 | globus_soap_message_handle_t message, | |
| 60 | globus_service_descriptor_t * descriptor, | |
| 61 | wsrl_SetTerminationTimeType * SetTerminationTime, | |
| 62 | wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse, | |
| 63 | xsd_any * fault) | |
| 64 | 0 | { |
| 65 | 0 | return GLOBUS_FAILURE; |
| 66 | } | |
| 67 | ||
| 68 | globus_result_t | |
| 69 | ResourcePropertiesTestPortType_Destroy_impl( | |
| 70 | globus_service_engine_t engine, | |
| 71 | globus_soap_message_handle_t message, | |
| 72 | globus_service_descriptor_t * descriptor, | |
| 73 | wsrl_DestroyType * Destroy, | |
| 74 | wsrl_DestroyResponseType * DestroyResponse, | |
| 75 | xsd_any * fault) | |
| 76 | 0 | { |
| 77 | 0 | return GLOBUS_FAILURE; |
| 78 | } | |
| 79 | ||
| 80 | globus_result_t | |
| 81 | ResourcePropertiesTestPortType_QueryResourceProperties_impl( | |
| 82 | globus_service_engine_t engine, | |
| 83 | globus_soap_message_handle_t message, | |
| 84 | globus_service_descriptor_t * descriptor, | |
| 85 | wsrp_QueryResourcePropertiesType * QueryResourceProperties, | |
| 86 | wsrp_QueryResourcePropertiesResponseType * QueryResourcePropertiesResponse, | |
| 87 | xsd_any * fault) | |
| 88 | 0 | { |
| 89 | 0 | return GLOBUS_FAILURE; |
| 90 | } | |
| 91 | ||
| 92 | globus_result_t | |
| 93 | ResourcePropertiesTestPortType_SetResourceProperties_impl( | |
| 94 | globus_service_engine_t engine, | |
| 95 | globus_soap_message_handle_t message, | |
| 96 | globus_service_descriptor_t * descriptor, | |
| 97 | wsrp_SetResourcePropertiesType * SetResourceProperties, | |
| 98 | wsrp_SetResourcePropertiesResponseType * SetResourcePropertiesResponse, | |
| 99 | xsd_any * fault) | |
| 100 | 0 | { |
| 101 | 0 | return GLOBUS_FAILURE; |
| 102 | } | |
| 103 | ||
| 104 | globus_result_t | |
| 105 | ResourcePropertiesTestPortType_GetMultipleResourceProperties_impl( | |
| 106 | globus_service_engine_t engine, | |
| 107 | globus_soap_message_handle_t message, | |
| 108 | globus_service_descriptor_t * descriptor, | |
| 109 | wsrp_GetMultipleResourcePropertiesType * GetMultipleResourceProperties, | |
| 110 | wsrp_GetMultipleResourcePropertiesResponseType * GetMultipleResourcePropertiesResponse, | |
| 111 | xsd_any * fault) | |
| 112 | 0 | { |
| 113 | 0 | return GLOBUS_FAILURE; |
| 114 | } | |
| 115 | ||
| 116 | globus_result_t | |
| 117 | ResourcePropertiesTestPortType_GetResourceProperty_impl( | |
| 118 | globus_service_engine_t engine, | |
| 119 | globus_soap_message_handle_t message, | |
| 120 | globus_service_descriptor_t * descriptor, | |
| 121 | xsd_QName * GetResourceProperty, | |
| 122 | wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse, | |
| 123 | xsd_any * fault) | |
| 124 | 0 | { |
| 125 | 0 | return GLOBUS_FAILURE; |
| 126 | } | |
| 127 | ||
| 128 | globus_result_t | |
| 129 | ResourcePropertiesTestPortType_CreateResourcePropertiesTest_impl( | |
| 130 | globus_service_engine_t engine, | |
| 131 | globus_soap_message_handle_t message, | |
| 132 | globus_service_descriptor_t * descriptor, | |
| 133 | rptest_CreateResourcePropertiesTestType * CreateResourcePropertiesTest, | |
| 134 | rptest_CreateResourcePropertiesTestResponseType * CreateResourcePropertiesTestResponse, | |
| 135 | xsd_any * fault) | |
| 136 | 180 | { |
| 137 | globus_result_t result; | |
| 138 | globus_uuid_t uuid; | |
| 139 | int rc; | |
| 140 | int i; | |
| 141 | xsd_QName * rp_qname; | |
| 142 | xsd_QName * type_qname; | |
| 143 | globus_xsd_type_registry_t registry; | |
| 144 | globus_xsd_type_info_t type_info; | |
| 145 | xsd_any * ref_prop; | |
| 146 | xsd_string * ref_prop_string; | |
| 147 | xsd_boolean * boolean_type; | |
| 148 | globus_resource_t resource; | |
| 149 | ||
| 150 | 180 | rc = globus_uuid_create(&uuid); |
| 151 | ||
| 152 | 180 | if (rc != GLOBUS_SUCCESS) |
| 153 | { | |
| 154 | 0 | result = GLOBUS_FAILURE; |
| 155 | ||
| 156 | 0 | goto out; |
| 157 | } | |
| 158 | 180 | result = globus_resource_create(uuid.text, &resource); |
| 159 | 180 | if (result != GLOBUS_SUCCESS) |
| 160 | { | |
| 161 | 0 | goto out; |
| 162 | } | |
| 163 | 180 | registry = GLOBUS_GLOBAL_TYPE_REGISTRY; |
| 164 | ||
| 165 | 378 | for (i = 0; i < CreateResourcePropertiesTest->ResourcePropertyDefinition.length; i++) |
| 166 | { | |
| 167 | 198 | rp_qname = &CreateResourcePropertiesTest->ResourcePropertyDefinition.elements[i].QName; |
| 168 | 198 | type_qname = &CreateResourcePropertiesTest->ResourcePropertyDefinition.elements[i].TypeQName; |
| 169 | 198 | boolean_type = CreateResourcePropertiesTest->ResourcePropertyDefinition.elements[i]._array; |
| 170 | ||
| 171 | 198 | result = globus_xsd_type_registry_get( |
| 172 | registry, | |
| 173 | type_qname, | |
| 174 | &type_info); | |
| 175 | 198 | if (result != GLOBUS_SUCCESS || type_info == NULL) |
| 176 | { | |
| 177 | 0 | result = globus_xsd_type_registry_get( |
| 178 | GLOBUS_GLOBAL_TYPE_REGISTRY, | |
| 179 | type_qname, | |
| 180 | &type_info); | |
| 181 | } | |
| 182 | 198 | if (result != GLOBUS_SUCCESS) |
| 183 | { | |
| 184 | 0 | goto destroy_resource_out; |
| 185 | } | |
| 186 | 198 | else if (type_info == NULL) |
| 187 | { | |
| 188 | 0 | if (xsd_QName_keyeq( |
| 189 | globus_resource_properties_any_qname, | |
| 190 | rp_qname)) | |
| 191 | { | |
| 192 | 0 | type_info = &xsd_any_info; |
| 193 | } | |
| 194 | else | |
| 195 | { | |
| 196 | 0 | result = GLOBUS_FAILURE; |
| 197 | } | |
| 198 | } | |
| 199 | ||
| 200 | 198 | result = globus_resource_create_property( |
| 201 | resource, | |
| 202 | rp_qname, | |
| 203 | (boolean_type && *boolean_type) | |
| 204 | ? type_info->array_info | |
| 205 | : type_info, | |
| 206 | NULL); | |
| 207 | ||
| 208 | 198 | if (result != GLOBUS_SUCCESS) |
| 209 | { | |
| 210 | 0 | goto destroy_resource_out; |
| 211 | } | |
| 212 | } | |
| 213 | ||
| 214 | 180 | xsd_string_init_cstr(&ref_prop_string, |
| 215 | globus_libc_strdup(uuid.text)); | |
| 216 | ||
| 217 | 180 | if (ref_prop_string == NULL) |
| 218 | { | |
| 219 | 0 | result = GLOBUS_FAILURE; |
| 220 | 0 | goto destroy_resource_out; |
| 221 | } | |
| 222 | 180 | xsd_any_init(&ref_prop); |
| 223 | 180 | if (ref_prop == NULL) |
| 224 | { | |
| 225 | 0 | result = GLOBUS_FAILURE; |
| 226 | 0 | goto destroy_ref_prop_string_out; |
| 227 | } | |
| 228 | 180 | ref_prop->any_info = &xsd_string_info; |
| 229 | 180 | xsd_QName_init(&ref_prop->element); |
| 230 | 180 | if (ref_prop->element == NULL) |
| 231 | { | |
| 232 | 0 | result = GLOBUS_FAILURE; |
| 233 | 0 | goto destroy_ref_prop_out; |
| 234 | } | |
| 235 | 180 | ref_prop->element->Namespace = globus_libc_strdup( |
| 236 | ResourcePropertiesTestService_NS); | |
| 237 | 180 | if (ref_prop->element->Namespace == NULL) |
| 238 | { | |
| 239 | 0 | result = GLOBUS_FAILURE; |
| 240 | 0 | goto destroy_ref_prop_element; |
| 241 | } | |
| 242 | 180 | ref_prop->element->local = globus_libc_strdup("ResourceID"); |
| 243 | 180 | if (ref_prop->element->local == NULL) |
| 244 | { | |
| 245 | 0 | result = GLOBUS_FAILURE; |
| 246 | 0 | goto destroy_ref_prop_element_ns; |
| 247 | } | |
| 248 | 180 | ref_prop->value = ref_prop_string; |
| 249 | ||
| 250 | 180 | result = globus_wsrf_core_create_endpoint_reference( |
| 251 | engine, | |
| 252 | RESOURCEPROPERTIESTESTSERVICE_BASE_PATH, | |
| 253 | &ref_prop, | |
| 254 | &CreateResourcePropertiesTestResponse->EndpointReference); | |
| 255 | 180 | if (result != GLOBUS_SUCCESS) |
| 256 | { | |
| 257 | 0 | goto destroy_ref_prop_element_local; |
| 258 | } | |
| 259 | 180 | globus_resource_finish(resource); |
| 260 | 180 | return result; |
| 261 | ||
| 262 | 0 | destroy_ref_prop_element_local: |
| 263 | 0 | free(ref_prop->element->local); |
| 264 | 0 | destroy_ref_prop_element_ns: |
| 265 | 0 | free(ref_prop->element->Namespace); |
| 266 | 0 | destroy_ref_prop_element: |
| 267 | 0 | free(ref_prop->element); |
| 268 | 0 | destroy_ref_prop_out: |
| 269 | 0 | free(ref_prop); |
| 270 | 0 | destroy_ref_prop_string_out: |
| 271 | 0 | free(ref_prop_string); |
| 272 | 0 | destroy_resource_out: |
| 273 | 0 | globus_resource_destroy(resource); |
| 274 | 0 | out: |
| 275 | 0 | return result; |