1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.payload;
15
16 import uk.nhs.interoperability.infrastructure.ITKIdentityImpl;
17 import uk.nhs.interoperability.infrastructure.ITKMessageProperties;
18 import uk.nhs.interoperability.infrastructure.ITKMessagePropertiesImpl;
19 import uk.nhs.interoperability.transport.ITKTransportProperties;
20 import uk.nhs.interoperability.transport.ITKTransportRoute;
21 import uk.nhs.interoperability.util.Logger;
22
23
24
25
26
27
28
29
30 public abstract class ITKMessageImpl implements ITKMessage {
31
32
33 protected ITKMessageProperties messageProperties;
34
35
36 protected String businessPayload;
37
38
39 protected boolean isResponse;
40
41
42 protected ITKTransportRoute preResolvedTransportRoute;
43
44
45
46
47 public String getBusinessPayload() {
48 return businessPayload;
49 }
50
51
52
53
54 public void setBusinessPayload(String businessPayload) {
55 this.businessPayload = businessPayload;
56 }
57
58
59
60
61 public ITKMessageImpl() {
62
63 }
64
65
66
67
68
69
70 public ITKMessageImpl(ITKMessageProperties itkMessageProperties) {
71 this(itkMessageProperties, null, null, false);
72 }
73
74
75
76
77
78
79
80
81
82 public ITKMessageImpl(ITKMessageProperties itkMessageProperties, String auditIdentity, String profileId, boolean reflectMessageProperties) {
83 if (reflectMessageProperties) {
84
85 ITKMessageProperties msgProperties = new ITKMessagePropertiesImpl();
86 msgProperties.setAuditIdentity(new ITKIdentityImpl(auditIdentity));
87
88 msgProperties.setFromAddress(itkMessageProperties.getToAddress());
89 msgProperties.setToAddress(itkMessageProperties.getFromAddress());
90 String responseServiceId = itkMessageProperties.getServiceId() + "Response";
91 msgProperties.setServiceId(responseServiceId);
92 msgProperties.setProfileId(profileId);
93
94 msgProperties.setInboundTransportProperties(itkMessageProperties.getInboundTransportProperties());
95
96 ITKTransportProperties itkTransportProperties = itkMessageProperties.getInboundTransportProperties();
97 if (itkTransportProperties != null) {
98 Logger.trace("Obtaining transport route from inbound transport properties");
99 this.preResolvedTransportRoute = itkMessageProperties.getInboundTransportProperties().getTransportReplyToRoute();
100 if (preResolvedTransportRoute != null) {
101
102
103
104
105 this.preResolvedTransportRoute.setWrapperType(ITKTransportRoute.DISTRIBUTION_ENVELOPE);
106 Logger.trace("Pre-resolved route: " + this.preResolvedTransportRoute);
107 }
108 }
109 this.messageProperties = msgProperties;
110 this.setIsReponse(true);
111 } else {
112 this.messageProperties = itkMessageProperties;
113 }
114 }
115
116
117
118
119 public ITKMessageProperties getMessageProperties() {
120 return messageProperties;
121 }
122
123
124
125
126 public void setMessageProperties(ITKMessageProperties messageProperties) {
127 this.messageProperties = messageProperties;
128 }
129
130
131
132
133 @Override
134 public ITKTransportRoute getPreresolvedRoute() {
135 return this.preResolvedTransportRoute;
136 }
137
138
139
140
141 @Override
142 public boolean isResponse() {
143 return this.isResponse;
144 }
145
146
147
148
149
150
151 public void setIsReponse(boolean isReponse) {
152 this.isResponse = isReponse;
153 }
154 }