use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class JavaNetNavajoClientImpl method readResponse.
private Navajo readResponse(boolean useCompression, HttpURLConnection con) throws IOException {
// Check for errors.
Navajo res = null;
InputStream inr = con.getInputStream();
InputStream inraw = null;
if (con.getResponseCode() >= 400) {
throw new IOException(readErrorStream(con));
} else {
if (useCompression) {
if (forceGzip) {
inraw = new GZIPInputStream(inr);
} else {
String responseEncoding = con.getHeaderField("Content-Encoding");
if (("jzlib".equals(responseEncoding) || "deflate".equals(responseEncoding))) {
inraw = new InflaterInputStream(inr);
} else {
inraw = inr;
}
}
} else {
inraw = inr;
}
}
if (inraw != null) {
res = NavajoFactory.getInstance().createNavajo(inraw);
}
return res;
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class JavaNetNavajoClientImpl method handleException.
private Navajo handleException(Throwable exception, String host) throws ClientException {
if (!generateConditionErrors) {
logger.error("Error: ", exception);
throw new ClientException(-1, -1, exception.getMessage(), exception);
}
Navajo n = null;
if (exception instanceof java.net.UnknownHostException) {
logger.warn("Connection problem: UnknownHostException exception to {}!", host, exception);
n = NavajoFactory.getInstance().createNavajo();
generateConnectionError(n, 7777777, "Unknown host: " + exception.getMessage());
} else if (exception instanceof java.net.NoRouteToHostException) {
logger.warn("Connection problem: NoRouteToHostException exception to {}!", host, exception);
n = NavajoFactory.getInstance().createNavajo();
generateConnectionError(n, 55555, "No route to host: " + exception.getMessage());
} else if (exception instanceof java.net.SocketTimeoutException || exception instanceof java.net.ConnectException || exception instanceof java.net.NoRouteToHostException) {
logger.warn("Connection problem: SocketTimeoutException exception to {}!", host, exception);
n = NavajoFactory.getInstance().createNavajo();
generateConnectionError(n, 55555, "Error on getting response data: " + exception.getMessage());
} else if (exception instanceof javax.net.ssl.SSLHandshakeException) {
logger.warn("Connection problem: SSLHandshakeException exception to {}!", host, exception);
n = NavajoFactory.getInstance().createNavajo();
generateConnectionError(n, 666666, "SSL fout " + exception.getMessage());
}
if (n != null) {
return n;
}
logger.warn("Connection problem: Exception {} to {}!", exception.getMessage(), host, exception);
throw new ClientException(-1, -1, exception.getMessage(), exception);
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestClient method testClientBig.
@Test(timeout = 20000)
@Ignore
public void testClientBig() throws ClientException {
NavajoClient cl = new JavaNetNavajoClientImpl();
cl.setAllowCompression(true);
cl.setForceGzip(true);
cl.setServerUrls(new String[] { TestConfig.NAVAJO_TEST_SERVER.getValue() });
cl.setUsername(TestConfig.NAVAJO_TEST_USER.getValue());
cl.setPassword(TestConfig.NAVAJO_TEST_PASS.getValue());
cl.useBasicAuthentication(true);
Navajo nc = NavajoFactory.getInstance().createNavajo();
Navajo result = cl.doSimpleSend(nc, "club/InitUpdateClub");
result.getMessage("Club").getProperty("ClubIdentifier").setAnyValue("BBFX31R");
cl.doSimpleSend(result, "club/ProcessQueryClub");
}
use of com.dexels.navajo.document.Navajo 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.Navajo in project navajo by Dexels.
the class TestAsyncService method main.
public static void main(String[] args) throws ClientException {
TestAsyncService tas = new TestAsyncService();
NavajoClientFactory.getClient().setUsername("");
NavajoClientFactory.getClient().setPassword("");
NavajoClientFactory.getClient().setServerUrl("http://localhost:8080/navajo/KNZB");
final Navajo n = NavajoClientFactory.getClient().doSimpleSend(null, "InitAsync");
tas.test(n);
}
Aggregations