From 436fb2ff39bfb5b91a2c21ab77670fb58dba001c Mon Sep 17 00:00:00 2001 From: Mike Hinchey Date: Fri, 28 Jan 2011 12:24:59 -0800 Subject: [PATCH] rfe9338: Improve error message due to session port connection failure Added error message to refer to documentation url on franz.com. The error message is unfortunately vague because other causes are possible. tests run: prepush tests added: none, must be tested manually, requires remote server performance: no impact rfe9338: Improve error message due to session port connection failure When using method that start a session (setAutoCommit, addRules, and registerSNAGenerator), if there is a connection error, give message to point to the documentation about SessionPorts. Change-Id: I2fe0979d2c83a3bad01a63aab70b56f76eef0927 Reviewed-on: https://gerrit.franz.com:9080/1163 Reviewed-by: John O'Rourke Reviewed-by: Ahmon Dancy Tested-by: Kevin Layer --- .../franz/agraph/http/AGHttpRepoClient.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com/franz/agraph/http/AGHttpRepoClient.java b/src/com/franz/agraph/http/AGHttpRepoClient.java index dccdc427..068eede8 100644 --- a/src/com/franz/agraph/http/AGHttpRepoClient.java +++ b/src/com/franz/agraph/http/AGHttpRepoClient.java @@ -1,5 +1,5 @@ /****************************************************************************** -** Copyright (c) 2008-2010 Franz Inc. +** Copyright (c) 2008-2011 Franz Inc. ** All rights reserved. This program and the accompanying materials ** are made available under the terms of the Eclipse Public License v1.0 ** which accompanies this distribution, and is available at @@ -342,7 +342,19 @@ public void setAutoCommit(boolean autoCommit) throws RepositoryException { } catch (RDFParseException e) { throw new RepositoryException(e); } catch (IOException e) { - throw new RepositoryException(e); + throw handleSessionConnectionError(e, url); + } + } + + private RepositoryException handleSessionConnectionError(IOException e, String url) throws RepositoryException { + if (e instanceof java.net.ConnectException) { + // To test this exception, setup remote server and only open port to + // the main port, not the SessionPorts and run TutorialTest.example6() + return new RepositoryException("Session port connection failure. Consult the Server Installation document for correct settings for SessionPorts. Url: " + url + + ". Documentation: http://www.franz.com/agraph/support/documentation/v4/server-installation.html#sessionport", e); + } else { + return new RepositoryException("Possible session port connection failure. Consult the Server Installation document for correct settings for SessionPorts. Url: " + url + + ". Documentation: http://www.franz.com/agraph/support/documentation/v4/server-installation.html#sessionport", e); } } @@ -1154,7 +1166,7 @@ public void addRules(InputStream rulestream) throws RepositoryException { } catch (RDFParseException e) { throw new RepositoryException(e); } catch (IOException e) { - throw new RepositoryException(e); + throw handleSessionConnectionError(e, url); } } @@ -1437,7 +1449,7 @@ public void registerSNAGenerator(String generator, List objectOfs, List< } catch (HttpException e) { throw new RepositoryException(e); } catch (IOException e) { - throw new RepositoryException(e); + throw handleSessionConnectionError(e, url); } catch (AGHttpException e) { throw new RepositoryException(e); } // TODO: need an RDFParseException for query param?