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_soap_message.h"
18 #include "globus_wsrf_resource.h"
19 #include "globus_service_engine.h"
20 #include "globus_operation_provider.h"
21 #include "globus_service_registry.h"
22 #include "globus_wsrf_core_tools.h"
23 #include "globus_soap_message_attrs.h"
24 #include "globus_notification_producer.h"
25 #include "globus_ws_addressing.h"
26
27 #include "wsnt_PauseSubscriptionType.h"
28 #include "wsnt_PauseSubscriptionResponseType.h"
29
30 #include "wsnt_ResumeSubscriptionType.h"
31 #include "wsnt_ResumeSubscriptionResponseType.h"
32
33 #include "wsr_ResourceUnknownFault.h"
34
35 #include "version.h"
36
37
38 /**
39 * @page wsnt_PausableSubscriptionManager_provider SubscriptionManager Provider
40 *
41 * <h2>Provider Usage Overview</h2>
42 * This operation provider implements the SubscriptionManager portType
43 * defined in http://docs.oasis-open.org/wsn/bw-2
44 .
45 * This portType consists of the @a PauseSubscription and @a ResumeSubscription operations.
46 * and related faults.
47 */
48
49 static
50 globus_result_t
51 wsnt_PauseSubscription_provider(
52 globus_service_engine_t engine,
53 globus_soap_message_handle_t handle,
54 globus_service_descriptor_t * service,
55 wsnt_PauseSubscriptionType * PauseSubscription,
56 wsnt_PauseSubscriptionResponseType *PauseSubscriptionResponse,
57 xsd_any * fault);
58
59 static
60 globus_result_t
61 wsnt_ResumeSubscription_provider(
62 globus_service_engine_t engine,
63 globus_soap_message_handle_t handle,
64 globus_service_descriptor_t * service,
65 wsnt_ResumeSubscriptionType * ResumeSubscription,
66 wsnt_ResumeSubscriptionResponseType * ResumeSubscriptionResponse,
67 xsd_any * fault);
68
69 static
70 int
71 wsnt_PausableSubscriptionManager_activate(void);
72
73 static
74 int
75 wsnt_PausableSubscriptionManager_deactivate(void);
76
77 /* Local Variables */
78 static xsd_QName wsnt_PauseSubscription_provider_qname =
79 {
80 "http://docs.oasis-open.org/wsn/bw-2/providers",
81 "PauseSubscription"
82 };
83
84 static xsd_QName wsnt_ResumeSubscription_provider_qname =
85 {
86 "http://docs.oasis-open.org/wsn/bw-2/providers",
87 "ResumeSubscription"
88 };
89
90 static
91 globus_operation_provider_descriptor_t
92 wsnt_PauseSubscription_descriptor =
93 {
94 &wsnt_PauseSubscription_provider_qname,
95 "PauseSubscription",
96 (void *)wsnt_PauseSubscription_provider,
97 NULL
98 };
99
100 static
101 globus_operation_provider_descriptor_t
102 wsnt_ResumeSubscription_descriptor =
103 {
104 &wsnt_ResumeSubscription_provider_qname,
105 "ResumeSubscription",
106 (void *)wsnt_ResumeSubscription_provider,
107 NULL
108 };
109
110 GlobusExtensionDefineModule(globus_wsnt_PausableSubscriptionManager_provider) =
111 {
112 "globus_wsnt_PausableSubscriptionManager_provider",
113 wsnt_PausableSubscriptionManager_activate,
114 wsnt_PausableSubscriptionManager_deactivate,
115 NULL,
116 NULL,
117 &local_version
118 };
119
120 /* Implementation */
121
122 static
123 globus_result_t
124 wsnt_PauseSubscription_provider(
125 globus_service_engine_t engine,
126 globus_soap_message_handle_t handle,
127 globus_service_descriptor_t * service,
128 wsnt_PauseSubscriptionType * PauseSubscription,
129 wsnt_PauseSubscriptionResponseType *PauseSubscriptionResponse,
130 xsd_any * fault)
131 0 {
132 globus_result_t result;
133 wsa_EndpointReferenceType * epr;
134
135 0 epr = globus_soap_message_handle_get_attr(
136 handle,
137 WSADDR_EPR_KEY);
138
139 0 if (epr == NULL)
140 {
141 0 result = globus_wsrf_core_create_fault(fault, &wsr_ResourceUnknownFault_qname);
142 0 goto out;
143 }
144
145 0 result = globus_notification_subscription_pause(epr);
146 0 if (result != GLOBUS_SUCCESS)
147 {
148 0 result = globus_wsrf_core_create_fault(fault, &wsr_ResourceUnknownFault_qname);
149 }
150
151 0 out:
152 0 return result;
153 }
154 /* wsnt_PauseSubscription_provider() */
155
156 static
157 globus_result_t
158 wsnt_ResumeSubscription_provider(
159 globus_service_engine_t engine,
160 globus_soap_message_handle_t handle,
161 globus_service_descriptor_t * service,
162 wsnt_ResumeSubscriptionType * ResumeSubscription,
163 wsnt_ResumeSubscriptionResponseType * ResumeSubscriptionResponse,
164 xsd_any * fault)
165 0 {
166 globus_result_t result;
167 wsa_EndpointReferenceType * epr;
168
169 0 epr = globus_soap_message_handle_get_attr(
170 handle,
171 WSADDR_EPR_KEY);
172
173 0 if (epr == NULL)
174 {
175 0 result = globus_wsrf_core_create_fault(fault, &wsr_ResourceUnknownFault_qname);
176 0 goto out;
177 }
178
179 0 result = globus_notification_subscription_resume(epr);
180 0 if (result != GLOBUS_SUCCESS)
181 {
182 0 result = globus_wsrf_core_create_fault(fault, &wsr_ResourceUnknownFault_qname);
183 }
184
185 0 out:
186 0 return result;
187 }
188 /* wsnt_ResumeSubscription_provider() */
189
190 static
191 int
192 wsnt_PausableSubscriptionManager_activate(void)
193 23 {
194 23 int res = 0;
195 GlobusFuncName(wsnt_PausableSubscriptionManager_activate);
196
197 23 res = globus_extension_registry_add(
198 GLOBUS_OPERATION_PROVIDER_REGISTRY,
199 &wsnt_PauseSubscription_provider_qname,
200 GlobusExtensionMyModule(globus_wsnt_PausableSubscriptionManager_provider),
201 &wsnt_PauseSubscription_descriptor);
202
203 23 if (res != GLOBUS_SUCCESS)
204 {
205 0 goto out;
206 }
207
208 23 res = globus_extension_registry_add(
209 GLOBUS_OPERATION_PROVIDER_REGISTRY,
210 &wsnt_ResumeSubscription_provider_qname,
211 GlobusExtensionMyModule(globus_wsnt_PausableSubscriptionManager_provider),
212 &wsnt_ResumeSubscription_descriptor);
213
214 23 if (res != GLOBUS_SUCCESS)
215 {
216 0 res = globus_extension_registry_remove(
217 GLOBUS_OPERATION_PROVIDER_REGISTRY,
218 &wsnt_PauseSubscription_provider_qname);
219 }
220
221 23 out:
222 23 return res;
223 }
224 /* wsnt_PausableSubscriptionManager_activate() */
225
226 static
227 int
228 wsnt_PausableSubscriptionManager_deactivate(void)
229 0 {
230 GlobusFuncName(wsnt_PausableSubscriptionManager_deactivate);
231
232 0 globus_extension_registry_remove(
233 GLOBUS_OPERATION_PROVIDER_REGISTRY,
234 &wsnt_ResumeSubscription_provider_qname);
235
236 0 globus_extension_registry_remove(
237 GLOBUS_OPERATION_PROVIDER_REGISTRY,
238 &wsnt_PauseSubscription_provider_qname);
239
240 0 return 0;
241 }