use of com.dexels.navajo.document.Header in project navajo by Dexels.
the class StandardFunctionsTest method testEvaluateExpression.
@Test
public void testEvaluateExpression() {
DispatcherFactory.createDispatcher(new TestDispatcher(new TestNavajoConfig()));
FunctionInterface fi = fff.getInstance(cl, "EvaluateExpression");
fi.reset();
Navajo doc = createTestNavajo();
Header h = NavajoFactory.getInstance().createHeader(doc, "aap", "noot", "mies", -1);
doc.addHeader(h);
fi.setInMessage(doc);
fi.insertStringOperand("true");
Object o = fi.evaluateWithTypeChecking();
assertNotNull(o);
}
use of com.dexels.navajo.document.Header in project navajo by Dexels.
the class NavajoDomStreamer method processNavajo.
public static List<NavajoStreamEvent> processNavajo(Navajo navajo) {
List<NavajoStreamEvent> result = new ArrayList<>();
Navajo output = NavajoFactory.getInstance().createNavajo();
List<Message> all = navajo.getAllMessages();
Header h = navajo.getHeader();
if (h != null) {
result.add(header(h));
} else {
logger.warn("Unexpected case: Deal with tml without header?");
}
for (Message message : all) {
emitMessage(message, result, output);
}
NavajoStreamEvent done = done(navajo.getAllMethods().stream().map(e -> new Method(e.getName())).collect(Collectors.toList()));
result.add(done);
return result;
}
use of com.dexels.navajo.document.Header in project navajo by Dexels.
the class NavajoRemoteContext method callService.
/* (non-Javadoc)
* @see com.dexels.navajo.client.context.ClientContext#callService(java.lang.String, com.dexels.navajo.document.Navajo)
*/
@Override
public void callService(String service, String tenant, String username, String password, Navajo input) throws ClientException {
if (myClient == null) {
throw new ClientException(1, -1, "No client has been set up!");
}
if (input == null) {
input = NavajoFactory.getInstance().createNavajo();
}
Header outHeader = input.getHeader();
if (outHeader == null) {
outHeader = NavajoFactory.getInstance().createHeader(input, service, username, password, -1);
input.addHeader(outHeader);
}
if (debugAll) {
outHeader.setHeaderAttribute("fullLog", "true");
}
long time = System.currentTimeMillis();
Navajo n = myClient.doSimpleSend(input, service);
logger.debug("Send complete!");
n.getHeader().setRPCName(service);
putNavajo(service, n);
logger.debug("Call took: {} millis!", System.currentTimeMillis() - time);
}
use of com.dexels.navajo.document.Header in project navajo by Dexels.
the class AsyncClientImpl method callService.
// Only used from Rhino
@Override
public void callService(Access inputAccess, Navajo input, String service, TmlRunnable onSuccess, TmlRunnable onFail, NavajoResponseCallback navajoResponseCallback) throws IOException {
final Access currentAccess = inputAccess.cloneWithoutNavajos();
if (input == null) {
input = NavajoFactory.getInstance().createNavajo();
}
currentAccess.setInDoc(input);
Header header = input.getHeader();
if (header == null) {
header = NavajoFactory.getInstance().createHeader(input, service, currentAccess.rpcUser, currentAccess.rpcUser, -1);
input.addHeader(header);
}
header.setRPCName(service);
header.setRPCUser(currentAccess.rpcUser);
header.setRPCPassword(currentAccess.rpcPwd);
NavajoResponseHandler nrh = new NavajoResponseHandler() {
Throwable caughtException = null;
@Override
public void onResponse(Navajo n) {
setActualCalls(getActualCalls() - 1);
currentAccess.setOutputDoc(n);
if (onSuccess != null) {
onSuccess.setResponseNavajo(n);
if (navajoResponseCallback != null) {
navajoResponseCallback.responseReceived(n);
}
setActualCalls(getActualCalls() - 1);
SchedulerRegistry.submit(onSuccess, false);
}
}
@Override
public synchronized void onFail(Throwable t) throws IOException {
caughtException = t;
logger.warn("Error: ", caughtException);
setActualCalls(getActualCalls() - 1);
try {
if (onFail != null) {
SchedulerRegistry.submit(onFail, false);
}
} finally {
setActualCalls(getActualCalls() - 1);
}
}
@Override
public synchronized Throwable getCaughtException() {
return caughtException;
}
};
setActualCalls(getActualCalls() + 1);
callService(currentAccess.getRequestUrl(), input, nrh, null);
}
use of com.dexels.navajo.document.Header in project navajo by Dexels.
the class GlobalManagerImpl method initGlobals.
@Override
public void initGlobals(Navajo inMessage) throws NavajoException {
Header h = inMessage.getHeader();
if (h == null) {
logger.warn("Can not append globals to input message: No header found.");
return;
}
String rpcName = h.getRPCName();
String username = h.getRPCUser();
initGlobals(rpcName, username, inMessage, settings);
}
Aggregations