use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleServiceProxyShowRequest.
@Mapping("/admin/service-proxy/show/?(\\?.*)?")
public Response handleServiceProxyShowRequest(final Map<String, String> params, final String relativeRootPath) throws Exception {
final StringWriter writer = new StringWriter();
final AbstractServiceProxy rule = (AbstractServiceProxy) RuleUtil.findRuleByIdentifier(router, params.get("name"));
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_SERVICE_PROXIES;
}
@Override
protected String getTitle() {
return super.getTitle() + " " + rule.toString() + " ServiceProxy";
}
@Override
protected void createTabContent() throws Exception {
h1().text(rule.toString() + " ServiceProxy").end();
script().raw("$(function() {\r\n" + " $( \"#subtab\" ).tabs();\r\n" + " });").end();
div().id("subtab");
ul();
li().a().href("#tab1").text("Visualization").end(2);
li().a().href("#tab2").text("Statistics").end(2);
// li().a().href("#tab3").text("XML Configuration").end(2);
end();
div().id("tab1");
createServiceProxyVisualization(rule, relativeRootPath);
end();
div().id("tab2");
createStatusCodesTable(rule.getStatisticsByStatusCodes());
br();
createButton("View Messages", "calls", null, createQueryString("proxy", rule.toString()));
end();
end();
}
}.createPage());
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class AdminRESTInterceptor method getBeautifiedBody.
@Mapping("/admin/web/exchanges/(-?\\d+)/(response|request)/body")
public Response getBeautifiedBody(QueryParameter params, String relativeRootPath) throws Exception {
AbstractExchange exc = router.getExchangeStore().getExchangeById(params.getGroupInt(1));
if (exc == null) {
return Response.notFound().build();
}
Message msg = params.getGroup(2).equals("response") ? exc.getResponse() : exc.getRequest();
if (msg == null || msg.isBodyEmpty()) {
return Response.noContent().build();
}
return Response.ok().contentType(MimeType.TEXT_HTML_UTF8).body(TextUtil.formatXML(new InputStreamReader(msg.getBodyAsStreamDecoded(), msg.getCharset()), true)).build();
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class AdminRESTInterceptor method getExchanges.
@Mapping("/admin/rest/exchanges(/?\\?.*)?")
public Response getExchanges(QueryParameter params, String relativeRootPath) throws Exception {
if (params.getString("waitForModification") != null) {
getRouter().getExchangeStore().waitForModification(params.getLong("waitForModification"));
}
List<AbstractExchange> exchanges;
synchronized (getRouter().getExchangeStore().getAllExchangesAsList()) {
exchanges = new ArrayList<AbstractExchange>(getRouter().getExchangeStore().getAllExchangesAsList());
}
exchanges = filter(params, exchanges);
Collections.sort(exchanges, ComparatorFactory.getAbstractExchangeComparator(params.getString("sort", "time"), params.getString("order", "desc")));
int offset = params.getInt("offset", 0);
int max = params.getInt("max", exchanges.size());
final int total = exchanges.size();
final List<AbstractExchange> paginated = exchanges.subList(offset, Math.min(offset + max, exchanges.size()));
return json(new JSONContent() {
public void write(JsonGenerator gen) throws Exception {
gen.writeStartObject();
gen.writeArrayFieldStart("exchanges");
for (AbstractExchange e : paginated) {
writeExchange(e, gen);
}
gen.writeEndArray();
gen.writeNumberField("total", total);
gen.writeNumberField("lastModified", getRouter().getExchangeStore().getLastModified());
gen.writeEndObject();
}
});
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class AdminRESTInterceptor method getRequestHeader.
@Mapping("/admin/rest/exchanges/(-?\\d+)/(response|request)/header")
public Response getRequestHeader(QueryParameter params, String relativeRootPath) throws Exception {
final AbstractExchange exc = router.getExchangeStore().getExchangeById(params.getGroupInt(1));
if (exc == null) {
return Response.notFound().build();
}
final Message msg = params.getGroup(2).equals("response") ? exc.getResponse() : exc.getRequest();
if (msg == null) {
return Response.noContent().build();
}
return json(new JSONContent() {
public void write(JsonGenerator gen) throws Exception {
gen.writeStartObject();
gen.writeArrayFieldStart("headers");
for (HeaderField hf : msg.getHeader().getAllHeaderFields()) {
gen.writeStartObject();
gen.writeStringField("name", hf.getHeaderName().toString());
gen.writeStringField("value", hf.getValue());
gen.writeEndObject();
}
gen.writeEndArray();
gen.writeEndObject();
}
});
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class AdminRESTInterceptor method getRequestBody.
@Mapping("/admin/rest/exchanges/(-?\\d+)/(response|request)/body")
public Response getRequestBody(QueryParameter params, String relativeRootPath) throws Exception {
AbstractExchange exc = router.getExchangeStore().getExchangeById(params.getGroupInt(1));
if (exc == null) {
return Response.notFound().build();
}
Message msg = params.getGroup(2).equals("response") ? exc.getResponse() : exc.getRequest();
String ct = params.getGroup(2).equals("response") ? exc.getResponseContentType() : exc.getRequestContentType();
if (msg == null || msg.isBodyEmpty()) {
return Response.noContent().build();
}
ResponseBuilder rb = Response.ok().contentType(ct).body(msg.getBodyAsStream(), false);
String contentEncoding = msg.getHeader().getContentEncoding();
if (contentEncoding != null)
rb.header(Header.CONTENT_ENCODING, contentEncoding);
return rb.build();
}
Aggregations