Search in sources :

Example 61 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class NavajoContext method getProperty.

public Property getProperty(String service, String path) {
    Navajo n = getNavajo(service);
    Property p = n.getProperty(path);
    if (p == null) {
        throw new IllegalStateException("Unknown property: " + path + " in service " + service);
    }
    return p;
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 62 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class NavajoContext method resolvePost.

public void resolvePost(String name, String value) {
    if (name.indexOf(':') == -1) {
        return;
    }
    String[] keyVal = name.split(":");
    String navajo = keyVal[0];
    String path = keyVal[1];
    Navajo n = getNavajo(navajo);
    if (n == null) {
        throw new IllegalArgumentException("Missing navajo: " + navajo + " in state. Was the session deleted?");
    }
    Property p = n.getProperty(path);
    if (Property.BOOLEAN_PROPERTY.equals(p.getType())) {
        p.setAnyValue("on".equals(value));
    } else {
        p.setValue(value);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 63 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class NavajoContext method putNavajo.

public void putNavajo(String service, Navajo n) {
    Navajo old = myNavajoMap.get(service);
    if (old != null) {
        myInverseNavajoMap.remove(old);
    }
    if (n == null) {
        logger.warn("Null navajo response for {}! Ignoring response", service);
        return;
    }
    if (n.getMessage("error") != null || n.getMessage("AuthenticationError") != null || n.getMessage("AuthorizationError") != null) {
        logger.warn("Navajo contains an error for {}! Ignoring response", service);
        return;
    }
    myNavajoMap.put(service, n);
    myInverseNavajoMap.put(n, service);
}
Also used : Navajo(com.dexels.navajo.document.Navajo)

Example 64 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class NavajoContext method dumpTopElement.

public void dumpTopElement() {
    Object o = myElementStack.peek();
    if (o instanceof Navajo) {
        Navajo n = (Navajo) o;
        StringWriter sw = new StringWriter();
        try {
            n.write(sw);
            logger.info("Navajo on top: {}", sw);
        } catch (NavajoException e) {
            logger.error("Error: ", e);
        }
    } else if (o instanceof Message) {
        logger.info("Message on top: {}", ((Message) o).getFullMessageName());
    } else if (o instanceof Property) {
        try {
            logger.info("Property on top: {}", ((Property) o).getFullPropertyName());
        } catch (NavajoException e) {
            logger.error("Error: ", e);
        }
    } else {
        if (o != null) {
            logger.info("Other object: {}", o.getClass());
        } else {
            logger.info("Null object on stack!");
        }
    }
}
Also used : StringWriter(java.io.StringWriter) Message(com.dexels.navajo.document.Message) NavajoException(com.dexels.navajo.document.NavajoException) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 65 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class TestXmlParser method testXmlWithComment.

@Test
public void testXmlWithComment() {
    StringReader sr = new StringReader("<tml> <!-- abc --> <message name=\"aap\"/></tml>");
    Navajo n = NavajoFactory.getInstance().createNavajo(sr);
    Assert.assertNotNull(n);
}
Also used : StringReader(java.io.StringReader) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13