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.AttachmentInInterceptor;
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.Collection;
29 import java.util.Collections;
30
31
32
33
34
35
36
37
38
39 public class InPayloadLoggerInterceptor extends AbstractSafeInterceptor {
40 @Delegate private final WsPayloadLoggerBase base = new WsPayloadLoggerBase();
41
42 public InPayloadLoggerInterceptor(String fileNamePattern) {
43 this(new SpringExpressionResolver(fileNamePattern));
44 }
45
46
47
48
49
50
51
52 public InPayloadLoggerInterceptor(ExpressionResolver resolver) {
53 super(Phase.RECEIVE);
54 addAfter(AttachmentInInterceptor.class.getName());
55 setExpressionResolver(resolver);
56 }
57
58
59 @Override
60 public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
61 return Collections.singletonList(
62 new InPayloadExtractorInterceptor(StringPayloadHolder.PayloadType.HTTP));
63 }
64
65
66 @Override
67 public void process(SoapMessage message) {
68 if (canProcess()) {
69 logPayload(message);
70 }
71 }
72 }