| 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_i_wsrf_service_group.h" | |
| 18 | #include "globus_wsrf_resource.h" | |
| 19 | #include "wssg_Content.h" | |
| 20 | ||
| 21 | /** | |
| 22 | * Modify the wssg:Content associated with an entry. | |
| 23 | * @ingroup wssg | |
| 24 | * Changes the content value of a service group entry. This will fail if | |
| 25 | * the content does not match the membership content rule of the containing | |
| 26 | * service group. | |
| 27 | * | |
| 28 | * @param entry_epr | |
| 29 | * EPR of the service group entry resource to modify. | |
| 30 | * @param content | |
| 31 | * New value of the entry's wssg:Content property. This will be copied | |
| 32 | * to the entry's resource properties. | |
| 33 | * | |
| 34 | * @retval GLOBUS_SUCCESS | |
| 35 | * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_NULL_PARAMETER | |
| 36 | * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_UNKNOWN | |
| 37 | * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_INVALID_CONTENT | |
| 38 | * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_OUT_OF_MEMORY | |
| 39 | */ | |
| 40 | globus_result_t | |
| 41 | globus_service_group_update_content( | |
| 42 | const wsa_EndpointReferenceType * entry_epr, | |
| 43 | const wssg_ContentType * content) | |
| 44 | 6 | { |
| 45 | globus_result_t result; | |
| 46 | globus_resource_t resource; | |
| 47 | 6 | wssg_ContentType * tmp_content = NULL; |
| 48 | GlobusFuncName(globus_service_group_update_content); | |
| 49 | ||
| 50 | 6 | GlobusServiceGroupDebugEnter(); |
| 51 | 6 | if (entry_epr == NULL || content == NULL) |
| 52 | { | |
| 53 | 4 | result = GLOBUS_SERVICE_GROUP_NULL_PARAMETER(); |
| 54 | ||
| 55 | 4 | goto out; |
| 56 | } | |
| 57 | ||
| 58 | 2 | result = wssg_ContentType_copy(&tmp_content, content); |
| 59 | ||
| 60 | 2 | if (result != GLOBUS_SUCCESS) |
| 61 | { | |
| 62 | 0 | result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY(); |
| 63 | ||
| 64 | 0 | goto out; |
| 65 | } | |
| 66 | ||
| 67 | 2 | result = globus_wsrf_core_get_resource_from_epr( |
| 68 | entry_epr, | |
| 69 | &resource); | |
| 70 | ||
| 71 | 2 | if (result != GLOBUS_SUCCESS) |
| 72 | { | |
| 73 | 0 | result = GLOBUS_SERVICE_GROUP_UNKNOWN(); |
| 74 | ||
| 75 | 0 | goto out; |
| 76 | } | |
| 77 | ||
| 78 | 2 | result = globus_resource_set_property( |
| 79 | resource, | |
| 80 | &wssg_Content_qname, | |
| 81 | tmp_content); | |
| 82 | ||
| 83 | 2 | if (result != GLOBUS_SUCCESS) |
| 84 | { | |
| 85 | 0 | int error_type = globus_error_get_type(globus_error_peek(result)); |
| 86 | ||
| 87 | 0 | if (error_type == GLOBUS_WSRF_RESOURCE_ERROR_TYPE_UNKNOWN_PROPERTY) |
| 88 | { | |
| 89 | 0 | result = GLOBUS_SERVICE_GROUP_UNKNOWN(); |
| 90 | } | |
| 91 | else | |
| 92 | { | |
| 93 | 0 | result = GLOBUS_SERVICE_GROUP_INVALID_CONTENT(); |
| 94 | } | |
| 95 | ||
| 96 | 0 | goto finish_out; |
| 97 | } | |
| 98 | ||
| 99 | 2 | finish_out: |
| 100 | 2 | globus_resource_finish(resource); |
| 101 | 6 | out: |
| 102 | 6 | GlobusServiceGroupDebugExit(); |
| 103 | 6 | return result; |
| 104 | } |