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 "wssg_Content.h"
19
20 /**
21 * Get the current state (as in the Entry resource property) of a service group
22 * entry
23 * @ingroup wssg
24 *
25 * @param entry_epr
26 * EPR referencing the entry to query.
27 * @param entry
28 * A pointer to an entry which will be initialized to contain the
29 * current value of the Entry resource property associated with the
30 * service named by @a entry_epr
31 *
32 * @retval GLOBUS_SUCCESS
33 * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_NULL_PARAMETER
34 * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_OUT_OF_MEMORY
35 * @retval #GLOBUS_SERVICE_GROUP_ERROR_TYPE_UNKNOWN
36 */
37 globus_result_t
38 globus_service_group_get_entry(
39 const wsa_EndpointReferenceType * entry_epr,
40 wssg_EntryType * entry)
41 15 {
42 globus_result_t result;
43 15 wssg_ContentType * tmp_content = NULL;
44 globus_resource_t resource;
45 GlobusFuncName(globus_service_group_get_entry);
46
47 15 GlobusServiceGroupDebugEnter();
48 15 if (entry_epr == NULL || entry == NULL)
49 {
50 6 result = GLOBUS_SERVICE_GROUP_NULL_PARAMETER();
51
52 6 goto out;
53 }
54
55 9 result = wssg_EntryType_init_contents(entry);
56 9 if (result != GLOBUS_SUCCESS)
57 {
58 0 result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY();
59
60 0 goto out;
61 }
62
63 9 result = wsa_EndpointReferenceType_copy(
64 &entry->ServiceGroupEntryEPR,
65 entry_epr);
66
67 9 if (result != GLOBUS_SUCCESS)
68 {
69 0 result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY();
70
71 0 goto destroy_entry_out;
72 }
73
74 9 result = globus_wsrf_core_get_resource_from_epr(
75 entry_epr,
76 &resource);
77
78 9 if (result != GLOBUS_SUCCESS &&
79 globus_error_match(
80 globus_error_peek(result),
81 GLOBUS_WSRF_RESOURCE_MODULE,
82 GLOBUS_WSRF_RESOURCE_ERROR_TYPE_UNKNOWN_RESOURCE))
83 {
84 /* This entry was destroyed */
85 0 result = GLOBUS_SERVICE_GROUP_UNKNOWN();
86
87 0 goto destroy_entry_out;
88 }
89 9 else if (result != GLOBUS_SUCCESS)
90 {
91 0 result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY();
92
93 0 goto destroy_entry_out;
94 }
95
96 9 result = globus_resource_get_property(
97 resource,
98 &wssg_Content_qname,
99 (void **) &tmp_content,
100 NULL);
101
102 9 if (result != GLOBUS_SUCCESS)
103 {
104 0 result = GLOBUS_SERVICE_GROUP_UNKNOWN();
105
106 0 goto finish_resource_out;
107 }
108 9 result = wssg_ContentType_copy(
109 &entry->Content,
110 tmp_content);
111 9 if (result != GLOBUS_SUCCESS)
112 {
113 0 result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY();
114
115 0 goto finish_resource_out;
116 }
117
118 9 finish_resource_out:
119 9 globus_resource_finish(resource);
120 9 destroy_entry_out:
121 9 if (result != GLOBUS_SUCCESS)
122 {
123 0 wssg_EntryType_destroy_contents(entry);
124 }
125 15 out:
126 15 GlobusServiceGroupDebugExit();
127 15 return result;
128 }