From: Jakub Skoczen Date: Wed, 24 Feb 2010 15:59:27 +0000 (+0100) Subject: Fix X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=caaebca1c2365c670725e1653f4fc37815be0f3e;p=yaz4j-moved-to-github.git Fix --- diff --git a/examples/zgate/src/main/java/com/indexdata/zgate/ZgateServlet.java b/examples/zgate/src/main/java/com/indexdata/zgate/ZgateServlet.java index 459accf..aa5282e 100644 --- a/examples/zgate/src/main/java/com/indexdata/zgate/ZgateServlet.java +++ b/examples/zgate/src/main/java/com/indexdata/zgate/ZgateServlet.java @@ -40,10 +40,19 @@ public class ZgateServlet extends HttpServlet { public static ConnKey fromZurl(String zurl) { int colPos = zurl.lastIndexOf(":"); int slashPos = zurl.lastIndexOf("/"); - String host = zurl.substring(0, colPos); - int port = Integer.parseInt(zurl.substring(colPos+1, slashPos)); - String dbname = zurl.substring(slashPos+1); - return new ConnKey(host, port, dbname); + if (colPos == -1 && slashPos == -1) { + return new ConnKey(zurl, 0, ""); + } else if (colPos == -1 && slashPos != -1) { + return new ConnKey(zurl.substring(0,slashPos), 0, + zurl.substring(slashPos+1)); + } else if (colPos != -1 && slashPos == -1) { + return new ConnKey(zurl.substring(0,colPos), + Integer.parseInt(zurl.substring(colPos+1)), ""); + } else { + return new ConnKey(zurl.substring(0, colPos), + Integer.parseInt(zurl.substring(colPos+1,slashPos)), + zurl.substring(slashPos+1)); + } } public String getHost() {