| 1 | /* | |
| 2 | * Portions of this file Copyright 1999-2005 University of Chicago | |
| 3 | * Portions of this file Copyright 1999-2005 The University of Southern California. | |
| 4 | * | |
| 5 | * This file or a portion of this file is licensed under the | |
| 6 | * terms of the Globus Toolkit Public License, found at | |
| 7 | * http://www.globus.org/toolkit/download/license.html. | |
| 8 | * If you redistribute this file, with or without | |
| 9 | * modifications, you must include this notice in the file. | |
| 10 | */ | |
| 11 | ||
| 12 | #include "globus_soap_message.h" | |
| 13 | #include "globus_wsrf_resource.h" | |
| 14 | #include "globus_service_engine.h" | |
| 15 | #include "globus_operation_provider.h" | |
| 16 | #include "globus_service_registry.h" | |
| 17 | #include "globus_wsrf_core_tools.h" | |
| 18 | #include "version.h" | |
| 19 | ||
| 20 | #include "wsrp_GetMultipleResourcePropertiesType.h" | |
| 21 | #include "wsrp_GetMultipleResourcePropertiesResponseType.h" | |
| 22 | ||
| 23 | #define WSRP_GET_MULTIPLE_RESOURCE_PROPERTIES 1 | |
| 24 | #include "wsrp_i_faults.h" | |
| 25 | ||
| 26 | GlobusExtensionDeclareModule(globus_ws_resource_properties); | |
| 27 | ||
| 28 | /** | |
| 29 | * @page wsrp_GetMultipleResourceProperties_provider GetMultipleResourceProperties Provider | |
| 30 | * | |
| 31 | * <h2>Provider Usage Overview</h2> | |
| 32 | * This operation provider implements the GetMultipleResourceProperties | |
| 33 | portType defined in | |
| 34 | * http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl . | |
| 35 | * This portType consists of the @a GetMultipleResourceProperties operation and | |
| 36 | * related faults. | |
| 37 | * | |
| 38 | * The WSRF service engine will automatically register this provider to handle | |
| 39 | * the GetMultipleResourceProperties operation for services which use the port | |
| 40 | * type. | |
| 41 | */ | |
| 42 | ||
| 43 | /* Prototypes */ | |
| 44 | static | |
| 45 | globus_result_t | |
| 46 | wsrp_GetMultipleResourceProperties_init_provider( | |
| 47 | globus_service_engine_t engine, | |
| 48 | globus_soap_message_handle_t handle, | |
| 49 | wsrp_GetMultipleResourcePropertiesType * | |
| 50 | input); | |
| 51 | ||
| 52 | static | |
| 53 | globus_result_t | |
| 54 | wsrp_GetMultipleResourceProperties_provider( | |
| 55 | globus_service_engine_t engine, | |
| 56 | globus_soap_message_handle_t handle, | |
| 57 | globus_service_descriptor_t * service, | |
| 58 | wsrp_GetMultipleResourcePropertiesType * | |
| 59 | input, | |
| 60 | wsrp_GetMultipleResourcePropertiesResponseType * | |
| 61 | output, | |
| 62 | char ** fault_name, | |
| 63 | void ** fault); | |
| 64 | ||
| 65 | static | |
| 66 | int | |
| 67 | wsrp_GetMultipleResourceProperties_activate(void); | |
| 68 | ||
| 69 | static | |
| 70 | int | |
| 71 | wsrp_GetMultipleResourceProperties_deactivate(void); | |
| 72 | ||
| 73 | /* Local Variables */ | |
| 74 | static xsd_QName wsrp_GetMultipleResourceProperties_qname = | |
| 75 | { | |
| 76 | "http://www.globus.org/docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl", | |
| 77 | "GetMultipleResourceProperties" | |
| 78 | }; | |
| 79 | ||
| 80 | static | |
| 81 | globus_operation_provider_descriptor_t | |
| 82 | wsrp_GetMultipleResourceProperties_descriptor = | |
| 83 | { | |
| 84 | &wsrp_GetMultipleResourceProperties_qname, | |
| 85 | "GetMultipleResourceProperties", | |
| 86 | (void *)wsrp_GetMultipleResourceProperties_init_provider, | |
| 87 | (void *)wsrp_GetMultipleResourceProperties_provider | |
| 88 | }; | |
| 89 | ||
| 90 | GlobusExtensionDefineModule(globus_ws_resource_properties) = | |
| 91 | { | |
| 92 | "wsrp_GetMultipleResourceProperties", | |
| 93 | wsrp_GetMultipleResourceProperties_activate, | |
| 94 | wsrp_GetMultipleResourceProperties_deactivate, | |
| 95 | NULL, | |
| 96 | NULL, | |
| 97 | &local_version | |
| 98 | }; | |
| 99 | ||
| 100 | /* Implementation */ | |
| 101 | static | |
| 102 | globus_result_t | |
| 103 | wsrp_GetMultipleResourceProperties_init_provider( | |
| 104 | globus_service_engine_t engine, | |
| 105 | globus_soap_message_handle_t handle, | |
| 106 | wsrp_GetMultipleResourcePropertiesType * | |
| 107 | input) | |
| 108 | 1785 | { |
| 109 | 1785 | return GLOBUS_SUCCESS; |
| 110 | } | |
| 111 | /* wsrp_GetMultipleResourceProperties_init_provider() */ | |
| 112 | ||
| 113 | static | |
| 114 | globus_result_t | |
| 115 | wsrp_GetMultipleResourceProperties_provider( | |
| 116 | globus_service_engine_t engine, | |
| 117 | globus_soap_message_handle_t handle, | |
| 118 | globus_service_descriptor_t * service, | |
| 119 | wsrp_GetMultipleResourcePropertiesType * | |
| 120 | input, | |
| 121 | wsrp_GetMultipleResourcePropertiesResponseType * | |
| 122 | output, | |
| 123 | char ** fault_name, | |
| 124 | void ** fault) | |
| 125 | 1785 | { |
| 126 | globus_resource_t resource; | |
| 127 | void * property; | |
| 128 | xsd_any * value; | |
| 129 | globus_xsd_type_info_t info; | |
| 130 | globus_result_t result; | |
| 131 | int i, j; | |
| 132 | 1785 | xsd_any * prop_any = NULL; |
| 133 | ||
| 134 | 1785 | result = globus_wsrf_core_get_resource( |
| 135 | handle, | |
| 136 | service, | |
| 137 | &resource); | |
| 138 | ||
| 139 | 1785 | if (result != GLOBUS_SUCCESS || resource == NULL) |
| 140 | { | |
| 141 | 0 | result = wsrp_l_ResourceUnknownFaultType_create( |
| 142 | fault_name, | |
| 143 | (wsrp_ResourceUnknownFaultType **) fault); | |
| 144 | ||
| 145 | 0 | goto out; |
| 146 | } | |
| 147 | ||
| 148 | 495089 | for (i = 0; i < input->ResourceProperty.length; i++) |
| 149 | { | |
| 150 | globus_object_t * error; | |
| 151 | ||
| 152 | 493304 | result = globus_resource_get_property( |
| 153 | resource, | |
| 154 | &input->ResourceProperty.elements[i], | |
| 155 | &property, | |
| 156 | &info); | |
| 157 | ||
| 158 | 493304 | if (result != GLOBUS_SUCCESS) |
| 159 | { | |
| 160 | 0 | error = globus_error_get(result); |
| 161 | ||
| 162 | 0 | if (globus_error_match(error, |
| 163 | GLOBUS_WSRF_RESOURCE_MODULE, | |
| 164 | GLOBUS_WSRF_RESOURCE_ERROR_TYPE_UNKNOWN_PROPERTY)) | |
| 165 | { | |
| 166 | 0 | result = wsrp_l_InvalidResourcePropertyQNameFaultType_create( |
| 167 | fault_name, | |
| 168 | (wsrp_InvalidResourcePropertyQNameFaultType **) fault); | |
| 169 | } | |
| 170 | else | |
| 171 | { | |
| 172 | 0 | result = wsrp_l_ResourceUnknownFaultType_create( |
| 173 | fault_name, | |
| 174 | (wsrp_ResourceUnknownFaultType **) fault); | |
| 175 | ||
| 176 | } | |
| 177 | 0 | globus_object_free(error); |
| 178 | ||
| 179 | 0 | goto free_array_out; |
| 180 | } | |
| 181 | ||
| 182 | 493304 | if (info == &xsd_any_info) |
| 183 | { | |
| 184 | 10 | prop_any = property; |
| 185 | } | |
| 186 | ||
| 187 | 493304 | if ((prop_any != NULL && |
| 188 | prop_any->any_info != NULL && | |
| 189 | prop_any->value != NULL) || | |
| 190 | (prop_any == NULL && property != NULL)) | |
| 191 | { | |
| 192 | 493296 | value = xsd_any_array_push(&output->any); |
| 193 | 493296 | if (value == NULL) |
| 194 | { | |
| 195 | 0 | result = globus_error_put(GLOBUS_ERROR_NO_INFO); |
| 196 | ||
| 197 | 0 | goto free_array_out; |
| 198 | } | |
| 199 | 493296 | value->any_info = info; |
| 200 | 493296 | result = xsd_QName_copy(&value->element, |
| 201 | &input->ResourceProperty.elements[i]); | |
| 202 | 493296 | if (result != GLOBUS_SUCCESS) |
| 203 | { | |
| 204 | 493296 | goto free_array_out; |
| 205 | } | |
| 206 | ||
| 207 | 493296 | result = info->copy(&value->value, property); |
| 208 | 493296 | if (result != GLOBUS_SUCCESS) |
| 209 | { | |
| 210 | 493304 | goto free_array_out; |
| 211 | } | |
| 212 | } | |
| 213 | } | |
| 214 | 1785 | globus_resource_finish(resource); |
| 215 | ||
| 216 | 1785 | return GLOBUS_SUCCESS; |
| 217 | ||
| 218 | 0 | free_array_out: |
| 219 | 0 | for (j = i-1; j >=0; j--) |
| 220 | { | |
| 221 | 0 | info = output->any.elements[j].any_info; |
| 222 | 0 | info->destroy(output->any.elements[j].value); |
| 223 | } | |
| 224 | 0 | free(output->any.elements); |
| 225 | 0 | output->any.length = 0; |
| 226 | 0 | output->any.elements = NULL; |
| 227 | ||
| 228 | 0 | globus_resource_finish(resource); |
| 229 | 0 | out: |
| 230 | 0 | return result; |
| 231 | } | |
| 232 | /* wsrp_GetMultipleResourceProperties_provider() */ | |
| 233 | ||
| 234 | static | |
| 235 | int | |
| 236 | wsrp_GetMultipleResourceProperties_activate(void) | |
| 237 | 28 | { |
| 238 | 28 | int res = 0; |
| 239 | GlobusFuncName(wsrp_GetMultipleResourceProperties_activate); | |
| 240 | ||
| 241 | 28 | res = globus_extension_registry_add( |
| 242 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 243 | &wsrp_GetMultipleResourceProperties_qname, | |
| 244 | GlobusExtensionMyModule(globus_ws_resource_properties), | |
| 245 | &wsrp_GetMultipleResourceProperties_descriptor); | |
| 246 | ||
| 247 | ||
| 248 | 28 | return res; |
| 249 | } | |
| 250 | /* wsrp_GetMultipleResourceProperties_activate() */ | |
| 251 | ||
| 252 | static | |
| 253 | int | |
| 254 | wsrp_GetMultipleResourceProperties_deactivate(void) | |
| 255 | 0 | { |
| 256 | GlobusFuncName(wsrp_GetMultipleResourceProperties_deactivate); | |
| 257 | ||
| 258 | 0 | globus_extension_registry_remove( |
| 259 | GLOBUS_OPERATION_PROVIDER_REGISTRY, | |
| 260 | &wsrp_GetMultipleResourceProperties_qname); | |
| 261 | ||
| 262 | 0 | return 0; |
| 263 | } |