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;
}
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);
}
}
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);
}
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!");
}
}
}
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);
}
Aggregations