Search in sources :

Example 1 with Header

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);
}
Also used : TestNavajoConfig(com.dexels.navajo.server.test.TestNavajoConfig) FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Header(com.dexels.navajo.document.Header) TestDispatcher(com.dexels.navajo.server.test.TestDispatcher) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 2 with Header

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;
}
Also used : Message(com.dexels.navajo.document.Message) Header(com.dexels.navajo.document.Header) ArrayList(java.util.ArrayList) Navajo(com.dexels.navajo.document.Navajo) Method(com.dexels.navajo.document.stream.api.Method) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent)

Example 3 with Header

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);
}
Also used : Header(com.dexels.navajo.document.Header) ClientException(com.dexels.navajo.client.ClientException) Navajo(com.dexels.navajo.document.Navajo)

Example 4 with Header

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);
}
Also used : Header(com.dexels.navajo.document.Header) Access(com.dexels.navajo.script.api.Access) NavajoResponseHandler(com.dexels.navajo.client.NavajoResponseHandler) Navajo(com.dexels.navajo.document.Navajo)

Example 5 with Header

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);
}
Also used : Header(com.dexels.navajo.document.Header)

Aggregations

Header (com.dexels.navajo.document.Header)29 Navajo (com.dexels.navajo.document.Navajo)19 NavajoException (com.dexels.navajo.document.NavajoException)9 IOException (java.io.IOException)9 FatalException (com.dexels.navajo.script.api.FatalException)7 UserException (com.dexels.navajo.script.api.UserException)7 Message (com.dexels.navajo.document.Message)6 SystemException (com.dexels.navajo.script.api.SystemException)6 AuthorizationException (com.dexels.navajo.script.api.AuthorizationException)5 Property (com.dexels.navajo.document.Property)4 TriggerException (com.dexels.navajo.server.enterprise.scheduler.TriggerException)4 ClientException (com.dexels.navajo.client.ClientException)3 Access (com.dexels.navajo.script.api.Access)3 NavajoResponseHandler (com.dexels.navajo.client.NavajoResponseHandler)2 MappableException (com.dexels.navajo.script.api.MappableException)2 BufferedReader (java.io.BufferedReader)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2