/** * Externalizes a {@link CouchDbDatastore} to a XML element * * @param datastore * @return */ public Element toElement(final CouchDbDatastore datastore) { final Element ds = getDocument().createElement("couchdb-datastore"); ds.setAttribute("name", datastore.getName()); if (!Strings.isNullOrEmpty(datastore.getDescription())) { ds.setAttribute("description", datastore.getDescription()); } appendElement(ds, "hostname", datastore.getHostname()); appendElement(ds, "port", datastore.getPort()); appendElement(ds, "username", datastore.getUsername()); appendElement(ds, "password", encodePassword(datastore.getPassword())); appendElement(ds, "ssl", datastore.isSslEnabled()); return ds; }
} else if (datastore instanceof CouchDbDatastore) { final CouchDbDatastore couchDbDatastore = (CouchDbDatastore) datastore; return (couchDbDatastore.isSslEnabled() ? "https://" : "http://") + couchDbDatastore.getHostname() + ":" + couchDbDatastore.getPort(); } else if (datastore instanceof PojoDatastore) {
_datastoreNameTextField.setText(originalDatastore.getName()); _datastoreNameTextField.setEnabled(false); _hostnameTextField.setText(originalDatastore.getHostname()); _portTextField.setText(originalDatastore.getPort() + ""); _sslCheckBox.setSelected(originalDatastore.isSslEnabled());
@Override protected UsageAwareDatastoreConnection<CouchDbDataContext> createDatastoreConnection() { final StdHttpClient.Builder httpClient = new StdHttpClient.Builder(); httpClient.host(getHostname()); if (_port != null) { httpClient.port(_port); } if (_username != null) { httpClient.username(_username); } if (_password != null) { httpClient.password(_password); } httpClient.enableSSL(_sslEnabled); httpClient.connectionTimeout(HTTP_TIMEOUT); httpClient.socketTimeout(HTTP_TIMEOUT); final CouchDbDataContext dataContext; if (_tableDefs != null && _tableDefs.length > 0) { dataContext = new CouchDbDataContext(httpClient, _tableDefs); } else { dataContext = new CouchDbDataContext(httpClient); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); }