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
19 #include "wssg_EntryType.h"
20 #include "wssg_Entry.h"
21
22 #include "wssg_ServiceGroupEPR.h"
23 #include "wssg_MemberEPR.h"
24 #include "wssg_Content.h"
25
26 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
27 /**
28  * Look up the EPR in the hash of groups and return it, locked.
29  * 
30  * @param service_group_epr
31  *     EPR of the service implementing the ServiceGroup portType.
32  * @param sg
33  *     Pointer to be set to the state associated with the service group. This
34  *     will be set to NULL if no service with the named EPR is known of,
35  *     otherwise, it will be set to the state, and the state will be locked.
36  */
37 globus_result_t
38 globus_i_service_group_lookup(
39     const wsa_EndpointReferenceType *   service_group_epr,
40     globus_wsrf_service_group_t *       sg)
41 50 {
42 50     globus_result_t                     result;
43 50     char *                              group_resource_id;
44 50     GlobusFuncName(globus_i_service_group_lookup);
45
46 50     GlobusServiceGroupDebugEnter();
47
48 50     *sg = NULL;
49
50 50     result = globus_wsrf_core_get_resource_id_from_epr(
51                 service_group_epr,
52                 &group_resource_id);
53 50     if (result != GLOBUS_SUCCESS)
54     {
55 0         result = GLOBUS_SERVICE_GROUP_OUT_OF_MEMORY();
56
57 0         goto out;
58     }
59
60 50     GlobusServiceGroupGlobalLock();
61 50     *sg = globus_hashtable_lookup(
62                 &globus_i_service_groups,
63                 group_resource_id);
64 50     if (*sg == NULL)
65     {
66 2         result = GLOBUS_SERVICE_GROUP_UNKNOWN();
67 2         GlobusServiceGroupGlobalUnlock();
68
69 2         goto free_group_resource_id_out;
70     }
71 48     GlobusServiceGroupLock(*sg);
72
73 48     GlobusServiceGroupGlobalUnlock();
74
75 free_group_resource_id_out:
76 50     free(group_resource_id);
77
78 out:
79 50     GlobusServiceGroupDebugExit();
80
81 50     return result;
82 }
83 /* globus_i_service_group_lookup() */