99import ecf5 .TylerCourtSchedulingMDEService ;
1010import ecf5 .TylerFilingAssemblyMDEService ;
1111import ecf5 .TylerFilingReviewMDEService ;
12+ import edu .suffolk .litlab .efsp .ConfigurationLoader ;
1213import edu .suffolk .litlab .efsp .Jurisdiction ;
1314import edu .suffolk .litlab .efsp .tyler .TylerClients ;
1415import edu .suffolk .litlab .efsp .tyler .TylerDomain ;
1516import edu .suffolk .litlab .efsp .tyler .TylerVersion ;
1617import jakarta .xml .ws .BindingProvider ;
18+ import jakarta .xml .ws .WebServiceFeature ;
1719import java .net .URL ;
1820import java .util .Optional ;
1921import java .util .function .Consumer ;
2022import java .util .function .Function ;
23+ import org .apache .cxf .ext .logging .LoggingFeature ;
2124import org .slf4j .Logger ;
2225import org .slf4j .LoggerFactory ;
2326
@@ -34,15 +37,39 @@ public class SoapClientChooserV5 {
3437 private static final String TYLER_FILING_ASSEM_WSDL = "-ECF5-TylerFilingAssemblyMDEService.wsdl" ;
3538 private static final String TYLER_FILING_REVIEW_WSDL = "-ECF5-TylerFilingReviewMDEService.wsdl" ;
3639
40+ private static Optional <Boolean > shouldLogRequests = Optional .empty ();
41+
42+ public static boolean shouldLogRequests () {
43+ if (shouldLogRequests .isEmpty ()) {
44+ shouldLogRequests = Optional .of (ConfigurationLoader .shouldLogRequests ());
45+ }
46+ return shouldLogRequests .orElse (false );
47+ }
48+
49+ public static WebServiceFeature getLoggingFeature () {
50+ LoggingFeature loggingFeature = new LoggingFeature ();
51+ loggingFeature .setPrettyLogging (true );
52+ return loggingFeature ;
53+ }
54+
3755 public static Optional <Function <Consumer <BindingProvider >, CourtPolicyClient >>
3856 getCourtPolicyFactory (Jurisdiction jurisdiction ) {
3957 var version = TylerClients .getVersion (jurisdiction );
4058 var domain = new TylerDomain (jurisdiction , TylerClients .getTylerEnv ());
4159 return version .flatMap (
4260 v -> {
4361 var url = createLocalWsdlUrl (domain , v , COURT_POLICY_WSDL );
62+ boolean shouldLog = shouldLogRequests ();
4463 return url .map (
45- u -> (consume ) -> new CourtPolicyClient (new CourtPolicyMDEService (u ), v , consume ));
64+ u ->
65+ (consume ) -> {
66+ if (shouldLog ) {
67+ return new CourtPolicyClient (
68+ new CourtPolicyMDEService (u , getLoggingFeature ()), v , consume );
69+ } else {
70+ return new CourtPolicyClient (new CourtPolicyMDEService (u ), v , consume );
71+ }
72+ });
4673 });
4774 }
4875
@@ -53,8 +80,17 @@ public class SoapClientChooserV5 {
5380 return version .flatMap (
5481 v -> {
5582 var url = createLocalWsdlUrl (domain , v , COURT_RECORD_WSDL );
83+ boolean shouldLog = shouldLogRequests ();
5684 return url .map (
57- u -> (consume ) -> new CourtRecordClient (new CourtRecordMDEService (u ), v , consume ));
85+ u ->
86+ (consume ) -> {
87+ if (shouldLog ) {
88+ return new CourtRecordClient (
89+ new CourtRecordMDEService (u , getLoggingFeature ()), v , consume );
90+ } else {
91+ return new CourtRecordClient (new CourtRecordMDEService (u ), v , consume );
92+ }
93+ });
5894 });
5995 }
6096
@@ -65,10 +101,18 @@ public class SoapClientChooserV5 {
65101 return version .flatMap (
66102 v -> {
67103 var url = createLocalWsdlUrl (domain , v , COURT_SCHED_WSDL );
104+ boolean shouldLog = shouldLogRequests ();
68105 return url .map (
69106 u ->
70- (consume ) ->
71- new CourtSchedulingClient (new CourtSchedulingMDEService (u ), v , consume ));
107+ (consume ) -> {
108+ if (shouldLog ) {
109+ return new CourtSchedulingClient (
110+ new CourtSchedulingMDEService (u , getLoggingFeature ()), v , consume );
111+ } else {
112+ return new CourtSchedulingClient (
113+ new CourtSchedulingMDEService (u ), v , consume );
114+ }
115+ });
72116 });
73117 }
74118
@@ -79,8 +123,17 @@ public class SoapClientChooserV5 {
79123 return version .flatMap (
80124 v -> {
81125 var url = createLocalWsdlUrl (domain , v , FILING_REVIEW_WSDL );
126+ boolean shouldLog = shouldLogRequests ();
82127 return url .map (
83- u -> (consume ) -> new FilingReviewClient (new FilingReviewMDEService (u ), v , consume ));
128+ u ->
129+ (consume ) -> {
130+ if (shouldLog ) {
131+ return new FilingReviewClient (
132+ new FilingReviewMDEService (u , getLoggingFeature ()), v , consume );
133+ } else {
134+ return new FilingReviewClient (new FilingReviewMDEService (u ), v , consume );
135+ }
136+ });
84137 });
85138 }
86139
@@ -91,7 +144,17 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
91144 return version .flatMap (
92145 v -> {
93146 var url = createLocalWsdlUrl (domain , v , SERVICE_WSDL );
94- return url .map (u -> (consume ) -> new ServiceClient (new ServiceMDEService (u ), v , consume ));
147+ boolean shouldLog = shouldLogRequests ();
148+ return url .map (
149+ u ->
150+ (consume ) -> {
151+ if (shouldLog ) {
152+ return new ServiceClient (
153+ new ServiceMDEService (u , getLoggingFeature ()), v , consume );
154+ } else {
155+ return new ServiceClient (new ServiceMDEService (u ), v , consume );
156+ }
157+ });
95158 });
96159 }
97160
@@ -102,10 +165,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
102165 return version .flatMap (
103166 v -> {
104167 var url = createLocalWsdlUrl (domain , v , TYLER_COURT_RECORD_WSDL );
168+ boolean shouldLog = shouldLogRequests ();
105169 return url .map (
106170 u ->
107- (consume ) ->
108- new TylerCourtRecordClient (new TylerCourtRecordMDEService (u ), v , consume ));
171+ (consume ) -> {
172+ if (shouldLog ) {
173+ return new TylerCourtRecordClient (
174+ new TylerCourtRecordMDEService (u , getLoggingFeature ()), v , consume );
175+ } else {
176+ return new TylerCourtRecordClient (
177+ new TylerCourtRecordMDEService (u ), v , consume );
178+ }
179+ });
109180 });
110181 }
111182
@@ -116,11 +187,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
116187 return version .flatMap (
117188 v -> {
118189 var url = createLocalWsdlUrl (domain , v , TYLER_COURT_SCHED_WSDL );
190+ boolean shouldLog = shouldLogRequests ();
119191 return url .map (
120192 u ->
121- (consume ) ->
122- new TylerCourtSchedulingClient (
123- new TylerCourtSchedulingMDEService (u ), v , consume ));
193+ (consume ) -> {
194+ if (shouldLog ) {
195+ return new TylerCourtSchedulingClient (
196+ new TylerCourtSchedulingMDEService (u , getLoggingFeature ()), v , consume );
197+ } else {
198+ return new TylerCourtSchedulingClient (
199+ new TylerCourtSchedulingMDEService (u ), v , consume );
200+ }
201+ });
124202 });
125203 }
126204
@@ -131,11 +209,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
131209 return version .flatMap (
132210 v -> {
133211 var url = createLocalWsdlUrl (domain , v , TYLER_FILING_ASSEM_WSDL );
212+ boolean shouldLog = shouldLogRequests ();
134213 return url .map (
135214 u ->
136- (consume ) ->
137- new TylerFilingAssemblyClient (
138- new TylerFilingAssemblyMDEService (u ), v , consume ));
215+ (consume ) -> {
216+ if (shouldLog ) {
217+ return new TylerFilingAssemblyClient (
218+ new TylerFilingAssemblyMDEService (u , getLoggingFeature ()), v , consume );
219+ } else {
220+ return new TylerFilingAssemblyClient (
221+ new TylerFilingAssemblyMDEService (u ), v , consume );
222+ }
223+ });
139224 });
140225 }
141226
@@ -146,10 +231,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
146231 return version .flatMap (
147232 v -> {
148233 var url = createLocalWsdlUrl (domain , v , TYLER_FILING_REVIEW_WSDL );
234+ boolean shouldLog = shouldLogRequests ();
149235 return url .map (
150236 u ->
151- (consume ) ->
152- new TylerFilingReviewClient (new TylerFilingReviewMDEService (u ), v , consume ));
237+ (consume ) -> {
238+ if (shouldLog ) {
239+ return new TylerFilingReviewClient (
240+ new TylerFilingReviewMDEService (u , getLoggingFeature ()), v , consume );
241+ } else {
242+ return new TylerFilingReviewClient (
243+ new TylerFilingReviewMDEService (u ), v , consume );
244+ }
245+ });
153246 });
154247 }
155248
0 commit comments