| 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 "WidgetService_skeleton.h" | |
| 18 | #include "WidgetService_internal_skeleton.h" | |
| 19 | ||
| 20 | #include "globus_wsrf_resource.h" | |
| 21 | #include "globus_soap_message_handle.h" | |
| 22 | #include "globus_libc.h" | |
| 23 | #include "globus_uuid.h" | |
| 24 | #include "globus_wsrf_core_tools.h" | |
| 25 | #include "widget_Foo.h" | |
| 26 | ||
| 27 | globus_result_t | |
| 28 | WidgetService_init( | |
| 29 | globus_service_descriptor_t * service_desc) | |
| 30 | 12 | { |
| 31 | int rc; | |
| 32 | GlobusFuncName(WidgetService_init); | |
| 33 | ||
| 34 | 12 | WidgetServiceDebugEnter(); |
| 35 | ||
| 36 | 12 | rc = globus_module_activate(GLOBUS_WSRF_RESOURCE_MODULE); |
| 37 | ||
| 38 | 12 | WidgetServiceDebugExit(); |
| 39 | ||
| 40 | 12 | return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE; |
| 41 | } | |
| 42 | /* WidgetService_init() */ | |
| 43 | ||
| 44 | globus_result_t | |
| 45 | WidgetService_finalize( | |
| 46 | globus_service_descriptor_t * service_desc) | |
| 47 | 0 | { |
| 48 | int rc; | |
| 49 | GlobusFuncName(WidgetService_finalize); | |
| 50 | ||
| 51 | 0 | WidgetServiceDebugEnter(); |
| 52 | ||
| 53 | /* do any service specific finalize stuff here, | |
| 54 | * opposite of WidgetService_init | |
| 55 | */ | |
| 56 | 0 | rc = globus_module_deactivate(GLOBUS_WSRF_RESOURCE_MODULE); |
| 57 | ||
| 58 | 0 | WidgetServiceDebugExit(); |
| 59 | ||
| 60 | 0 | return (rc == GLOBUS_SUCCESS) ? GLOBUS_SUCCESS : GLOBUS_FAILURE; |
| 61 | } | |
| 62 | /* WidgetService_finalize() */ | |
| 63 | ||
| 64 | globus_result_t | |
| 65 | WidgetPortType_GetResourceProperty_impl( | |
| 66 | globus_service_engine_t engine, | |
| 67 | globus_soap_message_handle_t message, | |
| 68 | globus_service_descriptor_t * descriptor, | |
| 69 | xsd_QName * GetResourceProperty, | |
| 70 | wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse, | |
| 71 | xsd_any * fault) | |
| 72 | 0 | { |
| 73 | 0 | return GLOBUS_FAILURE; |
| 74 | } | |
| 75 | /* WidgetPortType_GetResourceProperty_impl() */ | |
| 76 | ||
| 77 | globus_result_t | |
| 78 | WidgetPortType_GetMultipleResourceProperties_impl( | |
| 79 | globus_service_engine_t engine, | |
| 80 | globus_soap_message_handle_t message, | |
| 81 | globus_service_descriptor_t * descriptor, | |
| 82 | wsrp_GetMultipleResourcePropertiesType * GetMultipleResourceProperties, | |
| 83 | wsrp_GetMultipleResourcePropertiesResponseType * GetMultipleResourcePropertiesResponse, | |
| 84 | xsd_any * fault) | |
| 85 | 0 | { |
| 86 | 0 | return GLOBUS_FAILURE; |
| 87 | } | |
| 88 | /* WidgetPortType_GetMultipleResourceProperties_impl() */ | |
| 89 | ||
| 90 | globus_result_t | |
| 91 | WidgetPortType_SetResourceProperties_impl( | |
| 92 | globus_service_engine_t engine, | |
| 93 | globus_soap_message_handle_t message, | |
| 94 | globus_service_descriptor_t * descriptor, | |
| 95 | wsrp_SetResourcePropertiesType * SetResourceProperties, | |
| 96 | wsrp_SetResourcePropertiesResponseType * SetResourcePropertiesResponse, | |
| 97 | xsd_any * fault) | |
| 98 | 0 | { |
| 99 | 0 | return GLOBUS_FAILURE; |
| 100 | } | |
| 101 | /* WidgetPortType_SetResourceProperties_impl() */ | |
| 102 | ||
| 103 | globus_result_t | |
| 104 | WidgetPortType_QueryResourceProperties_impl( | |
| 105 | globus_service_engine_t engine, | |
| 106 | globus_soap_message_handle_t message, | |
| 107 | globus_service_descriptor_t * descriptor, | |
| 108 | wsrp_QueryResourcePropertiesType * QueryResourceProperties, | |
| 109 | wsrp_QueryResourcePropertiesResponseType * QueryResourcePropertiesResponse, | |
| 110 | xsd_any * fault) | |
| 111 | 0 | { |
| 112 | 0 | return GLOBUS_FAILURE; |
| 113 | } | |
| 114 | /* WidgetPortType_QueryResourceProperties_impl() */ | |
| 115 | ||
| 116 | globus_result_t | |
| 117 | WidgetPortType_Destroy_impl( | |
| 118 | globus_service_engine_t engine, | |
| 119 | globus_soap_message_handle_t message, | |
| 120 | globus_service_descriptor_t * descriptor, | |
| 121 | wsrl_DestroyType * Destroy, | |
| 122 | wsrl_DestroyResponseType * DestroyResponse, | |
| 123 | xsd_any * fault) | |
| 124 | 0 | { |
| 125 | 0 | return GLOBUS_FAILURE; |
| 126 | } | |
| 127 | /* WidgetPortType_Destroy_impl() */ | |
| 128 | ||
| 129 | globus_result_t | |
| 130 | WidgetPortType_SetTerminationTime_impl( | |
| 131 | globus_service_engine_t engine, | |
| 132 | globus_soap_message_handle_t message, | |
| 133 | globus_service_descriptor_t * descriptor, | |
| 134 | wsrl_SetTerminationTimeType * SetTerminationTime, | |
| 135 | wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse, | |
| 136 | xsd_any * fault) | |
| 137 | 0 | { |
| 138 | 0 | return GLOBUS_FAILURE; |
| 139 | } | |
| 140 | /* WidgetPortType_SetTerminationTime_impl() */ | |
| 141 | ||
| 142 | globus_result_t | |
| 143 | WidgetPortType_createWidget_impl( | |
| 144 | globus_service_engine_t engine, | |
| 145 | globus_soap_message_handle_t message, | |
| 146 | globus_service_descriptor_t * descriptor, | |
| 147 | widget_createWidgetType * createWidget, | |
| 148 | widget_createWidgetResponseType * createWidgetResponse, | |
| 149 | xsd_any * fault) | |
| 150 | 72 | { |
| 151 | globus_result_t result; | |
| 152 | globus_uuid_t uuid; | |
| 153 | xsd_any * reference_property; | |
| 154 | xsd_string_array * foo_value; | |
| 155 | globus_resource_t resource; | |
| 156 | int rc; | |
| 157 | ||
| 158 | 72 | rc = globus_uuid_create(&uuid); |
| 159 | 72 | if (rc != GLOBUS_SUCCESS) |
| 160 | { | |
| 161 | 0 | goto out; |
| 162 | } | |
| 163 | ||
| 164 | 72 | result = globus_resource_create(uuid.text, &resource); |
| 165 | 72 | if (result != GLOBUS_SUCCESS) |
| 166 | { | |
| 167 | 0 | goto out; |
| 168 | } | |
| 169 | 72 | xsd_string_array_init(&foo_value); |
| 170 | ||
| 171 | 72 | result = globus_resource_create_property( |
| 172 | resource, | |
| 173 | &widget_Foo_qname, | |
| 174 | &xsd_string_array_info, | |
| 175 | foo_value); | |
| 176 | 72 | if (result != GLOBUS_SUCCESS) |
| 177 | { | |
| 178 | 0 | goto destroy_out; |
| 179 | } | |
| 180 | ||
| 181 | 72 | xsd_any_init(&reference_property); |
| 182 | 72 | if (reference_property == NULL) |
| 183 | { | |
| 184 | 0 | result = GLOBUS_FAILURE; |
| 185 | 0 | goto destroy_out; |
| 186 | } | |
| 187 | ||
| 188 | 72 | reference_property->any_info = &xsd_string_info; |
| 189 | 72 | xsd_QName_init(&reference_property->element); |
| 190 | 72 | if (reference_property->element == NULL) |
| 191 | { | |
| 192 | 0 | result = GLOBUS_FAILURE; |
| 193 | 0 | goto destroy_ref_property; |
| 194 | } | |
| 195 | 72 | reference_property->element->Namespace = globus_libc_strdup(widget_Foo_qname.Namespace); |
| 196 | 72 | if (reference_property->element->Namespace == NULL) |
| 197 | { | |
| 198 | 0 | result = GLOBUS_FAILURE; |
| 199 | 0 | goto destroy_ref_element; |
| 200 | } | |
| 201 | 72 | reference_property->element->local = globus_libc_strdup("ResourceID"); |
| 202 | 72 | if (reference_property->element->local == NULL) |
| 203 | { | |
| 204 | 0 | result = GLOBUS_FAILURE; |
| 205 | 0 | goto destroy_ref_element_Namespace; |
| 206 | } | |
| 207 | 72 | xsd_string_init((xsd_string **) &reference_property->value); |
| 208 | 72 | (*(xsd_string*)reference_property->value) = globus_libc_strdup(uuid.text); |
| 209 | 72 | if (reference_property->value == NULL) |
| 210 | { | |
| 211 | 0 | result = GLOBUS_FAILURE; |
| 212 | 0 | goto destroy_ref_element_local; |
| 213 | } | |
| 214 | 72 | result = globus_wsrf_core_create_endpoint_reference( |
| 215 | engine, | |
| 216 | WIDGETSERVICE_BASE_PATH, | |
| 217 | &reference_property, | |
| 218 | &createWidgetResponse->EndpointReference); | |
| 219 | 72 | if (result != GLOBUS_SUCCESS) |
| 220 | { | |
| 221 | 0 | result = GLOBUS_FAILURE; |
| 222 | 0 | goto destroy_ref_value; |
| 223 | } | |
| 224 | 72 | result = WidgetServiceInitResource( |
| 225 | &createWidgetResponse->EndpointReference); | |
| 226 | 72 | if (result != GLOBUS_SUCCESS) |
| 227 | { | |
| 228 | 0 | goto destroy_response; |
| 229 | } | |
| 230 | 72 | result = globus_resource_finish(resource); |
| 231 | 72 | if (result != GLOBUS_SUCCESS) |
| 232 | { | |
| 233 | 0 | goto destroy_response; |
| 234 | } | |
| 235 | ||
| 236 | 72 | return GLOBUS_SUCCESS; |
| 237 | ||
| 238 | 0 | destroy_response: |
| 239 | 0 | wsa_EndpointReferenceType_destroy_contents( |
| 240 | &createWidgetResponse->EndpointReference); | |
| 241 | 0 | destroy_ref_value: |
| 242 | 0 | if (reference_property->value != NULL) |
| 243 | { | |
| 244 | 0 | free(reference_property->value); |
| 245 | } | |
| 246 | 0 | reference_property->value = NULL; |
| 247 | 0 | destroy_ref_element_local: |
| 248 | 0 | free(reference_property->element->local); |
| 249 | 0 | reference_property->element->local = NULL; |
| 250 | 0 | destroy_ref_element_Namespace: |
| 251 | 0 | free(reference_property->element->Namespace); |
| 252 | 0 | reference_property->element->Namespace = NULL; |
| 253 | 0 | destroy_ref_element: |
| 254 | 0 | xsd_QName_destroy(reference_property->element); |
| 255 | 0 | destroy_ref_property: |
| 256 | 0 | xsd_any_destroy(reference_property); |
| 257 | 0 | destroy_out: |
| 258 | 0 | globus_resource_destroy(resource); |
| 259 | 0 | out: |
| 260 | 0 | return result; |
| 261 | } |