/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param securityContext the security context created depending upon the * authentication type - BasicAuthContext, DigestAuthContext or KerberosAuthContext * and communication channel type (SSL) * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, SecurityContext securityContext) { return newClient(host, port, null, securityContext, null); }
/** * Initializes a handle registry with the default associations * between the content handles provided by the API and the supported * IO representation classes. Use this method only after clearing * or overwriting associations in the handle registry. */ static public void registerDefaultHandles() { HandleFactoryRegistryImpl.registerDefaults(getHandleRegistry()); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type) { return newClient(host, port, null, makeSecurityContext(user, password, type, null, null), null); } /**
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @param verifier a callback for checking hostnames * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) { DatabaseClientImpl client = newClientImpl(host, port, user, password, type, context, verifier); client.setHandleRegistry(getHandleRegistry().copy()); return client; } static private DatabaseClientImpl newClientImpl(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) {
@Test public void testConfigurator() { ConfiguratorImpl configurator = new ConfiguratorImpl(); DatabaseClientFactory.addConfigurator(configurator); DatabaseClient client = DatabaseClientFactory.newClient( Common.HOST, Common.PORT, new DigestAuthContext(Common.USER, Common.PASS)); try { assertTrue("Factory did not apply custom configurator", configurator.isConfigured); OkHttpClient okClient = (OkHttpClient) client.getClientImplementation(); assertEquals(testConnectTimeoutMillis, okClient.connectTimeoutMillis()); } finally { client.release(); } }
/** * Creates a client to access the database by means of a REST server * without any authentication. Such clients can be convenient for * experimentation but should not be used in production. * * @param host the host with the REST server * @param port the port for the REST server * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port) { return newClient(host, port, null, null, null, null, null, null); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context) { return newClient(host, port, null, makeSecurityContext(user, password, type, context, SSLHostnameVerifier.COMMON), null); } /**
/** * Initializes a handle registry with the default associations * between the content handles provided by the API and the supported * IO representation classes. Use this method only after clearing * or overwriting associations in the handle registry. */ static public void registerDefaultHandles() { HandleFactoryRegistryImpl.registerDefaults(getHandleRegistry()); }
/** * Creates a client to access the database by means of a REST server * without any authentication. Such clients can be convenient for * experimentation but should not be used in production. * * @param host the host with the REST server * @param port the port for the REST server * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port) { return newClient(host, port, null, null, null, null, null); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param database the database to access (default: configured database for the REST server) * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @param verifier a callback for checking hostnames * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, String database, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) { return newClient(host, port, database, makeSecurityContext(user, password, type, context, verifier), null); }
@Override public DocumentWriteSet addAs(String docId, DocumentMetadataWriteHandle metadataHandle, Object content) { if (content == null) throw new IllegalArgumentException("content must not be null"); Class<?> as = content.getClass(); ContentHandle<?> handle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(handle, content); return add(docId, metadataHandle, handle); }
/** * Creates a client to access the database by means of a REST server * without any authentication. Such clients can be convenient for * experimentation but should not be used in production. * * @param host the host with the REST server * @param port the port for the REST server * @param database the database to access (default: configured database for the REST server) * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, String database) { return newClient(host, port, database, null, null, null, null, null); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param database the database to access (default: configured database for the REST server) * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, String database, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type) { return newClient(host, port, database, makeSecurityContext(user, password, type, null, null), null); } /**
@Override public DocumentWriteSet addAs(String docId, DocumentMetadataWriteHandle metadataHandle, Object content, String temporalDocumentURI) { if (content == null) throw new IllegalArgumentException("content must not be null"); Class<?> as = content.getClass(); ContentHandle<?> handle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(handle, content); return add(docId, metadataHandle, handle, temporalDocumentURI); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type) { return newClient(host, port, user, password, type, null, null); } /**
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @param verifier a callback for checking hostnames * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) { return newClient(host, port, null, makeSecurityContext(user, password, type, context, verifier), null); } /**
@Override public WriteBatcher addAs(String uri, DocumentMetadataWriteHandle metadataHandle, Object content) { if (content == null) throw new IllegalArgumentException("content must not be null"); AbstractWriteHandle handle; Class<?> as = content.getClass(); if (AbstractWriteHandle.class.isAssignableFrom(as)) { handle = (AbstractWriteHandle) content; } else { ContentHandle<?> contentHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(contentHandle, content); handle = contentHandle; } return add(uri, metadataHandle, handle); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context) { return newClient(host, port, user, password, type, context, SSLHostnameVerifier.COMMON); } /**
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param database the database to access (default: configured database for the REST server) * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @return a new client for making database requests * @deprecated (as of 4.0.1) use {@link #newClient(String host, int port, String database, SecurityContext securityContext)} */ @Deprecated static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context) { return newClient(host, port, database, makeSecurityContext(user, password, type, context, SSLHostnameVerifier.COMMON), null); } /**
@Override public <T> T getAs(Class<T> as) { ContentHandle<T> readHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); if ( readHandle == null ) return null; HandleAccessor.receiveContent(readHandle, item); return readHandle.get(); } }