use of com.dexels.navajo.script.api.LocalClient in project navajo by Dexels.
the class TmlContinuationMultitenantServlet method service.
@Override
protected void service(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
if (useReactiveEndpoint(req)) {
reactiveHttpServlet.service(req, resp);
return;
}
String instance = determineTenantFromRequest(req);
LocalClient localClient = getLocalClient();
if (localClient == null) {
localClient = getLocalClient(req);
}
TmlRunnable runner = TmlRunnableBuilder.prepareRunnable(req, resp, localClient, instance, requestTimeout);
if (runner != null) {
getTmlScheduler().submit(runner, false);
}
} catch (Throwable e) {
if (e instanceof ServletException) {
throw (ServletException) e;
}
logger.error("Servlet call failed dramatically", e);
}
}
use of com.dexels.navajo.script.api.LocalClient in project navajo by Dexels.
the class TmlContinuationMultitenantServlet method getLocalClient.
protected LocalClient getLocalClient(final HttpServletRequest req) throws ServletException {
LocalClient tempClient = localClient;
if (localClient == null) {
tempClient = (LocalClient) req.getServletContext().getAttribute("localClient");
}
final LocalClient lc = tempClient;
if (lc == null) {
logger.error("No localclient found");
throw new ServletException("No local client registered in servlet context");
}
return lc;
}
use of com.dexels.navajo.script.api.LocalClient in project navajo by Dexels.
the class RestTmlServlet method callDirect.
private final void callDirect(HttpServletRequest request, HttpServletResponse response) throws IOException {
String service = request.getParameter("service");
// String type = request.getParameter("type");
String username = request.getParameter("username");
String password = request.getParameter("password");
logger.info(">in callDirect(): service = " + service + ", username = " + username + " class: " + getClass().getName());
if (service == null) {
// logger.info("Empty service specified, request originating from "
// + request.getRemoteHost());
logger.info("thread = " + Thread.currentThread().hashCode());
logger.info("path = " + request.getPathInfo());
logger.info("query = " + request.getQueryString());
logger.info("protocol = " + request.getProtocol());
logger.info("agent = " + request.getRemoteUser());
logger.info("uri = " + request.getRequestURI());
logger.info("method = " + request.getMethod());
logger.info("contenttype = " + request.getContentType());
logger.info("scheme = " + request.getScheme());
logger.info("server = " + request.getServerName());
logger.info("port = " + request.getServerPort());
logger.info("contentlength = " + request.getContentLength());
Enumeration<String> enm = request.getHeaderNames();
while (enm.hasMoreElements()) {
String key = enm.nextElement();
String header = request.getHeader(key);
logger.info(">>" + key + "=" + header);
}
return;
}
Navajo tbMessage;
try {
tbMessage = constructFromRequest(request);
Header header = constructHeader(tbMessage, service, username, password, -1);
tbMessage.addHeader(header);
LocalClient lc = (LocalClient) getServletContext().getAttribute("localClient");
if (lc == null) {
response.sendError(500, "No navajocontext configured (in NavajoFilterServlet)");
return;
}
Navajo resultMessage = lc.call(tbMessage);
response.setContentType("text/xml");
ServletOutputStream outputStream = response.getOutputStream();
java.io.OutputStreamWriter out = new java.io.OutputStreamWriter(outputStream, "UTF-8");
response.setContentType("text/xml; charset=UTF-8");
writeOutput(resultMessage, out, service);
// resultMessage.write(out);
out.flush();
out.close();
} catch (NavajoException e) {
logger.error("Error: ", e);
} catch (FatalException e) {
logger.error("Error: ", e);
}
}
Aggregations