Skip to content

Commit

Permalink
skip the execution of the most CXF interceptors on GET requests (e.g.…
Browse files Browse the repository at this point in the history
… on retrieving of WSDL documents)
  • Loading branch information
unixoid committed Feb 22, 2012
1 parent 7737e06 commit 28c6d27
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 16 deletions.
Expand Up @@ -48,7 +48,7 @@ abstract public class AbstractAuditInterceptor extends AbstractSafeInterceptor {
public static final String DATASET_CONTEXT_KEY = AbstractAuditInterceptor.class.getName() + ".DATASET";

/**
* Key used to store audit datasets in Web Service contexts.
* Key used to find XUA user name tokens in Web Service contexts.
*/
public static final String XUA_USERNAME_CONTEXT_KEY = AbstractAuditInterceptor.class.getName() + ".XUA_USERNAME";

Expand Down
Expand Up @@ -43,6 +43,10 @@ public AuditInRequestInterceptor(WsAuditStrategy auditStrategy, WsTransactionCon

@Override
protected void process(SoapMessage message) throws Exception {
if (isGET(message)) {
return;
}

WsAuditDataset auditDataset = getAuditDataset(message);
extractAddressesFromServletRequest(message, auditDataset);
extractXuaUserNameFromSaml2Assertion(message, auditDataset);
Expand Down
Expand Up @@ -52,6 +52,10 @@ public AuditOutRequestInterceptor(

@Override
protected void process(SoapMessage message) throws Exception {
if (isGET(message)) {
return;
}

WsAuditDataset auditDataset = getAuditDataset(message);
auditDataset.setServiceEndpointUrl((String) message.get(Message.ENDPOINT_ADDRESS));

Expand Down
Expand Up @@ -90,6 +90,10 @@ private static boolean isClient(boolean asyncReceiver, boolean serverSide) {

@Override
protected void process(SoapMessage message) throws Exception {
if (isGET(message)) {
return;
}

// partial responses are for us out of interest
if (MessageUtils.isPartialResponse(message)) {
return;
Expand Down
Expand Up @@ -51,6 +51,10 @@ public InNamespaceMergeInterceptor() {

@Override
public void handleMessage(Message message) throws Fault {
if (isGET(message)) {
return;
}

StringPayloadHolder payloadHolder = message.getContent(StringPayloadHolder.class);
if (payloadHolder != null) {
String payload = payloadHolder.get(SOAP_BODY);
Expand Down Expand Up @@ -134,9 +138,9 @@ protected static String enrichNamespaces(Document source, String target) {
// insert remained definitions (if any)
if (!namespaces.isEmpty()) {
StringBuilder sb = new StringBuilder(startTag);
for (String prefix : namespaces.keySet()) {
sb.append(" xmlns:").append(prefix).append("=\"")
.append(namespaces.get(prefix)).append('"');
for (Map.Entry<String, String> ns : namespaces.entrySet()) {
sb.append(" xmlns:").append(ns.getKey()).append("=\"")
.append(ns.getValue()).append('"');
}
sb.append(target.substring(endPos));
return sb.toString();
Expand Down
Expand Up @@ -70,6 +70,10 @@ private static String getPhase(PayloadType payloadType) {

@Override
public void handleMessage(Message message) {
if (isGET(message)) {
return;
}

// extract current message contents from the stream,
// substitute the used stream by an again-usable one.
byte[] bytes;
Expand Down
Expand Up @@ -50,6 +50,10 @@ public InPayloadInjectorInterceptor(int position) {
@SuppressWarnings("unchecked")
@Override
public void handleMessage(Message message) {
if (isGET(message)) {
return;
}

List list = message.getContent(List.class);
StringPayloadHolder payloadHolder = message.getContent(StringPayloadHolder.class);
if ((list != null) && (payloadHolder != null)) {
Expand Down
Expand Up @@ -48,6 +48,10 @@ public OutPayloadExtractorInterceptor() {

@Override
public void handleMessage(Message message) {
if (isGET(message)) {
return;
}

WrappedOutputStream wrapper = OutStreamSubstituteInterceptor.getStreamWrapper(message);
if (! Boolean.FALSE.equals(message.getContextualProperty(PAYLOAD_COLLECTING_DEACTIVATION_ENABLED))) {
wrapper.deactivate();
Expand Down
Expand Up @@ -49,18 +49,6 @@ public WrappedOutputStream(OutputStream os, String charsetName) {
}


/**
* Returns the collected message payload and deactivates
* any further data collecting.
* @return SOAP payload as a <code>String</code>.
*/
@Deprecated
public String getCollectedPayloadAndDeactivate() {
deactivate();
return getCollectedPayload();
}


/**
* Returns the collected message payload.
* @return SOAP payload as XML String.
Expand Down

0 comments on commit 28c6d27

Please sign in to comment.