1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws.cxf.payload;
17
18 import lombok.experimental.Delegate;
19 import org.apache.cxf.binding.soap.SoapMessage;
20 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
21 import org.apache.cxf.message.Message;
22 import org.apache.cxf.phase.Phase;
23 import org.apache.cxf.phase.PhaseInterceptor;
24 import org.openehealth.ipf.commons.ihe.core.payload.ExpressionResolver;
25 import org.openehealth.ipf.commons.ihe.core.payload.SpringExpressionResolver;
26 import org.openehealth.ipf.commons.ihe.ws.cxf.AbstractSafeInterceptor;
27
28 import java.util.Arrays;
29 import java.util.Collection;
30
31
32
33
34
35
36
37
38
39 public class OutPayloadLoggerInterceptor extends AbstractSafeInterceptor {
40 @Delegate private final WsPayloadLoggerBase base = new WsPayloadLoggerBase();
41
42 public OutPayloadLoggerInterceptor(String fileNamePattern) {
43 this(new SpringExpressionResolver(fileNamePattern));
44 }
45
46
47
48
49
50
51
52 public OutPayloadLoggerInterceptor(ExpressionResolver resolver) {
53 super(Phase.PRE_STREAM_ENDING);
54 addAfter(AttachmentOutInterceptor.AttachmentOutEndingInterceptor.class.getName());
55 setExpressionResolver(resolver);
56 }
57
58 @Override
59 public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
60 return Arrays.asList(
61 new DisablePayloadCollectingDeactivationInterceptor(),
62 new OutStreamSubstituteInterceptor());
63 }
64
65
66 @Override
67 public void process(SoapMessage message) {
68 if (canProcess()) {
69 logPayload(message);
70 }
71 }
72
73 }