Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
predic8 committed Nov 14, 2024
1 parent a852db2 commit 8c9bbcb
Show file tree
Hide file tree
Showing 13 changed files with 877 additions and 668 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/com/predic8/membrane/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.predic8.membrane.core.http.*;
import com.predic8.membrane.core.interceptor.rest.*;

import javax.xml.namespace.*;
import java.io.*;
import java.util.*;

Expand Down Expand Up @@ -58,6 +59,13 @@ public class Constants {
public static final String WSDL_SOAP11_NS = "http://schemas.xmlsoap.org/wsdl/soap/";
public static final String WSDL_SOAP12_NS = "http://schemas.xmlsoap.org/wsdl/soap12/";
public static final String WSDL_HTTP_NS = "http://schemas.xmlsoap.org/wsdl/http/";

public static final QName WSDL11_ADDRESS_SOAP11 = new QName(WSDL_SOAP11_NS,
"address");
public static final QName WSDL11_ADDRESS_SOAP12 = new QName(WSDL_SOAP12_NS,
"address");
public static final QName WSDL11_ADDRESS_HTTP = new QName(WSDL_HTTP_NS, "address");

public static final String WADL_NS = "http://wadl.dev.java.net/2009/02";
public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import javax.xml.stream.XMLStreamException;
import java.io.StringWriter;

import static com.predic8.membrane.core.interceptor.Outcome.CONTINUE;

abstract public class RelocatingInterceptor extends AbstractInterceptor {

private static Logger log = LoggerFactory.getLogger(RelocatingInterceptor.class.getName());
Expand All @@ -39,30 +41,30 @@ public Outcome handleResponse(Exchange exc) throws Exception {

if (exc.getRule() instanceof ProxyRule) {
log.debug(name + " ProxyRule found: No relocating done!");
return Outcome.CONTINUE;
return CONTINUE;
}

if (!wasGetRequest(exc)) {
log.debug(name + " HTTP method wasn't GET: No relocating done!");
return Outcome.CONTINUE;
return CONTINUE;
}

if (!hasContent(exc)) {
log.debug(name + " No Content: No relocating done!");
return Outcome.CONTINUE;
return CONTINUE;
}

if (!exc.getResponse().isXML()) {
log.debug(name + " Body contains no XML: No relocating done!");
return Outcome.CONTINUE;
return CONTINUE;
}

try {
rewrite(exc);
} catch (XMLStreamException e) {
throw new Exception("while rewriting " + exc.getRequestURI(), e);
}
return Outcome.CONTINUE;
return CONTINUE;
}

abstract void rewrite(Exchange exc) throws Exception;
Expand Down
Loading

0 comments on commit 8c9bbcb

Please sign in to comment.