public HttpDatastoreRpc(DatastoreOptions options) { HttpTransportOptions httpTransportOptions = (HttpTransportOptions) options.getTransportOptions(); HttpTransport transport = httpTransportOptions.getHttpTransportFactory().create(); com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder = new com.google.datastore.v1.client.DatastoreOptions.Builder() .projectId(options.getProjectId()) .initializer(getHttpRequestInitializer(options, httpTransportOptions)) .transport(transport); String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : ""; if (isLocalHost(normalizedHost)) { clientBuilder = clientBuilder.localHost(removeScheme(normalizedHost)); } else if (!removeScheme(com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST) .equals(removeScheme(normalizedHost)) && !normalizedHost.isEmpty()) { String fullUrl = normalizedHost; if (fullUrl.charAt(fullUrl.length() - 1) != '/') { fullUrl = fullUrl + '/'; } fullUrl = fullUrl + com.google.datastore.v1.client.DatastoreFactory.VERSION + "/projects/" + options.getProjectId(); clientBuilder = clientBuilder.projectId(null).projectEndpoint(fullUrl); } client = com.google.datastore.v1.client.DatastoreFactory.get().create(clientBuilder.build()); }
public HttpDatastoreRpc(DatastoreOptions options) { HttpTransportOptions httpTransportOptions = (HttpTransportOptions) options.getTransportOptions(); HttpTransport transport = httpTransportOptions.getHttpTransportFactory().create(); com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder = new com.google.datastore.v1.client.DatastoreOptions.Builder() .projectId(options.getProjectId()) .initializer(getHttpRequestInitializer(options, httpTransportOptions)) .transport(transport); String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : ""; if (isLocalHost(normalizedHost)) { clientBuilder = clientBuilder.localHost(removeScheme(normalizedHost)); } else if (!removeScheme(com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST) .equals(removeScheme(normalizedHost)) && !normalizedHost.isEmpty()) { String fullUrl = normalizedHost; if (fullUrl.charAt(fullUrl.length() - 1) != '/') { fullUrl = fullUrl + '/'; } fullUrl = fullUrl + com.google.datastore.v1.client.DatastoreFactory.VERSION + "/projects/" + options.getProjectId(); clientBuilder = clientBuilder.projectId(null).projectEndpoint(fullUrl); } client = com.google.datastore.v1.client.DatastoreFactory.get().create(clientBuilder.build()); }