1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 | package gov.hhs.fha.nhinc.hiemsubscription;
|
---|
6 |
|
---|
7 | import gov.hhs.fha.nhinc.nhinclib.NullChecker;
|
---|
8 | import gov.hhs.fha.nhinc.nhincsubscription.NhincNotificationProducerService;
|
---|
9 | import gov.hhs.fha.nhinc.nhincsubscription.NotificationProducer;
|
---|
10 | import gov.hhs.fha.nhinc.saml.extraction.SamlTokenExtractorHelper;
|
---|
11 | import gov.hhs.fha.nhinc.common.nhinccommoninternalorch.SubscribeRequestType;
|
---|
12 | import gov.hhs.fha.nhinc.saml.extraction.SamlTokenExtractor;
|
---|
13 | import javax.xml.ws.WebServiceContext;
|
---|
14 | import org.apache.commons.logging.Log;
|
---|
15 | import org.apache.commons.logging.LogFactory;
|
---|
16 | import org.oasis_open.docs.wsn.b_2.Subscribe;
|
---|
17 | import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | *
|
---|
21 | * @author jhoppesc
|
---|
22 | */
|
---|
23 | public class HiemSubscriptionImpl {
|
---|
24 |
|
---|
25 | private static Log log = LogFactory.getLog(HiemSubscriptionImpl.class);
|
---|
26 |
|
---|
27 | public static SubscribeResponse subscribe(Subscribe subscribeRequest, WebServiceContext context) {
|
---|
28 | log.debug("Entering HiemSubscriptionImpl.subscribe");
|
---|
29 |
|
---|
30 | SubscribeResponse resp = new SubscribeResponse();
|
---|
31 | SubscribeRequestType request = new SubscribeRequestType();
|
---|
32 |
|
---|
33 | request.setSubscribe(subscribeRequest);
|
---|
34 | request.setAssertion(SamlTokenExtractor.GetAssertion(context));
|
---|
35 |
|
---|
36 |
|
---|
37 | String homeCommunityId = SamlTokenExtractorHelper.getHomeCommunityId();
|
---|
38 |
|
---|
39 | if (NullChecker.isNotNullish(homeCommunityId)) {
|
---|
40 | NhincNotificationProducerService service = new NhincNotificationProducerService();
|
---|
41 | NotificationProducer port = service.getNotificationProducerPort();
|
---|
42 | ((javax.xml.ws.BindingProvider) port).getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SamlTokenExtractorHelper.getEndpointURL(homeCommunityId, SamlTokenExtractorHelper.INTERNAL_HIEM_SUBSCRIBE));
|
---|
43 |
|
---|
44 | try {
|
---|
45 | resp = port.subscribe(request);
|
---|
46 | } catch (Exception e) {
|
---|
47 | log.error("Received Fault: " + e.getMessage());
|
---|
48 | resp = null;
|
---|
49 | }
|
---|
50 | }
|
---|
51 | else {
|
---|
52 | resp = null;
|
---|
53 | }
|
---|
54 |
|
---|
55 | log.debug("Exiting HiemSubscriptionImpl.subscribe");
|
---|
56 | return resp;
|
---|
57 | }
|
---|
58 | }
|
---|