@Override public CouchServerVersion getVersion() throws Exception { if( null != version ) { return version; } else { JSONObject obj = ConnectionUtils.getJsonResource(context, url); // Parse version Object jsonVersion = obj.get("version"); if( null != jsonVersion && jsonVersion instanceof String ) { String[] versions = ((String)jsonVersion).split("\\."); if( versions.length >= 2 ) { int major = Integer.parseInt(versions[0]); int minor = Integer.parseInt(versions[1]); version = new CouchServerVersionImpl((String)jsonVersion,major,minor); return version; } } throw new Exception("Unable to parse server version: "+jsonVersion); } }
public CouchClient getClient(CouchContext context, URL url, int versionMajor, int versionMinor) throws Exception { CouchClientImpl client = new CouchClientImpl(context, url); CouchServerVersionImpl serverVersion = new CouchServerVersionImpl(""+versionMajor+"."+versionMinor,versionMajor, versionMinor); client.setVersion(serverVersion); return client; }
throw new Exception("Can not parse server version: "+version); serverVersion = new CouchServerVersionImpl(version, Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));